]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Add an option to confirm trash emptying into settings
authorRoman Inflianskas <infroma@gmail.com>
Fri, 2 Mar 2018 11:41:36 +0000 (14:41 +0300)
committerRoman Inflianskas <infroma@gmail.com>
Sat, 3 Mar 2018 05:46:55 +0000 (08:46 +0300)
Summary:
Add an option to confirm trash emptying into settings.

BUG: 340572

Reviewers: #dolphin, ngraham, markg

Reviewed By: #dolphin, ngraham, markg

Subscribers: markg, ngraham, rkflx, #dolphin

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D10968

src/settings/general/confirmationssettingspage.cpp
src/settings/general/confirmationssettingspage.h

index 90dd0ad37aae6a02c86bf045e879c0cec8734e7b..39a70582125664a7f2028c6e9e2f453134fcf364 100644 (file)
@@ -28,6 +28,7 @@
 #include <QVBoxLayout>
 
 namespace {
+    const bool ConfirmEmptyTrash = true;
     const bool ConfirmTrash = false;
     const bool ConfirmDelete = true;
     const bool ConfirmScriptExecution = true;
@@ -36,6 +37,7 @@ namespace {
 ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
     SettingsPageBase(parent),
     m_confirmMoveToTrash(nullptr),
+    m_confirmEmptyTrash(nullptr),
     m_confirmDelete(nullptr),
     m_confirmClosingMultipleTabs(nullptr)
 {
@@ -46,6 +48,8 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
 
     m_confirmMoveToTrash = new QCheckBox(i18nc("@option:check Ask for confirmation when",
                                                "Moving files or folders to trash"), this);
+    m_confirmEmptyTrash = new QCheckBox(i18nc("@option:check Ask for confirmation when",
+                                              "Emptying trash"), this);
     m_confirmDelete = new QCheckBox(i18nc("@option:check Ask for confirmation when",
                                           "Deleting files or folders"), this);
     m_confirmScriptExecution = new QCheckBox(i18nc("@option:check Ask for confirmation when",
@@ -59,6 +63,7 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
 
     topLayout->addWidget(confirmLabelKde);
     topLayout->addWidget(m_confirmMoveToTrash);
+    topLayout->addWidget(m_confirmEmptyTrash);
     topLayout->addWidget(m_confirmDelete);
     topLayout->addWidget(m_confirmScriptExecution);
     topLayout->addWidget(confirmLabelDolphin);
@@ -68,6 +73,7 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
     loadSettings();
 
     connect(m_confirmMoveToTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
+    connect(m_confirmEmptyTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
     connect(m_confirmDelete, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
     connect(m_confirmScriptExecution, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
     connect(m_confirmClosingMultipleTabs, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
@@ -82,6 +88,7 @@ void ConfirmationsSettingsPage::applySettings()
     KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig(QStringLiteral("kiorc"), KConfig::NoGlobals);
     KConfigGroup confirmationGroup(kioConfig, "Confirmations");
     confirmationGroup.writeEntry("ConfirmTrash", m_confirmMoveToTrash->isChecked());
+    confirmationGroup.writeEntry("ConfirmEmptyTrash", m_confirmEmptyTrash->isChecked());
     confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked());
     confirmationGroup.sync();
 
@@ -104,6 +111,7 @@ void ConfirmationsSettingsPage::restoreDefaults()
     settings->useDefaults(false);
 
     m_confirmMoveToTrash->setChecked(ConfirmTrash);
+    m_confirmEmptyTrash->setChecked(ConfirmEmptyTrash);
     m_confirmDelete->setChecked(ConfirmDelete);
     m_confirmScriptExecution->setChecked(ConfirmScriptExecution);
 }
@@ -113,6 +121,7 @@ void ConfirmationsSettingsPage::loadSettings()
     KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig(QStringLiteral("kiorc"), KConfig::IncludeGlobals);
     const KConfigGroup confirmationGroup(kioConfig, "Confirmations");
     m_confirmMoveToTrash->setChecked(confirmationGroup.readEntry("ConfirmTrash", ConfirmTrash));
+    m_confirmEmptyTrash->setChecked(confirmationGroup.readEntry("ConfirmEmptyTrash", ConfirmEmptyTrash));
     m_confirmDelete->setChecked(confirmationGroup.readEntry("ConfirmDelete", ConfirmDelete));
 
     const KConfigGroup scriptExecutionGroup(KSharedConfig::openConfig(QStringLiteral("kiorc")), "Executable scripts");
index 22e47aead81ebe489d38c003fa93b12391bb2b20..1aa7be700e25bd1e07c9af55b2d23a3d29e01e81 100644 (file)
@@ -45,6 +45,7 @@ private:
 
 private:
     QCheckBox* m_confirmMoveToTrash;
+    QCheckBox* m_confirmEmptyTrash;
     QCheckBox* m_confirmDelete;
     QCheckBox* m_confirmClosingMultipleTabs;
     QCheckBox* m_confirmScriptExecution;