From 333e2ae031fec6139a712f15283f0fffb23f2dc6 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Wed, 8 Feb 2017 16:07:19 +0100 Subject: [Settings Dialog] Show Trash settings only if authorized 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 | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/settings/dolphinsettingsdialog.cpp') diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp index 9eb57f10b..5314c24ed 100644 --- a/src/settings/dolphinsettingsdialog.cpp +++ b/src/settings/dolphinsettingsdialog.cpp @@ -29,6 +29,7 @@ #include "viewmodes/viewsettingspage.h" #include "trash/trashsettingspage.h" +#include #include #include #include @@ -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); +} -- cgit v1.3 From 7fce8f0e9b1e0bb2deb6e32fe88d5411b9be2834 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Mon, 13 Feb 2017 13:51:05 +0100 Subject: Don't add trashSettingsPage to m_pages if null Otherwise we might crash in applySettings() or restoreDefaults() --- src/settings/dolphinsettingsdialog.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/settings/dolphinsettingsdialog.cpp') diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp index 5314c24ed..50fd41e4c 100644 --- a/src/settings/dolphinsettingsdialog.cpp +++ b/src/settings/dolphinsettingsdialog.cpp @@ -105,7 +105,9 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl& url, QWidget* parent) : m_pages.append(viewSettingsPage); m_pages.append(navigationSettingsPage); m_pages.append(servicesSettingsPage); - m_pages.append(trashSettingsPage); + if (trashSettingsPage) { + m_pages.append(trashSettingsPage); + } m_pages.append(generalSettingsPage); const KConfigGroup dialogConfig(KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "SettingsDialog"); -- cgit v1.3