Skip to content

Commit

Permalink
Add special context menu for entries
Browse files Browse the repository at this point in the history
* Fixes #2813

Added special context menu for entries to move the most-used actions to the top.

Re-ordered actions in the entry menu to be more user friendly.
  • Loading branch information
droidmonkey committed Oct 20, 2019
1 parent 5d1eae2 commit 68631f6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
19 changes: 17 additions & 2 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,21 @@ MainWindow::MainWindow()

m_countDefaultAttributes = m_ui->menuEntryCopyAttribute->actions().size();

m_entryContextMenu = new QMenu(this);
m_entryContextMenu->addAction(m_ui->actionEntryCopyUsername);
m_entryContextMenu->addAction(m_ui->actionEntryCopyPassword);
m_entryContextMenu->addAction(m_ui->menuEntryCopyAttribute->menuAction());
m_entryContextMenu->addAction(m_ui->menuEntryTotp->menuAction());
m_entryContextMenu->addSeparator();
m_entryContextMenu->addAction(m_ui->actionEntryAutoType);
m_entryContextMenu->addSeparator();
m_entryContextMenu->addAction(m_ui->actionEntryEdit);
m_entryContextMenu->addAction(m_ui->actionEntryClone);
m_entryContextMenu->addAction(m_ui->actionEntryDelete);
m_entryContextMenu->addSeparator();
m_entryContextMenu->addAction(m_ui->actionEntryOpenUrl);
m_entryContextMenu->addAction(m_ui->actionEntryDownloadIcon);

restoreGeometry(config()->get("GUI/MainWindowGeometry").toByteArray());
restoreState(config()->get("GUI/MainWindowState").toByteArray());
#ifdef WITH_XC_BROWSER
Expand Down Expand Up @@ -639,6 +654,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
case DatabaseWidget::Mode::EditMode:
case DatabaseWidget::Mode::ImportMode:
case DatabaseWidget::Mode::LockedMode: {
// Enable select actions when editing an entry
bool editEntryActive = dbWidget->isEntryEditActive();
const auto editEntryActionsMask = QList<QAction*>({m_ui->actionEntryCopyUsername,
m_ui->actionEntryCopyPassword,
Expand All @@ -656,7 +672,6 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
entryActions << m_ui->menuEntryCopyAttribute->actions();
entryActions << m_ui->menuEntryTotp->actions();
for (auto action : entryActions) {
// Enable select actions when editing an entry
bool enabled = editEntryActive && editEntryActionsMask.contains(action);
if (action->menu()) {
action->menu()->setEnabled(enabled);
Expand Down Expand Up @@ -1110,7 +1125,7 @@ void MainWindow::releaseContextFocusLock()

void MainWindow::showEntryContextMenu(const QPoint& globalPos)
{
m_ui->menuEntries->popup(globalPos);
m_entryContextMenu->popup(globalPos);
}

void MainWindow::showGroupContextMenu(const QPoint& globalPos)
Expand Down
1 change: 1 addition & 0 deletions src/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ private slots:
SignalMultiplexer m_actionMultiplexer;
QAction* m_clearHistoryAction;
QAction* m_searchWidgetAction;
QMenu* m_entryContextMenu;
QActionGroup* m_lastDatabasesActions;
QActionGroup* m_copyAdditionalAttributeActions;
InactivityTimer* m_inactivityTimer;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
<height>21</height>
</rect>
</property>
<property name="focusPolicy">
Expand Down Expand Up @@ -298,11 +298,11 @@
<addaction name="actionEntryCopyUsername"/>
<addaction name="actionEntryCopyPassword"/>
<addaction name="menuEntryCopyAttribute"/>
<addaction name="separator"/>
<addaction name="menuEntryTotp"/>
<addaction name="actionEntryOpenUrl"/>
<addaction name="separator"/>
<addaction name="actionEntryAutoType"/>
<addaction name="separator"/>
<addaction name="actionEntryOpenUrl"/>
<addaction name="actionEntryDownloadIcon"/>
</widget>
<widget class="QMenu" name="menuGroups">
Expand Down

0 comments on commit 68631f6

Please sign in to comment.