]> cloud.milkyroute.net Git - dolphin.git/commitdiff
[Settings Dialog] Show Trash settings only if authorized
authorKai Uwe Broulik <kde@privat.broulik.de>
Wed, 8 Feb 2017 15:07:19 +0000 (16:07 +0100)
committerKai Uwe Broulik <kde@privat.broulik.de>
Wed, 8 Feb 2017 15:07:19 +0000 (16:07 +0100)
If this KCM is disabled through KIOSK restriction opening it would result in an error message.
Hide the entry altogether in this case.

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

src/settings/dolphinsettingsdialog.cpp
src/settings/dolphinsettingsdialog.h

index 9eb57f10b109e724c4d33cb0a9fc9fd9c8e9f5d3..5314c24ed845727b16d086629b2d02eacc1d70f4 100644 (file)
@@ -29,6 +29,7 @@
 #include "viewmodes/viewsettingspage.h"
 #include "trash/trashsettingspage.h"
 
+#include <KAuthorized>
 #include <KWindowConfig>
 #include <KLocalizedString>
 #include <QIcon>
@@ -85,11 +86,13 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl& url, QWidget* parent) :
     connect(servicesSettingsPage, &ServicesSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);
 
     // Trash
-    TrashSettingsPage* trashSettingsPage = new TrashSettingsPage(this);
-    KPageWidgetItem* trashSettingsFrame = addPage(trashSettingsPage,
-                                                   i18nc("@title:group", "Trash"));
-    trashSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("trash-empty")));
-    connect(trashSettingsPage, &TrashSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);
+    auto* trashSettingsPage = createTrashSettingsPage(this);
+    if (trashSettingsPage) {
+        KPageWidgetItem* trashSettingsFrame = addPage(trashSettingsPage,
+                                                     i18nc("@title:group", "Trash"));
+        trashSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("trash-empty")));
+        connect(trashSettingsPage, &TrashSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);
+    }
 
     // General
     GeneralSettingsPage* generalSettingsPage = new GeneralSettingsPage(url, this);
@@ -145,3 +148,11 @@ void DolphinSettingsDialog::restoreDefaults()
     }
 }
 
+SettingsPageBase *DolphinSettingsDialog::createTrashSettingsPage(QWidget *parent)
+{
+    if (!KAuthorized::authorizeControlModule(QStringLiteral("kcmtrash.desktop"))) {
+        return nullptr;
+    }
+
+    return new TrashSettingsPage(parent);
+}
index 93f714799bc9a5bc190ba9ddd32266457c0533fd..194af28fc5c5ba241b9bfa60caf74cb3c090b9b0 100644 (file)
@@ -49,6 +49,8 @@ private slots:
     void restoreDefaults();
 
 private:
+    static SettingsPageBase *createTrashSettingsPage(QWidget *parent);
+
     QList<SettingsPageBase*> m_pages;
 };