Commit 666341bc authored by Laurent Montel's avatar Laurent Montel
Browse files

Adapt to new api (scripted)

parent efe28074
Pipeline #248520 passed with stage
in 3 minutes and 23 seconds
......@@ -36,6 +36,7 @@
#endif
#include "kleopatra_debug.h"
#include <kwidgetsaddons_version.h>
using namespace Kleo;
using namespace Kleo::Commands;
......@@ -141,10 +142,23 @@ void CertificateToPIVCardCommand::Private::start()
auto confirmButton = KStandardGuiItem::yes();
confirmButton.setText(i18nc("@action:button", "Write certificate"));
confirmButton.setToolTip(QString());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const auto choice = KMessageBox::questionTwoActions(
#else
const auto choice = KMessageBox::questionYesNo(
parentWidgetOrView(), message, i18nc("@title:window", "Write certificate to card"),
confirmButton, KStandardGuiItem::cancel(), QString(), KMessageBox::Notify | KMessageBox::WindowModal);
#endif
parentWidgetOrView(),
message,
i18nc("@title:window", "Write certificate to card"),
confirmButton,
KStandardGuiItem::cancel(),
QString(),
KMessageBox::Notify | KMessageBox::WindowModal);
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (choice != KMessageBox::ButtonCode::PrimaryAction) {
#else
if (choice != KMessageBox::Yes) {
#endif
finished();
return;
}
......
......@@ -27,8 +27,9 @@
#include <QFile>
#include <QFileDialog>
#include "kleopatra_debug.h"
#include "command_p.h"
#include "kleopatra_debug.h"
#include <kwidgetsaddons_version.h>
using namespace Kleo;
using namespace Kleo::Commands;
......@@ -118,14 +119,22 @@ void GenRevokeCommand::doStart()
}
const QFileInfo fi{mOutputFileName};
if (fi.exists()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
auto sel = KMessageBox::questionTwoActions(d->parentWidgetOrView(),
#else
auto sel = KMessageBox::questionYesNo(d->parentWidgetOrView(),
xi18n("The file <filename>%1</filename> already exists. Do you wish to overwrite it?", fi.fileName()),
i18nc("@title:window", "Overwrite File?"),
KStandardGuiItem::overwrite(),
KStandardGuiItem::cancel(),
{},
KMessageBox::Notify|KMessageBox::Dangerous);
#endif
xi18n("The file <filename>%1</filename> already exists. Do you wish to overwrite it?", fi.fileName()),
i18nc("@title:window", "Overwrite File?"),
KStandardGuiItem::overwrite(),
KStandardGuiItem::cancel(),
{},
KMessageBox::Notify | KMessageBox::Dangerous);
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (sel == KMessageBox::ButtonCode::SecondaryAction) {
#else
if (sel == KMessageBox::No) {
#endif
proposedFileName = mOutputFileName;
mOutputFileName.clear();
}
......
......@@ -39,6 +39,7 @@
#endif
#include "kleopatra_debug.h"
#include <kwidgetsaddons_version.h>
using namespace Kleo;
using namespace Kleo::Commands;
......@@ -459,10 +460,19 @@ void KeyToCardCommand::keyToOpenPGPCardDone(const GpgME::Error &err)
/* TODO DELETE_KEY is too strong, because it also deletes the stub
* of the secret key. I could not find out how GnuPG does this. Question
* to GnuPG Developers is pending an answer
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(d->parentWidgetOrView(),
#else
if (KMessageBox::questionYesNo(d->parentWidgetOrView(),
#endif
i18n("Do you want to delete the key on this computer?"),
i18nc("@title:window",
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
"Key transferred to card")) == KMessageBox::ButtonCode::PrimaryAction) {
#else
"Key transferred to card")) == KMessageBox::Yes) {
#endif
const QString cmd = QStringLiteral("DELETE_KEY --force %1").arg(d->subkey.keyGrip());
// Using readerstatus is a bit overkill but it's an easy way to talk to the agent.
ReaderStatus::mutableInstance()->startSimpleTransaction(card, cmd.toUtf8(), this, "deleteDone");
......
......@@ -27,6 +27,7 @@
#include <KLocalizedString>
#include <KMessageBox>
#include <KStandardGuiItem>
#include <kwidgetsaddons_version.h>
#include <QGpgME/Protocol>
#include <QGpgME/QuickJob>
......@@ -78,11 +79,15 @@ static bool confirmRevocations(QWidget *parent, const std::vector<CertificationD
"<para>You are about to revoke the certification of user ID<nl/>%1<nl/>made with the key<nl/>%2.</para>",
QString::fromUtf8(userId.id()),
Formatting::formatForComboBox(certificationKey));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
answer = KMessageBox::questionTwoActions(parent,
#else
answer = KMessageBox::questionYesNo(parent,
message,
i18nc("@title:window", "Confirm Revocation"),
KGuiItem{i18n("Revoke Certification")},
KStandardGuiItem::cancel());
#endif
message,
i18nc("@title:window", "Confirm Revocation"),
KGuiItem{i18n("Revoke Certification")},
KStandardGuiItem::cancel());
} else {
QStringList l;
Kleo::transform(certifications, std::back_inserter(l), [](const auto &c) {
......@@ -91,14 +96,22 @@ static bool confirmRevocations(QWidget *parent, const std::vector<CertificationD
const auto message = i18np("You are about to revoke the following certification:", //
"You are about to revoke the following %1 certifications:",
certifications.size());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
answer = KMessageBox::questionTwoActionsList(parent,
#else
answer = KMessageBox::questionYesNoList(parent,
message,
l,
i18nc("@title:window", "Confirm Revocation"),
KGuiItem{i18n("Revoke Certifications")},
KStandardGuiItem::cancel());
#endif
message,
l,
i18nc("@title:window", "Confirm Revocation"),
KGuiItem{i18n("Revoke Certifications")},
KStandardGuiItem::cancel());
}
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
return answer == KMessageBox::ButtonCode::PrimaryAction;
#else
return answer == KMessageBox::Yes;
#endif
}
}
......@@ -206,14 +219,22 @@ void RevokeCertificationCommand::Private::scheduleNextRevocation()
completedRevocations.size());
const auto yesButton = KGuiItem{i18ncp("@action:button", "Publish Revocation", "Publish Revocations", completedRevocations.size()),
QIcon::fromTheme(QStringLiteral("view-certificate-export-server"))};
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const auto answer = KMessageBox::questionTwoActions(parentWidgetOrView(),
#else
const auto answer = KMessageBox::questionYesNo(parentWidgetOrView(),
message,
i18nc("@title:window", "Confirm Publication"),
yesButton,
KStandardGuiItem::cancel(),
{},
KMessageBox::Notify | KMessageBox::Dangerous);
#endif
message,
i18nc("@title:window", "Confirm Publication"),
yesButton,
KStandardGuiItem::cancel(),
{},
KMessageBox::Notify | KMessageBox::Dangerous);
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
const auto cmd = new ExportOpenPGPCertsToServerCommand{certificationTarget};
cmd->start();
}
......@@ -357,3 +378,4 @@ void RevokeCertificationCommand::doCancel()
#undef q
#include "moc_revokecertificationcommand.cpp"
......@@ -48,6 +48,7 @@
#include <QLabel>
#include <QRegularExpression>
#include <kwidgetsaddons_version.h>
#include <memory>
using namespace Kleo;
......@@ -105,12 +106,22 @@ void CryptoOperationsConfigWidget::applyProfile(const QString &profile)
qCDebug(KLEOPATRA_LOG) << "Applying profile " << profile;
if (profile == i18n("default")) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::warningTwoActions(
#else
if (KMessageBox::warningYesNo(
this,
i18n("This means that every configuration option of the GnuPG System will be reset to its default."),
i18n("Apply profile"),
KStandardGuiItem::apply(),
KStandardGuiItem::no()) != KMessageBox::Yes) {
#endif
this,
i18n("This means that every configuration option of the GnuPG System will be reset to its default."),
i18n("Apply profile"),
KStandardGuiItem::apply(),
KStandardGuiItem::cancel())
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
!= KMessageBox::ButtonCode::PrimaryAction) {
#else
!= KMessageBox::Yes) {
#endif
return;
}
resetDefaults();
......
......@@ -26,6 +26,7 @@
#include <QMutex>
#include "kleopatra_debug.h"
#include <kwidgetsaddons_version.h>
using namespace Kleo;
......@@ -80,13 +81,23 @@ void GroupsConfigPage::Private::onKeysMayHaveChanged()
buttonYes.setText(i18n("Save changes"));
auto buttonNo = KStandardGuiItem::no();
buttonNo.setText(i18n("Discard changes"));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const auto answer = KMessageBox::questionTwoActions(
#else
const auto answer = KMessageBox::questionYesNo(
#endif
q->topLevelWidget(),
xi18nc("@info", "<para>The certificates or the certificate groups have been updated in the background.</para>"
"<para>Do you want to save your changes?</para>"),
xi18nc("@info",
"<para>The certificates or the certificate groups have been updated in the background.</para>"
"<para>Do you want to save your changes?</para>"),
i18nc("@title::window", "Save changes?"),
buttonYes, buttonNo);
buttonYes,
buttonNo);
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
q->save();
} else {
q->load();
......
......@@ -35,6 +35,7 @@
#include <KLocalizedString>
#include "kleopatra_debug.h"
#include <kwidgetsaddons_version.h>
KleoPageConfigDialog::KleoPageConfigDialog(QWidget *parent)
: KPageDialog(parent)
......@@ -86,17 +87,29 @@ void KleoPageConfigDialog::slotCurrentPageChanged(KPageWidgetItem *current, KPag
KCModule *previousModule = qobject_cast<KCModule*>(previous->widget());
bool canceled = false;
if (previousModule && mChangedModules.contains(previousModule)) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int queryUser = KMessageBox::warningTwoActionsCancel(
#else
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());
#endif
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 KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (queryUser == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (queryUser == KMessageBox::Yes) {
#endif
previousModule->save();
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
} else if (queryUser == KMessageBox::ButtonCode::SecondaryAction) {
#else
} else if (queryUser == KMessageBox::No) {
#endif
previousModule->load();
}
canceled = queryUser == KMessageBox::Cancel;
......
......@@ -35,6 +35,7 @@
#include <KLocalizedString>
#include <KMessageBox>
#include "kleopatra_debug.h"
#include <kwidgetsaddons_version.h>
#include <QDir>
#include <QFile>
......@@ -208,15 +209,25 @@ void AutoDecryptVerifyFilesController::Private::exec()
QString outFileName = fi.fileName();
if (!embeddedFileName.isEmpty() && embeddedFileName != fi.fileName()) {
// we switch "Yes" and "No" because Yes is default, but saving with embedded file name could be dangerous
const auto answer = KMessageBox::questionYesNoCancel(m_dialog,
xi18n("Shall the file be saved with the original file name <filename>%1</filename>?", embeddedFileName),
i18n("Use Original File Name?"),
KGuiItem(xi18n("No, Save As <filename>%1</filename>", fi.fileName())),
KGuiItem(xi18n("Yes, Save As <filename>%1</filename>", embeddedFileName)));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const auto answer = KMessageBox::questionTwoActionsCancel(
m_dialog,
#else
const auto answer =
KMessageBox::questionYesNoCancel(m_dialog,
#endif
xi18n("Shall the file be saved with the original file name <filename>%1</filename>?", embeddedFileName),
i18n("Use Original File Name?"),
KGuiItem(xi18n("No, Save As <filename>%1</filename>", fi.fileName())),
KGuiItem(xi18n("Yes, Save As <filename>%1</filename>", embeddedFileName)));
if (answer == KMessageBox::Cancel) {
qCDebug(KLEOPATRA_LOG) << "Saving canceled for:" << inpath;
continue;
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
} else if (answer == KMessageBox::ButtonCode::SecondaryAction) {
#else
} else if (answer == KMessageBox::No) {
#endif
outFileName = embeddedFileName;
}
}
......@@ -226,18 +237,29 @@ void AutoDecryptVerifyFilesController::Private::exec()
if (ofi.exists()) {
int sel = KMessageBox::No;
if (!overWriteAll) {
sel = KMessageBox::questionYesNoCancel(m_dialog, i18n("The file <b>%1</b> already exists.\n"
"Overwrite?", outpath),
i18n("Overwrite Existing File?"),
KStandardGuiItem::overwrite(),
KGuiItem(i18n("Overwrite All")),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
sel = KMessageBox::questionTwoActionsCancel(m_dialog,
i18n("The file <b>%1</b> already exists.\n"
#else
sel = KMessageBox::questionYesNoCancel(m_dialog,
i18n("The file <b>%1</b> already exists.\n"
#endif
"Overwrite?",
outpath),
i18n("Overwrite Existing File?"),
KStandardGuiItem::overwrite(),
KGuiItem(i18n("Overwrite All")),
KStandardGuiItem::cancel());
}
if (sel == KMessageBox::Cancel) {
qCDebug(KLEOPATRA_LOG) << "Overwriting canceled for: " << outpath;
continue;
}
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (sel == KMessageBox::ButtonCode::SecondaryAction) { // Overwrite All
#else
if (sel == KMessageBox::No) { //Overwrite All
#endif
overWriteAll = true;
}
if (!QFile::remove(outpath)) {
......@@ -556,3 +578,4 @@ void AutoDecryptVerifyFilesController::doTaskDone(const Task *task, const std::s
QTimer::singleShot(0, this, SLOT(schedule()));
}
#include "moc_autodecryptverifyfilescontroller.cpp"
......@@ -52,6 +52,7 @@
#include <KLocalizedString>
#include <KMessageBox>
#include <KSeparator>
#include <kwidgetsaddons_version.h>
#include <gpgme++/context.h>
#include <gpgme++/key.h>
......@@ -624,10 +625,23 @@ void CertificateDetailsWidget::Private::revokeUserID(const GpgME::UserID &userId
auto confirmButton = KStandardGuiItem::yes();
confirmButton.setText(i18nc("@action:button", "Revoke User ID"));
confirmButton.setToolTip({});
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const auto choice = KMessageBox::questionTwoActions(
#else
const auto choice = KMessageBox::questionYesNo(
q->window(), message, i18nc("@title:window", "Confirm Revocation"),
confirmButton, KStandardGuiItem::cancel(), {}, KMessageBox::Notify | KMessageBox::WindowModal);
#endif
q->window(),
message,
i18nc("@title:window", "Confirm Revocation"),
confirmButton,
KStandardGuiItem::cancel(),
{},
KMessageBox::Notify | KMessageBox::WindowModal);
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (choice != KMessageBox::ButtonCode::PrimaryAction) {
#else
if (choice != KMessageBox::Yes) {
#endif
return;
}
......@@ -1142,3 +1156,4 @@ GpgME::Key CertificateDetailsWidget::key() const
}
#include "moc_certificatedetailswidget.cpp"
......@@ -41,6 +41,7 @@
#include <KSharedConfig>
#include <gpgme++/gpgmepp_version.h>
#include <kwidgetsaddons_version.h>
#if GPGMEPP_VERSION >= 0x11000 // 1.16.0
# define CRYPTOCONFIG_HAS_GROUPLESS_ENTRY_OVERLOAD
#endif
......@@ -201,7 +202,17 @@ void KWatchGnuPGMainWindow::setGnuPGConfig()
void KWatchGnuPGMainWindow::slotWatcherExited(int, QProcess::ExitStatus)
{
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(this,
i18n("The watchgnupg logging process died.\nDo you want to try to restart it?"),
QString(),
KGuiItem(i18n("Try Restart")),
KGuiItem(i18n("Do Not Try")))
== KMessageBox::ButtonCode::PrimaryAction) {
#else
if (KMessageBox::questionYesNo(this, i18n("The watchgnupg logging process died.\nDo you want to try to restart it?"), QString(), KGuiItem(i18n("Try Restart")), KGuiItem(i18n("Do Not Try"))) == KMessageBox::Yes) {
#endif
mCentralWidget->append(i18n("====== Restarting logging process ====="));
mCentralWidget->ensureCursorVisible();
startWatcher();
......
......@@ -59,6 +59,7 @@
#include <KConfigGroup>
#include <KConfigDialog>
#include <KColorScheme>
#include <kwidgetsaddons_version.h>
#include <QAbstractItemView>
#include <QCloseEvent>
......@@ -198,14 +199,19 @@ public:
void closeAndQuit()
{
const QString app = KAboutData::applicationData().displayName();
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int rc = KMessageBox::questionTwoActionsCancel(q,
#else
const int rc = KMessageBox::questionYesNoCancel(q,
xi18n("<application>%1</application> may be used by other applications as a service.<nl/>"
"You may instead want to close this window without exiting <application>%1</application>.", app),
i18nc("@title:window", "Really Quit?"),
KStandardGuiItem_close(),
KStandardGuiItem_quit(),
KStandardGuiItem::cancel(),
QLatin1String("really-quit-") + app.toLower());
#endif
xi18n("<application>%1</application> may be used by other applications as a service.<nl/>"
"You may instead want to close this window without exiting <application>%1</application>.",
app),
i18nc("@title:window", "Really Quit?"),
KStandardGuiItem_close(),
KStandardGuiItem_quit(),
KStandardGuiItem::cancel(),
QLatin1String("really-quit-") + app.toLower());
if (rc == KMessageBox::Cancel) {
return;
}
......@@ -214,7 +220,11 @@ public:
return;
}
// WARNING: 'this' might be deleted at this point!
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (rc == KMessageBox::ButtonCode::SecondaryAction) {
#else
if (rc == KMessageBox::No) {
#endif
qApp->quit();
}
}
......
......@@ -40,6 +40,7 @@
#endif
#include <cerrno>
#include <kwidgetsaddons_version.h>
using namespace Kleo;
using namespace Kleo::_detail;
......@@ -523,16 +524,31 @@ bool FileOutput::obtainOverwritePermission()
if (m_policy->policy() != OverwritePolicy::Ask) {
return m_policy->policy() == OverwritePolicy::Allow;
}
const int sel = KMessageBox::questionYesNoCancel(m_policy->parentWidget(), i18n("The file <b>%1</b> already exists.\n"
"Overwrite?", m_fileName),
i18n("Overwrite Existing File?"),
KStandardGuiItem::overwrite(),
KGuiItem(i18n("Overwrite All")),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int sel = KMessageBox::questionTwoActionsCancel(m_policy->parentWidget(),
i18n("The file <b>%1</b> already exists.\n"
#else
const int sel = KMessageBox::questionYesNoCancel(m_policy->parentWidget(),
i18n("The file <b>%1</b> already exists.\n"
#endif
"Overwrite?",
m_fileName),
i18n("Overwrite Existing File?"),
KStandardGuiItem::overwrite(),
KGuiItem(i18n("Overwrite All")),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (sel == KMessageBox::ButtonCode::SecondaryAction) { // Overwrite All
#else
if (sel == KMessageBox::No) { //Overwrite All
#endif
m_policy->setPolicy(OverwritePolicy::Allow);
}
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
return sel == KMessageBox::ButtonCode::PrimaryAction || sel == KMessageBox::ButtonCode::SecondaryAction;
#else
return sel == KMessageBox::Yes || sel == KMessageBox::No;
#endif
}
void FileOutput::doFinalize()
......
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