mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-28 07:17:08 -05:00
Add context menus for group and entry view.
This commit is contained in:
parent
e323fd169e
commit
5c0a83eae5
@ -22,9 +22,10 @@
|
|||||||
#include <QtGui/QAction>
|
#include <QtGui/QAction>
|
||||||
#include <QtGui/QHBoxLayout>
|
#include <QtGui/QHBoxLayout>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
#include <QtGui/QSplitter>
|
|
||||||
#include <QtGui/QLineEdit>
|
#include <QtGui/QLineEdit>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtGui/QSplitter>
|
||||||
|
|
||||||
#include "core/DataPath.h"
|
#include "core/DataPath.h"
|
||||||
#include "core/Metadata.h"
|
#include "core/Metadata.h"
|
||||||
@ -44,6 +45,8 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
|||||||
, m_newGroup(0)
|
, m_newGroup(0)
|
||||||
, m_newEntry(0)
|
, m_newEntry(0)
|
||||||
, m_newParent(0)
|
, m_newParent(0)
|
||||||
|
, m_menuGroup(new QMenu(this))
|
||||||
|
, m_menuEntry(new QMenu(this))
|
||||||
{
|
{
|
||||||
m_searchUi->setupUi(m_searchWidget);
|
m_searchUi->setupUi(m_searchWidget);
|
||||||
|
|
||||||
@ -59,9 +62,13 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
|||||||
|
|
||||||
m_groupView = new GroupView(db, splitter);
|
m_groupView = new GroupView(db, splitter);
|
||||||
m_groupView->setObjectName("groupView");
|
m_groupView->setObjectName("groupView");
|
||||||
|
m_groupView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(m_groupView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showGroupContextMenu(QPoint)));
|
||||||
|
|
||||||
m_entryView = new EntryView(rightHandSideWidget);
|
m_entryView = new EntryView(rightHandSideWidget);
|
||||||
m_entryView->setObjectName("entryView");
|
m_entryView->setObjectName("entryView");
|
||||||
|
m_entryView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(m_entryView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showEntryContextMenu(QPoint)));
|
||||||
|
|
||||||
QSizePolicy policy;
|
QSizePolicy policy;
|
||||||
policy = m_groupView->sizePolicy();
|
policy = m_groupView->sizePolicy();
|
||||||
@ -108,6 +115,19 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
|||||||
addWidget(m_databaseSettingsWidget);
|
addWidget(m_databaseSettingsWidget);
|
||||||
addWidget(m_historyEditEntryWidget);
|
addWidget(m_historyEditEntryWidget);
|
||||||
|
|
||||||
|
m_actionEntryNew = m_menuEntry->addAction(tr("Add new entry"), this, SLOT(createEntry()));
|
||||||
|
m_actionEntryClone = m_menuEntry->addAction(tr("Clone entry"), this, SLOT(cloneEntry()));
|
||||||
|
m_actionEntryClone->setEnabled(false);
|
||||||
|
m_actionEntryEditView = m_menuEntry->addAction(tr("View/Edit entry"), this, SLOT(switchToEntryEdit()));
|
||||||
|
m_actionEntryEditView->setEnabled(false);
|
||||||
|
m_actionEntryDelete = m_menuEntry->addAction(tr("Delete entry"), this, SLOT(deleteEntry()));
|
||||||
|
m_actionEntryDelete->setEnabled(false);
|
||||||
|
|
||||||
|
m_actionGroupNew = m_menuGroup->addAction(tr("Add new group"), this, SLOT(createGroup()));
|
||||||
|
m_actionGroupEdit = m_menuGroup->addAction(tr("Edit group"), this, SLOT(switchToGroupEdit()));
|
||||||
|
m_actionGroupDelete = m_menuGroup->addAction(tr("Delete group"), this, SLOT(deleteGroup()));
|
||||||
|
m_actionGroupDelete->setEnabled(false);
|
||||||
|
|
||||||
connect(m_groupView, SIGNAL(groupChanged(Group*)), m_entryView, SLOT(setGroup(Group*)));
|
connect(m_groupView, SIGNAL(groupChanged(Group*)), m_entryView, SLOT(setGroup(Group*)));
|
||||||
connect(m_groupView, SIGNAL(groupChanged(Group*)), this, SLOT(clearLastGroup(Group*)));
|
connect(m_groupView, SIGNAL(groupChanged(Group*)), this, SLOT(clearLastGroup(Group*)));
|
||||||
connect(m_entryView, SIGNAL(entryActivated(Entry*)), SLOT(switchToEntryEdit(Entry*)));
|
connect(m_entryView, SIGNAL(entryActivated(Entry*)), SLOT(switchToEntryEdit(Entry*)));
|
||||||
@ -121,6 +141,8 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
|||||||
connect(m_searchUi->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(startSearchTimer()));
|
connect(m_searchUi->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(startSearchTimer()));
|
||||||
connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(search()));
|
connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(search()));
|
||||||
connect(closeAction, SIGNAL(triggered()), this, SLOT(closeSearch()));
|
connect(closeAction, SIGNAL(triggered()), this, SLOT(closeSearch()));
|
||||||
|
connect(m_entryView, SIGNAL(entrySelectionChanged()), SLOT(updateEntryActions()));
|
||||||
|
connect(m_groupView, SIGNAL(groupChanged(Group*)), SLOT(updateGroupActions()));
|
||||||
|
|
||||||
setCurrentIndex(0);
|
setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
@ -431,3 +453,29 @@ void DatabaseWidget::clearLastGroup(Group* group)
|
|||||||
m_searchWidget->hide();
|
m_searchWidget->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseWidget::updateGroupActions()
|
||||||
|
{
|
||||||
|
m_actionGroupDelete->setEnabled(canDeleteCurrentGoup());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseWidget::updateEntryActions()
|
||||||
|
{
|
||||||
|
bool singleEntrySelected = m_entryView->isSingleEntrySelected();
|
||||||
|
bool inSearch = m_entryView->inSearch();
|
||||||
|
|
||||||
|
m_actionEntryNew->setEnabled(!inSearch);
|
||||||
|
m_actionEntryClone->setEnabled(singleEntrySelected && !inSearch);
|
||||||
|
m_actionEntryEditView->setEnabled(singleEntrySelected);
|
||||||
|
m_actionEntryDelete->setEnabled(singleEntrySelected);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseWidget::showGroupContextMenu(const QPoint& pos)
|
||||||
|
{
|
||||||
|
m_menuGroup->exec(m_groupView->viewport()->mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseWidget::showEntryContextMenu(const QPoint& pos)
|
||||||
|
{
|
||||||
|
m_menuEntry->exec(m_entryView->viewport()->mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
@ -30,6 +30,7 @@ class Entry;
|
|||||||
class EntryView;
|
class EntryView;
|
||||||
class Group;
|
class Group;
|
||||||
class GroupView;
|
class GroupView;
|
||||||
|
class QMenu;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class SearchWidget;
|
class SearchWidget;
|
||||||
@ -52,10 +53,6 @@ public:
|
|||||||
GroupView* groupView();
|
GroupView* groupView();
|
||||||
EntryView* entryView();
|
EntryView* entryView();
|
||||||
bool dbHasKey();
|
bool dbHasKey();
|
||||||
void cloneEntry();
|
|
||||||
void deleteEntry();
|
|
||||||
void deleteGroup();
|
|
||||||
|
|
||||||
bool canDeleteCurrentGoup();
|
bool canDeleteCurrentGoup();
|
||||||
int addWidget(QWidget* w);
|
int addWidget(QWidget* w);
|
||||||
void setCurrentIndex(int index);
|
void setCurrentIndex(int index);
|
||||||
@ -67,7 +64,10 @@ Q_SIGNALS:
|
|||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void createEntry();
|
void createEntry();
|
||||||
|
void cloneEntry();
|
||||||
|
void deleteEntry();
|
||||||
void createGroup();
|
void createGroup();
|
||||||
|
void deleteGroup();
|
||||||
void switchToEntryEdit();
|
void switchToEntryEdit();
|
||||||
void switchToGroupEdit();
|
void switchToGroupEdit();
|
||||||
void switchToMasterKeyChange();
|
void switchToMasterKeyChange();
|
||||||
@ -88,6 +88,10 @@ private Q_SLOTS:
|
|||||||
void startSearchTimer();
|
void startSearchTimer();
|
||||||
void showSearch();
|
void showSearch();
|
||||||
void closeSearch();
|
void closeSearch();
|
||||||
|
void updateGroupActions();
|
||||||
|
void updateEntryActions();
|
||||||
|
void showGroupContextMenu(const QPoint& pos);
|
||||||
|
void showEntryContextMenu(const QPoint& pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void truncateHistories();
|
void truncateHistories();
|
||||||
@ -108,6 +112,17 @@ private:
|
|||||||
Group* m_newParent;
|
Group* m_newParent;
|
||||||
Group* m_lastGroup;
|
Group* m_lastGroup;
|
||||||
QTimer* m_searchTimer;
|
QTimer* m_searchTimer;
|
||||||
|
|
||||||
|
QMenu* m_menuGroup;
|
||||||
|
QAction* m_actionGroupNew;
|
||||||
|
QAction* m_actionGroupEdit;
|
||||||
|
QAction* m_actionGroupDelete;
|
||||||
|
|
||||||
|
QMenu* m_menuEntry;
|
||||||
|
QAction* m_actionEntryNew;
|
||||||
|
QAction* m_actionEntryClone;
|
||||||
|
QAction* m_actionEntryEditView;
|
||||||
|
QAction* m_actionEntryDelete;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_DATABASEWIDGET_H
|
#endif // KEEPASSX_DATABASEWIDGET_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user