Commit 89955860 authored by Laurent Montel's avatar Laurent Montel
Browse files

Adapt to new api (scripted)

parent a8cc8a93
Pipeline #248507 passed with stage
in 5 minutes and 43 seconds
......@@ -19,6 +19,7 @@
#include <QSplitter>
#include <QStackedWidget>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
using namespace KSieveUi;
namespace
......@@ -134,12 +135,20 @@ void SieveEditorGraphicalModeWidget::setImportScript(const QString &script)
mSieveParsingWarning->animatedShow();
}
} else {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActions(this,
#else
const int answer = KMessageBox::questionYesNo(this,
i18n("Error during importing script. Do you want to switch to text mode?"),
QString(),
KGuiItem(i18nc("@action:button", "Switch to Text Mode")),
KGuiItem(i18nc("@action:button", "Do Not Switch"), QStringLiteral("dialog-cancel")));
#endif
i18n("Error during importing script. Do you want to switch to text mode?"),
QString(),
KGuiItem(i18nc("@action:button", "Switch to Text Mode")),
KGuiItem(i18nc("@action:button", "Do Not Switch"), QStringLiteral("dialog-cancel")));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
Q_EMIT switchTextMode(script);
}
qCDebug(LIBKSIEVE_LOG) << " cannot import script";
......
......@@ -24,6 +24,7 @@
#include <QMenu>
#include <QPointer>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
namespace
{
......@@ -260,12 +261,20 @@ void SieveScriptListBox::slotDelete()
{
QListWidgetItem *item = mSieveListScript->currentItem();
if (item) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::warningTwoActions(this,
#else
const int answer = KMessageBox::warningYesNo(this,
i18n("Do you want to delete \"%1\" script?", item->text()),
i18nc("@title:window", "Delete Script"),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
#endif
i18n("Do you want to delete \"%1\" script?", item->text()),
i18nc("@title:window", "Delete Script"),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
auto itemScript = static_cast<SieveScriptListItem *>(item);
Q_EMIT removePage(itemScript->scriptPage());
delete item;
......
......@@ -16,6 +16,7 @@
#include <QKeyEvent>
#include <QPushButton>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
using namespace KSieveUi;
class KSieveUi::SieveEditorPrivate
......@@ -175,12 +176,20 @@ void SieveEditor::addNormalMessage(const QString &msg)
void SieveEditor::closeEvent(QCloseEvent *e)
{
if (d->mSieveEditorWidget->originalScript() != d->mSieveEditorWidget->script()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::warningTwoActions(this,
#else
const int answer = KMessageBox::warningYesNo(this,
i18n("Script is modified. Do you want to close editor?"),
QString(),
KGuiItem(i18nc("@action:button", "Close Editor"), QStringLiteral("dialog-close")),
KGuiItem(i18nc("@action:button", "Do Not Close"), QStringLiteral("dialog-cancel")));
#endif
i18n("Script is modified. Do you want to close editor?"),
QString(),
KGuiItem(i18nc("@action:button", "Close Editor"), QStringLiteral("dialog-close")),
KGuiItem(i18nc("@action:button", "Do Not Close"), QStringLiteral("dialog-cancel")));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::SecondaryAction) {
#else
if (answer == KMessageBox::No) {
#endif
e->ignore();
return;
}
......
......@@ -14,6 +14,7 @@
#include <QTextStream>
#include <cerrno>
#include <kwidgetsaddons_version.h>
using namespace KSieveUi;
SieveEditorAbstractWidget::SieveEditorAbstractWidget(QWidget *parent)
......@@ -51,12 +52,20 @@ void SieveEditorAbstractWidget::setImportScript(const QString &)
void SieveEditorAbstractWidget::slotImport()
{
if (!currentscript().isEmpty()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::warningTwoActions(this,
#else
const int answer = KMessageBox::warningYesNo(this,
i18n("You will overwrite script. Do you want to continue?"),
i18n("Import Script"),
KStandardGuiItem::cont(),
KStandardGuiItem::cancel());
#endif
i18n("You will overwrite script. Do you want to continue?"),
i18n("Import Script"),
KStandardGuiItem::cont(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::SecondaryAction) {
#else
if (answer == KMessageBox::No) {
#endif
return;
}
}
......
......@@ -21,6 +21,7 @@
#include <QStackedWidget>
#include <QTabBar>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
using namespace KSieveUi;
namespace
......@@ -72,12 +73,20 @@ void MultiImapVacationDialog::reject()
auto vacationPage = qobject_cast<VacationPageWidget *>(d->mTabWidget->widget(i));
if (vacationPage) {
if (vacationPage->wasChanged()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActions(this,
#else
const int answer = KMessageBox::questionYesNo(this,
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")));
#endif
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
QDialog::reject(); // Discard current changes
}
canCloseDialog = false;
......
......@@ -13,6 +13,7 @@
#include <KMessageBox>
#include <QPointer>
#include <QWidget>
#include <kwidgetsaddons_version.h>
using namespace KSieveUi;
......@@ -51,13 +52,22 @@ void VacationManager::slotUpdateVacationScriptStatus(bool active, const QString
if (active) {
if (!d->mQuestionAsked) {
d->mQuestionAsked = true;
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(nullptr,
#else
if (KMessageBox::questionYesNo(nullptr,
i18n("There is still an active out-of-office reply configured.\n"
"Do you want to edit it?"),
i18n("Out-of-office reply still active"),
KGuiItem(i18n("Edit"), QStringLiteral("document-properties")),
KGuiItem(i18n("Ignore"), QStringLiteral("dialog-cancel")))
#endif
i18n("There is still an active out-of-office reply configured.\n"
"Do you want to edit it?"),
i18n("Out-of-office reply still active"),
KGuiItem(i18n("Edit"), QStringLiteral("document-properties")),
KGuiItem(i18n("Ignore"), QStringLiteral("dialog-cancel")))
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
== KMessageBox::ButtonCode::PrimaryAction) {
#else
== KMessageBox::Yes) {
#endif
slotEditVacation(serverName);
}
}
......
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