diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index fa3d7ae88..2bb7206de 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -83,6 +83,9 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) : #else ui->_folderList->setMinimumWidth( 300 ); #endif + createAccountToolbox(); + connect(AccountManager::instance(), SIGNAL(accountAdded(AccountState*)), + SLOT(slotAccountAdded(AccountState*))); connect(ui->_folderList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotCustomContextMenuRequested(QPoint))); @@ -126,8 +129,46 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) : connect( &_quotaInfo, SIGNAL(quotaUpdated(qint64,qint64)), this, SLOT(slotUpdateQuota(qint64,qint64))); - connect(ui->signInButton, SIGNAL(clicked()) , this, SLOT(slotSignInAccount())); - connect(ui->deleteButton, SIGNAL(clicked()) , this, SLOT(slotDeleteAccount())); +} + + +void AccountSettings::createAccountToolbox() +{ + QMenu *menu = new QMenu(); + _addAccountAction = new QAction(tr("Add new"), this); + menu->addAction(_addAccountAction); + connect(_addAccountAction, SIGNAL(triggered(bool)), SLOT(slotOpenAccountWizard())); + + _toggleSignInOutAction = new QAction(tr("Sign out"), this); + connect(_toggleSignInOutAction, SIGNAL(triggered(bool)), SLOT(slotToggleSignInState())); + menu->addAction(_toggleSignInOutAction); + + QAction *action = new QAction(tr("Remove"), this); + menu->addAction(action); + connect( action, SIGNAL(triggered(bool)), SLOT(slotDeleteAccount())); + + ui->_accountToolbox->setText(tr("Account") + QLatin1Char(' ')); + ui->_accountToolbox->setMenu(menu); + ui->_accountToolbox->setPopupMode(QToolButton::InstantPopup); + + // Expand already on single click + ui->_folderList->setExpandsOnDoubleClick(false); + QObject::connect(ui->_folderList, SIGNAL(clicked(const QModelIndex &)), + this, SLOT(slotFolderListClicked(const QModelIndex&))); +} + +void AccountSettings::slotOpenAccountWizard() +{ + if (QSystemTrayIcon::isSystemTrayAvailable()) { + topLevelWidget()->close(); + } + OwncloudSetupWizard::runWizard(qApp, SLOT(slotownCloudWizardDone(int)), 0); +} + +void AccountSettings::slotToggleSignInState() +{ + bool signedInState = _accountState->isSignedOut(); + _accountState->setSignedOut( !signedInState ); } void AccountSettings::doExpand() @@ -485,12 +526,6 @@ void AccountSettings::slotAccountStateChanged(int state) serverWithUser = tr("%1 as %2").arg(server, cred->user()); } - if (state != AccountState::SignedOut && ui->signInButton->hasFocus()) { - // The button is about to be hidden, clear the focus so the focus don't go to the - // "remove account" button - ui->signInButton->clearFocus(); - } - ui->signInButton->setVisible(state == AccountState::SignedOut); if (state == AccountState::Connected) { showConnectionLabel( tr("Connected to %1.").arg(serverWithUser) ); } else if (state == AccountState::ServiceUnavailable) { @@ -518,6 +553,15 @@ void AccountSettings::slotAccountStateChanged(int state) ui->_folderList->setExpanded(_model->index(i), false); } } + /* set the correct label for the Account toolbox button */ + if( _accountState ) { + bool isConnected = _accountState->isConnected(); + if( isConnected ) { + _toggleSignInOutAction->setText(tr("Sign out")); + } else { + _toggleSignInOutAction->setText(tr("Sign in")); + } + } } void AccountSettings::slotLinkActivated(const QString& link) @@ -624,9 +668,14 @@ void AccountSettings::refreshSelectiveSyncStatus() } } -void AccountSettings::slotSignInAccount() +void AccountSettings::slotAccountAdded(AccountState*) { - _accountState->setSignedOut(false); + // if the theme is limited to single account, the button must hide if + // there is already one account. + if( AccountManager::instance()->accounts().size() > 1 && + !Theme::instance()->multiAccount() ) { + _addAccountAction->setVisible(false); + } } void AccountSettings::slotDeleteAccount() @@ -657,6 +706,9 @@ void AccountSettings::slotDeleteAccount() // if there is no more account, show the wizard. if( manager->accounts().isEmpty() ) { + // allow to add a new account if there is non any more. Always think + // about single account theming! + _addAccountAction->setVisible(true); OwncloudSetupWizard::runWizard(qApp, SLOT(slotownCloudWizardDone(int))); } diff --git a/src/gui/accountsettings.h b/src/gui/accountsettings.h index 4d8ad31af..f7a416975 100644 --- a/src/gui/accountsettings.h +++ b/src/gui/accountsettings.h @@ -76,8 +76,10 @@ protected slots: void slotOpenCurrentFolder(); void slotFolderWizardAccepted(); void slotFolderWizardRejected(); - void slotSignInAccount(); void slotDeleteAccount(); + void slotToggleSignInState(); + void slotOpenAccountWizard(); + void slotAccountAdded(AccountState *); void refreshSelectiveSyncStatus(); void slotCustomContextMenuRequested(const QPoint&); void slotFolderListClicked( const QModelIndex& indx ); @@ -88,6 +90,7 @@ private: void showConnectionLabel(const QString& message, QStringList errors = QStringList()); bool event(QEvent*) Q_DECL_OVERRIDE; + void createAccountToolbox(); Ui::AccountSettings *ui; @@ -96,6 +99,8 @@ private: bool _wasDisabledBefore; AccountState *_accountState; QuotaInfo _quotaInfo; + QAction *_toggleSignInOutAction; + QAction *_addAccountAction; }; } // namespace OCC diff --git a/src/gui/accountsettings.ui b/src/gui/accountsettings.ui index 40e979651..8cc236cef 100644 --- a/src/gui/accountsettings.ui +++ b/src/gui/accountsettings.ui @@ -6,30 +6,18 @@ 0 0 - 469 - 652 + 575 + 557 Form - - + + - - - 0 - - - 0 - - - 0 - - - 0 - - + + @@ -42,7 +30,7 @@ - + @@ -61,42 +49,17 @@ - - - - - 0 - 0 - - - - Enter your credentials to connect to the server - + + - Sign in - - - - - - - - 0 - 0 - - - - Remove the account configuration from the client - - - Remove Account + ... - + @@ -147,7 +110,7 @@ - + @@ -166,7 +129,7 @@ - + diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index c4a8e35c3..accd535e7 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -83,13 +83,6 @@ GeneralSettings::GeneralSettings(QWidget *parent) : _ui->monoIconsCheckBox->setVisible(QDir(themeDir).exists()); connect(_ui->ignoredFilesButton, SIGNAL(clicked()), SLOT(slotIgnoreFilesEditor())); - connect(_ui->addAccountButton, SIGNAL(clicked()), SLOT(slotOpenAccountWizard())); - - connect(AccountManager::instance(), SIGNAL(accountAdded(AccountState*)), - SLOT(slotAccountAddedOrRemoved())); - connect(AccountManager::instance(), SIGNAL(accountRemoved(AccountState*)), - SLOT(slotAccountAddedOrRemoved())); - slotAccountAddedOrRemoved(); } GeneralSettings::~GeneralSettings() @@ -169,12 +162,4 @@ void GeneralSettings::slotOpenAccountWizard() OwncloudSetupWizard::runWizard(qApp, SLOT(slotownCloudWizardDone(int)), 0); } -void GeneralSettings::slotAccountAddedOrRemoved() -{ - _ui->addAccountButton->setVisible( - AccountManager::instance()->accounts().isEmpty() - || Theme::instance()->multiAccount()); -} - - } // namespace OCC diff --git a/src/gui/generalsettings.h b/src/gui/generalsettings.h index e64c784ef..3a9b750cd 100644 --- a/src/gui/generalsettings.h +++ b/src/gui/generalsettings.h @@ -44,8 +44,6 @@ private slots: void slotUpdateInfo(); void slotIgnoreFilesEditor(); void slotOpenAccountWizard(); - void slotAccountAddedOrRemoved(); - private: void loadMiscSettings(); diff --git a/src/gui/generalsettings.ui b/src/gui/generalsettings.ui index c1399bb25..26a6daa58 100644 --- a/src/gui/generalsettings.ui +++ b/src/gui/generalsettings.ui @@ -13,8 +13,8 @@ Form - - + + General Settings @@ -47,7 +47,7 @@ - + Advanced @@ -77,31 +77,7 @@ - - - - - - Add an Account - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - + @@ -145,7 +121,7 @@ - + @@ -165,7 +141,7 @@ - + About @@ -181,7 +157,7 @@ - + Updates @@ -232,7 +208,7 @@ - + Qt::Vertical @@ -247,6 +223,16 @@ + + autostartCheckBox + desktopNotificationsCheckBox + monoIconsCheckBox + ignoredFilesButton + newFolderLimitCheckBox + newFolderLimitSpinBox + crashreporterCheckBox + restartButton +