diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index 6a8b0118a..17d0e490e 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -397,6 +397,11 @@ void DatabaseTabWidget::performAutoType() currentDatabaseWidget()->performAutoType(); } +void DatabaseTabWidget::openUrl() +{ + currentDatabaseWidget()->openUrl(); +} + void DatabaseTabWidget::createGroup() { currentDatabaseWidget()->createGroup(); diff --git a/src/gui/DatabaseTabWidget.h b/src/gui/DatabaseTabWidget.h index 37aea0fb2..7bd99abee 100644 --- a/src/gui/DatabaseTabWidget.h +++ b/src/gui/DatabaseTabWidget.h @@ -74,6 +74,7 @@ public Q_SLOTS: void copyUsername(); void copyPassword(); void performAutoType(); + void openUrl(); void createGroup(); void editGroup(); void deleteGroup(); diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 36fb53cfe..e2d9984c2 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -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) diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index 9d682e056..2abd72b30 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -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 diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 961e87539..e81d95dc4 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -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); diff --git a/src/gui/MainWindow.ui b/src/gui/MainWindow.ui index f699f9daa..bb2b989f7 100644 --- a/src/gui/MainWindow.ui +++ b/src/gui/MainWindow.ui @@ -70,7 +70,7 @@ 0 0 800 - 20 + 21 @@ -113,6 +113,7 @@ + @@ -319,6 +320,14 @@ Perform Auto-Type + + + false + + + Open URL + +