context menu for group view

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@40 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 18 years ago
parent 69c3c401dd
commit 9fb1f983bf
  1. 10
      src/lib/GroupView.cpp
  2. 3
      src/lib/GroupView.h
  3. 99
      src/mainwindow.cpp

@ -32,6 +32,7 @@
#include <QPainter>
#include <QPen>
#include <QBrush>
#include <QMenu>
#include "main.h"
#include "GroupView.h"
#define INSERT_AREA_WIDTH 4
@ -42,6 +43,7 @@ db=NULL;
LastHoverItem=NULL;
setHeaderLabels(QStringList()<<tr("Gruppen"));
ShowSearchGroup=false;
ContextMenu=new QMenu(this);
}
void KeepassGroupView::selectSearchGroup(){
@ -248,6 +250,13 @@ if(ShowSearchGroup && (item == Items.back()))return true;
else return false;
}
void KeepassGroupView::contextMenuEvent(QContextMenuEvent* e){
if(!(GroupViewItem*)itemAt(e->pos()) && selectedItems().size()){
setItemSelected(selectedItems()[0],false);
}
e->accept();
ContextMenu->popup(e->globalPos());
}
GroupViewItem::GroupViewItem(QTreeWidget *parent):QTreeWidgetItem(parent){
}
@ -260,3 +269,4 @@ GroupViewItem::GroupViewItem(QTreeWidgetItem *parent):QTreeWidgetItem(parent){
GroupViewItem::GroupViewItem(QTreeWidgetItem *parent, QTreeWidgetItem *preceding):QTreeWidgetItem(parent,preceding){
}

@ -22,6 +22,7 @@
#include <QTreeWidget>
#include <QLine>
#include <QContextMenuEvent>
#include "../PwManager.h"
class GroupViewItem;
@ -37,6 +38,7 @@ public:
PwDatabase *db;
bool ShowSearchGroup; //needs a "updateItems()" after a change!
vector<GroupViewItem*>Items;
QMenu *ContextMenu;
signals:
void fileModified();
@ -49,6 +51,7 @@ protected:
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void paintEvent ( QPaintEvent * event );
virtual void contextMenuEvent(QContextMenuEvent *event);
private:
QLine InsertionMarker;

@ -60,44 +60,14 @@
KeepassMainWindow::KeepassMainWindow(QWidget *parent, Qt::WFlags flags):QMainWindow(parent,flags){
setupUi(this);
FileNewAction->setShortcut(tr("Ctrl+N"));
FileOpenAction->setShortcut(tr("Ctrl+O"));
FileSaveAction->setShortcut(tr("Ctrl+S"));
EditNewGroupAction->setShortcut(tr("Ctrl+G"));
EditPasswordToClipboardAction->setShortcut(tr("Ctrl+C"));
EditUsernameToClipboardAction->setShortcut(tr("Ctrl+B"));
EditOpenUrlAction->setShortcut(tr("Ctrl+U"));
EditNewEntryAction->setShortcut(tr("Ctrl+Y"));
EditEditEntryAction->setShortcut(tr("Ctrl+E"));
EditDeleteEntryAction->setShortcut(tr("Ctrl+D"));
EditCloneEntryAction->setShortcut(tr("Ctrl+K"));
EditSearchAction->setShortcut(tr("Ctrl+F"));
#ifdef Q_WS_MAC
FileCloseAction->setShortcut(tr("Ctrl+W"));
FileSaveAsAction->setShortcut(tr("Shift+Ctrl+S"));
EditGroupSearchAction->setShortcut(tr("Shift+Ctrl+F"));
#endif
ViewHidePasswordsAction->setChecked(config.ListView_HidePasswords);
ViewHideUsernamesAction->setChecked(config.ListView_HideUsernames);
ViewColumnsTitleAction->setChecked(config.Columns[0]);
ViewColumnsUsernameAction->setChecked(config.Columns[1]);
ViewColumnsUrlAction->setChecked(config.Columns[2]);
ViewColumnsPasswordAction->setChecked(config.Columns[3]);
ViewColumnsCommentAction->setChecked(config.Columns[4]);
ViewColumnsExpireAction->setChecked(config.Columns[5]);
ViewColumnsCreationAction->setChecked(config.Columns[6]);
ViewColumnsLastChangeAction->setChecked(config.Columns[7]);
ViewColumnsLastAccessAction->setChecked(config.Columns[8]);
ViewColumnsAttachmentAction->setChecked(config.Columns[9]);
QuickSearchEdit=new QLineEdit(toolBar);
QuickSearchEdit->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
setupConnections();
setupIcons();
setupToolbar();
setStateFileOpen(false);
setupMenus();
setupConnections();
FileOpen=false;
Clipboard=QApplication::clipboard();
}
@ -154,18 +124,18 @@ void KeepassMainWindow::setupConnections(){
}
void KeepassMainWindow::setupToolbar(){
toolBar->addAction(FileNewAction);
toolBar->addAction(FileOpenAction);
toolBar->addAction(FileSaveAction);
toolBar->addSeparator();
toolBar->addAction(EditNewEntryAction);
toolBar->addAction(EditEditEntryAction);
toolBar->addAction(EditDeleteEntryAction);
toolBar->addSeparator();
toolBar->addAction(EditPasswordToClipboardAction);
toolBar->addAction(EditUsernameToClipboardAction);
toolBar->addSeparator();
toolBar->addWidget(QuickSearchEdit);
toolBar->addAction(FileNewAction);
toolBar->addAction(FileOpenAction);
toolBar->addAction(FileSaveAction);
toolBar->addSeparator();
toolBar->addAction(EditNewEntryAction);
toolBar->addAction(EditEditEntryAction);
toolBar->addAction(EditDeleteEntryAction);
toolBar->addSeparator();
toolBar->addAction(EditPasswordToClipboardAction);
toolBar->addAction(EditUsernameToClipboardAction);
toolBar->addSeparator();
toolBar->addWidget(QuickSearchEdit);
}
void KeepassMainWindow::setupIcons(){
@ -190,6 +160,47 @@ EditSearchAction->setIcon(*Icon_EditSearch);
EditGroupSearchAction->setIcon(*Icon_EditSearch);
}
void KeepassMainWindow::setupMenus(){
GroupView->ContextMenu->addAction(EditNewGroupAction);
GroupView->ContextMenu->addAction(EditEditGroupAction);
GroupView->ContextMenu->addAction(EditDeleteGroupAction);
GroupView->ContextMenu->addSeparator();
GroupView->ContextMenu->addAction(EditNewEntryAction);
GroupView->ContextMenu->addSeparator();
GroupView->ContextMenu->addAction(EditGroupSearchAction);
ViewHidePasswordsAction->setChecked(config.ListView_HidePasswords);
ViewHideUsernamesAction->setChecked(config.ListView_HideUsernames);
ViewColumnsTitleAction->setChecked(config.Columns[0]);
ViewColumnsUsernameAction->setChecked(config.Columns[1]);
ViewColumnsUrlAction->setChecked(config.Columns[2]);
ViewColumnsPasswordAction->setChecked(config.Columns[3]);
ViewColumnsCommentAction->setChecked(config.Columns[4]);
ViewColumnsExpireAction->setChecked(config.Columns[5]);
ViewColumnsCreationAction->setChecked(config.Columns[6]);
ViewColumnsLastChangeAction->setChecked(config.Columns[7]);
ViewColumnsLastAccessAction->setChecked(config.Columns[8]);
ViewColumnsAttachmentAction->setChecked(config.Columns[9]);
FileNewAction->setShortcut(tr("Ctrl+N"));
FileOpenAction->setShortcut(tr("Ctrl+O"));
FileSaveAction->setShortcut(tr("Ctrl+S"));
EditNewGroupAction->setShortcut(tr("Ctrl+G"));
EditPasswordToClipboardAction->setShortcut(tr("Ctrl+C"));
EditUsernameToClipboardAction->setShortcut(tr("Ctrl+B"));
EditOpenUrlAction->setShortcut(tr("Ctrl+U"));
EditNewEntryAction->setShortcut(tr("Ctrl+Y"));
EditEditEntryAction->setShortcut(tr("Ctrl+E"));
EditDeleteEntryAction->setShortcut(tr("Ctrl+D"));
EditCloneEntryAction->setShortcut(tr("Ctrl+K"));
EditSearchAction->setShortcut(tr("Ctrl+F"));
#ifdef Q_WS_MAC
FileCloseAction->setShortcut(tr("Ctrl+W"));
FileSaveAsAction->setShortcut(tr("Shift+Ctrl+S"));
EditGroupSearchAction->setShortcut(tr("Shift+Ctrl+F"));
#endif
}
void KeepassMainWindow::openDatabase(QString filename){
Q_ASSERT(!FileOpen);