Skip to content

Commit

Permalink
Selective sync: Hide ui on disconnect #5809
Browse files Browse the repository at this point in the history
The previous patch did forget about the big-folder-ui which should
also be hidden on disconnect.
  • Loading branch information
ckamm committed Jun 13, 2018
1 parent e4574b2 commit 9c66dbb
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,6 @@ void AccountSettings::slotAccountStateChanged()
if (ui->_folderList->isExpanded(_model->index(i)))
ui->_folderList->setExpanded(_model->index(i), false);
}
} else if (_model->isDirty()) {
// If we connect and have pending changes, show the list.
doExpand();
}

// Disabling expansion of folders might require hiding the selective
Expand Down Expand Up @@ -756,8 +753,6 @@ AccountSettings::~AccountSettings()

void AccountSettings::refreshSelectiveSyncStatus()
{
bool shouldBeVisible = _model->isDirty() && _accountState->isConnected();

QString msg;
int cnt = 0;
foreach (Folder *folder, FolderMan::instance()->map().values()) {
Expand Down Expand Up @@ -788,10 +783,20 @@ void AccountSettings::refreshSelectiveSyncStatus()
}
}

// Some selective sync ui (either normal editing or big folder) will show
// if this variable ends up true.
bool shouldBeVisible = false;

if (msg.isEmpty()) {
// Show the ui if the model is dirty only
shouldBeVisible = _model->isDirty() && _accountState->isConnected();

ui->selectiveSyncButtons->setVisible(true);
ui->bigFolderUi->setVisible(false);
} else {
// There's a reason the big folder ui should be shown
shouldBeVisible = _accountState->isConnected();

ConfigFile cfg;
QString info = !cfg.confirmExternalStorage()
? tr("There are folders that were not synchronized because they are too big: ")
Expand All @@ -802,7 +807,6 @@ void AccountSettings::refreshSelectiveSyncStatus()
ui->selectiveSyncNotification->setText(info + msg);
ui->selectiveSyncButtons->setVisible(false);
ui->bigFolderUi->setVisible(true);
shouldBeVisible = true;
}

ui->selectiveSyncApply->setEnabled(_model->isDirty() || !msg.isEmpty());
Expand All @@ -812,6 +816,7 @@ void AccountSettings::refreshSelectiveSyncStatus()
if (shouldBeVisible) {
ui->selectiveSyncStatus->setMaximumHeight(0);
ui->selectiveSyncStatus->setVisible(true);
doExpand();
}
auto anim = new QPropertyAnimation(ui->selectiveSyncStatus, "maximumHeight", ui->selectiveSyncStatus);
anim->setEndValue(shouldBeVisible ? hint.height() : 0);
Expand Down

0 comments on commit 9c66dbb

Please sign in to comment.