Add action to open the entry URL.

Closes #37
This commit is contained in:
Felix Geyer 2012-07-27 18:38:52 +02:00
parent e9a96ff80a
commit 3a2f387892
6 changed files with 45 additions and 2 deletions

View file

@ -397,6 +397,11 @@ void DatabaseTabWidget::performAutoType()
currentDatabaseWidget()->performAutoType(); currentDatabaseWidget()->performAutoType();
} }
void DatabaseTabWidget::openUrl()
{
currentDatabaseWidget()->openUrl();
}
void DatabaseTabWidget::createGroup() void DatabaseTabWidget::createGroup()
{ {
currentDatabaseWidget()->createGroup(); currentDatabaseWidget()->createGroup();

View file

@ -74,6 +74,7 @@ public Q_SLOTS:
void copyUsername(); void copyUsername();
void copyPassword(); void copyPassword();
void performAutoType(); void performAutoType();
void openUrl();
void createGroup(); void createGroup();
void editGroup(); void editGroup();
void deleteGroup(); void deleteGroup();

View file

@ -20,6 +20,7 @@
#include <QtCore/QTimer> #include <QtCore/QTimer>
#include <QtGui/QAction> #include <QtGui/QAction>
#include <QtGui/QDesktopServices>
#include <QtGui/QHBoxLayout> #include <QtGui/QHBoxLayout>
#include <QtGui/QLabel> #include <QtGui/QLabel>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
@ -160,6 +161,8 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
m_actionEntryAutoType->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V)); m_actionEntryAutoType->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V));
} }
m_actionEntryAutoType->setEnabled(false); m_actionEntryAutoType->setEnabled(false);
m_actionEntryOpenUrl = m_menuEntry->addAction(tr("Open URL"), this, SLOT(openUrl()), Qt::CTRL + Qt::Key_U);
m_actionEntryOpenUrl->setEnabled(false);
m_actionGroupNew = m_menuGroup->addAction(tr("Add new group"), this, SLOT(createGroup())); m_actionGroupNew = m_menuGroup->addAction(tr("Add new group"), this, SLOT(createGroup()));
m_actionGroupNew->setIcon(filePath()->icon("actions", "group-new", false)); m_actionGroupNew->setIcon(filePath()->icon("actions", "group-new", false));
@ -241,6 +244,8 @@ bool DatabaseWidget::actionEnabled(Action action)
return m_actionEntryCopyPassword->isEnabled(); return m_actionEntryCopyPassword->isEnabled();
case EntryAutoType: case EntryAutoType:
return m_actionEntryAutoType->isEnabled(); return m_actionEntryAutoType->isEnabled();
case EntryOpenUrl:
return m_actionEntryOpenUrl->isEnabled();
default: default:
Q_ASSERT(false); Q_ASSERT(false);
return false; return false;
@ -353,6 +358,19 @@ void DatabaseWidget::performAutoType()
autoType()->performAutoType(currentEntry, window()); autoType()->performAutoType(currentEntry, window());
} }
void DatabaseWidget::openUrl()
{
Entry* currentEntry = m_entryView->currentEntry();
if (!currentEntry) {
Q_ASSERT(false);
return;
}
if (!currentEntry->url().isEmpty()) {
QDesktopServices::openUrl(currentEntry->url());
}
}
void DatabaseWidget::createGroup() void DatabaseWidget::createGroup()
{ {
if (!m_groupView->currentGroup()) { if (!m_groupView->currentGroup()) {
@ -699,6 +717,7 @@ void DatabaseWidget::updateEntryActions()
m_actionEntryCopyUsername->setEnabled(singleEntrySelected); m_actionEntryCopyUsername->setEnabled(singleEntrySelected);
m_actionEntryCopyPassword->setEnabled(singleEntrySelected); m_actionEntryCopyPassword->setEnabled(singleEntrySelected);
m_actionEntryAutoType->setEnabled(singleEntrySelected); m_actionEntryAutoType->setEnabled(singleEntrySelected);
m_actionEntryOpenUrl->setEnabled(singleEntrySelected);
} }
void DatabaseWidget::showGroupContextMenu(const QPoint& pos) void DatabaseWidget::showGroupContextMenu(const QPoint& pos)

View file

@ -63,7 +63,8 @@ public:
EntryDelete, EntryDelete,
EntryCopyUsername, EntryCopyUsername,
EntryCopyPassword, EntryCopyPassword,
EntryAutoType EntryAutoType,
EntryOpenUrl
}; };
explicit DatabaseWidget(Database* db, QWidget* parent = Q_NULLPTR); explicit DatabaseWidget(Database* db, QWidget* parent = Q_NULLPTR);
@ -90,6 +91,7 @@ public Q_SLOTS:
void copyUsername(); void copyUsername();
void copyPassword(); void copyPassword();
void performAutoType(); void performAutoType();
void openUrl();
void createGroup(); void createGroup();
void deleteGroup(); void deleteGroup();
void switchToEntryEdit(); void switchToEntryEdit();
@ -155,6 +157,7 @@ private:
QAction* m_actionEntryCopyUsername; QAction* m_actionEntryCopyUsername;
QAction* m_actionEntryCopyPassword; QAction* m_actionEntryCopyPassword;
QAction* m_actionEntryAutoType; QAction* m_actionEntryAutoType;
QAction* m_actionEntryOpenUrl;
}; };
#endif // KEEPASSX_DATABASEWIDGET_H #endif // KEEPASSX_DATABASEWIDGET_H

View file

@ -65,6 +65,7 @@ MainWindow::MainWindow()
m_ui->actionEntryCopyUsername->setShortcut(Qt::CTRL + Qt::Key_B); m_ui->actionEntryCopyUsername->setShortcut(Qt::CTRL + Qt::Key_B);
m_ui->actionEntryCopyPassword->setShortcut(Qt::CTRL + Qt::Key_C); m_ui->actionEntryCopyPassword->setShortcut(Qt::CTRL + Qt::Key_C);
setShortcut(m_ui->actionEntryAutoType, QKeySequence::Paste, Qt::CTRL + Qt::Key_V); setShortcut(m_ui->actionEntryAutoType, QKeySequence::Paste, Qt::CTRL + Qt::Key_V);
m_ui->actionEntryOpenUrl->setShortcut(Qt::CTRL + Qt::Key_U);
m_ui->actionDatabaseNew->setIcon(filePath()->icon("actions", "document-new")); m_ui->actionDatabaseNew->setIcon(filePath()->icon("actions", "document-new"));
m_ui->actionDatabaseOpen->setIcon(filePath()->icon("actions", "document-open")); m_ui->actionDatabaseOpen->setIcon(filePath()->icon("actions", "document-open"));
@ -135,6 +136,8 @@ MainWindow::MainWindow()
SLOT(copyPassword())); SLOT(copyPassword()));
connect(m_ui->actionEntryAutoType, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionEntryAutoType, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(performAutoType())); SLOT(performAutoType()));
connect(m_ui->actionEntryOpenUrl, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(openUrl()));
connect(m_ui->actionGroupNew, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionGroupNew, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(createGroup())); SLOT(createGroup()));
@ -206,6 +209,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionEntryCopyUsername->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryCopyUsername)); m_ui->actionEntryCopyUsername->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryCopyUsername));
m_ui->actionEntryCopyPassword->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryCopyPassword)); m_ui->actionEntryCopyPassword->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryCopyPassword));
m_ui->actionEntryAutoType->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryAutoType)); m_ui->actionEntryAutoType->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryAutoType));
m_ui->actionEntryOpenUrl->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryOpenUrl));
m_ui->actionGroupNew->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupNew)); m_ui->actionGroupNew->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupNew));
m_ui->actionGroupEdit->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupEdit)); m_ui->actionGroupEdit->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupEdit));
m_ui->actionGroupDelete->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupDelete)); m_ui->actionGroupDelete->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupDelete));
@ -226,6 +230,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionEntryCopyUsername->setEnabled(false); m_ui->actionEntryCopyUsername->setEnabled(false);
m_ui->actionEntryCopyPassword->setEnabled(false); m_ui->actionEntryCopyPassword->setEnabled(false);
m_ui->actionEntryAutoType->setEnabled(false); m_ui->actionEntryAutoType->setEnabled(false);
m_ui->actionEntryOpenUrl->setEnabled(false);
m_ui->actionGroupNew->setEnabled(false); m_ui->actionGroupNew->setEnabled(false);
m_ui->actionGroupEdit->setEnabled(false); m_ui->actionGroupEdit->setEnabled(false);
m_ui->actionGroupDelete->setEnabled(false); m_ui->actionGroupDelete->setEnabled(false);
@ -249,6 +254,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionEntryCopyUsername->setEnabled(false); m_ui->actionEntryCopyUsername->setEnabled(false);
m_ui->actionEntryCopyPassword->setEnabled(false); m_ui->actionEntryCopyPassword->setEnabled(false);
m_ui->actionEntryAutoType->setEnabled(false); m_ui->actionEntryAutoType->setEnabled(false);
m_ui->actionEntryOpenUrl->setEnabled(false);
m_ui->actionGroupNew->setEnabled(false); m_ui->actionGroupNew->setEnabled(false);
m_ui->actionGroupEdit->setEnabled(false); m_ui->actionGroupEdit->setEnabled(false);
m_ui->actionGroupDelete->setEnabled(false); m_ui->actionGroupDelete->setEnabled(false);

View file

@ -70,7 +70,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>800</width>
<height>20</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -113,6 +113,7 @@
<addaction name="actionEntryCopyUsername"/> <addaction name="actionEntryCopyUsername"/>
<addaction name="actionEntryCopyPassword"/> <addaction name="actionEntryCopyPassword"/>
<addaction name="actionEntryAutoType"/> <addaction name="actionEntryAutoType"/>
<addaction name="actionEntryOpenUrl"/>
</widget> </widget>
<widget class="QMenu" name="menuGroups"> <widget class="QMenu" name="menuGroups">
<property name="title"> <property name="title">
@ -319,6 +320,14 @@
<string>Perform Auto-Type</string> <string>Perform Auto-Type</string>
</property> </property>
</action> </action>
<action name="actionEntryOpenUrl">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Open URL</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>