mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 06:36:55 +02:00
Check for a valid xmpp id in the config widget
This commit is contained in:
@@ -33,10 +33,11 @@ namespace Tomahawk
|
|||||||
namespace Accounts
|
namespace Accounts
|
||||||
{
|
{
|
||||||
|
|
||||||
XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent ) :
|
XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent )
|
||||||
AccountConfigWidget( parent ),
|
: AccountConfigWidget( parent )
|
||||||
m_ui( new Ui::XmppConfigWidget ),
|
, m_ui( new Ui::XmppConfigWidget )
|
||||||
m_account( account )
|
, m_account( account )
|
||||||
|
, m_disableChecksForGoogle( false )
|
||||||
{
|
{
|
||||||
m_ui->setupUi( this );
|
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();
|
void saveConfig();
|
||||||
|
|
||||||
|
virtual void checkForErrors();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataError( bool exists );
|
void dataError( bool exists );
|
||||||
|
|
||||||
@@ -63,6 +65,7 @@ private:
|
|||||||
|
|
||||||
bool m_serverWasEditedByUser;
|
bool m_serverWasEditedByUser;
|
||||||
|
|
||||||
|
bool m_disableChecksForGoogle;
|
||||||
friend class GoogleWrapper; // So google wrapper can modify the labels and text
|
friend class GoogleWrapper; // So google wrapper can modify the labels and text
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -85,6 +85,7 @@ GoogleWrapper::GoogleWrapper ( const QString& pluginID )
|
|||||||
: XmppAccount ( pluginID )
|
: XmppAccount ( pluginID )
|
||||||
{
|
{
|
||||||
XmppConfigWidget* config = static_cast< XmppConfigWidget* >( m_configWidget.data() );
|
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->headerLabel->setText( tr( "Configure this Google Account" ) );
|
||||||
config->m_ui->emailLabel->setText( tr( "Google Address:" ) );
|
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!" ) );
|
config->m_ui->xmppBlurb->setText( tr( "Enter your Google login to connect with your friends using Tomahawk!" ) );
|
||||||
|
Reference in New Issue
Block a user