Commit 2891a6cb authored by Laurent Montel's avatar Laurent Montel
Browse files

Adapt to new api (scripted)

parent 9ecf4832
Pipeline #248532 passed with stage
in 15 minutes and 13 seconds
......@@ -21,6 +21,7 @@
#include <KLazyLocalizedString>
#include <QItemSelectionModel>
#include <QPointer>
#include <kwidgetsaddons_version.h>
using namespace Akonadi;
......@@ -149,14 +150,23 @@ public:
{
const AgentInstance::List instances = selectedAgentInstances();
if (!instances.isEmpty()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(mParentWidget,
#else
if (KMessageBox::questionYesNo(mParentWidget,
contextText(AgentActionManager::DeleteAgentInstance, AgentActionManager::MessageBoxText),
contextText(AgentActionManager::DeleteAgentInstance, AgentActionManager::MessageBoxTitle),
KStandardGuiItem::del(),
KStandardGuiItem::cancel(),
QString(),
KMessageBox::Dangerous)
#endif
contextText(AgentActionManager::DeleteAgentInstance, AgentActionManager::MessageBoxText),
contextText(AgentActionManager::DeleteAgentInstance, AgentActionManager::MessageBoxTitle),
KStandardGuiItem::del(),
KStandardGuiItem::cancel(),
QString(),
KMessageBox::Dangerous)
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
== KMessageBox::ButtonCode::PrimaryAction) {
#else
== KMessageBox::Yes) {
#endif
for (const AgentInstance &instance : instances) {
AgentManager::self()->removeInstance(instance);
}
......
......@@ -22,6 +22,7 @@
#include <QAbstractItemView>
#include <QKeyEvent>
#include <QPointer>
#include <kwidgetsaddons_version.h>
using namespace Akonadi;
......@@ -196,12 +197,20 @@ void ManageAccountWidget::slotRemoveSelectedAccount()
{
const Akonadi::AgentInstance instance = d->ui.mAccountList->currentAgentInstance();
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int rc = KMessageBox::questionTwoActions(this,
#else
const int rc = KMessageBox::questionYesNo(this,
i18n("Do you want to remove account '%1'?", instance.name()),
i18n("Remove account?"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#endif
i18n("Do you want to remove account '%1'?", instance.name()),
i18n("Remove account?"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (rc == KMessageBox::ButtonCode::SecondaryAction) {
#else
if (rc == KMessageBox::No) {
#endif
return;
}
......
......@@ -50,6 +50,7 @@
#include <QTimer>
#include <KLazyLocalizedString>
#include <kwidgetsaddons_version.h>
using namespace Akonadi;
......@@ -803,7 +804,12 @@ public:
const QString collectionName = collections.first().name();
const QString text = contextText(StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxText, collections.count(), collectionName);
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(
#else
if (KMessageBox::questionYesNo(
#endif
parentWidget,
text,
contextText(StandardActionManager::DeleteCollections, StandardActionManager::MessageBoxTitle, collections.count(), collectionName),
......@@ -811,7 +817,11 @@ public:
KStandardGuiItem::cancel(),
QString(),
KMessageBox::Dangerous)
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
!= KMessageBox::ButtonCode::PrimaryAction) {
#else
!= KMessageBox::Yes) {
#endif
return;
}
......@@ -977,13 +987,22 @@ public:
Akonadi::AgentInstance instance = Akonadi::AgentManager::self()->instance(collection.resource());
if (!instance.isOnline()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(
#else
if (KMessageBox::questionYesNo(
#endif
parentWidget,
i18n("Before syncing folder \"%1\" it is necessary to have the resource online. Do you want to make it online?", collection.displayName()),
i18n("Account \"%1\" is offline", instance.name()),
KGuiItem(i18nc("@action:button", "Go Online")),
KStandardGuiItem::cancel())
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
!= KMessageBox::ButtonCode::PrimaryAction) {
#else
!= KMessageBox::Yes) {
#endif
return false;
}
instance.setIsOnline(true);
......@@ -1092,14 +1111,23 @@ public:
{
Q_ASSERT(itemSelectionModel);
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(parentWidget,
#else
if (KMessageBox::questionYesNo(parentWidget,
contextText(StandardActionManager::DeleteItems, StandardActionManager::MessageBoxText, items.count(), QString()),
contextText(StandardActionManager::DeleteItems, StandardActionManager::MessageBoxTitle, items.count(), QString()),
KStandardGuiItem::del(),
KStandardGuiItem::cancel(),
QString(),
KMessageBox::Dangerous)
#endif
contextText(StandardActionManager::DeleteItems, StandardActionManager::MessageBoxText, items.count(), QString()),
contextText(StandardActionManager::DeleteItems, StandardActionManager::MessageBoxTitle, items.count(), QString()),
KStandardGuiItem::del(),
KStandardGuiItem::cancel(),
QString(),
KMessageBox::Dangerous)
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
!= KMessageBox::ButtonCode::PrimaryAction) {
#else
!= KMessageBox::Yes) {
#endif
return;
}
......@@ -1299,7 +1327,12 @@ public:
return;
}
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(
#else
if (KMessageBox::questionYesNo(
#endif
parentWidget,
contextText(StandardActionManager::DeleteResources, StandardActionManager::MessageBoxText, instances.count(), instances.first().name()),
contextText(StandardActionManager::DeleteResources, StandardActionManager::MessageBoxTitle, instances.count(), instances.first().name()),
......@@ -1307,7 +1340,11 @@ public:
KStandardGuiItem::cancel(),
QString(),
KMessageBox::Dangerous)
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
!= KMessageBox::ButtonCode::PrimaryAction) {
#else
!= KMessageBox::Yes) {
#endif
return;
}
......
......@@ -13,6 +13,7 @@
#include "tagfetchscope.h"
#include "tagmodel.h"
#include "ui_tageditwidget.h"
#include <kwidgetsaddons_version.h>
#include <KCheckableProxyModel>
#include <KLocalizedString>
......@@ -163,7 +164,12 @@ void TagEditWidgetPrivate::deleteTag()
const auto tag = m_deleteCandidate.data(Akonadi::TagModel::TagRole).value<Akonadi::Tag>();
const QString text = xi18nc("@info", "Do you really want to remove the tag <resource>%1</resource>?", tag.name());
const QString caption = i18nc("@title:window", "Delete Tag");
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(d, text, caption, KStandardGuiItem::del(), KStandardGuiItem::cancel()) == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (KMessageBox::questionYesNo(d, text, caption, KStandardGuiItem::del(), KStandardGuiItem::cancel()) == KMessageBox::Yes) {
#endif
new TagDeleteJob(tag, this);
}
}
......
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