1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5 (C) 2000 Kurt Granroth <granroth@kde.org>
6 (C) 2000 Michael Koch <koch@kde.org>
7 (C) 2001 Holger Freyther <freyther@kde.org>
8 (C) 2002 Ellis Whitehead <ellis@kde.org>
9 (C) 2003 Andras Mantia <amantia@kde.org>
10 (C) 2005-2006 Hamish Rodda <rodda@kde.org>
11
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public
14 License version 2 as published by the Free Software Foundation.
15
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Library General Public License for more details.
20
21 You should have received a copy of the GNU Library General Public License
22 along with this library; see the file COPYING.LIB. If not, write to
23 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 Boston, MA 02110-1301, USA.
25*/
26
27#ifndef KTOGGLEFULLSCREENACTION_H
28#define KTOGGLEFULLSCREENACTION_H
29
30#include <ktoggleaction.h>
31
32/**
33 * An action for switching between to/from full screen mode. Note that
34 * QWidget::isFullScreen() may reflect the new or the old state
35 * depending on how the action was triggered (by the application or
36 * from the window manager). Also don't try to track the window state
37 * yourself. Rely on this action's state (isChecked()) instead.
38 *
39 * Important: If you need to set/change the fullscreen state manually,
40 * use KToggleFullScreenAction::setFullScreen() or a similar function,
41 * do not call directly the slot connected to the toggled() signal. The slot
42 * still needs to explicitly set the window state though.
43 *
44 * Note: Do NOT use QWidget::showFullScreen() or QWidget::showNormal().
45 * They have several side-effects besides just switching the fullscreen
46 * state (for example, showNormal() resets all window states, not just
47 * fullscreen). Use the KToggleFullScreenAction::setFullScreen() helper function.
48 */
49class KDEUI_EXPORT KToggleFullScreenAction : public KToggleAction
50{
51 Q_OBJECT
52
53 public:
54 /**
55 * Create a KToggleFullScreenAction. Call setWindow() to associate this
56 * action with a window.
57 *
58 * @param parent This action's parent object.
59 */
60 explicit KToggleFullScreenAction( QObject *parent );
61
62 /**
63 * Create a KToggleFullScreenAction
64 * @param window the window that will switch to/from full screen mode
65 * @param parent This action's parent object.
66 */
67 KToggleFullScreenAction( QWidget *window, QObject *parent );
68
69 /**
70 * Destroys the toggle fullscreen action.
71 */
72 virtual ~KToggleFullScreenAction();
73
74 /**
75 * Sets the window that will be related to this action.
76 */
77 void setWindow( QWidget* window );
78
79 /**
80 * Helper function to set or reset the fullscreen state of a window.
81 * Use this function rather than showFullScreen()/showNormal() QWidget functions.
82 * @since 4.0.3
83 */
84 static void setFullScreen( QWidget* window, bool set );
85
86 protected:
87 bool eventFilter( QObject* object, QEvent* event );
88
89 private Q_SLOTS:
90 virtual void slotToggled( bool checked );
91
92 private:
93 class Private;
94 Private* const d;
95};
96
97#endif
98