mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Create src/gui/{entry,group}/ and move corresponding files to these dirs.
This commit is contained in:
106
src/gui/group/EditGroupWidget.cpp
Normal file
106
src/gui/group/EditGroupWidget.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 or (at your option)
|
||||
* version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "EditGroupWidget.h"
|
||||
#include "ui_EditGroupWidgetMain.h"
|
||||
#include "ui_EditWidget.h"
|
||||
|
||||
#include "core/Metadata.h"
|
||||
#include "gui/EditWidgetIcons.h"
|
||||
|
||||
EditGroupWidget::EditGroupWidget(QWidget* parent)
|
||||
: EditWidget(parent)
|
||||
, m_mainUi(new Ui::EditGroupWidgetMain())
|
||||
, m_editGroupWidgetMain(new QWidget())
|
||||
, m_editGroupWidgetIcons(new EditWidgetIcons())
|
||||
, m_group(0)
|
||||
{
|
||||
m_mainUi->setupUi(m_editGroupWidgetMain);
|
||||
|
||||
add(tr("Group"), m_editGroupWidgetMain);
|
||||
add(tr("Icon"), m_editGroupWidgetIcons);
|
||||
|
||||
QFont labelHeaderFont = headlineLabel()->font();
|
||||
labelHeaderFont.setBold(true);
|
||||
labelHeaderFont.setPointSize(labelHeaderFont.pointSize() + 2);
|
||||
headlineLabel()->setFont(labelHeaderFont);
|
||||
|
||||
connect(this, SIGNAL(accepted()), SLOT(save()));
|
||||
connect(this, SIGNAL(rejected()), SLOT(cancel()));
|
||||
}
|
||||
|
||||
EditGroupWidget::~EditGroupWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void EditGroupWidget::loadGroup(Group* group, bool create, Database* database)
|
||||
{
|
||||
m_group = group;
|
||||
m_database = database;
|
||||
|
||||
if (create) {
|
||||
headlineLabel()->setText(tr("Add group"));
|
||||
}
|
||||
else {
|
||||
headlineLabel()->setText(tr("Edit group"));
|
||||
}
|
||||
|
||||
m_mainUi->editName->setText(m_group->name());
|
||||
m_mainUi->editNotes->setPlainText(m_group->notes());
|
||||
|
||||
setCurrentRow(0);
|
||||
IconStruct iconStruct;
|
||||
iconStruct.uuid = group->iconUuid();
|
||||
iconStruct.number = group->iconNumber();
|
||||
m_editGroupWidgetIcons->load(group->uuid(), database, iconStruct);
|
||||
|
||||
m_mainUi->editName->setFocus();
|
||||
}
|
||||
|
||||
void EditGroupWidget::save()
|
||||
{
|
||||
m_group->setName(m_mainUi->editName->text());
|
||||
m_group->setNotes(m_mainUi->editNotes->toPlainText());
|
||||
|
||||
IconStruct iconStruct = m_editGroupWidgetIcons->save();
|
||||
|
||||
if (iconStruct.number < 0) {
|
||||
m_group->setIcon(Group::DefaultIconNumber);
|
||||
}
|
||||
else if (iconStruct.uuid.isNull()) {
|
||||
m_group->setIcon(iconStruct.number);
|
||||
}
|
||||
else {
|
||||
m_group->setIcon(iconStruct.uuid);
|
||||
}
|
||||
|
||||
m_group = 0;
|
||||
m_database = 0;
|
||||
Q_EMIT editFinished(true);
|
||||
}
|
||||
|
||||
void EditGroupWidget::cancel()
|
||||
{
|
||||
if (!m_group->iconUuid().isNull() &&
|
||||
!m_database->metadata()->containsCustomIcon(m_group->iconUuid())) {
|
||||
m_group->setIcon(Entry::DefaultIconNumber);
|
||||
}
|
||||
|
||||
m_group = 0;
|
||||
m_database = 0;
|
||||
Q_EMIT editFinished(false);
|
||||
}
|
||||
Reference in New Issue
Block a user