Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F34252315
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
13 KB
Subscribers
None
View Options
diff --git a/src/conf/configuredialog.cpp b/src/conf/configuredialog.cpp
index 5aba5d3f8..e91479368 100644
--- a/src/conf/configuredialog.cpp
+++ b/src/conf/configuredialog.cpp
@@ -1,83 +1,78 @@
/*
configuredialog.cpp
This file is part of kleopatra
SPDX-FileCopyrightText: 2000 Espen Sand <espen@kde.org>
SPDX-FileCopyrightText: 2001-2002 Marc Mutz <mutz@kde.org>
SPDX-FileCopyrightText: 2004, 2008 Klarälvdalens Datakonsult AB
SPDX-FileCopyrightText: 2016 Bundesamt für Sicherheit in der Informationstechnik
SPDX-FileContributor: Intevation GmbH
SPDX-License-Identifier: GPL-2.0-only
*/
#include "configuredialog.h"
#include <KConfig>
#include <KLocalizedString>
#include <KConfigGroup>
#include <KSharedConfig>
#include "conf/appearanceconfigpage.h"
#include "conf/cryptooperationsconfigpage.h"
#include "conf/dirservconfigpage.h"
#include "conf/gnupgsystemconfigurationpage.h"
#include "conf/smimevalidationconfigurationpage.h"
ConfigureDialog::ConfigureDialog(QWidget *parent)
: KleoPageConfigDialog(parent)
{
setFaceType(KPageDialog::List);
setWindowTitle(i18nc("@title:window", "Configure"));
addModule(i18n("Directory Services"),
- i18n("Configuration of directory services"),
QStringLiteral("kleopatra/configuration.html#configuration-directory-services"),
QStringLiteral("view-certificate-server-configure"),
new DirectoryServicesConfigurationPage(this));
addModule(i18n("Appearance"),
- i18n("Colors & Fonts Configuration"),
QStringLiteral("kleopatra/configuration-appearance.html"),
QStringLiteral("applications-graphics"),
new Kleo::Config::AppearanceConfigurationPage(this));
addModule(i18n("Crypto Operations"),
- i18n("Configuration of Crypto Operations"),
QStringLiteral("kleopatra/configuration-cryptooperations.html"),
QStringLiteral("document-encrypt"),
new Kleo::Config::CryptoOperationsConfigurationPage(this));
addModule(i18n("S/MIME Validation"),
- i18n("Configuration of S/MIME certificate validation options"),
QStringLiteral("kleopatra/configuration.html#configuration-smime-validation"),
QStringLiteral("preferences-system-network"),
new Kleo::Config::SMimeValidationConfigurationPage(this));
addModule(i18n("GnuPG System"),
- i18n("Configuration of GnuPG System options"),
QStringLiteral("kleopatra/configuration.html#configuration-gnupgsystem"),
QStringLiteral("document-encrypt"),
new Kleo::Config::GnuPGSystemConfigurationPage(this));
// We store the minimum size of the dialog on hide, because otherwise
// the KCMultiDialog starts with the size of the first kcm, not
// the largest one. This way at least after the first showing of
// the largest kcm the size is kept.
const KConfigGroup geometry(KSharedConfig::openStateConfig(), "Geometry");
const int width = geometry.readEntry("ConfigureDialogWidth", 0);
const int height = geometry.readEntry("ConfigureDialogHeight", 0);
if (width != 0 && height != 0) {
setMinimumSize(width, height);
}
}
void ConfigureDialog::hideEvent(QHideEvent *e)
{
const QSize minSize = minimumSizeHint();
KConfigGroup geometry(KSharedConfig::openStateConfig(), "Geometry");
geometry.writeEntry("ConfigureDialogWidth", minSize.width());
geometry.writeEntry("ConfigureDialogHeight", minSize.height());
KleoPageConfigDialog::hideEvent(e);
}
ConfigureDialog::~ConfigureDialog()
{
}
diff --git a/src/conf/kleopageconfigdialog.cpp b/src/conf/kleopageconfigdialog.cpp
index c0e7a5f6c..b688353b5 100644
--- a/src/conf/kleopageconfigdialog.cpp
+++ b/src/conf/kleopageconfigdialog.cpp
@@ -1,242 +1,241 @@
/*
kleopageconfigdialog.cpp
This file is part of Kleopatra
SPDX-FileCopyrightText: 2016 Bundesamt für Sicherheit in der Informationstechnik
SPDX-FileContributor: Intevation GmbH
SPDX-License-Identifier: GPL-2.0-only
It is derived from KCMultidialog which is:
SPDX-FileCopyrightText: 2000 Matthias Elter <elter@kde.org>
SPDX-FileCopyrightText: 2003 Daniel Molkentin <molkentin@kde.org>
SPDX-FileCopyrightText: 2003, 2006 Matthias Kretz <kretz@kde.org>
SPDX-FileCopyrightText: 2004 Frans Englich <frans.englich@telia.com>
SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <config-kleopatra.h>
#include "kleopageconfigdialog.h"
#include <QDialogButtonBox>
#include <QPushButton>
#include <QUrl>
#include <QDesktopServices>
#include <QProcess>
#include <KCModule>
#include <KStandardGuiItem>
#include <KMessageBox>
#include <KLocalizedString>
#include "kleopatra_debug.h"
KleoPageConfigDialog::KleoPageConfigDialog(QWidget *parent)
: KPageDialog(parent)
{
setModal(false);
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
buttonBox->setStandardButtons(QDialogButtonBox::Help
| QDialogButtonBox::RestoreDefaults
| QDialogButtonBox::Cancel
| QDialogButtonBox::Apply
| QDialogButtonBox::Ok
| QDialogButtonBox::Reset);
KGuiItem::assign(buttonBox->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
KGuiItem::assign(buttonBox->button(QDialogButtonBox::RestoreDefaults),
KStandardGuiItem::defaults());
KGuiItem::assign(buttonBox->button(QDialogButtonBox::Apply), KStandardGuiItem::apply());
KGuiItem::assign(buttonBox->button(QDialogButtonBox::Reset), KStandardGuiItem::reset());
KGuiItem::assign(buttonBox->button(QDialogButtonBox::Help), KStandardGuiItem::help());
buttonBox->button(QDialogButtonBox::Reset)->setEnabled(false);
buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
connect(buttonBox->button(QDialogButtonBox::Apply), &QAbstractButton::clicked,
this, &KleoPageConfigDialog::slotApplyClicked);
connect(buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked,
this, &KleoPageConfigDialog::slotOkClicked);
connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked,
this, &KleoPageConfigDialog::slotDefaultClicked);
connect(buttonBox->button(QDialogButtonBox::Help), &QAbstractButton::clicked,
this, &KleoPageConfigDialog::slotHelpClicked);
connect(buttonBox->button(QDialogButtonBox::Reset), &QAbstractButton::clicked,
this, &KleoPageConfigDialog::slotUser1Clicked);
setButtonBox(buttonBox);
connect(this, &KPageDialog::currentPageChanged,
this, &KleoPageConfigDialog::slotCurrentPageChanged);
}
void KleoPageConfigDialog::slotCurrentPageChanged(KPageWidgetItem *current, KPageWidgetItem *previous)
{
if (!previous) {
return;
}
blockSignals(true);
setCurrentPage(previous);
KCModule *previousModule = qobject_cast<KCModule*>(previous->widget());
bool canceled = false;
if (previousModule && mChangedModules.contains(previousModule)) {
const int queryUser = KMessageBox::warningYesNoCancel(
this,
i18n("The settings of the current module have changed.\n"
"Do you want to apply the changes or discard them?"),
i18n("Apply Settings"),
KStandardGuiItem::apply(),
KStandardGuiItem::discard(),
KStandardGuiItem::cancel());
if (queryUser == KMessageBox::Yes) {
previousModule->save();
} else if (queryUser == KMessageBox::No) {
previousModule->load();
}
canceled = queryUser == KMessageBox::Cancel;
}
if (!canceled) {
mChangedModules.removeAll(previousModule);
setCurrentPage(current);
}
blockSignals(false);
clientChanged();
}
void KleoPageConfigDialog::apply()
{
QPushButton *applyButton = buttonBox()->button(QDialogButtonBox::Apply);
applyButton->setFocus();
for (KCModule *module : mChangedModules) {
module->save();
}
mChangedModules.clear();
Q_EMIT configCommitted();
clientChanged();
}
void KleoPageConfigDialog::slotDefaultClicked()
{
const KPageWidgetItem *item = currentPage();
if (!item) {
return;
}
KCModule *module = qobject_cast<KCModule*>(item->widget());
if (!module) {
return;
}
module->defaults();
clientChanged();
}
void KleoPageConfigDialog::slotUser1Clicked()
{
const KPageWidgetItem *item = currentPage();
if (!item) {
return;
}
KCModule *module = qobject_cast<KCModule*>(item->widget());
if (!module) {
return;
}
module->load();
mChangedModules.removeAll(module);
clientChanged();
}
void KleoPageConfigDialog::slotApplyClicked()
{
apply();
}
void KleoPageConfigDialog::slotOkClicked()
{
apply();
accept();
}
void KleoPageConfigDialog::slotHelpClicked()
{
const KPageWidgetItem *item = currentPage();
if (!item) {
return;
}
const QString docPath = mHelpUrls.value(item->name());
QUrl docUrl;
#ifdef Q_OS_WIN
docUrl = QUrl(QLatin1String("https://docs.kde.org/index.php?branch=stable5&language=")
+ QLocale().name() + QLatin1String("&application=kleopatra"));
#else
docUrl = QUrl(QStringLiteral("help:/")).resolved(QUrl(docPath)); // same code as in KHelpClient::invokeHelp
#endif
if (docUrl.scheme() == QLatin1String("help") || docUrl.scheme() == QLatin1String("man") || docUrl.scheme() == QLatin1String("info")) {
QProcess::startDetached(QStringLiteral("khelpcenter"), QStringList() << docUrl.toString());
} else {
QDesktopServices::openUrl(docUrl);
}
}
-void KleoPageConfigDialog::addModule(const QString &name, const QString &comment, const QString &docPath, const QString &icon, KCModule *module)
+void KleoPageConfigDialog::addModule(const QString &name, const QString &docPath, const QString &icon, KCModule *module)
{
mModules << module;
KPageWidgetItem *item = addPage(module, name);
item->setIcon(QIcon::fromTheme(icon));
- item->setHeader(comment);
connect(module, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
mHelpUrls.insert(name, docPath);
}
void KleoPageConfigDialog::moduleChanged(bool state)
{
KCModule *module = qobject_cast<KCModule*>(sender());
qCDebug(KLEOPATRA_LOG) << "Module changed: " << state << " mod " << module;
if (mChangedModules.contains(module)) {
if (!state) {
mChangedModules.removeAll(module);
}
return;
}
if (state) {
mChangedModules << module;
}
clientChanged();
}
void KleoPageConfigDialog::clientChanged()
{
const KPageWidgetItem *item = currentPage();
if (!item) {
return;
}
KCModule *module = qobject_cast<KCModule*>(item->widget());
if (!module) {
return;
}
qCDebug(KLEOPATRA_LOG) << "Client changed: " << " mod " << module;
bool change = mChangedModules.contains(module);
QPushButton *resetButton = buttonBox()->button(QDialogButtonBox::Reset);
if (resetButton) {
resetButton->setEnabled(change);
}
QPushButton *applyButton = buttonBox()->button(QDialogButtonBox::Apply);
if (applyButton) {
applyButton->setEnabled(change);
}
}
diff --git a/src/conf/kleopageconfigdialog.h b/src/conf/kleopageconfigdialog.h
index f01e833b5..adbec42d3 100644
--- a/src/conf/kleopageconfigdialog.h
+++ b/src/conf/kleopageconfigdialog.h
@@ -1,50 +1,50 @@
/*
kleopageconfigdialog.h.h
This file is part of Kleopatra
SPDX-FileCopyrightText: 2016 Bundesamt für Sicherheit in der Informationstechnik
SPDX-FileContributor: Intevation GmbH
SPDX-License-Identifier: GPL-2.0-only
*/
#pragma once
#include <KPageDialog>
#include <QList>
class KPageWidgetItem;
class KCModule;
/**
* KPageDialog based config dialog to be used when
* KCMUtils are not available. */
class KleoPageConfigDialog : public KPageDialog
{
Q_OBJECT
public:
explicit KleoPageConfigDialog(QWidget *parent = nullptr);
- void addModule(const QString &name, const QString &comment, const QString &docPath, const QString &icon, KCModule *module);
+ void addModule(const QString &name, const QString &docPath, const QString &icon, KCModule *module);
Q_SIGNALS:
void configCommitted();
protected Q_SLOTS:
void slotDefaultClicked();
void slotUser1Clicked();
void slotApplyClicked();
void slotOkClicked();
void slotHelpClicked();
void slotCurrentPageChanged(KPageWidgetItem *current, KPageWidgetItem *previous);
void moduleChanged(bool value);
private:
void clientChanged();
void apply();
QList<KCModule *> mModules;
QList<KCModule *> mChangedModules;
QMap<QString, QString> mHelpUrls;
};
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Dec 24, 10:47 PM (1 d, 20 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
57/39/8fef5b03f53980db368dd3bc264e
Attached To
rKLEOPATRA Kleopatra
Event Timeline
Log In to Comment