1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 15:29:42 +01:00

fix creating factory and other first start issue

This commit is contained in:
Leo Franchi 2012-02-14 18:38:44 -05:00
parent 0c231d5532
commit 75ea38010f
4 changed files with 30 additions and 32 deletions

View File

@ -632,28 +632,15 @@ AccountDelegate::drawConfigWrench ( QPainter* painter, QStyleOptionViewItemV4& o
QRect
AccountDelegate::checkRectForIndex( const QStyleOptionViewItem& option, const QModelIndex& idx ) const
{
// the checkbox for this row was hit
const AccountModel::RowType rowType = static_cast< AccountModel::RowType >( idx.data( AccountModel::RowTypeRole ).toInt() );
QStyleOptionViewItemV4 opt = option;
initStyleOption( &opt, idx );
if ( rowType == AccountModel::TopLevelAccount || rowType == AccountModel::TopLevelFactory )
{
// Top level item, return the corresponding rect
const int ypos = ( opt.rect.top() + opt.rect.height() / 2 ) - ( WRENCH_SIZE / 2 );
QRect checkRect = QRect( PADDING, ypos, WRENCH_SIZE, WRENCH_SIZE );
return checkRect;
} /*else if ( rowType == AccountModel::ChildAccount )
{
// Return smaller rect of individual child account
const int smallWrenchSize = opt.rect.height() - PADDING;
int ypos = ( opt.rect.center().y() ) - ( smallWrenchSize / 2 );
QRect checkRect = QRect( opt.rect.left() + PADDING, ypos, smallWrenchSize, smallWrenchSize );
return checkRect;
}*/
// Top level item, return the corresponding rect
const int ypos = ( opt.rect.top() + opt.rect.height() / 2 ) - ( WRENCH_SIZE / 2 );
const QRect checkRect = QRect( PADDING, ypos, WRENCH_SIZE, WRENCH_SIZE );
return checkRect;
return QRect();
}

View File

@ -81,6 +81,7 @@ GoogleWrapper::GoogleWrapper ( const QString& pluginID )
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!" ) );
config->m_ui->xmppUsername->setPlaceholderText( tr( "username@gmail.com" ) );
config->m_ui->logoLabel->setPixmap( QPixmap( ":/gmail-logo.png" ) );
config->m_ui->xmppServer->setText( "talk.google.com" );
config->m_ui->xmppPort->setValue( 5222 );

View File

@ -57,12 +57,16 @@ void
XmppConfigWidget::saveConfig()
{
QVariantHash credentials = m_account->credentials();
credentials[ "username" ] = m_ui->xmppUsername->text();
credentials[ "password" ] = m_ui->xmppPassword->text();
credentials[ "server" ] = m_ui->xmppServer->text();
credentials[ "port" ] = m_ui->xmppPort->text();
credentials[ "username" ] = m_ui->xmppUsername->text().trimmed();
credentials[ "password" ] = m_ui->xmppPassword->text().trimmed();
QVariantHash configuration = m_account->configuration();
configuration[ "server" ] = m_ui->xmppServer->text().trimmed();
configuration[ "port" ] = m_ui->xmppPort->text().trimmed();
m_account->setAccountFriendlyName( m_ui->xmppUsername->text() );
m_account->setCredentials( credentials );
m_account->setConfiguration( configuration);
m_account->sync();
static_cast< XmppSipPlugin* >( m_account->sipPlugin() )->checkSettings();

View File

@ -33,6 +33,13 @@ AccountModel::AccountModel( QObject* parent )
: QAbstractListModel( parent )
{
connect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( loadData() ) );
connect( AccountManager::instance(), SIGNAL( added( Tomahawk::Accounts::Account* ) ), this, SLOT( accountAdded( Tomahawk::Accounts::Account* ) ) );
connect( AccountManager::instance(), SIGNAL( removed( Tomahawk::Accounts::Account* ) ), this, SLOT( accountRemoved( Tomahawk::Accounts::Account* ) ) );
connect( AccountManager::instance(), SIGNAL( stateChanged( Account* ,Accounts::Account::ConnectionState ) ), this, SLOT( accountStateChanged( Account*, Accounts::Account::ConnectionState ) ) );
connect( AtticaManager::instance(), SIGNAL( resolverInstalled( QString ) ), this, SLOT( atticaInstalled( QString ) ) );
loadData();
}
@ -70,12 +77,6 @@ AccountModel::loadData()
}
}
connect ( AccountManager::instance(), SIGNAL( added( Tomahawk::Accounts::Account* ) ), this, SLOT( accountAdded( Tomahawk::Accounts::Account* ) ) );
connect ( AccountManager::instance(), SIGNAL( removed( Tomahawk::Accounts::Account* ) ), this, SLOT( accountRemoved( Tomahawk::Accounts::Account* ) ) );
connect ( AccountManager::instance(), SIGNAL( stateChanged( Account* ,Accounts::Account::ConnectionState ) ), this, SLOT( accountStateChanged( Account*, Accounts::Account::ConnectionState ) ) );
connect( AtticaManager::instance(), SIGNAL( resolverInstalled( QString ) ), this, SLOT( atticaInstalled( QString ) ) );
endResetModel();
}
@ -296,8 +297,14 @@ AccountModel::setData( const QModelIndex& index, const QVariant& value, int role
switch ( node->type )
{
case AccountModelNode::UniqueFactoryType:
Q_ASSERT( node->accounts.size() == 1 );
acct = node->accounts.first();
if ( node->accounts.isEmpty() )
{
// No account for this unique factory, create it
// Don't add it to node->accounts here, slot attached to accountmanager::accountcreated will do it for us
acct = node->factory->createAccount();
AccountManager::instance()->addAccount( acct );
TomahawkSettings::instance()->addAccount( acct->accountId() );
}
break;
case AccountModelNode::AtticaType:
{
@ -411,6 +418,7 @@ void
AccountModel::accountAdded( Account* account )
{
// Find the factory this belongs up, and update
qDebug() << "IN ACCOUNT ADDED!!!!";
AccountFactory* factory = AccountManager::instance()->factoryForAccount( account );
AtticaResolverAccount* attica = qobject_cast< AtticaResolverAccount* >( account );
for ( int i = 0; i < m_accounts.size(); i++ )
@ -421,8 +429,6 @@ AccountModel::accountAdded( Account* account )
{
n->accounts << account;
thisIsTheOne = true;
return;
}
else if ( attica && n->atticaContent.id() == attica->atticaId() )
{