diff options
| author | Felix Ernst <[email protected]> | 2024-07-22 10:51:33 +0000 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2024-07-22 10:51:33 +0000 |
| commit | 6e6fcf8da80b5b6821837054ae51eaa19edc24b8 (patch) | |
| tree | 6a627a61e8bcba056784b796cb5cecb419c08af4 /src/admin/workerintegration.h | |
| parent | f5687396c4f84d4045d652d7f8a5d783be54f7ea (diff) | |
Notify users if authorization is required to proceed
Previous to this commit entering a folder without read access would show the non-descriptive error message "Could not enter folder". If the user actually is not allowed to view the contents of the folder, this is indeed true and this commit will preserve this message as is.
However, if an admin protocol is installed, users can actually view the contents of most folders after authorizing themselves as administrators. So this commit changes the error message in those specific circumstances to instead read "Authorization required to enter this folder." and provide a button to authorize themselves. This button is the "Act as Administrator" action.
If no admin protocol is installed, this commit has no effect.
The idea for this change came from Harald Sitter.
I receive funding for changes like this by the Next Generation Internet Initiative, which (as I understand it) will no longer provide funds for future projects like this if the current EU draft budget goes through as it is.
Diffstat (limited to 'src/admin/workerintegration.h')
| -rw-r--r-- | src/admin/workerintegration.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/admin/workerintegration.h b/src/admin/workerintegration.h index 19cc5c172..1e32c33d3 100644 --- a/src/admin/workerintegration.h +++ b/src/admin/workerintegration.h @@ -11,6 +11,7 @@ #include <QObject> class DolphinMainWindow; +class DolphinViewContainer; class KActionCollection; class QAction; class QUrl; @@ -57,6 +58,20 @@ public: */ static void createActAsAdminAction(KActionCollection *actionCollection, DolphinMainWindow *dolphinMainWindow); + /** + * An interface that only allows friend classes to show the WorkerIntegration::m_actAsAdminAction to users. + * Aside from these friend classes the action is only accessible through the actionCollection of DolphinMainWindow. + */ + class FriendAccess + { + /** @returns WorkerIntegration::m_actAsAdminAction or crashes if WorkerIntegration::createActAsAdminAction() has not been called previously. */ + static QAction *actAsAdminAction(); + + friend class Bar; /// Allows the bar to access the actAsAdminAction, so users can use the bar to change who they are acting as. + friend DolphinViewContainer; // Allows the view container to access the actAsAdminAction, so the action can be shown to users when they are trying to + // view a folder for which they are lacking read permissions. + }; + private: WorkerIntegration(DolphinMainWindow *parent, QAction *actAsAdminAction); @@ -69,14 +84,9 @@ private: /** Updates the toggled/checked state of the action depending on the state of the currently active view. */ static void updateActAsAdminAction(); - /** Used by the friend class Bar to show the m_actAsAdminAction to users. */ - static QAction *actAsAdminAction(); - private: /** @see createActAsAdminAction() */ QAction *const m_actAsAdminAction = nullptr; - - friend class Bar; // Allows the bar to access the actAsAdminAction, so users can use the bar to change who they are acting as. }; } |
