menu item (de)activation for selection modes of group/entry view

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@10 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent 28e824ac0c
commit 8642ccfe94
  1. 4
      src/forms/MainWindow.ui
  2. 100
      src/mainwindow.cpp
  3. 9
      src/mainwindow.h

@ -158,7 +158,7 @@
<addaction name="separator" />
<addaction name="EditPasswordToClipboardAction" />
<addaction name="EditUsernameToClipboardAction" />
<addaction name="ActionOpenUrl" />
<addaction name="OpenUrlAction" />
<addaction name="EditSaveAttachmentAction" />
<addaction name="separator" />
<addaction name="EditNewEntryAction" />
@ -284,7 +284,7 @@
<string>Benutzername in Zwischenablage kopieren</string>
</property>
</action>
<action name="ActionOpenUrl" >
<action name="OpenUrlAction" >
<property name="text" >
<string>URL öffnen</string>
</property>

@ -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<EntryViewItem*>(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);
}

@ -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);