KDEUI
ktogglefullscreenaction.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> 00003 (C) 1999 Simon Hausmann <hausmann@kde.org> 00004 (C) 2000 Nicolas Hadacek <haadcek@kde.org> 00005 (C) 2000 Kurt Granroth <granroth@kde.org> 00006 (C) 2000 Michael Koch <koch@kde.org> 00007 (C) 2001 Holger Freyther <freyther@kde.org> 00008 (C) 2002 Ellis Whitehead <ellis@kde.org> 00009 (C) 2002 Joseph Wenninger <jowenn@kde.org> 00010 (C) 2003 Andras Mantia <amantia@kde.org> 00011 (C) 2005-2006 Hamish Rodda <rodda@kde.org> 00012 00013 This library is free software; you can redistribute it and/or 00014 modify it under the terms of the GNU Library General Public 00015 License version 2 as published by the Free Software Foundation. 00016 00017 This library is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 Library General Public License for more details. 00021 00022 You should have received a copy of the GNU Library General Public License 00023 along with this library; see the file COPYING.LIB. If not, write to 00024 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00025 Boston, MA 02110-1301, USA. 00026 */ 00027 00028 #include "ktogglefullscreenaction.h" 00029 00030 #include <QtCore/QEvent> 00031 00032 #include <kdebug.h> 00033 #include <kicon.h> 00034 #include <klocale.h> 00035 00036 class KToggleFullScreenAction::Private 00037 { 00038 public: 00039 Private( KToggleFullScreenAction* action ) 00040 : q( action ) 00041 , window( 0 ) 00042 { 00043 } 00044 00045 void updateTextsAndIcon() 00046 { 00047 if ( q->isChecked() ) { 00048 q->setText( i18nc( "@action:inmenu", "Exit F&ull Screen Mode" ) ); 00049 q->setIconText( i18nc( "@action:intoolbar", "Exit Full Screen" ) ); 00050 q->setToolTip( i18nc( "@info:tooltip", "Exit full screen mode" ) ); 00051 q->setIcon( KIcon( "view-restore" ) ); 00052 } else { 00053 q->setText( i18nc( "@action:inmenu", "F&ull Screen Mode" ) ); 00054 q->setIconText( i18nc( "@action:intoolbar", "Full Screen" ) ); 00055 q->setToolTip( i18nc( "@info:tooltip", "Display the window in full screen" ) ); 00056 q->setIcon( KIcon( "view-fullscreen" ) ); 00057 } 00058 } 00059 00060 KToggleFullScreenAction* q; 00061 QWidget* window; 00062 }; 00063 00064 KToggleFullScreenAction::KToggleFullScreenAction( QObject *parent ) 00065 : KToggleAction( parent ), 00066 d( new Private( this ) ) 00067 { 00068 d->updateTextsAndIcon(); 00069 } 00070 00071 KToggleFullScreenAction::KToggleFullScreenAction( QWidget *window, QObject *parent ) 00072 : KToggleAction( parent ), 00073 d( new Private( this ) ) 00074 { 00075 d->updateTextsAndIcon(); 00076 setWindow( window ); 00077 } 00078 00079 KToggleFullScreenAction::~KToggleFullScreenAction() 00080 { 00081 delete d; 00082 } 00083 00084 void KToggleFullScreenAction::setWindow( QWidget* window ) 00085 { 00086 if ( d->window ) 00087 d->window->removeEventFilter( this ); 00088 00089 d->window = window; 00090 00091 if ( d->window ) 00092 d->window->installEventFilter( this ); 00093 } 00094 00095 void KToggleFullScreenAction::slotToggled( bool checked ) 00096 { 00097 KToggleAction::slotToggled( checked ); 00098 d->updateTextsAndIcon(); 00099 } 00100 00101 bool KToggleFullScreenAction::eventFilter( QObject* object, QEvent* event ) 00102 { 00103 if ( object == d->window ) 00104 if ( event->type() == QEvent::WindowStateChange ) { 00105 if ( d->window->isFullScreen() != isChecked() ) 00106 activate( QAction::Trigger ); 00107 } 00108 00109 return false; 00110 } 00111 00112 void KToggleFullScreenAction::setFullScreen( QWidget* window, bool set ) 00113 { 00114 if( set ) 00115 window->setWindowState( window->windowState() | Qt::WindowFullScreen ); 00116 else 00117 window->setWindowState( window->windowState() & ~Qt::WindowFullScreen ); 00118 } 00119 00120 #include "ktogglefullscreenaction.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Mon Jan 21 2019 12:32:44 by doxygen 1.7.5.1 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2019 The KDE developers.
Generated on Mon Jan 21 2019 12:32:44 by doxygen 1.7.5.1 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.