mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 09:34:53 +02:00
Allow saving of invalid config on second try
This commit is contained in:
@@ -188,12 +188,35 @@ DelegateConfigWrapper::onConfigTestResult( Tomahawk::Accounts::ConfigTestResultT
|
|||||||
|
|
||||||
if( result == Tomahawk::Accounts::ConfigTestResultSuccess )
|
if( result == Tomahawk::Accounts::ConfigTestResultSuccess )
|
||||||
{
|
{
|
||||||
m_errorLabel->setText( "" );
|
m_invalidData = QVariantMap();
|
||||||
closeDialog( QDialog::Accepted );
|
closeDialog( QDialog::Accepted );
|
||||||
}
|
}
|
||||||
else
|
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." ) ) );
|
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 );
|
layout()->removeWidget( m_widget );
|
||||||
m_widget->setParent( 0 );
|
m_widget->setParent( 0 );
|
||||||
m_widget->setVisible( false );
|
m_widget->setVisible( false );
|
||||||
|
m_errorLabel->setText( "" );
|
||||||
|
|
||||||
done( code );
|
done( code );
|
||||||
}
|
}
|
||||||
|
@@ -69,6 +69,7 @@ private:
|
|||||||
QPushButton *m_okButton, *m_deleteButton;
|
QPushButton *m_okButton, *m_deleteButton;
|
||||||
QLabel* m_errorLabel;
|
QLabel* m_errorLabel;
|
||||||
bool m_deleted;
|
bool m_deleted;
|
||||||
|
QVariantMap m_invalidData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user