void AccountWidget::setupConnections( const QPersistentModelIndex& idx, int accountIdx ) { m_myFactoryIdx = idx; m_myAccountIdx = accountIdx; Tomahawk::Accounts::Account* account = idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().at( accountIdx ); if ( account ) { connect( m_statusToggle, SIGNAL( toggled( bool ) ), this, SLOT( changeAccountConnectionState( bool ) ) ); connect( m_inviteButton, SIGNAL( clicked() ), this, SLOT( sendInvite() ) ); connect( m_inviteEdit, SIGNAL( returnPressed() ), this, SLOT( sendInvite() ) ); if ( account->sipPlugin() ) { m_inviteEdit->setPlaceholderText( account->sipPlugin()->inviteString() ); connect( account->sipPlugin(), SIGNAL( inviteSentSuccess( QString ) ), SLOT( onInviteSentSuccess( QString ) ) ); connect( account->sipPlugin(), SIGNAL( inviteSentFailure( QString ) ), SLOT( onInviteSentFailure( QString ) ) ); } } }
void accountConfigClosed( int ret ) { if( ret == QDialog::Accepted ) { Tomahawk::Accounts::Account* account = qobject_cast< Tomahawk::Accounts::Account* >( m_w->property( "accountplugin" ).value< QObject* >() ); account->saveConfig(); } }
void AccountWidget::sendInvite() { Tomahawk::Accounts::Account* account = m_myFactoryIdx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().at( m_myAccountIdx ); if ( account ) { if ( !m_inviteEdit->text().isEmpty() ) account->sipPlugin()->addContact( m_inviteEdit->text() ); m_inviteButton->setEnabled( false ); m_inviteEdit->setEnabled( false ); QTimer::singleShot( 500, this, SLOT( clearInviteWidgets() ) ); } }
void AccountWidget::update( const QPersistentModelIndex& idx, int accountIdx ) { Tomahawk::Accounts::Account* account = idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().at( accountIdx ); if ( account ) { const QPixmap& pixmap = account->icon(); QSize pixmapSize( 32, 32 ); m_imageLabel->setPixmap( pixmap.scaled( pixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); m_imageLabel->setFixedSize( pixmapSize ); QFontMetrics fm = m_idLabel->fontMetrics(); m_idLabel->setText( account->accountFriendlyName() ); m_idLabel->setToolTip( "<b>" + account->accountServiceName() + "</b><br>" + account->accountFriendlyName() ); //we already know it's a factory because of the FactoryProxy Tomahawk::Accounts::AccountFactory* fac = qobject_cast< Tomahawk::Accounts::AccountFactory* >( idx.data( Tomahawk::Accounts::AccountModel::AccountData ) .value< QObject* >() ); if ( fac->factoryId() == "twitteraccount" ) { m_inviteContainer->setVisible( false ); m_inviteButton->setVisible( false ); } switch ( account->connectionState() ) { case Tomahawk::Accounts::Account::Connected: if ( account->enabled() ) m_statusToggle->setChecked( true ); else qDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Connected but Disabled!"; m_spinner->fadeOut(); m_statusToggle->setBackChecked( true ); setInviteWidgetsEnabled( true ); break; case Tomahawk::Accounts::Account::Connecting: if ( !account->enabled() ) qDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Connecting but Disabled!"; m_spinner->fadeIn(); m_statusToggle->setBackChecked( false ); setInviteWidgetsEnabled( false ); break; case Tomahawk::Accounts::Account::Disconnected: if ( !account->enabled() ) m_statusToggle->setChecked( false ); else qDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Disconnected but Enabled!"; m_spinner->fadeOut(); m_statusToggle->setBackChecked( false ); setInviteWidgetsEnabled( false ); break; case Tomahawk::Accounts::Account::Disconnecting: if ( account->enabled() ) qDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Disconnecting but Enabled!"; m_spinner->fadeIn(); m_statusToggle->setBackChecked( true ); setInviteWidgetsEnabled( false ); } } }
void AccountWidget::update( const QPersistentModelIndex& idx, int accountIdx ) { Tomahawk::Accounts::Account* account = idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().at( accountIdx ); if ( account ) { const QPixmap& pixmap = account->icon(); QSize pixmapSize( scaled( 32, 32 ) ); m_imageLabel->setPixmap( pixmap.scaled( pixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); m_imageLabel->setFixedSize( pixmapSize ); QFontMetrics fm = m_idLabel->fontMetrics(); m_idLabel->setText( account->accountFriendlyName() ); m_idLabel->setToolTip( "<b>" + account->accountServiceName() + "</b><br>" + account->accountFriendlyName() ); switch ( account->connectionState() ) { case Tomahawk::Accounts::Account::Connected: { if ( account->enabled() ) m_statusToggle->setChecked( true ); else tDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Connected but Disabled!"; m_spinner->fadeOut(); m_statusToggle->setBackChecked( true ); setInviteWidgetsEnabled( true ); break; } case Tomahawk::Accounts::Account::Connecting: { if ( !account->enabled() ) tDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Connecting but Disabled!"; m_spinner->fadeIn(); m_statusToggle->setBackChecked( false ); setInviteWidgetsEnabled( false ); break; } case Tomahawk::Accounts::Account::Disconnected: { if ( !account->enabled() ) m_statusToggle->setChecked( false ); else tDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Disconnected but Enabled!"; m_spinner->fadeOut(); m_statusToggle->setBackChecked( false ); setInviteWidgetsEnabled( false ); break; } case Tomahawk::Accounts::Account::Disconnecting: { if ( account->enabled() ) tDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Disconnecting but Enabled!"; m_spinner->fadeIn(); m_statusToggle->setBackChecked( true ); setInviteWidgetsEnabled( false ); } } if ( !account->enabled() && account->connectionState() == Tomahawk::Accounts::Account::Disconnected ) { m_spinner->fadeOut(); m_statusToggle->setBackChecked( false ); m_statusToggle->setChecked( false ); setInviteWidgetsEnabled( false ); } else if ( account->enabled() && account->connectionState() == Tomahawk::Accounts::Account::Connected ) { m_spinner->fadeOut(); m_statusToggle->setBackChecked( true ); m_statusToggle->setChecked( true ); setInviteWidgetsEnabled( true ); } } }