• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • actions
ktogglefullscreenaction.cpp
Go to the documentation of this file.
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) 2002 Joseph Wenninger <jowenn@kde.org>
10  (C) 2003 Andras Mantia <amantia@kde.org>
11  (C) 2005-2006 Hamish Rodda <rodda@kde.org>
12 
13  This library is free software; you can redistribute it and/or
14  modify it under the terms of the GNU Library General Public
15  License version 2 as published by the Free Software Foundation.
16 
17  This library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  Library General Public License for more details.
21 
22  You should have received a copy of the GNU Library General Public License
23  along with this library; see the file COPYING.LIB. If not, write to
24  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25  Boston, MA 02110-1301, USA.
26 */
27 
28 #include "ktogglefullscreenaction.h"
29 
30 #include <QtCore/QEvent>
31 
32 #include <kdebug.h>
33 #include <kicon.h>
34 #include <klocale.h>
35 
36 class KToggleFullScreenAction::Private
37 {
38 public:
39  Private( KToggleFullScreenAction* action )
40  : q( action )
41  , window( 0 )
42  {
43  }
44 
45  void updateTextsAndIcon()
46  {
47  if ( q->isChecked() ) {
48  q->setText( i18nc( "@action:inmenu", "Exit F&ull Screen Mode" ) );
49  q->setIconText( i18nc( "@action:intoolbar", "Exit Full Screen" ) );
50  q->setToolTip( i18nc( "@info:tooltip", "Exit full screen mode" ) );
51  q->setIcon( KIcon( "view-restore" ) );
52  } else {
53  q->setText( i18nc( "@action:inmenu", "F&ull Screen Mode" ) );
54  q->setIconText( i18nc( "@action:intoolbar", "Full Screen" ) );
55  q->setToolTip( i18nc( "@info:tooltip", "Display the window in full screen" ) );
56  q->setIcon( KIcon( "view-fullscreen" ) );
57  }
58  }
59 
60  KToggleFullScreenAction* q;
61  QWidget* window;
62 };
63 
64 KToggleFullScreenAction::KToggleFullScreenAction( QObject *parent )
65  : KToggleAction( parent ),
66  d( new Private( this ) )
67 {
68  d->updateTextsAndIcon();
69 }
70 
71 KToggleFullScreenAction::KToggleFullScreenAction( QWidget *window, QObject *parent )
72  : KToggleAction( parent ),
73  d( new Private( this ) )
74 {
75  d->updateTextsAndIcon();
76  setWindow( window );
77 }
78 
79 KToggleFullScreenAction::~KToggleFullScreenAction()
80 {
81  delete d;
82 }
83 
84 void KToggleFullScreenAction::setWindow( QWidget* window )
85 {
86  if ( d->window )
87  d->window->removeEventFilter( this );
88 
89  d->window = window;
90 
91  if ( d->window )
92  d->window->installEventFilter( this );
93 }
94 
95 void KToggleFullScreenAction::slotToggled( bool checked )
96 {
97  KToggleAction::slotToggled( checked );
98  d->updateTextsAndIcon();
99 }
100 
101 bool KToggleFullScreenAction::eventFilter( QObject* object, QEvent* event )
102 {
103  if ( object == d->window )
104  if ( event->type() == QEvent::WindowStateChange ) {
105  if ( d->window->isFullScreen() != isChecked() )
106  activate( QAction::Trigger );
107  }
108 
109  return false;
110 }
111 
112 void KToggleFullScreenAction::setFullScreen( QWidget* window, bool set )
113 {
114  if( set )
115  window->setWindowState( window->windowState() | Qt::WindowFullScreen );
116  else
117  window->setWindowState( window->windowState() & ~Qt::WindowFullScreen );
118 }
119 
120 #include "ktogglefullscreenaction.moc"
KToggleFullScreenAction::setWindow
void setWindow(QWidget *window)
Sets the window that will be related to this action.
Definition: ktogglefullscreenaction.cpp:84
ktogglefullscreenaction.h
QEvent
QWidget
QEvent::type
Type type() const
kdebug.h
QAction::isChecked
bool isChecked() const
KToggleAction::slotToggled
virtual void slotToggled(bool checked)
Definition: ktoggleaction.cpp:93
klocale.h
i18nc
QString i18nc(const char *ctxt, const char *text)
QWidget::setWindowState
void setWindowState(QFlags< Qt::WindowState > windowState)
QWidget::windowState
Qt::WindowStates windowState() const
QObject
KToggleFullScreenAction::setFullScreen
static void setFullScreen(QWidget *window, bool set)
Helper function to set or reset the fullscreen state of a window.
Definition: ktogglefullscreenaction.cpp:112
KIcon
A wrapper around QIcon that provides KDE icon features.
Definition: kicon.h:40
KToggleFullScreenAction::eventFilter
bool eventFilter(QObject *object, QEvent *event)
Definition: ktogglefullscreenaction.cpp:101
KToggleFullScreenAction::~KToggleFullScreenAction
virtual ~KToggleFullScreenAction()
Destroys the toggle fullscreen action.
Definition: ktogglefullscreenaction.cpp:79
KToggleFullScreenAction::KToggleFullScreenAction
KToggleFullScreenAction(QObject *parent)
Create a KToggleFullScreenAction.
Definition: ktogglefullscreenaction.cpp:64
KToggleAction
Checkbox like action.
Definition: ktoggleaction.h:40
QAction::activate
void activate(ActionEvent event)
KToggleFullScreenAction
An action for switching between to/from full screen mode.
Definition: ktogglefullscreenaction.h:49
kicon.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal