Commit 6330273a authored by Laurent Montel's avatar Laurent Montel
Browse files

Adapt to new api (scripted)

parent df981dd2
Pipeline #248509 passed with stage
in 1 minute and 45 seconds
......@@ -31,6 +31,7 @@
#include <QPointer>
#include <QPushButton>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
NotesAgentAlarmDialog::NotesAgentAlarmDialog(QWidget *parent)
: QDialog(parent)
......@@ -142,12 +143,20 @@ void NotesAgentAlarmDialog::slotShowNote()
void NotesAgentAlarmDialog::slotRemoveAlarm()
{
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::warningTwoActions(this,
#else
const int answer = KMessageBox::warningYesNo(this,
i18n("Are you sure to remove alarm?"),
i18nc("@title:window", "Remove Alarm"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#endif
i18n("Are you sure to remove alarm?"),
i18nc("@title:window", "Remove Alarm"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
const Akonadi::Item::Id id = mListWidget->currentItemId();
if (id != -1) {
Akonadi::Item item(id);
......
......@@ -24,6 +24,7 @@
#include <QLocale>
#include <QPointer>
#include <kwidgetsaddons_version.h>
using namespace NoteShared;
......@@ -91,12 +92,20 @@ void CreateNewNoteJob::slotFetchCollection(KJob *job)
{
if (job->error()) {
qCDebug(NOTESHARED_LOG) << " Error during fetch: " << job->errorString();
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::warningTwoActions(nullptr,
#else
const int answer = KMessageBox::warningYesNo(nullptr,
i18n("An error occurred during fetching. Do you want to select a new default collection?"),
QString(),
KGuiItem(i18nc("@action:button", "Select New Default")),
KGuiItem(i18nc("@action:button", "Ignore"), QStringLiteral("dialog-cancel")));
#endif
i18n("An error occurred during fetching. Do you want to select a new default collection?"),
QString(),
KGuiItem(i18nc("@action:button", "Select New Default")),
KGuiItem(i18nc("@action:button", "Ignore"), 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 selectNewCollection();
} else {
deleteLater();
......@@ -106,12 +115,20 @@ void CreateNewNoteJob::slotFetchCollection(KJob *job)
auto fetchCollection = qobject_cast<Akonadi::CollectionFetchJob *>(job);
if (fetchCollection->collections().isEmpty()) {
qCDebug(NOTESHARED_LOG) << "No collection fetched";
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::warningTwoActions(nullptr,
#else
const int answer = KMessageBox::warningYesNo(nullptr,
i18n("An error occurred during fetching. Do you want to select a new default collection?"),
QString(),
KGuiItem(i18nc("@action:button", "Select New Default")),
KGuiItem(i18nc("@action:button", "Ignore"), QStringLiteral("dialog-cancel")));
#endif
i18n("An error occurred during fetching. Do you want to select a new default collection?"),
QString(),
KGuiItem(i18nc("@action:button", "Select New Default")),
KGuiItem(i18nc("@action:button", "Ignore"), 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 selectNewCollection();
} else {
deleteLater();
......@@ -121,13 +138,22 @@ void CreateNewNoteJob::slotFetchCollection(KJob *job)
Akonadi::Collection col = fetchCollection->collections().at(0);
if (col.isValid()) {
if (!col.hasAttribute<NoteShared::ShowFolderNotesAttribute>()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer =
KMessageBox::warningTwoActions(nullptr,
#else
const int answer =
KMessageBox::warningYesNo(nullptr,
i18n("Collection is hidden. New note will be stored but not displayed. Do you want to show collection?"),
QString(),
KGuiItem(i18nc("@action::button", "Show Collection")),
KGuiItem(i18nc("@action::button", "Do Not Show"), QStringLiteral("dialog-cancel")));
#endif
i18n("Collection is hidden. New note will be stored but not displayed. Do you want to show collection?"),
QString(),
KGuiItem(i18nc("@action::button", "Show Collection")),
KGuiItem(i18nc("@action::button", "Do Not Show"), QStringLiteral("dialog-cancel")));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
col.addAttribute(new NoteShared::ShowFolderNotesAttribute());
auto modifyJob = new Akonadi::CollectionModifyJob(col);
connect(modifyJob, &Akonadi::CollectionModifyJob::result, this, &CreateNewNoteJob::slotCollectionModifyFinished);
......
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