OS X: Fix settings dialog after multi-account introduction

For #3459 #3386 #3401
This commit is contained in:
Markus Goetz 2015-07-16 14:07:05 +02:00
parent 55e1f8a060
commit 3d55191573
3 changed files with 9 additions and 10 deletions

@ -1 +1 @@
Subproject commit 10621d46b5973ccc3d4b41d7d81046dd051feeaa
Subproject commit 8828099fd05b191cedf4d52f62f2405de6471415

View File

@ -76,7 +76,7 @@ SettingsDialogMac::SettingsDialogMac(ownCloudGui *gui, QWidget *parent)
QIcon protocolIcon(QLatin1String(":/client/resources/activity.png"));
_protocolWidget = new ProtocolWidget;
_protocolIdx = addPreferencesPanel(protocolIcon, tr("Activity"), _protocolWidget);
addPreferencesPanel(protocolIcon, tr("Activity"), _protocolWidget);
QIcon generalIcon = MacStandardIcon::icon(MacStandardIcon::PreferencesGeneral);
GeneralSettings *generalSettings = new GeneralSettings;
@ -104,15 +104,16 @@ void SettingsDialogMac::closeEvent(QCloseEvent *event)
void SettingsDialogMac::showActivityPage()
{
setCurrentPanelIndex(_protocolIdx);
// Count backwards (0-based) from the last panel (multiple accounts can be on the left)
setCurrentPanelIndex(preferencePanelCount() - 1 - 2);
}
void SettingsDialogMac::accountAdded(AccountState *s)
{
QIcon accountIcon = MacStandardIcon::icon(MacStandardIcon::UserAccounts);
auto accountSettings = new AccountSettings(s, this);
//FIXME: add at the begining: (and don(t foget to adjust for _protocolIdx)
addPreferencesPanel(accountIcon, s->account()->displayName(), accountSettings);
insertPreferencesPanel(0, accountIcon, s->account()->displayName(), accountSettings);
connect( accountSettings, &AccountSettings::folderChanged, _gui, &ownCloudGui::slotFoldersChanged);
connect( accountSettings, &AccountSettings::openFolderAlias, _gui, &ownCloudGui::slotFolderOpenAction);
@ -120,11 +121,10 @@ void SettingsDialogMac::accountAdded(AccountState *s)
void SettingsDialogMac::accountRemoved(AccountState *s)
{
// FIXME: is it the correct way to remove a panel?
auto list = findChildren<AccountSettings*>(QString(), Qt::FindDirectChildrenOnly);
auto list = findChildren<AccountSettings*>(QString());
foreach(auto p, list) {
if (p->accountsState() == s) {
p->deleteLater();
removePreferencesPanel(p);
}
}
}

View File

@ -52,8 +52,7 @@ private slots:
private:
void closeEvent(QCloseEvent *event);
QListWidgetItem *_accountItem;
ProtocolWidget *_protocolWidget;
ProtocolWidget *_protocolWidget; // this is actually the activityPage
ownCloudGui *_gui;
int _protocolIdx;