mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-28 00:39:43 -05:00
Implement GUI for creating entries.
This commit is contained in:
parent
019bcd380e
commit
4d8e9561a7
@ -206,6 +206,13 @@ void DatabaseManager::saveDatabaseAs(int index)
|
|||||||
saveDatabaseAs(indexDatabase(index));
|
saveDatabaseAs(indexDatabase(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseManager::createEntry()
|
||||||
|
{
|
||||||
|
Database* db = indexDatabase(m_tabWidget->currentIndex());
|
||||||
|
DatabaseWidget* dbWidget = m_dbList[db].dbWidget;
|
||||||
|
dbWidget->createEntry();
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseManager::createGroup()
|
void DatabaseManager::createGroup()
|
||||||
{
|
{
|
||||||
Database* db = indexDatabase(m_tabWidget->currentIndex());
|
Database* db = indexDatabase(m_tabWidget->currentIndex());
|
||||||
|
@ -57,6 +57,7 @@ public Q_SLOTS:
|
|||||||
void saveDatabase(int index = -1);
|
void saveDatabase(int index = -1);
|
||||||
void saveDatabaseAs(int index = -1);
|
void saveDatabaseAs(int index = -1);
|
||||||
void closeDatabase(int index = -1);
|
void closeDatabase(int index = -1);
|
||||||
|
void createEntry();
|
||||||
void createGroup();
|
void createGroup();
|
||||||
void editGroup();
|
void editGroup();
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
||||||
: QStackedWidget(parent)
|
: QStackedWidget(parent)
|
||||||
, m_newGroup(0)
|
, m_newGroup(0)
|
||||||
, m_newGroupParent(0)
|
, m_newParent(0)
|
||||||
{
|
{
|
||||||
m_mainWidget = new QWidget(this);
|
m_mainWidget = new QWidget(this);
|
||||||
QLayout* layout = new QHBoxLayout(m_mainWidget);
|
QLayout* layout = new QHBoxLayout(m_mainWidget);
|
||||||
@ -78,11 +78,19 @@ EntryView* DatabaseWidget::entryView()
|
|||||||
return m_entryView;
|
return m_entryView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseWidget::createEntry()
|
||||||
|
{
|
||||||
|
m_newEntry = new Entry();
|
||||||
|
m_newEntry->setUuid(Uuid::random());
|
||||||
|
m_newParent = m_groupView->currentGroup();
|
||||||
|
switchToEntryEdit(m_newEntry, true);
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseWidget::createGroup()
|
void DatabaseWidget::createGroup()
|
||||||
{
|
{
|
||||||
m_newGroup = new Group();
|
m_newGroup = new Group();
|
||||||
m_newGroup->setUuid(Uuid::random());
|
m_newGroup->setUuid(Uuid::random());
|
||||||
m_newGroupParent = m_groupView->currentGroup();
|
m_newParent = m_groupView->currentGroup();
|
||||||
switchToGroupEdit(m_newGroup, true);
|
switchToGroupEdit(m_newGroup, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,14 +98,25 @@ void DatabaseWidget::switchToView(bool accepted)
|
|||||||
{
|
{
|
||||||
if (m_newGroup) {
|
if (m_newGroup) {
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
m_newGroup->setParent(m_newGroupParent);
|
m_newGroup->setParent(m_newParent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delete m_newGroup;
|
delete m_newGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_newGroup = 0;
|
m_newGroup = 0;
|
||||||
m_newGroupParent = 0;
|
m_newParent = 0;
|
||||||
|
}
|
||||||
|
else if (m_newEntry) {
|
||||||
|
if (accepted) {
|
||||||
|
m_newEntry->setGroup(m_newParent);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
delete m_newEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_newEntry = 0;
|
||||||
|
m_newParent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentIndex(0);
|
setCurrentIndex(0);
|
||||||
@ -105,7 +124,12 @@ void DatabaseWidget::switchToView(bool accepted)
|
|||||||
|
|
||||||
void DatabaseWidget::switchToEntryEdit(Entry* entry)
|
void DatabaseWidget::switchToEntryEdit(Entry* entry)
|
||||||
{
|
{
|
||||||
m_editEntryWidget->loadEntry(entry);
|
switchToEntryEdit(entry, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseWidget::switchToEntryEdit(Entry* entry, bool create)
|
||||||
|
{
|
||||||
|
m_editEntryWidget->loadEntry(entry, create, m_groupView->currentGroup()->name());
|
||||||
setCurrentIndex(1);
|
setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,11 +140,10 @@ void DatabaseWidget::switchToGroupEdit(Group* group, bool create)
|
|||||||
}
|
}
|
||||||
void DatabaseWidget::switchToEntryEdit()
|
void DatabaseWidget::switchToEntryEdit()
|
||||||
{
|
{
|
||||||
// TODO switchToEntryEdit(m_entryView->currentEntry());
|
// TODO switchToEntryEdit(m_entryView->currentEntry(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::switchToGroupEdit()
|
void DatabaseWidget::switchToGroupEdit()
|
||||||
{
|
{
|
||||||
switchToGroupEdit(m_groupView->currentGroup(), false);
|
switchToGroupEdit(m_groupView->currentGroup(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ public:
|
|||||||
EntryView* entryView();
|
EntryView* entryView();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
void createEntry();
|
||||||
void createGroup();
|
void createGroup();
|
||||||
void switchToEntryEdit();
|
void switchToEntryEdit();
|
||||||
void switchToGroupEdit();
|
void switchToGroupEdit();
|
||||||
@ -45,6 +46,7 @@ public Q_SLOTS:
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void switchToView(bool accepted);
|
void switchToView(bool accepted);
|
||||||
void switchToEntryEdit(Entry* entry);
|
void switchToEntryEdit(Entry* entry);
|
||||||
|
void switchToEntryEdit(Entry* entry, bool create);
|
||||||
void switchToGroupEdit(Group* entry, bool create);
|
void switchToGroupEdit(Group* entry, bool create);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -54,7 +56,8 @@ private:
|
|||||||
GroupView* m_groupView;
|
GroupView* m_groupView;
|
||||||
EntryView* m_entryView;
|
EntryView* m_entryView;
|
||||||
Group* m_newGroup;
|
Group* m_newGroup;
|
||||||
Group* m_newGroupParent;
|
Entry* m_newEntry;
|
||||||
|
Group* m_newParent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_DATABASEWIDGET_H
|
#endif // KEEPASSX_DATABASEWIDGET_H
|
||||||
|
@ -62,11 +62,16 @@ EditEntryWidget::~EditEntryWidget()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditEntryWidget::loadEntry(Entry* entry)
|
void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupName)
|
||||||
{
|
{
|
||||||
m_entry = entry;
|
m_entry = entry;
|
||||||
|
|
||||||
m_ui->headerLabel->setText(m_entry->group()->name()+" > "+tr("Edit entry"));
|
if (create) {
|
||||||
|
m_ui->headerLabel->setText(groupName+" > "+tr("Add entry"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui->headerLabel->setText(groupName+" > "+tr("Edit entry"));
|
||||||
|
}
|
||||||
|
|
||||||
m_mainUi->titleEdit->setText(entry->title());
|
m_mainUi->titleEdit->setText(entry->title());
|
||||||
m_mainUi->usernameEdit->setText(entry->username());
|
m_mainUi->usernameEdit->setText(entry->username());
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
explicit EditEntryWidget(QWidget* parent = 0);
|
explicit EditEntryWidget(QWidget* parent = 0);
|
||||||
~EditEntryWidget();
|
~EditEntryWidget();
|
||||||
|
|
||||||
void loadEntry(Entry* entry);
|
void loadEntry(Entry* entry, bool create, const QString& groupName);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void editFinished(bool accepted);
|
void editFinished(bool accepted);
|
||||||
|
@ -37,6 +37,7 @@ MainWindow::MainWindow()
|
|||||||
connect(m_ui->actionDatabaseSave, SIGNAL(triggered()), m_dbManager, SLOT(saveDatabase()));
|
connect(m_ui->actionDatabaseSave, SIGNAL(triggered()), m_dbManager, SLOT(saveDatabase()));
|
||||||
connect(m_ui->actionDatabaseSaveAs, SIGNAL(triggered()), m_dbManager, SLOT(saveDatabaseAs()));
|
connect(m_ui->actionDatabaseSaveAs, SIGNAL(triggered()), m_dbManager, SLOT(saveDatabaseAs()));
|
||||||
connect(m_ui->actionDatabaseClose, SIGNAL(triggered()), m_dbManager, SLOT(closeDatabase()));
|
connect(m_ui->actionDatabaseClose, SIGNAL(triggered()), m_dbManager, SLOT(closeDatabase()));
|
||||||
|
connect(m_ui->actionEntryNew, SIGNAL(triggered()), m_dbManager, SLOT(createEntry()));
|
||||||
connect(m_ui->actionGroupNew, SIGNAL(triggered()), m_dbManager, SLOT(createGroup()));
|
connect(m_ui->actionGroupNew, SIGNAL(triggered()), m_dbManager, SLOT(createGroup()));
|
||||||
connect(m_ui->actionGroupEdit, SIGNAL(triggered()), m_dbManager, SLOT(editGroup()));
|
connect(m_ui->actionGroupEdit, SIGNAL(triggered()), m_dbManager, SLOT(editGroup()));
|
||||||
connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(close()));
|
connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(close()));
|
||||||
|
Loading…
Reference in New Issue
Block a user