mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-03 12:47:45 +02:00
Automatically fill in server name
This commit is contained in:
@@ -42,13 +42,17 @@ XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent ) :
|
|||||||
|
|
||||||
m_ui->xmppUsername->setText( account->credentials().contains( "username" ) ? account->credentials()[ "username" ].toString() : QString() );
|
m_ui->xmppUsername->setText( account->credentials().contains( "username" ) ? account->credentials()[ "username" ].toString() : QString() );
|
||||||
m_ui->xmppPassword->setText( account->credentials().contains( "password" ) ? account->credentials()[ "password" ].toString() : QString() );
|
m_ui->xmppPassword->setText( account->credentials().contains( "password" ) ? account->credentials()[ "password" ].toString() : QString() );
|
||||||
m_ui->xmppServer->setText( account->configuration().contains( "server" ) ? account->configuration()[ "server" ].toString() : QString() );
|
|
||||||
m_ui->xmppPort->setValue( account->configuration().contains( "port" ) ? account->configuration()[ "port" ].toInt() : 5222 );
|
m_ui->xmppPort->setValue( account->configuration().contains( "port" ) ? account->configuration()[ "port" ].toInt() : 5222 );
|
||||||
m_ui->xmppPublishTracksCheckbox->setChecked( account->configuration().contains( "publishtracks" ) ? account->configuration()[ "publishtracks" ].toBool() : true);
|
m_ui->xmppPublishTracksCheckbox->setChecked( account->configuration().contains( "publishtracks" ) ? account->configuration()[ "publishtracks" ].toBool() : true);
|
||||||
m_ui->xmppEnforceSecureCheckbox->setChecked( account->configuration().contains( "enforcesecure" ) ? account->configuration()[ "enforcesecure" ].toBool() : false);
|
m_ui->xmppEnforceSecureCheckbox->setChecked( account->configuration().contains( "enforcesecure" ) ? account->configuration()[ "enforcesecure" ].toBool() : false);
|
||||||
m_ui->jidExistsLabel->hide();
|
m_ui->jidExistsLabel->hide();
|
||||||
|
|
||||||
|
m_ui->xmppServer->setText( account->configuration().contains( "server" ) ? account->configuration()[ "server" ].toString() : QString() );
|
||||||
|
m_serverWasEditedByUser = account->configuration().value( "serverWasEditedByUser", false ).toBool();
|
||||||
|
|
||||||
connect( m_ui->xmppUsername, SIGNAL( textChanged( QString ) ), SLOT( onCheckJidExists( QString ) ) );
|
connect( m_ui->xmppUsername, SIGNAL( textChanged( QString ) ), SLOT( onCheckJidExists( QString ) ) );
|
||||||
|
connect( m_ui->xmppUsername, SIGNAL( textChanged( QString ) ), SLOT( onUsernameEdited() ) );
|
||||||
|
connect( m_ui->xmppServer, SIGNAL( editingFinished() ), SLOT( onServerEdited() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,11 +69,14 @@ XmppConfigWidget::saveConfig()
|
|||||||
credentials[ "password" ] = m_ui->xmppPassword->text().trimmed();
|
credentials[ "password" ] = m_ui->xmppPassword->text().trimmed();
|
||||||
|
|
||||||
QVariantHash configuration = m_account->configuration();
|
QVariantHash configuration = m_account->configuration();
|
||||||
configuration[ "server" ] = m_ui->xmppServer->text().trimmed();
|
|
||||||
configuration[ "port" ] = m_ui->xmppPort->text().trimmed();
|
configuration[ "port" ] = m_ui->xmppPort->text().trimmed();
|
||||||
configuration[ "publishtracks"] = m_ui->xmppPublishTracksCheckbox->isChecked();
|
configuration[ "publishtracks"] = m_ui->xmppPublishTracksCheckbox->isChecked();
|
||||||
configuration[ "enforcesecure"] = m_ui->xmppEnforceSecureCheckbox->isChecked();
|
configuration[ "enforcesecure"] = m_ui->xmppEnforceSecureCheckbox->isChecked();
|
||||||
|
|
||||||
|
configuration[ "server" ] = m_ui->xmppServer->text().trimmed();
|
||||||
|
configuration[ "serverWasEditedByUser" ] = m_serverWasEditedByUser;
|
||||||
|
|
||||||
|
|
||||||
m_account->setAccountFriendlyName( m_ui->xmppUsername->text() );
|
m_account->setAccountFriendlyName( m_ui->xmppUsername->text() );
|
||||||
m_account->setCredentials( credentials );
|
m_account->setCredentials( credentials );
|
||||||
m_account->setConfiguration( configuration);
|
m_account->setConfiguration( configuration);
|
||||||
@@ -80,7 +87,7 @@ XmppConfigWidget::saveConfig()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmppConfigWidget::onCheckJidExists( QString jid )
|
XmppConfigWidget::onCheckJidExists( const QString &jid )
|
||||||
{
|
{
|
||||||
QList< Tomahawk::Accounts::Account* > accounts = Tomahawk::Accounts::AccountManager::instance()->accounts( Tomahawk::Accounts::SipType );
|
QList< Tomahawk::Accounts::Account* > accounts = Tomahawk::Accounts::AccountManager::instance()->accounts( Tomahawk::Accounts::SipType );
|
||||||
foreach( Tomahawk::Accounts::Account* account, accounts )
|
foreach( Tomahawk::Accounts::Account* account, accounts )
|
||||||
@@ -109,6 +116,21 @@ XmppConfigWidget::onCheckJidExists( QString jid )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
XmppConfigWidget::onUsernameEdited()
|
||||||
|
{
|
||||||
|
if( m_ui->xmppUsername->text().trimmed().split( '@' ).count() == 2 && !m_serverWasEditedByUser )
|
||||||
|
m_ui->xmppServer->setText( m_ui->xmppUsername->text().trimmed().split( '@' ).at( 1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
XmppConfigWidget::onServerEdited()
|
||||||
|
{
|
||||||
|
m_serverWasEditedByUser = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -53,12 +53,16 @@ signals:
|
|||||||
void dataError( bool exists );
|
void dataError( bool exists );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onCheckJidExists( QString jid );
|
void onCheckJidExists( const QString& jid );
|
||||||
|
void onUsernameEdited();
|
||||||
|
void onServerEdited();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::XmppConfigWidget *m_ui;
|
Ui::XmppConfigWidget *m_ui;
|
||||||
XmppAccount *m_account;
|
XmppAccount *m_account;
|
||||||
|
|
||||||
|
bool m_serverWasEditedByUser;
|
||||||
|
|
||||||
friend class GoogleWrapper; // So google wrapper can modify the labels and text
|
friend class GoogleWrapper; // So google wrapper can modify the labels and text
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user