1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 1999 Reginald Stadlbauer <reggie@kde.org> |
4 | SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org> |
5 | SPDX-FileCopyrightText: 2000 Nicolas Hadacek <haadcek@kde.org> |
6 | SPDX-FileCopyrightText: 2000 Kurt Granroth <granroth@kde.org> |
7 | SPDX-FileCopyrightText: 2000 Michael Koch <koch@kde.org> |
8 | SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org> |
9 | SPDX-FileCopyrightText: 2002 Ellis Whitehead <ellis@kde.org> |
10 | SPDX-FileCopyrightText: 2003 Andras Mantia <amantia@kde.org> |
11 | SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org> |
12 | |
13 | SPDX-License-Identifier: LGPL-2.0-only |
14 | */ |
15 | |
16 | #ifndef KTOGGLEFULLSCREENACTION_H |
17 | #define KTOGGLEFULLSCREENACTION_H |
18 | |
19 | #include <ktoggleaction.h> |
20 | |
21 | class QWidget; |
22 | |
23 | class KToggleFullScreenActionPrivate; |
24 | |
25 | /*! |
26 | * \class KToggleFullScreenAction |
27 | * \inmodule KWidgetsAddons |
28 | * |
29 | * \brief An action for switching between to/from full screen mode. |
30 | * |
31 | * Note that |
32 | * QWidget::isFullScreen() may reflect the new or the old state |
33 | * depending on how the action was triggered (by the application or |
34 | * from the window manager). Also don't try to track the window state |
35 | * yourself. Rely on this action's state (isChecked()) instead. |
36 | * |
37 | * Important: If you need to set/change the fullscreen state manually, |
38 | * use KToggleFullScreenAction::setFullScreen() or a similar function, |
39 | * do not call directly the slot connected to the toggled() signal. The slot |
40 | * still needs to explicitly set the window state though. |
41 | * |
42 | * \note Do NOT use QWidget::showFullScreen() or QWidget::showNormal(). |
43 | * They have several side-effects besides just switching the fullscreen |
44 | * state (for example, showNormal() resets all window states, not just |
45 | * fullscreen). Use the KToggleFullScreenAction::setFullScreen() helper function. |
46 | */ |
47 | class KWIDGETSADDONS_EXPORT KToggleFullScreenAction : public KToggleAction |
48 | { |
49 | Q_OBJECT |
50 | |
51 | public: |
52 | /*! |
53 | * Create a KToggleFullScreenAction. Call setWindow() to associate this |
54 | * action with a window. |
55 | * |
56 | * \a parent This action's parent object. |
57 | */ |
58 | explicit KToggleFullScreenAction(QObject *parent); |
59 | |
60 | /*! |
61 | * Create a KToggleFullScreenAction |
62 | * |
63 | * \a window the window that will switch to/from full screen mode |
64 | * |
65 | * \a parent This action's parent object. |
66 | */ |
67 | KToggleFullScreenAction(QWidget *window, QObject *parent); |
68 | |
69 | ~KToggleFullScreenAction() override; |
70 | |
71 | /*! |
72 | * Sets the window that will be related to this action. |
73 | */ |
74 | void setWindow(QWidget *window); |
75 | |
76 | /*! |
77 | * Helper function to set or reset the fullscreen state of a window. |
78 | * |
79 | * Use this function rather than showFullScreen()/showNormal() QWidget functions. |
80 | * \since 4.0.3 |
81 | */ |
82 | static void setFullScreen(QWidget *window, bool set); |
83 | |
84 | protected: |
85 | bool eventFilter(QObject *object, QEvent *event) override; |
86 | |
87 | // KF6 TODO: remove |
88 | protected Q_SLOTS: |
89 | void slotToggled(bool checked) override; |
90 | |
91 | private: |
92 | Q_DECLARE_PRIVATE(KToggleFullScreenAction) |
93 | }; |
94 | |
95 | #endif |
96 | |