diff --git a/src/gui/EntryView.cpp b/src/gui/EntryView.cpp index 4750ae83b..784a8cce0 100644 --- a/src/gui/EntryView.cpp +++ b/src/gui/EntryView.cpp @@ -25,6 +25,7 @@ EntryView::EntryView(QWidget* parent) : QTreeView(parent) , m_model(new EntryModel(this)) , m_sortModel(new QSortFilterProxyModel(this)) + , m_inSearch(false) { m_sortModel->setSourceModel(m_model); m_sortModel->setDynamicSortFilter(true); @@ -58,6 +59,11 @@ void EntryView::search(QList entries) Q_EMIT entrySelectionChanged(); } +bool EntryView::inSearch() +{ + return m_inSearch; +} + void EntryView::emitEntryActivated(const QModelIndex& index) { Q_EMIT entryActivated(entryFromIndex(index)); @@ -98,9 +104,11 @@ Entry* EntryView::entryFromIndex(const QModelIndex& index) void EntryView::switchToSearch() { showColumn(0); + m_inSearch = true; } void EntryView::switchToView() { hideColumn(0); + m_inSearch = false; } diff --git a/src/gui/EntryView.h b/src/gui/EntryView.h index abacfc05c..bf7bab147 100644 --- a/src/gui/EntryView.h +++ b/src/gui/EntryView.h @@ -37,6 +37,7 @@ public: void setCurrentEntry(Entry* entry); Entry* entryFromIndex(const QModelIndex& index); void search(QList entries); + bool inSearch(); public Q_SLOTS: void setGroup(Group* group); @@ -53,6 +54,7 @@ Q_SIGNALS: private: EntryModel* const m_model; QSortFilterProxyModel* const m_sortModel; + bool m_inSearch; }; #endif // KEEPASSX_ENTRYVIEW_H diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 2606ceb54..d3e0db7e9 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -102,8 +102,13 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) switch (mode) { case DatabaseWidget::ViewMode: - m_ui->actionEntryNew->setEnabled(true); - m_ui->actionGroupNew->setEnabled(true); + if (dbWidget->entryView()->inSearch()) { + m_ui->actionEntryNew->setEnabled(false); + } + else { + m_ui->actionEntryNew->setEnabled(true); + } + if (dbWidget->entryView()->currentIndex().isValid()) { m_ui->actionEntryEdit->setEnabled(true); m_ui->actionEntryDelete->setEnabled(true); @@ -112,13 +117,21 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) m_ui->actionEntryEdit->setEnabled(false); m_ui->actionEntryDelete->setEnabled(false); } - m_ui->actionGroupEdit->setEnabled(true); - if (dbWidget->canDeleteCurrentGoup()) { - m_ui->actionGroupDelete->setEnabled(true); + if (dbWidget->entryView()->inSearch()) { + m_ui->actionGroupNew->setEnabled(false); + m_ui->actionGroupEdit->setEnabled(false); + m_ui->actionGroupDelete->setEnabled(false); } else { - m_ui->actionGroupDelete->setEnabled(false); + m_ui->actionGroupNew->setEnabled(true); + m_ui->actionGroupEdit->setEnabled(true); + if (dbWidget->canDeleteCurrentGoup()) { + m_ui->actionGroupDelete->setEnabled(true); + } + else { + m_ui->actionGroupDelete->setEnabled(false); + } } m_ui->actionChangeMasterKey->setEnabled(true); m_ui->actionChangeDatabaseSettings->setEnabled(true);