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

Offer CMS-specific actions only if CMS is enabled

GnuPG-bug-id: 5688
parent 556f70fa
......@@ -9,6 +9,8 @@
#include "kdtoolsglobal.h"
#include "mainwindow.h"
#include <settings.h>
#include <commands/importcertificatefromclipboardcommand.h>
#include <commands/encryptclipboardcommand.h>
#include <commands/signclipboardcommand.h>
......@@ -32,7 +34,9 @@ ClipboardMenu::ClipboardMenu(QObject *parent)
mClipboardMenu = new KActionMenu(i18n("Clipboard"), this);
mImportClipboardAction = new QAction(i18n("Certificate Import"), this);
mEncryptClipboardAction = new QAction(i18n("Encrypt..."), this);
mSmimeSignClipboardAction = new QAction(i18n("S/MIME-Sign..."), this);
if (Settings{}.cmsEnabled()) {
mSmimeSignClipboardAction = new QAction(i18n("S/MIME-Sign..."), this);
}
mOpenPGPSignClipboardAction = new QAction(i18n("OpenPGP-Sign..."), this);
mDecryptVerifyClipboardAction = new QAction(i18n("Decrypt/Verify..."), this);
......@@ -45,12 +49,16 @@ ClipboardMenu::ClipboardMenu(QObject *parent)
connect(mImportClipboardAction, &QAction::triggered, this, &ClipboardMenu::slotImportClipboard);
connect(mEncryptClipboardAction, &QAction::triggered, this, &ClipboardMenu::slotEncryptClipboard);
connect(mSmimeSignClipboardAction, &QAction::triggered, this, &ClipboardMenu::slotSMIMESignClipboard);
if (mSmimeSignClipboardAction) {
connect(mSmimeSignClipboardAction, &QAction::triggered, this, &ClipboardMenu::slotSMIMESignClipboard);
}
connect(mOpenPGPSignClipboardAction, &QAction::triggered, this, &ClipboardMenu::slotOpenPGPSignClipboard);
connect(mDecryptVerifyClipboardAction, &QAction::triggered, this, &ClipboardMenu::slotDecryptVerifyClipboard);
mClipboardMenu->addAction(mImportClipboardAction);
mClipboardMenu->addAction(mEncryptClipboardAction);
mClipboardMenu->addAction(mSmimeSignClipboardAction);
if (mSmimeSignClipboardAction) {
mClipboardMenu->addAction(mSmimeSignClipboardAction);
}
mClipboardMenu->addAction(mOpenPGPSignClipboardAction);
mClipboardMenu->addAction(mDecryptVerifyClipboardAction);
connect(QApplication::clipboard(), &QClipboard::changed, this, &ClipboardMenu::slotEnableDisableActions);
......@@ -107,6 +115,8 @@ void ClipboardMenu::slotEnableDisableActions()
mImportClipboardAction->setEnabled(ImportCertificateFromClipboardCommand::canImportCurrentClipboard());
mEncryptClipboardAction->setEnabled(EncryptClipboardCommand::canEncryptCurrentClipboard());
mOpenPGPSignClipboardAction->setEnabled(SignClipboardCommand::canSignCurrentClipboard());
mSmimeSignClipboardAction->setEnabled(SignClipboardCommand::canSignCurrentClipboard());
if (mSmimeSignClipboardAction) {
mSmimeSignClipboardAction->setEnabled(SignClipboardCommand::canSignCurrentClipboard());
}
mDecryptVerifyClipboardAction->setEnabled(DecryptVerifyClipboardCommand::canDecryptVerifyCurrentClipboard());
}
......@@ -16,6 +16,7 @@
#include <utils/action_data.h>
#include <settings.h>
#include "tooltippreferences.h"
#include "kleopatra_debug.h"
#include "commands/exportcertificatecommand.h"
......@@ -343,8 +344,7 @@ TabWidget *KeyListController::tabWidget() const
void KeyListController::createActions(KActionCollection *coll)
{
const std::vector<action_data> action_data = {
static const std::vector<action_data> common_and_openpgp_action_data = {
// File menu
{
"file_new_certificate", i18n("New Key Pair..."), QString(),
......@@ -429,19 +429,32 @@ void KeyListController::createActions(KActionCollection *coll)
nullptr, nullptr, nullptr, QString(), false, true
},
{
"certificates_trust_root", i18n("Trust Root Certificate"), QString(),
"certificates_change_passphrase", i18n("Change Passphrase..."), QString(),
nullptr, nullptr, nullptr, QString(), false, true
},
{
"certificates_distrust_root", i18n("Distrust Root Certificate"), QString(),
"certificates_add_userid", i18n("Add User-ID..."), QString(),
nullptr, nullptr, nullptr, QString(), false, true
},
// Tools menu
{
"certificates_change_passphrase", i18n("Change Passphrase..."), QString(),
"tools_refresh_openpgp_certificates", i18n("Refresh OpenPGP Certificates"), QString(),
"view-refresh", nullptr, nullptr, QString(), false, true
},
// Window menu
// (come from TabWidget)
// Help menu
// (come from MainWindow)
};
static const std::vector<action_data> cms_action_data = {
// Certificate menu
{
"certificates_trust_root", i18n("Trust Root Certificate"), QString(),
nullptr, nullptr, nullptr, QString(), false, true
},
{
"certificates_add_userid", i18n("Add User-ID..."), QString(),
"certificates_distrust_root", i18n("Distrust Root Certificate"), QString(),
nullptr, nullptr, nullptr, QString(), false, true
},
{
......@@ -453,10 +466,6 @@ void KeyListController::createActions(KActionCollection *coll)
"tools_refresh_x509_certificates", i18n("Refresh S/MIME Certificates"), QString(),
"view-refresh", nullptr, nullptr, QString(), false, true
},
{
"tools_refresh_openpgp_certificates", i18n("Refresh OpenPGP Certificates"), QString(),
"view-refresh", nullptr, nullptr, QString(), false, true
},
{
"crl_clear_crl_cache", i18n("Clear CRL Cache"), QString(),
nullptr, nullptr, nullptr, QString(), false, true
......@@ -469,12 +478,16 @@ void KeyListController::createActions(KActionCollection *coll)
"crl_import_crl", i18n("Import CRL From File..."), QString(),
nullptr, nullptr, nullptr, QString(), false, true
},
// Window menu
// (come from TabWidget)
// Help menu
// (come from MainWindow)
};
std::vector<action_data> action_data = common_and_openpgp_action_data;
if (Settings{}.cmsEnabled()) {
action_data.reserve(action_data.size() + cms_action_data.size());
std::copy(std::begin(cms_action_data), std::end(cms_action_data),
std::back_inserter(action_data));
}
make_actions_from_data(action_data, coll);
if (QAction *action = coll->action(QStringLiteral("view_stop_operations"))) {
......
Supports Markdown
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