2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2022 Felix Ernst <felixernst@kde.org>
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
8 #ifndef ADMINWORKERINTEGRATION_H
9 #define ADMINWORKERINTEGRATION_H
13 class DolphinMainWindow
;
14 class KActionCollection
;
19 * @brief This namespace contains everything that is necessary to nicely integrate "KIO Admin Worker" into Dolphin.
21 * @see https://commits.kde.org/kio-admin
26 * Used with the KMessageBox API so users can disable the warning.
27 * @see KMessageBox::saveDontShowAgainContinue()
28 * @see KMessageBox::enableMessage()
30 constexpr QLatin1String warningDontShowAgainName
{"warnAboutRisksBeforeActingAsAdmin"};
32 /** @returns an elaborate warning about the dangers of acting with administrative privileges. */
33 QString
warningMessage();
36 * @brief A class encapsulating the "Act as Admin"-toggle action.
38 * @see https://commits.kde.org/kio-admin
40 class WorkerIntegration
: public QObject
46 * Adds a toggle action to the \a actionCollection.
47 * The action switches between acting as a normal user or acting as an administrator.
49 static void createActAsAdminAction(KActionCollection
*actionCollection
, DolphinMainWindow
*dolphinMainWindow
);
52 * Triggers the m_actAsAdminAction only if it is currently checked.
54 static void exitAdminMode();
57 WorkerIntegration(DolphinMainWindow
*parent
, QAction
*actAsAdminAction
);
60 * Toggles between acting with admin rights or not.
61 * This enables editing more files than the normal user account would be allowed to but requires re-authorization.
63 void toggleActAsAdmin();
65 /** Updates the toggled/checked state of the action depending on the state of the currently active view. */
66 static void updateActAsAdminAction();
69 /** @see createActAsAdminAction() */
70 QAction
*const m_actAsAdminAction
= nullptr;
75 #endif // ADMINWORKERINTEGRATION_H