diff --git a/src/AccountDelegate.cpp b/src/AccountDelegate.cpp index 71e76c786..c2074a4b1 100644 --- a/src/AccountDelegate.cpp +++ b/src/AccountDelegate.cpp @@ -156,6 +156,7 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option, // Draw config wrench if there is one const bool hasConfigWrench = index.data( AccountModel::HasConfig ).toBool(); int rightEdge = opt.rect.right(); + m_cachedConfigRects[ index ] = QRect(); if ( hasConfigWrench ) { const QRect confRect = QRect( rightEdge - 2*PADDING - WRENCH_SIZE, center - WRENCH_SIZE / 2, WRENCH_SIZE, WRENCH_SIZE ); @@ -170,6 +171,7 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option, } // Draw individual accounts and add account button for factories + m_cachedButtonRects[ index ] = QRect(); if ( rowType == Tomahawk::Accounts::AccountModel::TopLevelFactory ) { const QList< Account* > accts = index.data( AccountModel::ChildrenOfFactoryRole ).value< QList< Tomahawk::Accounts::Account* > >(); @@ -183,7 +185,7 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option, Q_ASSERT( !hasConfigWrench ); // Draw button in center of row - btnRect= QRect( opt.rect.right() - PADDING - btnWidth, center - ( installMetrics.height() + 4 ) / 2, btnWidth, installMetrics.height() + 4 ); + btnRect= QRect( opt.rect.right() - PADDING - btnWidth, center - ( installMetrics.height() + 4 ) / 2, btnWidth, installMetrics.height() + 2*PADDING ); rightEdge = btnRect.left(); } else diff --git a/src/AccountFactoryWrapper.cpp b/src/AccountFactoryWrapper.cpp index ce0b3de55..2704d3830 100644 --- a/src/AccountFactoryWrapper.cpp +++ b/src/AccountFactoryWrapper.cpp @@ -52,6 +52,10 @@ AccountFactoryWrapper::AccountFactoryWrapper( AccountFactory* factory, QWidget* connect( m_ui->buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( m_ui->buttonBox, SIGNAL( clicked( QAbstractButton*) ), this, SLOT( buttonClicked( QAbstractButton* ) ) ); + + connect ( AccountManager::instance(), SIGNAL( added( Tomahawk::Accounts::Account* ) ), this, SLOT( load() ) ); + connect ( AccountManager::instance(), SIGNAL( removed( Tomahawk::Accounts::Account* ) ), this, SLOT( load() ) ); + #ifdef Q_OS_MAC setContentsMargins( 0, 0, 0, 0 ); m_ui->verticalLayout->setSpacing( 4 ); @@ -70,6 +74,10 @@ AccountFactoryWrapper::load() item->setData( 0, AccountRole, QVariant::fromValue< QObject *>( acc ) ); } } + + if ( m_ui->accountsList->model()->rowCount() == 0 ) + accept(); + #ifndef Q_OS_MAC const int padding = 7; #else @@ -133,7 +141,7 @@ AccountFactoryWrapper::buttonClicked( QAbstractButton* button ) { m_createAccount = true; emit createAccount( m_factory ); - accept(); +// accept(); return; } else diff --git a/src/AccountFactoryWrapper.h b/src/AccountFactoryWrapper.h index 62fa9a23d..02c8ec335 100644 --- a/src/AccountFactoryWrapper.h +++ b/src/AccountFactoryWrapper.h @@ -54,10 +54,9 @@ public slots: private slots: void buttonClicked( QAbstractButton* ); - -private: void load(); +private: Tomahawk::Accounts::AccountFactory* m_factory; Ui_AccountFactoryWrapper* m_ui; QPushButton* m_addButton; diff --git a/src/AccountFactoryWrapper.ui b/src/AccountFactoryWrapper.ui index 9a119015e..b7ba54df3 100644 --- a/src/AccountFactoryWrapper.ui +++ b/src/AccountFactoryWrapper.ui @@ -7,7 +7,7 @@ 0 0 507 - 298 + 150 diff --git a/src/delegateconfigwrapper.h b/src/delegateconfigwrapper.h index 4ff15313b..5bd4faad6 100644 --- a/src/delegateconfigwrapper.h +++ b/src/delegateconfigwrapper.h @@ -90,6 +90,7 @@ public slots: { m_deleted = true; emit deleted(); + reject(); } else done( QDialog::Rejected ); diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 545e4ca00..e3f73d2b3 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -511,11 +511,11 @@ SettingsDialog::openAccountFactoryConfig( AccountFactory* factory ) if ( accts.size() == 1 ) { // If there's just one, open the config directly w/ the delete button. Otherwise open the multi dialog - openAccountConfig( accts.first() ); + openAccountConfig( accts.first(), true ); return; } -#ifndef Q_WS_MAC +#ifndef Q_OS_MAC AccountFactoryWrapper dialog( factory, this ); QWeakPointer< AccountFactoryWrapper > watcher( &dialog ); @@ -525,7 +525,7 @@ SettingsDialog::openAccountFactoryConfig( AccountFactory* factory ) #else // on osx a sheet needs to be non-modal AccountFactoryWrapper* dialog = new AccountFactoryWrapper( factory, this ); - connect( dialog, SIGNAL( createAccount( Tomahawk::Accounts::AccountFactory ) ), this, SLOT( createAccountFromFactory( Tomahawk::Accounts::AccountFactory* ) ) ); + connect( dialog, SIGNAL( createAccount( Tomahawk::Accounts::AccountFactory* ) ), this, SLOT( createAccountFromFactory( Tomahawk::Accounts::AccountFactory* ) ) ); dialog->show(); #endif