From 0c7e1f1a6b3ea13c192c86239e50da1dff765776 Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Tue, 15 May 2012 10:50:08 +0200 Subject: [PATCH] Entry edit widget inherits from base edit widget. --- src/CMakeLists.txt | 1 - src/gui/EditEntryWidget.cpp | 38 +++++++------------- src/gui/EditEntryWidget.h | 7 ++-- src/gui/EditEntryWidget.ui | 69 ------------------------------------- 4 files changed, 16 insertions(+), 99 deletions(-) delete mode 100644 src/gui/EditEntryWidget.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a95489ea5..db566483e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -118,7 +118,6 @@ set(keepassx_FORMS gui/ChangeMasterKeyWidget.ui gui/DatabaseOpenDialog.ui gui/DatabaseSettingsWidget.ui - gui/EditEntryWidget.ui gui/EditEntryWidgetAdvanced.ui gui/EditEntryWidgetIcons.ui gui/EditEntryWidgetMain.ui diff --git a/src/gui/EditEntryWidget.cpp b/src/gui/EditEntryWidget.cpp index 35c28817a..9ce203f58 100644 --- a/src/gui/EditEntryWidget.cpp +++ b/src/gui/EditEntryWidget.cpp @@ -16,7 +16,7 @@ */ #include "EditEntryWidget.h" -#include "ui_EditEntryWidget.h" +#include "ui_EditWidget.h" #include "ui_EditEntryWidgetAdvanced.h" #include "ui_EditEntryWidgetMain.h" #include "ui_EditEntryWidgetNotes.h" @@ -36,9 +36,8 @@ #include "gui/FileDialog.h" EditEntryWidget::EditEntryWidget(QWidget* parent) - : DialogyWidget(parent) + : EditWidget(parent) , m_entry(0) - , m_ui(new Ui::EditEntryWidget()) , m_mainUi(new Ui::EditEntryWidgetMain()) , m_notesUi(new Ui::EditEntryWidgetNotes()) , m_advancedUi(new Ui::EditEntryWidgetAdvanced()) @@ -48,29 +47,22 @@ EditEntryWidget::EditEntryWidget(QWidget* parent) , m_advancedWidget(new QWidget(this)) , m_iconsWidget(new QWidget(this)) { - m_ui->setupUi(this); - - QFont headerLabelFont = m_ui->headerLabel->font(); + QFont headerLabelFont = headlineLabel()->font(); headerLabelFont.setBold(true); headerLabelFont.setPointSize(headerLabelFont.pointSize() + 2); - m_ui->headerLabel->setFont(headerLabelFont); - - m_ui->categoryList->addItem(tr("Entry")); - m_ui->categoryList->addItem(tr("Description")); - m_ui->categoryList->addItem(tr("Advanced")); - m_ui->categoryList->addItem(tr("Icon")); + headlineLabel()->setFont(headerLabelFont); m_mainUi->setupUi(m_mainWidget); - m_ui->stackedWidget->addWidget(m_mainWidget); + add(tr("Entry"), m_mainWidget); m_notesUi->setupUi(m_notesWidget); - m_ui->stackedWidget->addWidget(m_notesWidget); + add(tr("Description"), m_notesWidget); m_advancedUi->setupUi(m_advancedWidget); - m_ui->stackedWidget->addWidget(m_advancedWidget); + add(tr("Advanced"), m_advancedWidget); m_iconsUi->setupUi(m_iconsWidget); - m_ui->stackedWidget->addWidget(m_iconsWidget); + add(tr("Icon"), m_iconsWidget); m_entryAttachments = new EntryAttachments(this); m_attachmentsModel = new EntryAttachmentsModel(m_advancedWidget); @@ -91,10 +83,6 @@ EditEntryWidget::EditEntryWidget(QWidget* parent) SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(updateCurrentAttribute())); - Q_ASSERT(m_ui->categoryList->model()->rowCount() == m_ui->stackedWidget->count()); - - connect(m_ui->categoryList, SIGNAL(currentRowChanged(int)), m_ui->stackedWidget, SLOT(setCurrentIndex(int))); - connect(m_mainUi->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePassword(bool))); connect(m_mainUi->expireCheck, SIGNAL(toggled(bool)), m_mainUi->expireDatePicker, SLOT(setEnabled(bool))); connect(m_mainUi->passwordEdit, SIGNAL(textEdited(QString)), SLOT(setPasswordCheckColors())); @@ -117,8 +105,8 @@ EditEntryWidget::EditEntryWidget(QWidget* parent) connect(m_iconsUi->addButton, SIGNAL(clicked()), SLOT(addCustomIcon())); connect(m_iconsUi->deleteButton, SIGNAL(clicked()), SLOT(removeCustomIcon())); - connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(saveEntry())); - connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(cancel())); + connect(this, SIGNAL(accepted()), SLOT(saveEntry())); + connect(this, SIGNAL(rejected()), SLOT(cancel())); } EditEntryWidget::~EditEntryWidget() @@ -136,10 +124,10 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupN m_create = create; if (create) { - m_ui->headerLabel->setText(groupName+" > "+tr("Add entry")); + headlineLabel()->setText(groupName+" > "+tr("Add entry")); } else { - m_ui->headerLabel->setText(groupName+" > "+tr("Edit entry")); + headlineLabel()->setText(groupName+" > "+tr("Edit entry")); } m_mainUi->titleEdit->setText(entry->title()); @@ -157,7 +145,7 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupN m_entryAttributes->copyCustomKeysFrom(entry->attributes()); *m_entryAttachments = *entry->attachments(); - m_ui->categoryList->setCurrentRow(0); + setCurrentRow(0); if (m_attributesModel->rowCount() != 0) { m_advancedUi->attributesView->setCurrentIndex(m_attributesModel->index(0, 0)); diff --git a/src/gui/EditEntryWidget.h b/src/gui/EditEntryWidget.h index 03a6514a3..01dfa069e 100644 --- a/src/gui/EditEntryWidget.h +++ b/src/gui/EditEntryWidget.h @@ -21,7 +21,7 @@ #include #include -#include "gui/DialogyWidget.h" +#include "gui/EditWidget.h" class Database; class Entry; @@ -35,14 +35,14 @@ class Metadata; class QStackedLayout; namespace Ui { - class EditEntryWidget; class EditEntryWidgetAdvanced; class EditEntryWidgetMain; class EditEntryWidgetNotes; class EditEntryWidgetIcons; + class EditWidget; } -class EditEntryWidget : public DialogyWidget +class EditEntryWidget : public EditWidget { Q_OBJECT @@ -84,7 +84,6 @@ private: Database* m_database; bool m_create; - const QScopedPointer m_ui; const QScopedPointer m_mainUi; const QScopedPointer m_notesUi; const QScopedPointer m_advancedUi; diff --git a/src/gui/EditEntryWidget.ui b/src/gui/EditEntryWidget.ui deleted file mode 100644 index c178bfbe2..000000000 --- a/src/gui/EditEntryWidget.ui +++ /dev/null @@ -1,69 +0,0 @@ - - - EditEntryWidget - - - - 0 - 0 - 400 - 300 - - - - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 1 - 3 - - - - - - - - - - - - - -1 - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - CategoryListWidget - QListWidget -
gui/EditEntryWidget_p.h
-
-
- - -