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

Adapt to new api (scripted)

parent 04e26598
Pipeline #248506 passed with stage
in 3 minutes and 18 seconds
......@@ -10,6 +10,7 @@
#include <KLocalizedString>
#include <KMessageBox>
#include <kwidgetsaddons_version.h>
SieveEditorConfigureServerWidget::SieveEditorConfigureServerWidget(QWidget *parent)
: QWidget(parent)
......@@ -54,12 +55,17 @@ void SieveEditorConfigureServerWidget::slotDeleteServer()
if (!item) {
return;
}
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::ButtonCode::PrimaryAction
== KMessageBox::questionTwoActions(this,
#else
if (KMessageBox::Yes
== KMessageBox::questionYesNo(this,
i18n("Do you want to remove this server \'%1\'?", item->text()),
i18nc("@title:window", "Remove Sieve Server"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel())) {
#endif
i18n("Do you want to remove this server \'%1\'?", item->text()),
i18nc("@title:window", "Remove Sieve Server"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel())) {
ui->serverSieveListWidget->deleteServerConfig(item);
delete item;
slotItemSelectionChanged();
......
......@@ -21,6 +21,7 @@
#include <QApplication>
#include <QStackedWidget>
#include <QTabBar>
#include <kwidgetsaddons_version.h>
namespace
{
......@@ -605,13 +606,21 @@ void SieveEditorMainWidget::slotTabCloseRequested(int index)
auto page = qobject_cast<SieveEditorPageWidget *>(mTabWidget->widget(index));
if (page) {
if (page->isModified()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int result = KMessageBox::questionTwoActionsCancel(this,
#else
const int result = KMessageBox::questionYesNoCancel(this,
i18n("Script was modified. Do you want to save before closing?"),
i18n("Close script"),
KStandardGuiItem::save(),
KStandardGuiItem::no(),
KStandardGuiItem::cancel());
#endif
i18n("Script was modified. Do you want to save before closing?"),
i18n("Close script"),
KStandardGuiItem::save(),
KStandardGuiItem::close(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (result == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (result == KMessageBox::Yes) {
#endif
if (page->uploadScriptAndCloseTab(index)) {
return;
}
......
......@@ -15,6 +15,7 @@
#include "sieveeditor_debug.h"
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
SieveEditorPageWidget::SieveEditorPageWidget(QWidget *parent)
: QWidget(parent)
......@@ -162,8 +163,20 @@ bool SieveEditorPageWidget::needToSaveScript()
{
bool result = false;
if (mIsNewScript) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int resultQuestion = KMessageBox::warningTwoActionsCancel(this,
i18n("Script '%1' is new. Do you want to save it?", mCurrentURL.fileName()),
i18n("Save Script"),
KStandardGuiItem::save(),
KStandardGuiItem::cancel());
#else
const int resultQuestion = KMessageBox::warningYesNoCancel(this, i18n("Script '%1' is new. Do you want to save it?", mCurrentURL.fileName()));
#endif
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (resultQuestion == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (resultQuestion == KMessageBox::Yes) {
#endif
uploadScript();
result = true;
} else if (resultQuestion == KMessageBox::Cancel) {
......@@ -171,8 +184,20 @@ bool SieveEditorPageWidget::needToSaveScript()
}
} else {
if (mSieveEditorWidget->isModified()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int resultQuestion = KMessageBox::warningTwoActionsCancel(this,
i18n("Script '%1' was changed. Do you want to save it ?", mCurrentURL.fileName()),
i18n("Save Script"),
KStandardGuiItem::save(),
KStandardGuiItem::cancel());
#else
const int resultQuestion = KMessageBox::warningYesNoCancel(this, i18n("Script '%1' was changed. Do you want to save it ?", mCurrentURL.fileName()));
#endif
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (resultQuestion == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (resultQuestion == KMessageBox::Yes) {
#endif
uploadScript();
result = true;
} else if (resultQuestion == KMessageBox::Cancel) {
......
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