File indexing completed on 2024-06-23 05:13:47

0001 /*
0002     configuredialog.cpp
0003 
0004     This file is part of kleopatra
0005     SPDX-FileCopyrightText: 2000 Espen Sand <espen@kde.org>
0006     SPDX-FileCopyrightText: 2001-2002 Marc Mutz <mutz@kde.org>
0007     SPDX-FileCopyrightText: 2004, 2008 Klarälvdalens Datakonsult AB
0008 
0009     SPDX-FileCopyrightText: 2016 Bundesamt für Sicherheit in der Informationstechnik
0010     SPDX-FileContributor: Intevation GmbH
0011 
0012     SPDX-License-Identifier: GPL-2.0-only
0013 */
0014 
0015 #include "configuredialog.h"
0016 
0017 #include "settings.h"
0018 
0019 #include <KConfig>
0020 #include <KConfigGroup>
0021 #include <KLocalizedString>
0022 #include <KSharedConfig>
0023 
0024 #include "conf/appearanceconfigpage.h"
0025 #include "conf/cryptooperationsconfigpage.h"
0026 #include "conf/dirservconfigpage.h"
0027 #include "conf/gnupgsystemconfigurationpage.h"
0028 #include "conf/smartcardconfigpage.h"
0029 #include "conf/smimevalidationconfigurationpage.h"
0030 
0031 ConfigureDialog::ConfigureDialog(QWidget *parent)
0032     : KleoPageConfigDialog(parent)
0033 {
0034     setFaceType(KPageDialog::List);
0035     setWindowTitle(i18nc("@title:window", "Configure"));
0036 
0037     const auto settings = Kleo::Settings{};
0038     if (settings.showDirectoryServicesConfiguration()) {
0039         addModule(i18n("Directory Services"),
0040                   QStringLiteral("kleopatra/configuration.html#configuration-directory-services"),
0041                   QStringLiteral("view-certificate-server-configure"),
0042                   new DirectoryServicesConfigurationPage(this));
0043     }
0044     if (settings.showAppearanceConfiguration()) {
0045         addModule(i18n("Appearance"),
0046                   QStringLiteral("kleopatra/configuration-appearance.html"),
0047                   QStringLiteral("applications-graphics"),
0048                   new Kleo::Config::AppearanceConfigurationPage(this));
0049     }
0050     if (settings.showCryptoOperationsConfiguration()) {
0051         addModule(i18n("Crypto Operations"),
0052                   QStringLiteral("kleopatra/configuration-cryptooperations.html"),
0053                   QStringLiteral("document-encrypt"),
0054                   new Kleo::Config::CryptoOperationsConfigurationPage(this));
0055     }
0056     if (settings.showSMimeValidationConfiguration() && settings.cmsEnabled()) {
0057         addModule(i18n("S/MIME Validation"),
0058                   QStringLiteral("kleopatra/configuration.html#configuration-smime-validation"),
0059                   QStringLiteral("preferences-system-network"),
0060                   new Kleo::Config::SMimeValidationConfigurationPage(this));
0061     }
0062     if (settings.showSmartCardsConfiguration()) {
0063         addModule(i18n("Smart Cards"),
0064                   QStringLiteral("kleopatra/configuration.html"),
0065                   QStringLiteral("auth-sim-locked"),
0066                   new Kleo::Config::SmartCardConfigurationPage{this});
0067     }
0068     if (settings.showGnuPGSystemConfiguration()) {
0069         addModule(i18n("GnuPG System"),
0070                   QStringLiteral("kleopatra/configuration.html#configuration-gnupgsystem"),
0071                   QStringLiteral("document-encrypt"),
0072                   new Kleo::Config::GnuPGSystemConfigurationPage(this));
0073     }
0074 
0075     // We store the minimum size of the dialog on hide, because otherwise
0076     // the KCMultiDialog starts with the size of the first kcm, not
0077     // the largest one. This way at least after the first showing of
0078     // the largest kcm the size is kept.
0079     const KConfigGroup geometry(KSharedConfig::openStateConfig(), QStringLiteral("Geometry"));
0080     const int width = geometry.readEntry("ConfigureDialogWidth", 0);
0081     const int height = geometry.readEntry("ConfigureDialogHeight", 0);
0082     if (width != 0 && height != 0) {
0083         setMinimumSize(width, height);
0084     }
0085 }
0086 
0087 void ConfigureDialog::hideEvent(QHideEvent *e)
0088 {
0089     const QSize minSize = minimumSizeHint();
0090     KConfigGroup geometry(KSharedConfig::openStateConfig(), QStringLiteral("Geometry"));
0091     geometry.writeEntry("ConfigureDialogWidth", minSize.width());
0092     geometry.writeEntry("ConfigureDialogHeight", minSize.height());
0093     KleoPageConfigDialog::hideEvent(e);
0094 }
0095 
0096 ConfigureDialog::~ConfigureDialog()
0097 {
0098 }
0099 
0100 #include "moc_configuredialog.cpp"