diff options
| author | Felix Ernst <[email protected]> | 2024-07-13 15:37:31 +0000 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2024-07-13 15:37:31 +0000 |
| commit | 19fdc5b67990bb75009a1fc511619bd449d559d7 (patch) | |
| tree | 846b3d1392fc94ed1e9530458bad046c706be1ad /src/admin/bar.h | |
| parent | 8271df42bda9284012ebc05f7edbd0689c07f6a1 (diff) | |
Stop acting as admin when the authorization expires
Previously, the authorization just silently expired without any
visible change. The surprise only came when the user tried to do
any action, which immediately would show a password prompt. We
don't want users to randomly type passwords into password
prompts unexpectedly showing up. This commit avoids that.
With this change, the view container visibly de-escalates
privileges and shows a message explaining what happened.
A method was implemented in kio-admin to make this possible. See:
https://commits.kde.org/kio-admin/a2da29289d12ef845e2c1da17ed04c59f1c47762
This commit also improves some logic around the responsibility
of hiding bars and activating view containers.
This is also part of my project funded by the European Commission.
Diffstat (limited to 'src/admin/bar.h')
| -rw-r--r-- | src/admin/bar.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/admin/bar.h b/src/admin/bar.h index 5399fa669..d1754f3bb 100644 --- a/src/admin/bar.h +++ b/src/admin/bar.h @@ -10,6 +10,7 @@ #include "animatedheightwidget.h" +class DolphinViewContainer; class QLabel; class QPushButton; class QResizeEvent; @@ -28,19 +29,24 @@ class Bar : public AnimatedHeightWidget Q_OBJECT public: - explicit Bar(QWidget *parent); + explicit Bar(DolphinViewContainer *parentViewContainer); /** Used to recolor this bar when this application's color scheme changes. */ bool event(QEvent *event) override; -Q_SIGNALS: - void activated(); - protected: /** Calls updateLabelString() */ void resizeEvent(QResizeEvent *resizeEvent) override; private: + /** + * Makes sure this admin bar hides itself when the elevated privileges expire so the user doesn't mistakenly assume that they are still acting with + * administrative rights. The view container is also changed to a non-admin url, so no password prompts will pop up unexpectedly. + * Then this method shows a message to the user to explain this. + * The mechanism of this method only fires once and will need to be called again the next time the user regains administrative rights for this view. + */ + void hideTheNextTimeAuthorizationExpires(); + /** Recolors this bar based on the current color scheme. */ void updateColors(); @@ -68,6 +74,19 @@ private: /** @see preferredHeight() */ int m_preferredHeight; + + /** + * A proxy action for the real actAsAdminAction. + * This proxy action can be used to reenable admin mode for the view belonging to this bar object specifically. + */ + QAction *m_reenableActAsAdminAction = nullptr; + + /** + * The parent of this bar. The bar acts on the DolphinViewContainer to exit the admin mode. This can happen in two ways: + * 1. The user closes the bar which implies exiting of the admin mode. + * 2. The admin authorization expires so all views can factually no longer be in admin mode. + */ + DolphinViewContainer *m_parentViewContainer; }; } |
