1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 17:14:00 +02:00

Allow saving of invalid config on second try

This commit is contained in:
Dominik Schmidt
2014-12-10 22:36:30 +01:00
parent e2fd7e5681
commit fffe3cbf1f
2 changed files with 27 additions and 2 deletions

View File

@@ -188,12 +188,35 @@ DelegateConfigWrapper::onConfigTestResult( Tomahawk::Accounts::ConfigTestResultT
if( result == Tomahawk::Accounts::ConfigTestResultSuccess )
{
m_errorLabel->setText( "" );
m_invalidData = QVariantMap();
closeDialog( QDialog::Accepted );
}
else
{
// TODO: make this nicer
const QVariantMap newData = m_widget->readData();
// check if user tried to save the same config for the second time
bool configChangedSinceLastTry = false;
if ( !m_invalidData.isEmpty() )
{
foreach( const QString& key, m_invalidData.keys() )
{
if ( m_invalidData[ key ] != newData[ key ] )
{
configChangedSinceLastTry = true;
break;
}
}
if ( !configChangedSinceLastTry )
{
closeDialog( QDialog::Accepted );
}
}
m_invalidData = m_widget->readData();
// TODO: generate message based on status code
m_errorLabel->setText( QString( "<font color='red'>%1</font>" ).arg( tr( "Your config is invalid." ) ) );
}
}
@@ -206,6 +229,7 @@ DelegateConfigWrapper::closeDialog( QDialog::DialogCode code )
layout()->removeWidget( m_widget );
m_widget->setParent( 0 );
m_widget->setVisible( false );
m_errorLabel->setText( "" );
done( code );
}

View File

@@ -69,6 +69,7 @@ private:
QPushButton *m_okButton, *m_deleteButton;
QLabel* m_errorLabel;
bool m_deleted;
QVariantMap m_invalidData;
};
#endif