From eb3a0be809d594ffe0183e3ca6c14da5cc1017c6 Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Mon, 14 May 2012 19:10:54 +0200 Subject: [PATCH] Group edit widget inherits from base edit widget. --- src/CMakeLists.txt | 2 +- src/gui/EditGroupWidget.cpp | 36 ++++++++++-------- src/gui/EditGroupWidget.h | 11 +++--- ...tGroupWidget.ui => EditGroupWidgetMain.ui} | 37 ++----------------- 4 files changed, 32 insertions(+), 54 deletions(-) rename src/gui/{EditGroupWidget.ui => EditGroupWidgetMain.ui} (54%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cfc452ad2..a95489ea5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -123,7 +123,7 @@ set(keepassx_FORMS gui/EditEntryWidgetIcons.ui gui/EditEntryWidgetMain.ui gui/EditEntryWidgetNotes.ui - gui/EditGroupWidget.ui + gui/EditGroupWidgetMain.ui gui/EditWidget.ui gui/MainWindow.ui ) diff --git a/src/gui/EditGroupWidget.cpp b/src/gui/EditGroupWidget.cpp index 9b596a6b1..0bc0e5753 100644 --- a/src/gui/EditGroupWidget.cpp +++ b/src/gui/EditGroupWidget.cpp @@ -16,22 +16,26 @@ */ #include "EditGroupWidget.h" -#include "ui_EditGroupWidget.h" +#include "ui_EditGroupWidgetMain.h" +#include "ui_EditWidget.h" EditGroupWidget::EditGroupWidget(QWidget* parent) - : DialogyWidget(parent) - , m_ui(new Ui::EditGroupWidget()) + : EditWidget(parent) + , m_mainUi(new Ui::EditGroupWidgetMain()) + , m_editGroupWidgetMain(new QWidget()) , m_group(0) { - m_ui->setupUi(this); + m_mainUi->setupUi(m_editGroupWidgetMain); - QFont labelHeaderFont = m_ui->labelHeader->font(); + add(tr("Group"), m_editGroupWidgetMain); + + QFont labelHeaderFont = headlineLabel()->font(); labelHeaderFont.setBold(true); labelHeaderFont.setPointSize(labelHeaderFont.pointSize() + 2); - m_ui->labelHeader->setFont(labelHeaderFont); + headlineLabel()->setFont(labelHeaderFont); - connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(save())); - connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(cancel())); + connect(this, SIGNAL(accepted()), SLOT(save())); + connect(this, SIGNAL(rejected()), SLOT(cancel())); } EditGroupWidget::~EditGroupWidget() @@ -43,22 +47,24 @@ void EditGroupWidget::loadGroup(Group* group, bool create) m_group = group; if (create) { - m_ui->labelHeader->setText(tr("Add group")); + headlineLabel()->setText(tr("Add group")); } else { - m_ui->labelHeader->setText(tr("Edit group")); + headlineLabel()->setText(tr("Edit group")); } - m_ui->editName->setText(m_group->name()); - m_ui->editNotes->setPlainText(m_group->notes()); + m_mainUi->editName->setText(m_group->name()); + m_mainUi->editNotes->setPlainText(m_group->notes()); - m_ui->editName->setFocus(); + setCurrentRow(0); + + m_mainUi->editName->setFocus(); } void EditGroupWidget::save() { - m_group->setName(m_ui->editName->text()); - m_group->setNotes(m_ui->editNotes->toPlainText()); + m_group->setName(m_mainUi->editName->text()); + m_group->setNotes(m_mainUi->editNotes->toPlainText()); m_group = 0; Q_EMIT editFinished(true); diff --git a/src/gui/EditGroupWidget.h b/src/gui/EditGroupWidget.h index 5ec6f4451..125ef1df7 100644 --- a/src/gui/EditGroupWidget.h +++ b/src/gui/EditGroupWidget.h @@ -20,15 +20,15 @@ #include -#include "gui/DialogyWidget.h" - +#include "gui/EditWidget.h" #include "core/Group.h" namespace Ui { - class EditGroupWidget; + class EditGroupWidgetMain; + class EditWidget; } -class EditGroupWidget : public DialogyWidget +class EditGroupWidget : public EditWidget { Q_OBJECT @@ -46,7 +46,8 @@ private Q_SLOTS: void cancel(); private: - const QScopedPointer m_ui; + const QScopedPointer m_mainUi; + QWidget* m_editGroupWidgetMain; Group* m_group; Q_DISABLE_COPY(EditGroupWidget) diff --git a/src/gui/EditGroupWidget.ui b/src/gui/EditGroupWidgetMain.ui similarity index 54% rename from src/gui/EditGroupWidget.ui rename to src/gui/EditGroupWidgetMain.ui index 448f07d43..c91cf8754 100644 --- a/src/gui/EditGroupWidget.ui +++ b/src/gui/EditGroupWidgetMain.ui @@ -1,35 +1,16 @@ - EditGroupWidget - + EditGroupWidgetMain + 0 0 - 544 - 263 + 676 + 334 - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 1 - 3 - - - - @@ -57,16 +38,6 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - -