Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selective sync: Hide ui on disconnect #6577

Merged
merged 1 commit into from
Jun 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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