From 7d114ea0f3dbb851ecb4f50ac56027b6cdf50aee Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Wed, 10 Dec 2014 22:46:15 +0100 Subject: [PATCH] Reset config widget data on Cancel --- src/libtomahawk/accounts/DelegateConfigWrapper.cpp | 10 ++++++++++ src/libtomahawk/accounts/DelegateConfigWrapper.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/libtomahawk/accounts/DelegateConfigWrapper.cpp b/src/libtomahawk/accounts/DelegateConfigWrapper.cpp index 8048c1b23..bf45fc500 100644 --- a/src/libtomahawk/accounts/DelegateConfigWrapper.cpp +++ b/src/libtomahawk/accounts/DelegateConfigWrapper.cpp @@ -136,6 +136,7 @@ DelegateConfigWrapper::closed( QAbstractButton* b ) } else { + m_widget->fillDataInWidgets( m_initialData ); closeDialog( QDialog::Rejected ); } } @@ -157,6 +158,15 @@ DelegateConfigWrapper::updateSizeHint() } +void DelegateConfigWrapper::showEvent(QShowEvent* event) +{ + // TODO: would be cool to load the data only on show event instead of on widget creation + m_initialData = m_widget->readData(); + + QDialog::showEvent(event); +} + + void DelegateConfigWrapper::aboutClicked( bool ) { diff --git a/src/libtomahawk/accounts/DelegateConfigWrapper.h b/src/libtomahawk/accounts/DelegateConfigWrapper.h index 0e56de1a5..2eddf9ed8 100644 --- a/src/libtomahawk/accounts/DelegateConfigWrapper.h +++ b/src/libtomahawk/accounts/DelegateConfigWrapper.h @@ -55,6 +55,9 @@ public slots: signals: void closedWithDelete(); +protected: + void showEvent( QShowEvent * event ) override; + private slots: void aboutClicked( bool ); void onConfigTestResult( Tomahawk::Accounts::ConfigTestResultType ); @@ -70,6 +73,7 @@ private: QLabel* m_errorLabel; bool m_deleted; QVariantMap m_invalidData; + QVariantMap m_initialData; }; #endif