KWidgetsAddons

ktogglefullscreenaction.cpp
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: 2002 Joseph Wenninger <jowenn@kde.org>
11 SPDX-FileCopyrightText: 2003 Andras Mantia <amantia@kde.org>
12 SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org>
13
14 SPDX-License-Identifier: LGPL-2.0-only
15*/
16
17#include "ktogglefullscreenaction.h"
18
19#include "ktoggleaction_p.h"
20
21#include <QEvent>
22#include <QWidget>
23
24class KToggleFullScreenActionPrivate : public KToggleActionPrivate
25{
26 Q_DECLARE_PUBLIC(KToggleFullScreenAction)
27
28public:
29 KToggleFullScreenActionPrivate(KToggleFullScreenAction *qq)
30 : KToggleActionPrivate(qq)
31 {
32 }
33
34 void updateTextsAndIcon()
35 {
37
38 q->setText(KToggleFullScreenAction::tr("F&ull Screen Mode", "@action:inmenu"));
39 q->setIconText(KToggleFullScreenAction::tr("Full Screen", "@action:intoolbar"));
40 q->setToolTip(KToggleFullScreenAction::tr("Display the window in full screen", "@info:tooltip"));
41 q->setIcon(QIcon::fromTheme(QStringLiteral("view-fullscreen")));
42 }
43
44 QWidget *window = nullptr;
45};
46
48 : KToggleAction(*new KToggleFullScreenActionPrivate(this), parent)
49{
51
52 d->updateTextsAndIcon();
53}
54
56 : KToggleAction(*new KToggleFullScreenActionPrivate(this), parent)
57{
59
60 d->updateTextsAndIcon();
61 setWindow(window);
62}
63
65
67{
69
70 if (d->window) {
71 d->window->removeEventFilter(this);
72 }
73
74 d->window = window;
75
76 if (d->window) {
77 d->window->installEventFilter(this);
78 }
79}
80
81void KToggleFullScreenAction::slotToggled(bool checked)
82{
83 KToggleAction::slotToggled(checked);
84}
85
86bool KToggleFullScreenAction::eventFilter(QObject *object, QEvent *event)
87{
89
90 if (object == d->window) {
91 if (event->type() == QEvent::WindowStateChange) {
92 if (d->window->isFullScreen() != isChecked()) {
94 }
95 }
96 }
97
98 return false;
99}
100
102{
103 if (set) {
105 } else {
106 window->setWindowState(window->windowState() & ~Qt::WindowFullScreen);
107 }
108}
109
110#include "moc_ktogglefullscreenaction.cpp"
Checkbox like action.
An action for switching between to/from full screen mode.
KToggleFullScreenAction(QObject *parent)
Create a KToggleFullScreenAction.
~KToggleFullScreenAction() override
Destroys the toggle fullscreen action.
static void setFullScreen(QWidget *window, bool set)
Helper function to set or reset the fullscreen state of a window.
void setWindow(QWidget *window)
Sets the window that will be related to this action.
void activate(ActionEvent event)
virtual bool event(QEvent *e) override
WindowStateChange
QIcon fromTheme(const QString &name)
void installEventFilter(QObject *filterObj)
QString tr(const char *sourceText, const char *disambiguation, int n)
WindowFullScreen
void setWindowState(Qt::WindowState state)
Qt::WindowState windowState() const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:51:03 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.