Commit 6242e6e7 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Add a separate configuration dialog for configuring groups of keys

The groups configuration has (or rather, soon will have) too many
dependencies to make a KCModule feasible without some major refactoring.

GnuPG-bug-id: 5175, 5239
parent 8d6a1326
Pipeline #51918 passed with stage
in 17 minutes and 40 seconds
......@@ -259,6 +259,9 @@ set(_kleopatra_SRCS
${_kleopatra_uiserver_files}
conf/configuredialog.cpp
conf/groupsconfigdialog.cpp
conf/groupsconfigpage.cpp
conf/groupsconfigwidget.cpp
newcertificatewizard/listwidget.cpp
newcertificatewizard/newcertificatewizard.cpp
......
......@@ -37,9 +37,6 @@ set(kcm_kleopatra_PART_SRCS
appearanceconfigpage.cpp
appearanceconfigwidget.cpp
gnupgsystemconfigurationpage.cpp
groupsconfigpage.cpp
groupsconfigwidget.cpp
${kleopatra_SOURCE_DIR}/src/dialogs/editgroupdialog.cpp
${kleopatra_BINARY_DIR}/src/kleopatra_debug.cpp
${_kcm_kleopatra_libkleopatraclient_extra_SRCS}
)
......@@ -85,7 +82,6 @@ install(FILES
kleopatra_config_dirserv.desktop
kleopatra_config_appear.desktop
kleopatra_config_gnupgsystem.desktop
kleopatra_config_groups.desktop
${_kcm_kleopatra_libkleopatraclient_extra_install_FILES}
DESTINATION ${KDE_INSTALL_KSERVICES5DIR}
)
......@@ -35,7 +35,6 @@ ConfigureDialog::ConfigureDialog(QWidget *parent)
{
setFaceType(KPageDialog::List);
setWindowTitle(i18nc("@title:window", "Configure"));
addModule(QStringLiteral("kleopatra_config_groups"));
addModule(QStringLiteral("kleopatra_config_dirserv"));
addModule(QStringLiteral("kleopatra_config_appear"));
addModule(QStringLiteral("kleopatra_config_cryptooperations"));
......
/*
conf/groupsconfigdialog.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kleopatra.h>
#include "groupsconfigdialog.h"
#include "groupsconfigpage.h"
#include <KConfigGroup>
#include <KGuiItem>
#include <KLocalizedString>
#include <KSharedConfig>
#include <KStandardGuiItem>
#include <QDialogButtonBox>
#include <QPushButton>
class GroupsConfigDialog::Private
{
friend class ::GroupsConfigDialog;
GroupsConfigDialog *const q;
GroupsConfigPage *configPage = nullptr;
bool changed = false;
public:
Private(GroupsConfigDialog *qq)
: q(qq)
, configPage(new GroupsConfigPage(qq))
{
restoreLayout();
}
~Private()
{
saveLayout();
}
private:
void saveLayout()
{
KConfigGroup configGroup(KSharedConfig::openConfig(), "GroupsConfigDialog");
configGroup.writeEntry("Size", q->size());
configGroup.sync();
}
void restoreLayout(const QSize &defaultSize = QSize())
{
const KConfigGroup configGroup(KSharedConfig::openConfig(), "GroupsConfigDialog");
const QSize size = configGroup.readEntry("Size", defaultSize);
if (size.isValid()) {
q->resize(size);
}
}
};
GroupsConfigDialog::GroupsConfigDialog(QWidget *parent)
: KConfigDialog(parent, GroupsConfigDialog::dialogName(), /*config=*/ nullptr)
, d(new Private(this))
{
setWindowTitle(i18nc("@title:window", "Configure Groups"));
setFaceType(KPageDialog::Plain);
addPage(d->configPage, i18n("Groups"), /*pixmapName=*/ QString(), /*header=*/ QString(), /*manage=*/ false);
// there are no defaults to restore
buttonBox()->removeButton(buttonBox()->button(QDialogButtonBox::RestoreDefaults));
QPushButton *resetButton = buttonBox()->addButton(QDialogButtonBox::Reset);
KGuiItem::assign(resetButton, KStandardGuiItem::reset());
resetButton->setEnabled(false);
connect(buttonBox()->button(QDialogButtonBox::Reset), &QAbstractButton::clicked,
this, &GroupsConfigDialog::updateWidgets);
connect(d->configPage, &GroupsConfigPage::changed, this, [this] (bool state) {
d->changed = state;
updateButtons();
if (QPushButton *button = buttonBox()->button(QDialogButtonBox::Reset)) {
button->setEnabled(d->changed);
}
});
}
GroupsConfigDialog::~GroupsConfigDialog() = default;
QString GroupsConfigDialog::dialogName()
{
return QStringLiteral("Group Settings");
}
void GroupsConfigDialog::updateSettings()
{
d->configPage->save();
}
void GroupsConfigDialog::updateWidgets()
{
d->configPage->load();
}
bool GroupsConfigDialog::hasChanged()
{
return d->changed;
}
/*
conf/groupsconfigdialog.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __KLEOPATRA_CONF_GROUPSCONFIGDIALOG_H__
#define __KLEOPATRA_CONF_GROUPSCONFIGDIALOG_H__
#include <KConfigDialog>
class GroupsConfigDialog : public KConfigDialog
{
Q_OBJECT
public:
explicit GroupsConfigDialog(QWidget *parent = nullptr);
~GroupsConfigDialog() override;
static QString dialogName();
private Q_SLOTS:
void updateSettings() override;
void updateWidgets() override;
private:
bool hasChanged() override;
private:
class Private;
const std::unique_ptr<Private> d;
};
#endif /* __KLEOPATRA_CONF_GROUPSCONFIGDIALOG_H__ */
......@@ -42,13 +42,10 @@ GroupsConfigPage::Private::Private(GroupsConfigPage *qq)
{
}
GroupsConfigPage::GroupsConfigPage(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
GroupsConfigPage::GroupsConfigPage(QWidget *parent)
: QWidget(parent)
, d(new Private(this))
{
// do not show the Defaults button; it has no effect
setButtons(buttons() & ~KCModule::Default);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
......@@ -59,15 +56,15 @@ GroupsConfigPage::GroupsConfigPage(QWidget *parent, const QVariantList &args)
layout->addWidget(d->widget);
connect(d->widget, &GroupsConfigWidget::changed, this, &GroupsConfigPage::markAsChanged);
connect(d->widget, &GroupsConfigWidget::changed, this, [this] () { Q_EMIT changed(true); });
}
GroupsConfigPage::~GroupsConfigPage() = default;
void GroupsConfigPage::load()
{
qCDebug(KLEOPATRA_LOG) << "GroupsConfigPage::load()";
d->widget->setGroups(KeyCache::instance()->configurableGroups());
Q_EMIT changed(false);
}
void GroupsConfigPage::save()
......@@ -77,13 +74,3 @@ void GroupsConfigPage::save()
// reload after saving to ensure that the groups reflect the saved groups (e.g. in case of immutable entries)
load();
}
extern "C"
{
Q_DECL_EXPORT KCModule *create_kleopatra_config_groups(QWidget *parent = nullptr, const QVariantList &args = QVariantList())
{
GroupsConfigPage *page = new GroupsConfigPage(parent, args);
page->setObjectName(QStringLiteral("kleopatra_config_groups"));
return page;
}
}
......@@ -11,17 +11,21 @@
#ifndef __KLEOPATRA_CONF_GROUPSCONFIGPAGE_H__
#define __KLEOPATRA_CONF_GROUPSCONFIGPAGE_H__
#include <KCModule>
#include <QWidget>
class GroupsConfigPage : public KCModule
class GroupsConfigPage : public QWidget
{
Q_OBJECT
public:
explicit GroupsConfigPage(QWidget *parent = nullptr, const QVariantList &args = QVariantList());
explicit GroupsConfigPage(QWidget *parent = nullptr);
~GroupsConfigPage() override;
void load() override;
void save() override;
public Q_SLOTS:
void load();
void save();
Q_SIGNALS:
void changed(bool state);
private:
class Private;
......
[Desktop Entry]
Icon=group
Type=Service
X-KDE-ServiceTypes=KCModule
X-DocPath=kleopatra/configuration.html
X-KDE-ModuleType=Library
X-KDE-Library=kcm_kleopatra
X-KDE-FactoryName=kleopatra_config_groups
X-KDE-HasReadOnlyMode=false
X-KDE-ParentApp=kleopatra
X-KDE-ParentComponents=kleopatra
X-KDE-CfgDlgHierarchy=Kleopatra
Name=Groups
Name[ca]=Grups
Name[en_GB]=Groups
Name[es]=Grupos
Name[fr]=Groupes
Name[it]=Gruppi
Name[nl]=Groepen
Name[pt]=Grupos
Name[pt_BR]=Grupos
Name[sl]=Grupe
Name[sv]=Grupper
Name[uk]=Групи
Name[x-test]=xxGroupsxx
Comment=Configuration of groups of keys
Comment[ca]=Configuració dels grups de claus
Comment[en_GB]=Configuration of groups of keys
Comment[es]=Configuración de los grupos de claves
Comment[fr]=Configuration des groupes de clé
Comment[it]=Configurazione di gruppi di chiavi
Comment[nl]=Configuratie van groepen sleutels
Comment[pt]=Configuração dos grupos de chaves
Comment[pt_BR]=Configuração de grupos de chaves
Comment[sl]=Nastavitve grup ključev
Comment[sv]=Anpassning av nyckelgrupper
Comment[uk]=Налаштування груп ключів
Comment[x-test]=xxConfiguration of groups of keysxx
X-KDE-Keywords=groups,keys,certificates,configuration
X-KDE-Keywords[ca]=grups,claus,certificats,configuració
X-KDE-Keywords[en_GB]=groups,keys,certificates,configuration
X-KDE-Keywords[es]=grupos,claves,certificados,configuración
X-KDE-Keywords[fr]=groupes, clés, certificats, configuration
X-KDE-Keywords[it]=gruppi,chiavi,certificati,configurazione
X-KDE-Keywords[nl]=groepen,sleutels,certificaten,configuratie
X-KDE-Keywords[pt]=grupos,chaves,certificados,configuração
X-KDE-Keywords[pt_BR]=grupos,chaves,certificados,configuração
X-KDE-Keywords[sl]=grupe,ključi,potrdila,nastavitev
X-KDE-Keywords[sv]=grupper,nycklar,certifikat,inställning
X-KDE-Keywords[uk]=groups,keys,certificates,configuration,групи,ключі,сертифікати,налаштування
X-KDE-Keywords[x-test]=xxgroupsxx,xxkeysxx,xxcertificatesxx,xxconfigurationxx
<!DOCTYPE gui >
<gui name="kleopatra" version="502" >
<gui name="kleopatra" version="503" >
<MenuBar>
<Menu name="file">
<text>&amp;File</text>
......@@ -72,6 +72,7 @@
<Menu name="settings">
<text>&amp;Settings</text>
<Action name="settings_self_test"/>
<Action name="configure_groups" append="configure_merge"/>
</Menu>
<Menu name="window" append="settings_merge">
<text>&amp;Window</text>
......
......@@ -25,6 +25,8 @@
#include "commands/decryptverifyfilescommand.h"
#include "commands/signencryptfilescommand.h"
#include "conf/groupsconfigdialog.h"
#include "utils/detail_p.h"
#include <Libkleo/GnuPG>
#include "utils/action_data.h"
......@@ -49,6 +51,7 @@
#include <KEditToolBar>
#include "kleopatra_debug.h"
#include <KConfigGroup>
#include <KConfigDialog>
#include <QAbstractItemView>
#include <QCloseEvent>
......@@ -191,6 +194,16 @@ public:
{
createAndStart<SelfTestCommand>();
}
void configureGroups()
{
if (KConfigDialog::showDialog(GroupsConfigDialog::dialogName())) {
return;
}
KConfigDialog *dialog = new GroupsConfigDialog(q);
dialog->show();
}
void configureBackend();
void showHandbook();
......@@ -431,6 +444,10 @@ void MainWindow::Private::setupActions()
"settings_self_test", i18n("Perform Self-Test"), QString(),
nullptr, q, SLOT(selfTest()), QString(), false, true
},
{
"configure_groups", i18n("Configure Groups..."), QString(),
"group", q, SLOT(configureGroups()), QString(), false, true
},
{
"manage_smartcard", i18nc("@action show smartcard management view", "Smartcards"),
i18n("Show smartcard management"), "secure-card", q, SLOT(showSmartcardView()), QString(), false, true
......
......@@ -45,6 +45,7 @@ private:
Q_PRIVATE_SLOT(d, void selfTest())
Q_PRIVATE_SLOT(d, void configureBackend())
Q_PRIVATE_SLOT(d, void configureToolbars())
Q_PRIVATE_SLOT(d, void configureGroups())
Q_PRIVATE_SLOT(d, void editKeybindings())
Q_PRIVATE_SLOT(d, void gnupgLogViewer())
Q_PRIVATE_SLOT(d, void slotConfigCommitted())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment