diff --git a/src/forms/MainWindow.ui b/src/forms/MainWindow.ui
index 92d4a1b..b4aea45 100644
--- a/src/forms/MainWindow.ui
+++ b/src/forms/MainWindow.ui
@@ -158,7 +158,7 @@
-
+
@@ -284,7 +284,7 @@
Benutzername in Zwischenablage kopieren
-
+
URL öffnen
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index d70bcb2..2f78168 100755
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -82,6 +82,8 @@ void KeepassMainWindow::setupConnections(){
SLOT(OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
connect(EntryView,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,
SLOT(OnEntryItemDoubleClicked(QTreeWidgetItem*,int)));
+ connect(EntryView,SIGNAL(itemSelectionChanged()), this, SLOT(OnEntrySelectionChanged()));
+ connect(GroupView,SIGNAL(itemSelectionChanged()), this, SLOT(OnGroupSelectionChanged()));
}
void KeepassMainWindow::setupToolbar(){
@@ -200,8 +202,28 @@ FileSaveAsAction->setEnabled(IsOpen);
FileCloseAction->setEnabled(IsOpen);
FileSettingsAction->setEnabled(IsOpen);
FileChangeKeyAction->setEnabled(IsOpen);
+EditSearchAction->setEnabled(IsOpen);
GroupView->setEnabled(IsOpen);
EntryView->setEnabled(IsOpen);
+if(!IsOpen){
+ EditNewGroupAction->setEnabled(false);
+ EditEditGroupAction->setEnabled(false);
+ EditDeleteGroupAction->setEnabled(false);
+ EditPasswordToClipboardAction->setEnabled(false);
+ EditUsernameToClipboardAction->setEnabled(false);
+ OpenUrlAction->setEnabled(false);
+ EditSaveAttachmentAction->setEnabled(false);
+ EditNewEntryAction->setEnabled(false);
+ EditEditEntryAction->setEnabled(false);
+ EditCloneEntryAction->setEnabled(false);
+ EditDeleteEntryAction->setEnabled(false);
+ EditGroupSearchAction->setEnabled(false);
+}
+else{
+ OnGroupSelectionChanged();
+ OnEntrySelectionChanged();
+}
+
}
void KeepassMainWindow::editEntry(CEntry* pEntry){
@@ -216,6 +238,66 @@ ModFlag=mod;
FileSaveAction->setEnabled(mod);
}
+void KeepassMainWindow::setStateGroupSelected(SelectionState s){
+GroupSelection=s;
+switch(GroupSelection){
+ case NONE:
+ EditNewGroupAction->setEnabled(true);
+ EditEditGroupAction->setEnabled(false);
+ EditDeleteGroupAction->setEnabled(false);
+ EditGroupSearchAction->setEnabled(false);
+ EditNewEntryAction->setEnabled(false);
+ break;
+ case SINGLE:
+ EditNewGroupAction->setEnabled(true);
+ EditEditGroupAction->setEnabled(true);
+ EditDeleteGroupAction->setEnabled(true);
+ EditGroupSearchAction->setEnabled(true);
+ EditNewEntryAction->setEnabled(true);
+ break;
+default: Q_ASSERT(false);
+}
+}
+
+void KeepassMainWindow::setStateEntrySelected(SelectionState s){
+EntrySelection=NONE;
+switch(EntrySelection){
+ case NONE:
+ EditPasswordToClipboardAction->setEnabled(false);
+ EditUsernameToClipboardAction->setEnabled(false);
+ OpenUrlAction->setEnabled(false);
+ EditSaveAttachmentAction->setEnabled(false);
+ EditEditEntryAction->setEnabled(false);
+ EditCloneEntryAction->setEnabled(false);
+ EditCloneEntryAction->setText(trUtf8("Eintrag duplizieren"));
+ EditDeleteEntryAction->setEnabled(false);
+ EditDeleteEntryAction->setText(trUtf8("Eintrag löschen"));
+ break;
+ case SINGLE:
+ EditPasswordToClipboardAction->setEnabled(true);
+ EditUsernameToClipboardAction->setEnabled(true);
+ OpenUrlAction->setEnabled(true);
+ EditSaveAttachmentAction->setEnabled(true);
+ EditEditEntryAction->setEnabled(true);
+ EditCloneEntryAction->setEnabled(true);
+ EditCloneEntryAction->setText(trUtf8("Eintrag duplizieren"));
+ EditDeleteEntryAction->setEnabled(true);
+ EditDeleteEntryAction->setText(trUtf8("Eintrag löschen"));
+ break;
+ case MULTIPLE:
+ EditPasswordToClipboardAction->setEnabled(false);
+ EditUsernameToClipboardAction->setEnabled(false);
+ OpenUrlAction->setEnabled(false);
+ EditSaveAttachmentAction->setEnabled(false);
+ EditEditEntryAction->setEnabled(false);
+ EditCloneEntryAction->setEnabled(true);
+ EditCloneEntryAction->setText(trUtf8("Einträge duplizieren"));
+ EditDeleteEntryAction->setEnabled(true);
+ EditDeleteEntryAction->setText(trUtf8("Einträge löschen"));
+ break;
+ default: Q_ASSERT(false);
+}
+}
bool KeepassMainWindow::OnFileSave(){
if(db->filename==QString())
@@ -268,4 +350,22 @@ void KeepassMainWindow::OnEntryItemDoubleClicked(QTreeWidgetItem* item,int colum
if(column) return;
if(!config.Columns[0]) return;
editEntry(static_cast(item)->pEntry);
+}
+
+void KeepassMainWindow::OnEntrySelectionChanged(){
+if(EntryView->selectedItems().size()==0)
+ setStateEntrySelected(NONE);
+if(EntryView->selectedItems().size()==1)
+ setStateEntrySelected(SINGLE);
+if(EntryView->selectedItems().size()>1)
+ setStateEntrySelected(MULTIPLE);
+
+}
+
+void KeepassMainWindow::OnGroupSelectionChanged(){
+if(GroupView->selectedItems().size()==0)
+ setStateGroupSelected(NONE);
+if(GroupView->selectedItems().size()==1)
+ setStateGroupSelected(SINGLE);
+Q_ASSERT(GroupView->selectedItems().size()<=1);
}
\ No newline at end of file
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 8dbc0d8..4d48243 100755
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -42,7 +42,7 @@
#include "ui_MainWindow.h"
-#define NO_ENTRY_SELECTED
+
class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
Q_OBJECT
@@ -63,9 +63,12 @@ private slots:
void OnImportFromKWalletXml();
void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*);
void OnEntryItemDoubleClicked(QTreeWidgetItem* item,int column);
-
+ void OnEntrySelectionChanged();
+ void OnGroupSelectionChanged();
private:
+ enum SelectionState{NONE,SINGLE,MULTIPLE};
+ SelectionState GroupSelection, EntrySelection;
bool FileOpen;
bool ModFlag;
inline void setupToolbar();
@@ -73,6 +76,8 @@ private:
inline void setupConnections();
void setStateFileOpen(bool);
void setStateFileModified(bool);
+ void setStateGroupSelected(SelectionState s);
+ void setStateEntrySelected(SelectionState s);
void openDatabase(QString filename);
bool closeDatabase();
void editEntry(CEntry* pEntry);