Skip to content

Commit

Permalink
Add checkbox to general settings to enabling file removal meaning mov…
Browse files Browse the repository at this point in the history
…ing files to trash, rather than immediate deletion

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed May 16, 2023
1 parent 3c2f28a commit 7425f8c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
25 changes: 16 additions & 9 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ GeneralSettings::GeneralSettings(QWidget *parent)
connect(_ui->newFolderLimitCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);
connect(_ui->newFolderLimitSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &GeneralSettings::saveMiscSettings);
connect(_ui->newExternalStorage, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);
connect(_ui->moveFilesToTrashCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);

#ifndef WITH_CRASHREPORTER
_ui->crashreporterCheckBox->setVisible(false);
Expand Down Expand Up @@ -246,17 +247,20 @@ void GeneralSettings::loadMiscSettings()
{
QScopedValueRollback<bool> scope(_currentlyLoading, true);
ConfigFile cfgFile;

_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
_ui->serverNotificationsCheckBox->setChecked(cfgFile.optionalServerNotifications());
_ui->callNotificationsCheckBox->setEnabled(_ui->serverNotificationsCheckBox->isEnabled());
_ui->callNotificationsCheckBox->setChecked(cfgFile.showCallNotifications());
_ui->showInExplorerNavigationPaneCheckBox->setChecked(cfgFile.showInExplorerNavigationPane());
_ui->crashreporterCheckBox->setChecked(cfgFile.crashReporter());
_ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage());
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
_ui->moveFilesToTrashCheckBox->setChecked(cfgFile.moveToTrash());

auto newFolderLimit = cfgFile.newBigFolderSizeLimit();
_ui->newFolderLimitCheckBox->setChecked(newFolderLimit.first);
_ui->newFolderLimitSpinBox->setValue(newFolderLimit.second);
_ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage());
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
}

#if defined(BUILD_UPDATER)
Expand Down Expand Up @@ -406,17 +410,20 @@ void GeneralSettings::slotToggleAutoUpdateCheck()

void GeneralSettings::saveMiscSettings()
{
if (_currentlyLoading)
if (_currentlyLoading) {
return;
}

ConfigFile cfgFile;
bool isChecked = _ui->monoIconsCheckBox->isChecked();
cfgFile.setMonoIcons(isChecked);
Theme::instance()->setSystrayUseMonoIcons(isChecked);
cfgFile.setCrashReporter(_ui->crashreporterCheckBox->isChecked());

cfgFile.setNewBigFolderSizeLimit(_ui->newFolderLimitCheckBox->isChecked(),
_ui->newFolderLimitSpinBox->value());
const auto monoIconsChecked = _ui->monoIconsCheckBox->isChecked();
cfgFile.setMonoIcons(monoIconsChecked);
Theme::instance()->setSystrayUseMonoIcons(monoIconsChecked);

cfgFile.setCrashReporter(_ui->crashreporterCheckBox->isChecked());
cfgFile.setNewBigFolderSizeLimit(_ui->newFolderLimitCheckBox->isChecked(), _ui->newFolderLimitSpinBox->value());
cfgFile.setConfirmExternalStorage(_ui->newExternalStorage->isChecked());
cfgFile.setMoveToTrash(_ui->moveFilesToTrashCheckBox->isChecked());
}

void GeneralSettings::slotToggleLaunchOnStartup(bool enable)
Expand Down
13 changes: 12 additions & 1 deletion src/gui/generalsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>556</width>
<height>563</height>
<height>613</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -276,6 +276,17 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="moveFilesToTrashCheckBox">
<property name="text">
<string>Move removed files to trash</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
Expand Down

0 comments on commit 7425f8c

Please sign in to comment.