mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 05:25:50 +03:00
Merge pull request #2692 from nextcloud/fix-issue-1029
Handle the warning message when unchecking folders for syncing.
This commit is contained in:
commit
be1fb77488
3 changed files with 147 additions and 92 deletions
|
@ -170,6 +170,12 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
|
|||
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);
|
||||
|
@ -214,7 +220,6 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
|
|||
customizeStyle();
|
||||
}
|
||||
|
||||
|
||||
void AccountSettings::slotNewMnemonicGenerated()
|
||||
{
|
||||
_ui->encryptionMessage->setText(tr("This account supports end-to-end encryption"));
|
||||
|
@ -888,13 +893,71 @@ AccountSettings::~AccountSettings()
|
|||
delete _ui;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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()
|
||||
{
|
||||
bool shouldBeVisible = _model->isDirty() && _accountState->isConnected();
|
||||
|
||||
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;
|
||||
|
@ -923,40 +986,16 @@ void AccountSettings::refreshSelectiveSyncStatus()
|
|||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@ public slots:
|
|||
void slotUpdateQuota(qint64 total, qint64 used);
|
||||
void slotAccountStateChanged();
|
||||
void slotStyleChanged();
|
||||
|
||||
AccountState *accountsState() { return _accountState; }
|
||||
void slotHideSelectiveSyncWidget();
|
||||
|
||||
protected slots:
|
||||
void slotAddFolder();
|
||||
|
@ -103,6 +103,9 @@ protected slots:
|
|||
void slotNewMnemonicGenerated();
|
||||
void slotEncryptFolderFinished(int status);
|
||||
|
||||
void slotSelectiveSyncChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
|
||||
const QVector<int> &roles);
|
||||
|
||||
private:
|
||||
void showConnectionLabel(const QString &message,
|
||||
QStringList errors = QStringList());
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>581</width>
|
||||
<width>588</width>
|
||||
<height>557</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -41,62 +41,6 @@
|
|||
</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>
|
||||
|
@ -241,6 +185,9 @@
|
|||
</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">
|
||||
|
@ -260,8 +207,74 @@
|
|||
</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>
|
||||
|
|
Loading…
Reference in a new issue