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

Adapt to new api (scripted)

parent 9c5560e1
Pipeline #248511 passed with stage
in 5 minutes and 48 seconds
......@@ -77,6 +77,7 @@
#include <QTimer>
#include <QToolBar>
#include <QWindow>
#include <kwidgetsaddons_version.h>
KOWindowList *ActionManager::mWindowList = nullptr;
......@@ -1642,17 +1643,29 @@ void ActionManager::importCalendar(const QUrl &url)
"the destination calendar.</p>"
"<p>If you select add, then a new calendar will be created for you automatically.</p>");
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActionsCancel(dialogParent(),
#else
const int answer = KMessageBox::questionYesNoCancel(dialogParent(),
questionText,
i18nc("@title:window", "Import Calendar"),
KGuiItem(i18n("Merge into existing calendar")),
KGuiItem(i18n("Add as new calendar")));
#endif
questionText,
i18nc("@title:window", "Import Calendar"),
KGuiItem(i18n("Merge into existing calendar")),
KGuiItem(i18n("Add as new calendar")));
switch (answer) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
case KMessageBox::ButtonCode::PrimaryAction: // merge
#else
case KMessageBox::Yes: // merge
#endif
importURL(url, true);
break;
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
case KMessageBox::ButtonCode::SecondaryAction: // import
#else
case KMessageBox::No: // import
#endif
importURL(url, false);
break;
default:
......
......@@ -79,13 +79,19 @@
#include <QSplitter>
#include <QStackedWidget>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
// Meaningful aliases for dialog box return codes.
enum ItemActions {
Cancel = KMessageBox::Cancel, // Do nothing.
Current = KMessageBox::Ok, // Selected recurrence only.
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
AlsoFuture = KMessageBox::ButtonCode::SecondaryAction, // Selected and future recurrences.
Parent = KMessageBox::ButtonCode::PrimaryAction, // Instance, but not child instances.
#else
AlsoFuture = KMessageBox::No, // Selected and future recurrences.
Parent = KMessageBox::Yes, // Instance, but not child instances.
#endif
All = KMessageBox::Continue, // Instance and child instances.
};
......@@ -1494,29 +1500,49 @@ void CalendarView::dissociateOccurrences(const Akonadi::Item &item, QDate date)
bool doFuture = false;
if (isFirstOccurrence) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
answer = KMessageBox::questionTwoActions(this,
#else
answer = KMessageBox::questionYesNo(this,
i18n("Do you want to dissociate "
"the occurrence on %1 "
"from the recurrence?",
QLocale::system().toString(date, QLocale::LongFormat)),
i18n("KOrganizer Confirmation"),
KGuiItem(i18n("&Dissociate")),
KStandardGuiItem::cancel());
#endif
i18n("Do you want to dissociate "
"the occurrence on %1 "
"from the recurrence?",
QLocale::system().toString(date, QLocale::LongFormat)),
i18n("KOrganizer Confirmation"),
KGuiItem(i18n("&Dissociate")),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
doOnlyThis = (answer == KMessageBox::ButtonCode::PrimaryAction);
#else
doOnlyThis = (answer == KMessageBox::Yes);
#endif
} else {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
answer = KMessageBox::questionTwoActionsCancel(this,
#else
answer = KMessageBox::questionYesNoCancel(this,
i18n("Do you want to dissociate "
"the occurrence on %1 "
"from the recurrence or also "
"dissociate future ones?",
QLocale::system().toString(date, QLocale::LongFormat)),
i18n("KOrganizer Confirmation"),
KGuiItem(i18n("&Only Dissociate This One")),
KGuiItem(i18n("&Also Dissociate Future Ones")));
#endif
i18n("Do you want to dissociate "
"the occurrence on %1 "
"from the recurrence or also "
"dissociate future ones?",
QLocale::system().toString(date, QLocale::LongFormat)),
i18n("KOrganizer Confirmation"),
KGuiItem(i18n("&Only Dissociate This One")),
KGuiItem(i18n("&Also Dissociate Future Ones")));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
doOnlyThis = (answer == KMessageBox::ButtonCode::PrimaryAction);
#else
doOnlyThis = (answer == KMessageBox::Yes);
#endif
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
doFuture = (answer == KMessageBox::ButtonCode::SecondaryAction);
#else
doFuture = (answer == KMessageBox::No);
#endif
}
if (doOnlyThis) {
......@@ -2160,17 +2186,25 @@ int CalendarView::questionIndependentChildren(const Akonadi::Item &item)
int km;
auto incidence = Akonadi::CalendarUtils::incidence(item);
if (!incidence->hasRecurrenceId() && !mCalendar->childItems(item.id()).isEmpty()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
km = KMessageBox::questionTwoActionsCancel(this,
#else
km = KMessageBox::questionYesNoCancel(this,
i18n("The item \"%1\" has sub-to-dos. "
"Do you want to delete just this item and "
"make all its sub-to-dos independent, or "
"delete the to-do with all its sub-to-dos?",
incidence->summary()),
i18n("KOrganizer Confirmation"),
KGuiItem(i18n("Delete Only This")),
KGuiItem(i18n("Delete All")));
#endif
i18n("The item \"%1\" has sub-to-dos. "
"Do you want to delete just this item and "
"make all its sub-to-dos independent, or "
"delete the to-do with all its sub-to-dos?",
incidence->summary()),
i18n("KOrganizer Confirmation"),
KGuiItem(i18n("Delete Only This")),
KGuiItem(i18n("Delete All")));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (km == KMessageBox::ButtonCode::SecondaryAction) {
#else
if (km == KMessageBox::No) {
#endif
km = KMessageBox::Continue;
}
} else {
......
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