addAction(syncNowWithRemoteDiscovery);
+ slotHideSelectiveSyncWidget();
+ _ui->bigFolderUi->setVisible(false);
+ connect(_model, &QAbstractItemModel::dataChanged, this, &AccountSettings::slotSelectiveSyncChanged);
+ connect(_ui->selectiveSyncApply, &QAbstractButton::clicked, this, &AccountSettings::slotHideSelectiveSyncWidget);
+ connect(_ui->selectiveSyncCancel, &QAbstractButton::clicked, this, &AccountSettings::slotHideSelectiveSyncWidget);
+
connect(_ui->selectiveSyncApply, &QAbstractButton::clicked, _model, &FolderStatusModel::slotApplySelectiveSync);
connect(_ui->selectiveSyncCancel, &QAbstractButton::clicked, _model, &FolderStatusModel::resetFolders);
connect(_ui->bigFolderApply, &QAbstractButton::clicked, _model, &FolderStatusModel::slotApplySelectiveSync);
customizeStyle();
}
-
void AccountSettings::slotNewMnemonicGenerated()
{
_ui->encryptionMessage->setText(tr("This account supports end-to-end encryption"));
delete _ui;
}
-void AccountSettings::refreshSelectiveSyncStatus()
+void AccountSettings::slotHideSelectiveSyncWidget()
+{
+ _ui->selectiveSyncApply->setEnabled(false);
+ _ui->selectiveSyncStatus->setVisible(false);
+ _ui->selectiveSyncButtons->setVisible(false);
+ _ui->selectiveSyncLabel->hide();
+}
+
+void AccountSettings::slotSelectiveSyncChanged(const QModelIndex &topLeft,
+ const QModelIndex &bottomRight,
+ const QVector<int> &roles)
{
- bool shouldBeVisible = _model->isDirty() && _accountState->isConnected();
+ Q_UNUSED(bottomRight);
+ if (!roles.contains(Qt::CheckStateRole)) {
+ return;
+ }
+
+ const auto info = _model->infoForIndex(topLeft);
+ if (!info) {
+ return;
+ }
+
+ const bool showWarning = _model->isDirty() && _accountState->isConnected() && info->_checked == Qt::Unchecked;
+ // FIXME: the model is not precise enough to handle extra cases
+ // e.g. the user clicked on the same checkbox 2x without applying the change in between.
+ // We don't know which checkbox changed to be able to toggle the selectiveSyncLabel display.
+ if (showWarning) {
+ _ui->selectiveSyncLabel->show();
+ }
+
+ const bool shouldBeVisible = _model->isDirty();
+ const bool wasVisible = _ui->selectiveSyncStatus->isVisible();
+ if (shouldBeVisible) {
+ _ui->selectiveSyncStatus->setVisible(true);
+ }
+
+ _ui->selectiveSyncApply->setEnabled(true);
+ _ui->selectiveSyncButtons->setVisible(true);
+
+ if (shouldBeVisible != wasVisible) {
+ const auto hint = _ui->selectiveSyncStatus->sizeHint();
+
+ if (shouldBeVisible) {
+ _ui->selectiveSyncStatus->setMaximumHeight(0);
+ }
+
+ const auto anim = new QPropertyAnimation(_ui->selectiveSyncStatus, "maximumHeight", _ui->selectiveSyncStatus);
+ anim->setEndValue(_model->isDirty() ? hint.height() : 0);
+ anim->start(QAbstractAnimation::DeleteWhenStopped);
+ connect(anim, &QPropertyAnimation::finished, [this, shouldBeVisible]() {
+ _ui->selectiveSyncStatus->setMaximumHeight(QWIDGETSIZE_MAX);
+ if (!shouldBeVisible) {
+ _ui->selectiveSyncStatus->hide();
+ }
+ });
+ }
+}
+
+void AccountSettings::refreshSelectiveSyncStatus()
+{
QString msg;
int cnt = 0;
const auto folders = FolderMan::instance()->map().values();
+ _ui->bigFolderUi->setVisible(false);
for (Folder *folder : folders) {
if (folder->accountState() != _accountState) {
continue;
}
}
- if (msg.isEmpty()) {
- _ui->selectiveSyncButtons->setVisible(true);
- _ui->bigFolderUi->setVisible(false);
- } else {
+ if (!msg.isEmpty()) {
ConfigFile cfg;
QString info = !cfg.confirmExternalStorage()
- ? tr("There are folders that were not synchronized because they are too big: ")
- : !cfg.newBigFolderSizeLimit().first
- ? tr("There are folders that were not synchronized because they are external storages: ")
- : tr("There are folders that were not synchronized because they are too big or external storages: ");
+ ? tr("There are folders that were not synchronized because they are too big: ")
+ : !cfg.newBigFolderSizeLimit().first
+ ? tr("There are folders that were not synchronized because they are external storages: ")
+ : tr("There are folders that were not synchronized because they are too big or external storages: ");
_ui->selectiveSyncNotification->setText(info + msg);
- _ui->selectiveSyncButtons->setVisible(false);
_ui->bigFolderUi->setVisible(true);
- shouldBeVisible = true;
- }
-
- _ui->selectiveSyncApply->setEnabled(_model->isDirty() || !msg.isEmpty());
- bool wasVisible = !_ui->selectiveSyncStatus->isHidden();
- if (wasVisible != shouldBeVisible) {
- QSize hint = _ui->selectiveSyncStatus->sizeHint();
- if (shouldBeVisible) {
- _ui->selectiveSyncStatus->setMaximumHeight(0);
- _ui->selectiveSyncStatus->setVisible(true);
- }
- auto anim = new QPropertyAnimation(_ui->selectiveSyncStatus, "maximumHeight", _ui->selectiveSyncStatus);
- anim->setEndValue(shouldBeVisible ? hint.height() : 0);
- anim->start(QAbstractAnimation::DeleteWhenStopped);
- connect(anim, &QPropertyAnimation::finished, [this, shouldBeVisible]() {
- _ui->selectiveSyncStatus->setMaximumHeight(QWIDGETSIZE_MAX);
- if (!shouldBeVisible) {
- _ui->selectiveSyncStatus->hide();
- }
- });
}
}
<rect>
<x>0</x>
<y>0</y>
- <width>581</width>
+ <width>588</width>
<height>557</height>
</rect>
</property>
</property>
</widget>
</item>
- <item>
- <widget class="QWidget" name="bigFolderUi" native="true">
- <layout class="QVBoxLayout" name="verticalLayout">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QLabel" name="selectiveSyncNotification">
- <property name="styleSheet">
- <string notr="true">color: red</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QPushButton" name="bigFolderSyncAll">
- <property name="text">
- <string>Synchronize all</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="bigFolderSyncNone">
- <property name="text">
- <string>Synchronize none</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="bigFolderApply">
- <property name="text">
- <string>Apply manual changes</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
</layout>
</item>
<item>
</item>
</layout>
</item>
+ <item row="1" column="0">
+ <widget class="KMessageWidget" name="encryptionMessage" native="true"/>
+ </item>
<item row="3" column="0">
<widget class="OCC::FolderStatusView" name="_folderList">
<property name="sizePolicy">
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="KMessageWidget" name="encryptionMessage" native="true"/>
+ <item row="5" column="0">
+ <widget class="QWidget" name="bigFolderUi" native="true">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="selectiveSyncNotification">
+ <property name="styleSheet">
+ <string notr="true">color: red</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="bigFolderSyncAll">
+ <property name="text">
+ <string>Synchronize all</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="bigFolderSyncNone">
+ <property name="text">
+ <string>Synchronize none</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="bigFolderApply">
+ <property name="text">
+ <string>Apply manual changes</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
</item>
</layout>
</widget>