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

Adapt to new api (scripted)

parent d8ba1edd
Pipeline #248469 passed with stage
in 3 minutes and 30 seconds
......@@ -9,9 +9,9 @@
#include "contacteditordialog.h"
#include "contacteditor.h"
#include <Akonadi/CollectionComboBox>
#include <Akonadi/Item>
#include <kwidgetsaddons_version.h>
#include <KContacts/Addressee>
......@@ -178,12 +178,20 @@ AkonadiContactEditor *ContactEditorDialog::editor() const
void ContactEditorDialog::accept()
{
if (d->mEditor->hasNoSavedData()) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActions(this,
#else
const int answer = KMessageBox::questionYesNo(this,
i18nc("@info", "Location was not saved. Do you want to close editor?"),
i18nc("@title:window", "Confirmation"),
KGuiItem(i18nc("@action:button", "Close Editor"), QStringLiteral("dialog-close")),
KGuiItem(i18nc("@action:button", "Do Not Close"), QStringLiteral("dialog-cancel")));
#endif
i18nc("@info", "Location was not saved. Do you want to close editor?"),
i18nc("@title:window", "Confirmation"),
KGuiItem(i18nc("@action:button", "Close Editor"), QStringLiteral("dialog-close")),
KGuiItem(i18nc("@action:button", "Do Not Close"), QStringLiteral("dialog-cancel")));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::SecondaryAction) {
#else
if (answer == KMessageBox::No) {
#endif
return;
}
}
......@@ -195,15 +203,24 @@ void ContactEditorDialog::accept()
void ContactEditorDialog::reject()
{
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActions(this,
#else
const int answer = KMessageBox::questionYesNo(this,
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")));
#endif
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
QDialog::reject(); // Discard current changes
}
}
#include "moc_contacteditordialog.cpp"
#include <kwidgetsaddons_version.h>
......@@ -10,11 +10,11 @@
#include "contactgroupeditor.h"
#include "contactgroupeditor_p.h"
#include <Akonadi/CollectionComboBox>
#include <Akonadi/Item>
#include <KContacts/ContactGroup>
#include <KLocalizedString>
#include <kwidgetsaddons_version.h>
#include <KConfig>
#include <KMessageBox>
......@@ -161,15 +161,24 @@ void ContactGroupEditorDialog::slotAccepted()
void ContactGroupEditorDialog::reject()
{
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActions(this,
#else
const int answer = KMessageBox::questionYesNo(this,
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")));
#endif
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
QDialog::reject(); // Discard current changes
}
}
#include "moc_contactgroupeditordialog.cpp"
#include <kwidgetsaddons_version.h>
......@@ -7,7 +7,6 @@
#include "addemailaddressjob.h"
#include "selectaddressbookdialog.h"
#include <Akonadi/AgentFilterProxyModel>
#include <Akonadi/AgentInstanceCreateJob>
#include <Akonadi/AgentType>
......@@ -21,6 +20,7 @@
#include <Akonadi/Item>
#include <Akonadi/ItemCreateJob>
#include <KContacts/ContactGroup>
#include <kwidgetsaddons_version.h>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -116,12 +116,22 @@ public:
const int nbItemCollection(canCreateItemCollections.size());
if (nbItemCollection == 0) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(
mParentWidget,
#else
if (KMessageBox::questionYesNo(mParentWidget,
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(mParentWidget);
dlg->setWindowTitle(i18nc("@title:window", "Add Address Book"));
dlg->agentFilterProxyModel()->addMimeTypeFilter(KContacts::Addressee::mimeType());
......@@ -218,13 +228,22 @@ public:
"<para>Do you want to edit this new contact now?</para>",
mCompleteAddress);
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(mParentWidget,
#else
if (KMessageBox::questionYesNo(mParentWidget,
text,
QString(),
KGuiItem(i18nc("@action:button", "Edit"), QStringLiteral("document-edit")),
KGuiItem(i18nc("@action:button", "Finish"), QStringLiteral("dialog-ok-apply")),
QStringLiteral("addedtokabc"))
#endif
text,
QString(),
KGuiItem(i18nc("@action:button", "Edit"), QStringLiteral("document-edit")),
KGuiItem(i18nc("@action:button", "Finish"), QStringLiteral("dialog-ok-apply")),
QStringLiteral("addedtokabc"))
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
== KMessageBox::ButtonCode::PrimaryAction) {
#else
== KMessageBox::Yes) {
#endif
QPointer<Akonadi::ContactEditorDialog> dlg = new Akonadi::ContactEditorDialog(Akonadi::ContactEditorDialog::EditMode, mParentWidget);
dlg->setContact(mItem);
QObject::connect(dlg.data(), &Akonadi::ContactEditorDialog::contactStored, q, [this](const Akonadi::Item &item) {
......@@ -293,3 +312,4 @@ void AddEmailAddressJob::setInteractive(bool b)
}
#include "moc_addemailaddressjob.cpp"
#include <kwidgetsaddons_version.h>
......@@ -6,7 +6,6 @@
#include "addemaildisplayjob.h"
#include "selectaddressbookdialog.h"
#include <Akonadi/AgentFilterProxyModel>
#include <Akonadi/AgentInstanceCreateJob>
#include <Akonadi/AgentType>
......@@ -19,6 +18,7 @@
#include <Akonadi/ContactSearchJob>
#include <Akonadi/ItemCreateJob>
#include <Akonadi/ItemModifyJob>
#include <kwidgetsaddons_version.h>
#include <KContacts/ContactGroup>
#include <KLocalizedString>
......@@ -155,12 +155,22 @@ public:
const int nbItemCollection(canCreateItemCollections.size());
if (nbItemCollection == 0) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(
mParentWidget,
#else
if (KMessageBox::questionYesNo(mParentWidget,
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(mParentWidget);
dlg->setWindowTitle(i18nc("@title:window", "Add Address Book"));
dlg->agentFilterProxyModel()->addMimeTypeFilter(KContacts::Addressee::mimeType());
......@@ -307,3 +317,4 @@ void AddEmailDisplayJob::start()
}
#include "moc_addemaildisplayjob.cpp"
#include <kwidgetsaddons_version.h>
......@@ -17,6 +17,7 @@
#include <KMessageBox>
#include <QMenu>
#include <QTreeView>
#include <kwidgetsaddons_version.h>
using namespace ContactEditor;
......@@ -64,12 +65,20 @@ AddressesLocationWidget::AddressesLocationWidget(QWidget *parent)
auto action = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Remove Address"));
action->setEnabled(!mReadOnly);
connect(action, &QAction::triggered, this, [this, idx]() {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const auto result = KMessageBox::questionTwoActions(this,
#else
const auto result = KMessageBox::questionYesNo(this,
i18n("Do you really want to delete this address?"),
QString(),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
#endif
i18n("Do you really want to delete this address?"),
QString(),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (result == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (result == KMessageBox::Yes) {
#endif
mAddressModel->removeAddress(idx.row());
}
});
......
......@@ -20,6 +20,7 @@
#include <QPushButton>
#include <QStackedWidget>
#include <QVBoxLayout>
#include <kwidgetsaddons_version.h>
using namespace ContactEditor;
......@@ -288,12 +289,20 @@ void AddressLocationWidget::slotUpdateAddress()
void AddressLocationWidget::slotRemoveAddress()
{
if (mCurrentMode == ModifyAddress) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const auto result = KMessageBox::questionTwoActions(this,
#else
const auto result = KMessageBox::questionYesNo(this,
i18n("Do you really want to delete this address?"),
QString(),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
#endif
i18n("Do you really want to delete this address?"),
QString(),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (result == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (result == KMessageBox::Yes) {
#endif
Q_EMIT removeAddress(mCurrentAddress);
reset();
}
......
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