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();
}
void DatabaseTabWidget::openUrl()
{
currentDatabaseWidget()->openUrl();
}
void DatabaseTabWidget::createGroup()
{
currentDatabaseWidget()->createGroup();

View File

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

View File

@ -20,6 +20,7 @@
#include <QtCore/QTimer>
#include <QtGui/QAction>
#include <QtGui/QDesktopServices>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
@ -160,6 +161,8 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
m_actionEntryAutoType->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V));
}
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->setIcon(filePath()->icon("actions", "group-new", false));
@ -241,6 +244,8 @@ bool DatabaseWidget::actionEnabled(Action action)
return m_actionEntryCopyPassword->isEnabled();
case EntryAutoType:
return m_actionEntryAutoType->isEnabled();
case EntryOpenUrl:
return m_actionEntryOpenUrl->isEnabled();
default:
Q_ASSERT(false);
return false;
@ -353,6 +358,19 @@ void DatabaseWidget::performAutoType()
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()
{
if (!m_groupView->currentGroup()) {
@ -699,6 +717,7 @@ void DatabaseWidget::updateEntryActions()
m_actionEntryCopyUsername->setEnabled(singleEntrySelected);
m_actionEntryCopyPassword->setEnabled(singleEntrySelected);
m_actionEntryAutoType->setEnabled(singleEntrySelected);
m_actionEntryOpenUrl->setEnabled(singleEntrySelected);
}
void DatabaseWidget::showGroupContextMenu(const QPoint& pos)

View File

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

View File

@ -65,6 +65,7 @@ MainWindow::MainWindow()
m_ui->actionEntryCopyUsername->setShortcut(Qt::CTRL + Qt::Key_B);
m_ui->actionEntryCopyPassword->setShortcut(Qt::CTRL + Qt::Key_C);
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->actionDatabaseOpen->setIcon(filePath()->icon("actions", "document-open"));
@ -135,6 +136,8 @@ MainWindow::MainWindow()
SLOT(copyPassword()));
connect(m_ui->actionEntryAutoType, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(performAutoType()));
connect(m_ui->actionEntryOpenUrl, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(openUrl()));
connect(m_ui->actionGroupNew, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(createGroup()));
@ -206,6 +209,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionEntryCopyUsername->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryCopyUsername));
m_ui->actionEntryCopyPassword->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryCopyPassword));
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->actionGroupEdit->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupEdit));
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->actionEntryCopyPassword->setEnabled(false);
m_ui->actionEntryAutoType->setEnabled(false);
m_ui->actionEntryOpenUrl->setEnabled(false);
m_ui->actionGroupNew->setEnabled(false);
m_ui->actionGroupEdit->setEnabled(false);
m_ui->actionGroupDelete->setEnabled(false);
@ -249,6 +254,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionEntryCopyUsername->setEnabled(false);
m_ui->actionEntryCopyPassword->setEnabled(false);
m_ui->actionEntryAutoType->setEnabled(false);
m_ui->actionEntryOpenUrl->setEnabled(false);
m_ui->actionGroupNew->setEnabled(false);
m_ui->actionGroupEdit->setEnabled(false);
m_ui->actionGroupDelete->setEnabled(false);

View File

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