Commit 86262e72 authored by Laurent Montel's avatar Laurent Montel
Browse files

Adapt to new api (scripted)

parent 734f533b
Pipeline #248527 passed with stage
in 23 minutes and 15 seconds
......@@ -14,6 +14,7 @@
#include <QIcon>
#include <QStandardPaths>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
#include <KConfigGroup>
#include <QAbstractTableModel>
......@@ -178,12 +179,20 @@ public:
if (buttonRect.contains(mouseEvent->pos())) {
const QString templateName = index.data(Qt::DisplayRole).toString();
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActions(nullptr,
#else
const int answer = KMessageBox::questionYesNo(nullptr,
i18nc("@label", "Do you really want to delete template '%1'?", templateName),
QString(),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
#endif
i18nc("@label", "Do you really want to delete template '%1'?", templateName),
QString(),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
model->removeRows(index.row(), 1);
return true;
}
......
......@@ -25,6 +25,7 @@
#include <gpgme++/context.h>
#include <gpgme++/data.h>
#include <gpgme++/key.h>
#include <kwidgetsaddons_version.h>
#include <qgpgme/dataprovider.h>
#endif // QGPGME_FOUND
......@@ -431,16 +432,24 @@ void VCardImportExportPluginInterface::exportVCard()
break;
}
} else {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActionsCancel(parentWidget(),
#else
const int answer = KMessageBox::questionYesNoCancel(parentWidget(),
i18nc("@info",
"You have selected a list of contacts, "
"shall they be exported to several files?"),
QString(),
KGuiItem(i18nc("@action:button", "Export to One File")),
KGuiItem(i18nc("@action:button", "Export to Several Files")));
#endif
i18nc("@info",
"You have selected a list of contacts, "
"shall they be exported to several files?"),
QString(),
KGuiItem(i18nc("@action:button", "Export to One File")),
KGuiItem(i18nc("@action:button", "Export to Several Files")));
switch (answer) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
case KMessageBox::ButtonCode::SecondaryAction: {
#else
case KMessageBox::No: {
#endif
const QUrl baseUrl = QFileDialog::getExistingDirectoryUrl();
if (baseUrl.isEmpty()) {
return; // user canceled export
......@@ -468,7 +477,11 @@ void VCardImportExportPluginInterface::exportVCard()
}
break;
}
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
case KMessageBox::ButtonCode::PrimaryAction: {
#else
case KMessageBox::Yes: {
#endif
QFileDialog::Options options = QFileDialog::DontConfirmOverwrite;
url = QFileDialog::getSaveFileUrl(parentWidget(), QString(), QUrl::fromLocalFile(QStringLiteral("addressbook.vcf")), QString(), nullptr, options);
if (url.isEmpty()) {
......
......@@ -15,6 +15,7 @@
#include <QScrollArea>
#include <QStackedWidget>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
using namespace KABMergeContacts;
MergeContactSelectInformationScrollArea::MergeContactSelectInformationScrollArea(QWidget *parent)
......@@ -83,12 +84,17 @@ void MergeContactSelectInformationScrollArea::slotMergeContacts()
}
const bool result = mSelectInformationWidget->verifySelectedInfo();
if (!result) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::ButtonCode::SecondaryAction
== KMessageBox::warningTwoActions(this,
#else
if (KMessageBox::No
== KMessageBox::warningYesNo(this,
i18n("Some information was not selected. You can lose this information. Do you want to continue merging?"),
i18n("Missing Selected Information"),
KStandardGuiItem::cont(),
KStandardGuiItem::cancel())) {
#endif
i18n("Some information was not selected. You can lose this information. Do you want to continue merging?"),
i18n("Missing Selected Information"),
KStandardGuiItem::cont(),
KStandardGuiItem::cancel())) {
return;
}
}
......
......@@ -16,6 +16,7 @@
#include <QPushButton>
#include <QTreeWidget>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
ConfirmBeforeDeletingWidget::ConfirmBeforeDeletingWidget(QWidget *parent)
: QWidget(parent)
......@@ -134,13 +135,21 @@ void ConfirmBeforeDeletingWidget::slotRemoveRule()
{
auto items = mTreeWidget->selectedItems();
if (!items.isEmpty()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActions(this,
#else
const int answer = KMessageBox::questionYesNo(this,
i18np("Do you want to remove this rule?", "Do you want to remove these rules?", items.count()),
i18nc("@title", "Remove Rule"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#endif
i18np("Do you want to remove this rule?", "Do you want to remove these rules?", items.count()),
i18nc("@title", "Remove Rule"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
while (!items.isEmpty()) {
delete items.takeFirst();
}
......
......@@ -12,6 +12,7 @@
#include <MailCommon/SnippetsModel>
#include <QHBoxLayout>
#include <QStackedWidget>
#include <kwidgetsaddons_version.h>
QuickTextWidget::QuickTextWidget(QWidget *parent)
: QWidget(parent)
......@@ -64,12 +65,20 @@ QuickTextWidget::~QuickTextWidget() = default;
void QuickTextWidget::save()
{
if (mSnippetWidget->wasChanged()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::warningTwoActions(this,
#else
const int answer = KMessageBox::warningYesNo(this,
i18n("QuickText was changed. Do you want to save it?"),
i18n("Save"),
KStandardGuiItem::save(),
KStandardGuiItem::discard());
#endif
i18n("QuickText was changed. Do you want to save it?"),
i18n("Save"),
KStandardGuiItem::save(),
KStandardGuiItem::discard());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
switch (mMode) {
case EditMode::AddSnippet:
saveAddSnippet();
......
......@@ -21,6 +21,7 @@
#include <KMessageBox>
#include <PimCommon/PimUtil>
#include <QPointer>
#include <kwidgetsaddons_version.h>
AutomaticAddContactsJob::AutomaticAddContactsJob(QObject *parent)
: QObject(parent)
......@@ -93,12 +94,21 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job)
const int nbItemCollection(canCreateItemCollections.size());
if (nbItemCollection == 0) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(nullptr,
#else
if (KMessageBox::questionYesNo(nullptr,
i18nc("@info", "You must create an address book before adding a contact. Do you want to create an address book?"),
i18nc("@title:window", "No Address Book Available"),
KGuiItem(i18nc("@action:button", "Create Address Book"), QStringLiteral("address-book-new")),
KStandardGuiItem::cancel())
#endif
i18nc("@info", "You must create an address book before adding a contact. Do you want to create an address book?"),
i18nc("@title:window", "No Address Book Available"),
KGuiItem(i18nc("@action:button", "Create Address Book"), QStringLiteral("address-book-new")),
KStandardGuiItem::cancel())
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
== KMessageBox::ButtonCode::PrimaryAction) {
#else
== KMessageBox::Yes) {
#endif
QPointer<Akonadi::AgentTypeDialog> dlg = new Akonadi::AgentTypeDialog(nullptr);
dlg->setWindowTitle(i18nc("@title:window", "Add Address Book"));
dlg->agentFilterProxyModel()->addMimeTypeFilter(KContacts::Addressee::mimeType());
......
......@@ -19,6 +19,7 @@
#include <KSharedConfig>
#include <QPointer>
#include <kwidgetsaddons_version.h>
CheckBeforeSendInterface::CheckBeforeSendInterface(QObject *parent)
: MessageComposer::PluginEditorCheckBeforeSendInterface(parent)
......@@ -31,12 +32,20 @@ bool CheckBeforeSendInterface::exec(const MessageComposer::PluginEditorCheckBefo
{
if (mSendPlainText) {
if (params.isHtmlMail()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActions(parentWidget(),
#else
const int answer = KMessageBox::questionYesNo(parentWidget(),
i18n("Do you want to send the email as HTML?"),
i18n("Send email as plain text"),
KGuiItem(i18nc("@action:button", "Send As HTML")),
KStandardGuiItem::cancel());
#endif
i18n("Do you want to send the email as HTML?"),
i18n("Send email as plain text"),
KGuiItem(i18nc("@action:button", "Send As HTML")),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::SecondaryAction) {
#else
if (answer == KMessageBox::No) {
#endif
return false;
}
}
......
......@@ -17,6 +17,7 @@
#include <QHBoxLayout>
#include <QTextBlock>
#include <kwidgetsaddons_version.h>
LanguageToolInterface::LanguageToolInterface(KActionCollection *ac, QWidget *parent)
: MessageComposer::PluginEditorGrammarCustomToolsViewInterface(parent)
......@@ -90,14 +91,23 @@ bool LanguageToolInterface::checkAgain()
{
if (richTextEditor()) {
if (!LanguageToolManager::self()->useLocalInstance()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::warningTwoActions(
#else
if (KMessageBox::warningYesNo(
#endif
parentWidget(),
i18n("You do not use local instance.\nYour text will send on a external web site (https://languagetool.org/).\nDo you want to continue?"),
i18n("Check Grammar with LanguageTool"),
KStandardGuiItem::cont(),
KStandardGuiItem::cancel(),
QStringLiteral("send_data_on_languagetool"))
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
== KMessageBox::ButtonCode::SecondaryAction) {
#else
== KMessageBox::No) {
#endif
return false;
}
}
......
......@@ -15,6 +15,7 @@
#include <QPointer>
#include <QPushButton>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
class OpenUrlWithConfigureItem : public QListWidgetItem
{
......@@ -187,13 +188,21 @@ void OpenUrlWithConfigureWidget::slotRemoveRule()
{
auto items = mListWidget->selectedItems();
if (!items.isEmpty()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActions(this,
#else
const int answer = KMessageBox::questionYesNo(this,
i18np("Do you want to remove this rule?", "Do you want to remove these rules?", items.count()),
i18nc("@title", "Remove Rule"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#endif
i18np("Do you want to remove this rule?", "Do you want to remove these rules?", items.count()),
i18nc("@title", "Remove Rule"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
while (!items.isEmpty()) {
delete items.takeFirst();
}
......
......@@ -19,6 +19,7 @@
#include <QPushButton>
#include <QStandardPaths>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
class ViewerPluginExternalScriptItem : public QListWidgetItem
{
......@@ -102,12 +103,20 @@ void ViewerPluginExternalConfigureWidget::slotRemoveScript()
{
QListWidgetItem *item = mListExternal->currentItem();
if (item) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::warningTwoActions(this,
#else
const int answer = KMessageBox::warningYesNo(this,
i18n("Do you want to remove this script \"%1\"?", item->text()),
i18n("Remove External Script"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#endif
i18n("Do you want to remove this script \"%1\"?", item->text()),
i18n("Remove External Script"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
auto scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
mFilesToRemove.append(scriptItem->scriptInfo().fileName());
delete mListExternal->takeItem(mListExternal->currentRow());
......
......@@ -41,6 +41,7 @@ using namespace PimCommon::ConfigureImmutableWidgetUtils;
#include <QStandardPaths>
#include <QWhatsThis>
#include <adblocksubscription.h>
#include <kwidgetsaddons_version.h>
using namespace AdBlock;
AdBlockSettingWidget::AdBlockSettingWidget(QWidget *parent)
......@@ -190,12 +191,20 @@ void AdBlockSettingWidget::removeRule()
if (select.isEmpty()) {
return;
}
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::warningTwoActions(this,
#else
const int answer = KMessageBox::warningYesNo(this,
i18np("Do you want to remove this rule?", "Do you want to remove these rules?", select.count()),
i18n("Remove"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#endif
i18np("Do you want to remove this rule?", "Do you want to remove these rules?", select.count()),
i18n("Remove"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::SecondaryAction) {
#else
if (answer == KMessageBox::No) {
#endif
return;
}
for (QListWidgetItem *item : select) {
......@@ -332,12 +341,20 @@ void AdBlockSettingWidget::slotRemoveSubscription()
{
QListWidgetItem *item = mUi->automaticFiltersListWidget->currentItem();
if (item) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActions(this,
#else
const int answer = KMessageBox::questionYesNo(this,
i18n("Do you want to delete list \"%1\"?", item->text()),
i18n("Delete current list"),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
#endif
i18n("Do you want to delete list \"%1\"?", item->text()),
i18n("Delete current list"),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
auto subItem = dynamic_cast<AdBlockListwidgetItem *>(item);
if (subItem) {
if (AdblockManager::self()->removeSubscription(subItem->subscription())) {
......
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