mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 01:09:42 +01:00
Check for a valid xmpp id in the config widget
This commit is contained in:
parent
e750ea45a3
commit
809330c877
@ -33,10 +33,11 @@ namespace Tomahawk
|
||||
namespace Accounts
|
||||
{
|
||||
|
||||
XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent ) :
|
||||
AccountConfigWidget( parent ),
|
||||
m_ui( new Ui::XmppConfigWidget ),
|
||||
m_account( account )
|
||||
XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent )
|
||||
: AccountConfigWidget( parent )
|
||||
, m_ui( new Ui::XmppConfigWidget )
|
||||
, m_account( account )
|
||||
, m_disableChecksForGoogle( false )
|
||||
{
|
||||
m_ui->setupUi( this );
|
||||
|
||||
@ -131,6 +132,34 @@ XmppConfigWidget::onServerEdited()
|
||||
}
|
||||
|
||||
|
||||
XmppConfigWidget::checkForErrors()
|
||||
{
|
||||
const QString username = m_ui->xmppUsername->text().trimmed();
|
||||
const QStringList usernameParts = username.split( '@', QString::KeepEmptyParts );
|
||||
|
||||
QString errorMessage;
|
||||
if( username.isEmpty() )
|
||||
{
|
||||
errorMessage.append( tr( "You forgot to enter your username!" ) );
|
||||
}
|
||||
|
||||
//HACK: don't check for xmpp id being an "email address"
|
||||
if( !m_disableChecksForGoogle )
|
||||
{
|
||||
if( usernameParts.count() != 2 || usernameParts.at( 0 ).isEmpty() || ( usernameParts.count() == 2 && usernameParts.at( 1 ).isEmpty() ) )
|
||||
{
|
||||
errorMessage.append( tr( "Your Xmpp Id should look like an email address" ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( !errorMessage.isEmpty() )
|
||||
{
|
||||
errorMessage.append( tr( "\n\nExample:\nusername@jabber.org" ) );
|
||||
m_errors.append( errorMessage );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,6 +49,8 @@ public:
|
||||
|
||||
void saveConfig();
|
||||
|
||||
virtual void checkForErrors();
|
||||
|
||||
signals:
|
||||
void dataError( bool exists );
|
||||
|
||||
@ -63,6 +65,7 @@ private:
|
||||
|
||||
bool m_serverWasEditedByUser;
|
||||
|
||||
bool m_disableChecksForGoogle;
|
||||
friend class GoogleWrapper; // So google wrapper can modify the labels and text
|
||||
};
|
||||
|
||||
|
@ -85,6 +85,7 @@ GoogleWrapper::GoogleWrapper ( const QString& pluginID )
|
||||
: XmppAccount ( pluginID )
|
||||
{
|
||||
XmppConfigWidget* config = static_cast< XmppConfigWidget* >( m_configWidget.data() );
|
||||
config->m_disableChecksForGoogle = true;
|
||||
config->m_ui->headerLabel->setText( tr( "Configure this Google Account" ) );
|
||||
config->m_ui->emailLabel->setText( tr( "Google Address:" ) );
|
||||
config->m_ui->xmppBlurb->setText( tr( "Enter your Google login to connect with your friends using Tomahawk!" ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user