Commit 4b4fdeab authored by Laurent Montel's avatar Laurent Montel
Browse files

Adapt to new api (scripted)

parent fbf93c2e
Pipeline #248538 passed with stage
in 1 minute and 26 seconds
......@@ -36,6 +36,7 @@
#include <KMessageBox>
#include <QtDebug>
#include <kwidgetsaddons_version.h>
Phrase::Phrase()
{
......@@ -300,12 +301,20 @@ int PhraseBook::save(QWidget *parent, const QString &title, QUrl &url, bool phra
#else
} else if (url.fileName(QUrl::PrettyDecoded).right(11).contains(QLatin1String(".phrasebook"), Qt::CaseInsensitive) == 0) {
#endif
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
int filetype = KMessageBox::questionTwoActionsCancel(nullptr, QStringLiteral("<qt>%1</qt>").arg(i18n("Your chosen filename <i>%1</i> has a different extension than <i>.phrasebook</i>. "
#else
int filetype = KMessageBox::questionYesNoCancel(nullptr, QStringLiteral("<qt>%1</qt>").arg(i18n("Your chosen filename <i>%1</i> has a different extension than <i>.phrasebook</i>. "
#endif
"Do you wish to add <i>.phrasebook</i> to the filename?", url.fileName())), i18n("File Extension"), KGuiItem(i18n("Add")), KGuiItem(i18n("Do Not Add")));
if (filetype == KMessageBox::Cancel) {
return 0;
}
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (filetype == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (filetype == KMessageBox::Yes) {
#endif
url = url.adjusted(QUrl::RemoveFilename);
url.setPath(url.path() + url.fileName(QUrl::PrettyDecoded) + QStringLiteral(".phrasebook"));
}
......@@ -315,12 +324,20 @@ int PhraseBook::save(QWidget *parent, const QString &title, QUrl &url, bool phra
if (url.fileName(QUrl::PrettyDecoded).rightRef(11).contains(QLatin1String(".phrasebook"), Qt::CaseInsensitive) == 0) {
result = save(url, false);
} else {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
int filetype = KMessageBox::questionTwoActionsCancel(nullptr, QStringLiteral("<qt>%1</qt>").arg(i18n("Your chosen filename <i>%1</i> has the extension <i>.phrasebook</i>. "
#else
int filetype = KMessageBox::questionYesNoCancel(nullptr, QStringLiteral("<qt>%1</qt>").arg(i18n("Your chosen filename <i>%1</i> has the extension <i>.phrasebook</i>. "
#endif
"Do you wish to save in phrasebook format?", url.fileName())), i18n("File Extension"), KGuiItem(i18n("As Phrasebook")), KGuiItem(i18n("As Plain Text")));
if (filetype == KMessageBox::Cancel) {
return 0;
}
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (filetype == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (filetype == KMessageBox::Yes) {
#endif
result = save(url, true);
} else {
result = save(url, false);
......
......@@ -36,6 +36,7 @@
#include "phrasebook.h"
#include <QDebug>
#include <kwidgetsaddons_version.h>
const int kTextColumn = 0;
const int kShortcutColumn = 1;
......@@ -421,16 +422,28 @@ void PhraseBookDialog::selectionChanged()
bool PhraseBookDialog::queryClose()
{
if (phrasebookChanged) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
int answer = KMessageBox::questionTwoActionsCancel(this,
#else
int answer = KMessageBox::questionYesNoCancel(this,
#endif
i18n("<qt>There are unsaved changes.<br />Do you want to apply the changes before closing the \"phrase book\" window or discard the changes?</qt>"),
i18n("Closing \"Phrase Book\" Window"),
KStandardGuiItem::apply(), KStandardGuiItem::discard(),
KStandardGuiItem::cancel(), QStringLiteral("AutomaticSave"));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
slotSave();
return true;
}
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
return (answer == KMessageBox::ButtonCode::SecondaryAction);
#else
return (answer == KMessageBox::No);
#endif
}
return true;
}
......
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