Commit ca8ef1ce authored by Laurent Montel's avatar Laurent Montel 😁

Fix Bug 430119 - Confirm add address on OK

FIXED-IN: 5.15.1
BUG: 430119
parent 5752645a
Pipeline #44274 passed with stage
in 10 minutes and 53 seconds
......@@ -309,4 +309,9 @@ void Akonadi::AkonadiContactEditor::setDefaultAddressBook(const Akonadi::Collect
d->mDefaultCollection = collection;
}
bool Akonadi::AkonadiContactEditor::hasNoSavedData() const
{
return d->mEditorWidget->hasNoSavedData();
}
#include "moc_contacteditor.cpp"
......@@ -133,6 +133,7 @@ public:
* @return
*/
Q_REQUIRED_RESULT KContacts::Addressee contact();
Q_REQUIRED_RESULT bool hasNoSavedData() const;
public Q_SLOTS:
/**
* Loads the @p contact into the editor.
......
......@@ -89,10 +89,7 @@ public:
void slotOkClicked()
{
if (mAddressBookBox) {
mEditor->setDefaultAddressBook(mAddressBookBox->currentCollection());
}
mEditor->saveContactInAddressBook();
q->accept();
}
void slotFinish()
......@@ -174,7 +171,18 @@ AkonadiContactEditor *ContactEditorDialog::editor() const
void ContactEditorDialog::accept()
{
//Nothing
if (d->mEditor->hasNoSavedData()) {
if (KMessageBox::questionYesNo(
this,
i18nc("@info", "Location was not saved. Do you want to close editor?"),
i18nc("@title:window", "Confirmation")) == KMessageBox::No) {
return;
}
}
if (d->mAddressBookBox) {
d->mEditor->setDefaultAddressBook(d->mAddressBookBox->currentCollection());
}
d->mEditor->saveContactInAddressBook();
}
void ContactEditorDialog::reject()
......
......@@ -52,6 +52,8 @@ public:
* @param readOnly set read-only mode
*/
virtual void setReadOnly(bool readOnly) = 0;
virtual Q_REQUIRED_RESULT bool hasNoSavedData() const { return false; }
};
}
......
......@@ -106,3 +106,8 @@ void AddressesLocationWidget::setReadOnly(bool readOnly)
mReadOnly = readOnly;
mAddressLocationWidget->setReadOnly(readOnly);
}
bool AddressesLocationWidget::hasNoSavedData() const
{
return mAddressLocationWidget->wasChanged();
}
......@@ -23,12 +23,13 @@ class AddressesLocationWidget : public QSplitter
Q_OBJECT
public:
explicit AddressesLocationWidget(QWidget *parent = nullptr);
~AddressesLocationWidget();
~AddressesLocationWidget() override;
void loadContact(const KContacts::Addressee &contact);
void storeContact(KContacts::Addressee &contact) const;
void setReadOnly(bool readOnly);
Q_REQUIRED_RESULT bool hasNoSavedData() const;
private:
AddressLocationWidget *mAddressLocationWidget = nullptr;
QTreeView *mAddressesLocationView = nullptr;
......
......@@ -33,7 +33,7 @@ public:
};
explicit AddressLocationWidget(QWidget *parent = nullptr);
~AddressLocationWidget();
~AddressLocationWidget() override;
void setAddress(const KContacts::Address &address);
Q_REQUIRED_RESULT KContacts::Address address() const;
......
......@@ -270,3 +270,8 @@ void ContactEditorWidget::setReadOnly(bool readOnly)
}
}
}
bool ContactEditorWidget::hasNoSavedData() const
{
return d->mAddressesLocationWidget->hasNoSavedData();
}
......@@ -61,6 +61,7 @@ public:
*/
void setReadOnly(bool readOnly) override;
Q_REQUIRED_RESULT bool hasNoSavedData() const override;
private:
class Private;
Private *const d;
......
Markdown is supported
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