mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 08:34:34 +02:00
Show inline error instead of error popup
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include "../utils/Logger.h"
|
#include "../utils/Logger.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
|
||||||
DelegateConfigWrapper::DelegateConfigWrapper( Tomahawk::Accounts::Account* account, QWidget* parent, Qt::WindowFlags flags )
|
DelegateConfigWrapper::DelegateConfigWrapper( Tomahawk::Accounts::Account* account, QWidget* parent, Qt::WindowFlags flags )
|
||||||
@@ -32,6 +33,7 @@ DelegateConfigWrapper::DelegateConfigWrapper( Tomahawk::Accounts::Account* accou
|
|||||||
, m_buttons( nullptr )
|
, m_buttons( nullptr )
|
||||||
, m_okButton( nullptr )
|
, m_okButton( nullptr )
|
||||||
, m_deleteButton( nullptr )
|
, m_deleteButton( nullptr )
|
||||||
|
, m_errorLabel( new QLabel( this ) )
|
||||||
, m_deleted( false )
|
, m_deleted( false )
|
||||||
{
|
{
|
||||||
setWindowTitle( tr("%1 Config" ).arg( account->accountFriendlyName() ) );
|
setWindowTitle( tr("%1 Config" ).arg( account->accountFriendlyName() ) );
|
||||||
@@ -65,6 +67,9 @@ DelegateConfigWrapper::DelegateConfigWrapper( Tomahawk::Accounts::Account* accou
|
|||||||
else if ( m_widget )
|
else if ( m_widget )
|
||||||
h->setContentsMargins( m_widget->contentsMargins() );
|
h->setContentsMargins( m_widget->contentsMargins() );
|
||||||
|
|
||||||
|
m_errorLabel->setAlignment( Qt::AlignCenter );
|
||||||
|
v->addWidget( m_errorLabel );
|
||||||
|
|
||||||
v->addLayout( h );
|
v->addLayout( h );
|
||||||
setLayout( v );
|
setLayout( v );
|
||||||
|
|
||||||
@@ -119,6 +124,7 @@ DelegateConfigWrapper::closed( QAbstractButton* b )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_errorLabel->setText( "" );
|
||||||
m_account->testConfig();
|
m_account->testConfig();
|
||||||
}
|
}
|
||||||
else if ( b == m_deleteButton )
|
else if ( b == m_deleteButton )
|
||||||
@@ -182,12 +188,13 @@ DelegateConfigWrapper::onConfigTestResult( Tomahawk::Accounts::ConfigTestResultT
|
|||||||
|
|
||||||
if( result == Tomahawk::Accounts::ConfigTestResultSuccess )
|
if( result == Tomahawk::Accounts::ConfigTestResultSuccess )
|
||||||
{
|
{
|
||||||
|
m_errorLabel->setText( "" );
|
||||||
closeDialog( QDialog::Accepted );
|
closeDialog( QDialog::Accepted );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: make this nicer
|
// TODO: make this nicer
|
||||||
QMessageBox::critical( this, tr( "Error" ), tr( "Your config is invalid and can't be saved." ) );
|
m_errorLabel->setText( QString( "<font color='red'>%1</font>" ).arg( tr( "Your config is invalid." ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,8 +26,11 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
class AccountConfigWidget;
|
class AccountConfigWidget;
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
class DelegateConfigWrapper : public QDialog
|
class DelegateConfigWrapper : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -64,6 +67,7 @@ private:
|
|||||||
QWidget* m_aboutW;
|
QWidget* m_aboutW;
|
||||||
QDialogButtonBox* m_buttons;
|
QDialogButtonBox* m_buttons;
|
||||||
QPushButton *m_okButton, *m_deleteButton;
|
QPushButton *m_okButton, *m_deleteButton;
|
||||||
|
QLabel* m_errorLabel;
|
||||||
bool m_deleted;
|
bool m_deleted;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user