diff options
| author | Felix Ernst <[email protected]> | 2024-05-11 17:16:35 +0000 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2024-05-11 17:16:35 +0000 |
| commit | 6c60655ce246a91758f4b9035edf318cb1197a2c (patch) | |
| tree | f7b6ac7d13cbdc76a67af70765373f735ca56a27 /src/settings/interface/confirmationssettingspage.cpp | |
| parent | 742566eb69e6bf46e7abb74e9ce9293c4b3ed7e8 (diff) | |
Add "Act as Administrator" toggle action
This commit adds an "Act as Administrator" toggle action to the
View menu if kio-admin is installed. The action allows switching
between acting as an admin with root-access or not.
This was already possible in Dolphin when kio-admin is installed by
editing the location bar directly. However this is somewhat
unintuitive and there are no warnings at all about the dangers of
acting as an administrator.
This commit adds a warning dialog when triggering the action. It is
somewhat explicit about the risks because this is in fact very
dangerous.
Furthermore, while acting on a view with administrative privileges,
a bar above the view shows up that contains a warning. The bar can
be closed to stop acting with elevated privileges.
The warning dialog can be disabled and re-enabled from the Dolphin
settings but only if the action is even available.
There is a lot more to be done to further improve this feature both
security-wise as well as when it comes to usability. But
considering that we are already encouraging users to use this
feature without any warnings at all, I feel like now is a good time
to merge this.
This work is part of a project funded through the NGI0 Entrust
Fund, a fund established by NLnet with financial support from the
European Commission's Next Generation Internet programme, under the
aegis of DG Communications Networks, Content and Technology. As
such, please contact me if you plan on doing related work so what
you are doing doesn't collide with work I am being funded to do.
Diffstat (limited to 'src/settings/interface/confirmationssettingspage.cpp')
| -rw-r--r-- | src/settings/interface/confirmationssettingspage.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/settings/interface/confirmationssettingspage.cpp b/src/settings/interface/confirmationssettingspage.cpp index ec63cbb67..ea8ef6dfd 100644 --- a/src/settings/interface/confirmationssettingspage.cpp +++ b/src/settings/interface/confirmationssettingspage.cpp @@ -6,10 +6,13 @@ #include "confirmationssettingspage.h" +#include "admin/workerintegration.h" #include "dolphin_generalsettings.h" #include "global.h" #include <KLocalizedString> +#include <KMessageBox> +#include <KProtocolInfo> #include <QCheckBox> #include <QComboBox> @@ -61,6 +64,7 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget *parent) m_confirmOpenManyFolders = new QCheckBox(i18nc("@option:check Ask for confirmation in Dolphin when", "Opening many folders at once"), this); m_confirmOpenManyTerminals = new QCheckBox(i18nc("@option:check Ask for confirmation in Dolphin when", "Opening many terminals at once"), this); + m_confirmRisksOfActingAsAdmin = new QCheckBox(i18nc("@option:check Ask for confirmation in Dolphin when", "Switching to act as an administrator"), this); QLabel *executableScriptLabel = new QLabel(i18nc("@title:group", "When opening an executable file:"), this); executableScriptLabel->setWordWrap(true); @@ -83,6 +87,11 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget *parent) topLayout->addRow(nullptr, m_confirmOpenManyFolders); topLayout->addRow(nullptr, m_confirmOpenManyTerminals); + if (KProtocolInfo::isKnownProtocol(QStringLiteral("admin"))) { + topLayout->addRow(nullptr, m_confirmRisksOfActingAsAdmin); + } else { + m_confirmRisksOfActingAsAdmin->hide(); + } topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); topLayout->addRow(executableScriptLabel, m_confirmScriptExecution); @@ -96,6 +105,7 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget *parent) connect(m_confirmClosingMultipleTabs, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); connect(m_confirmOpenManyFolders, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); connect(m_confirmOpenManyTerminals, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); + connect(m_confirmRisksOfActingAsAdmin, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); #if HAVE_TERMINAL connect(m_confirmClosingTerminalRunningProgram, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); @@ -133,6 +143,11 @@ void ConfirmationsSettingsPage::applySettings() settings->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs->isChecked()); settings->setConfirmOpenManyFolders(m_confirmOpenManyFolders->isChecked()); settings->setConfirmOpenManyTerminals(m_confirmOpenManyTerminals->isChecked()); + if (m_confirmRisksOfActingAsAdmin->isChecked()) { + KMessageBox::enableMessage(Admin::warningDontShowAgainName); + } else { + KMessageBox::saveDontShowAgainContinue(Admin::warningDontShowAgainName); + } #if HAVE_TERMINAL settings->setConfirmClosingTerminalRunningProgram(m_confirmClosingTerminalRunningProgram->isChecked()); @@ -152,6 +167,7 @@ void ConfirmationsSettingsPage::restoreDefaults() m_confirmEmptyTrash->setChecked(ConfirmEmptyTrash); m_confirmDelete->setChecked(ConfirmDelete); m_confirmScriptExecution->setCurrentIndex(ConfirmScriptExecution); + KMessageBox::enableMessage(Admin::warningDontShowAgainName); } void ConfirmationsSettingsPage::loadSettings() @@ -179,6 +195,7 @@ void ConfirmationsSettingsPage::loadSettings() // the UI has inversed meaning compared to the interpretation m_confirmOpenManyFolders->setChecked(GeneralSettings::confirmOpenManyFolders()); m_confirmOpenManyTerminals->setChecked(GeneralSettings::confirmOpenManyTerminals()); + m_confirmRisksOfActingAsAdmin->setChecked(KMessageBox::shouldBeShownContinue(Admin::warningDontShowAgainName)); #if HAVE_TERMINAL m_confirmClosingTerminalRunningProgram->setChecked(GeneralSettings::confirmClosingTerminalRunningProgram()); |
