Group edit widget inherits from base edit widget.

This commit is contained in:
Florian Geyer 2012-05-14 19:10:54 +02:00
parent f596cc4eec
commit eb3a0be809
4 changed files with 32 additions and 54 deletions

View File

@ -123,7 +123,7 @@ set(keepassx_FORMS
gui/EditEntryWidgetIcons.ui gui/EditEntryWidgetIcons.ui
gui/EditEntryWidgetMain.ui gui/EditEntryWidgetMain.ui
gui/EditEntryWidgetNotes.ui gui/EditEntryWidgetNotes.ui
gui/EditGroupWidget.ui gui/EditGroupWidgetMain.ui
gui/EditWidget.ui gui/EditWidget.ui
gui/MainWindow.ui gui/MainWindow.ui
) )

View File

@ -16,22 +16,26 @@
*/ */
#include "EditGroupWidget.h" #include "EditGroupWidget.h"
#include "ui_EditGroupWidget.h" #include "ui_EditGroupWidgetMain.h"
#include "ui_EditWidget.h"
EditGroupWidget::EditGroupWidget(QWidget* parent) EditGroupWidget::EditGroupWidget(QWidget* parent)
: DialogyWidget(parent) : EditWidget(parent)
, m_ui(new Ui::EditGroupWidget()) , m_mainUi(new Ui::EditGroupWidgetMain())
, m_editGroupWidgetMain(new QWidget())
, m_group(0) , 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.setBold(true);
labelHeaderFont.setPointSize(labelHeaderFont.pointSize() + 2); labelHeaderFont.setPointSize(labelHeaderFont.pointSize() + 2);
m_ui->labelHeader->setFont(labelHeaderFont); headlineLabel()->setFont(labelHeaderFont);
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(save())); connect(this, SIGNAL(accepted()), SLOT(save()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(cancel())); connect(this, SIGNAL(rejected()), SLOT(cancel()));
} }
EditGroupWidget::~EditGroupWidget() EditGroupWidget::~EditGroupWidget()
@ -43,22 +47,24 @@ void EditGroupWidget::loadGroup(Group* group, bool create)
m_group = group; m_group = group;
if (create) { if (create) {
m_ui->labelHeader->setText(tr("Add group")); headlineLabel()->setText(tr("Add group"));
} }
else { else {
m_ui->labelHeader->setText(tr("Edit group")); headlineLabel()->setText(tr("Edit group"));
} }
m_ui->editName->setText(m_group->name()); m_mainUi->editName->setText(m_group->name());
m_ui->editNotes->setPlainText(m_group->notes()); m_mainUi->editNotes->setPlainText(m_group->notes());
m_ui->editName->setFocus(); setCurrentRow(0);
m_mainUi->editName->setFocus();
} }
void EditGroupWidget::save() void EditGroupWidget::save()
{ {
m_group->setName(m_ui->editName->text()); m_group->setName(m_mainUi->editName->text());
m_group->setNotes(m_ui->editNotes->toPlainText()); m_group->setNotes(m_mainUi->editNotes->toPlainText());
m_group = 0; m_group = 0;
Q_EMIT editFinished(true); Q_EMIT editFinished(true);

View File

@ -20,15 +20,15 @@
#include <QtCore/QScopedPointer> #include <QtCore/QScopedPointer>
#include "gui/DialogyWidget.h" #include "gui/EditWidget.h"
#include "core/Group.h" #include "core/Group.h"
namespace Ui { namespace Ui {
class EditGroupWidget; class EditGroupWidgetMain;
class EditWidget;
} }
class EditGroupWidget : public DialogyWidget class EditGroupWidget : public EditWidget
{ {
Q_OBJECT Q_OBJECT
@ -46,7 +46,8 @@ private Q_SLOTS:
void cancel(); void cancel();
private: private:
const QScopedPointer<Ui::EditGroupWidget> m_ui; const QScopedPointer<Ui::EditGroupWidgetMain> m_mainUi;
QWidget* m_editGroupWidgetMain;
Group* m_group; Group* m_group;
Q_DISABLE_COPY(EditGroupWidget) Q_DISABLE_COPY(EditGroupWidget)

View File

@ -1,35 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>EditGroupWidget</class> <class>EditGroupWidgetMain</class>
<widget class="QWidget" name="EditGroupWidget"> <widget class="QWidget" name="EditGroupWidgetMain">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>544</width> <width>676</width>
<height>263</height> <height>334</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labelHeader"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>3</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy"> <property name="fieldGrowthPolicy">
@ -57,16 +38,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>