From 5db5c1c5e345535ef97f919d2745158c5b7ed9e0 Mon Sep 17 00:00:00 2001 From: christian Date: Wed, 25 Aug 2010 11:34:55 +0200 Subject: [PATCH] released as 0.4 --- debian/changelog | 2 +- src/fullscreenexitbutton.h | 134 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/fullscreenexitbutton.h diff --git a/debian/changelog b/debian/changelog index e3c5a1e..c7819e8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,7 +5,7 @@ presencevnc (0.4) unstable; urgency=low * Fix tearing after scrolling * Hide toolbar in fullscreen mode - -- Christian Pulvermacher Sat, 07 Aug 2010 11:52:56 +0200 + -- Christian Pulvermacher Mon, 23 Aug 2010 13:39:41 +0200 presencevnc (0.3) unstable; urgency=low diff --git a/src/fullscreenexitbutton.h b/src/fullscreenexitbutton.h new file mode 100644 index 0000000..ebe437c --- /dev/null +++ b/src/fullscreenexitbutton.h @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FULLSCREENEXITBUTTON_H +#define FULLSCREENEXITBUTTON_H + +#include "mainwindow.h" + +#include +#include +#include + +class FullScreenExitButton : public QToolButton +{ + Q_OBJECT +public: + inline explicit FullScreenExitButton(MainWindow *parent); + +protected: + inline bool eventFilter(QObject *obj, QEvent *ev); + +private: + QTimer timer; +}; + +FullScreenExitButton::FullScreenExitButton(MainWindow *parent) + : QToolButton(parent) +{ + Q_ASSERT(parent); + + // set the fullsize icon from Maemo's theme + setIcon(QIcon("/usr/share/icons/hicolor/48x48/hildon/general_fullsize.png")); + + // ensure that our size is fixed to our ideal size + setFixedSize(sizeHint()); + + // set the background to 0.5 alpha + //TODO doesn't work. + QPalette pal = palette(); + QColor backgroundColor = pal.color(backgroundRole()); + backgroundColor.setAlpha(128); + pal.setColor(backgroundRole(), backgroundColor); + setPalette(pal); + + // ensure that we're painting our background + setAutoFillBackground(true); + + // when we're clicked, tell the parent to exit fullscreen + connect(this, SIGNAL(clicked()), parent, SLOT(toggleFullscreen())); + + // hide after 4s of inactivity + connect(&timer, SIGNAL(timeout()), this, SLOT(hide())); + timer.setInterval(4000); + timer.setSingleShot(true); + + // install an event filter to listen for the parent's events + parent->installEventFilter(this); + + setVisible(false); //assuming we don't start in fullscreen + timer.start(); +} + +bool FullScreenExitButton::eventFilter(QObject *obj, QEvent *ev) +{ + if (obj != parent()) + return QToolButton::eventFilter(obj, ev); + + QWidget *parent = parentWidget(); + bool isFullScreen = parent->windowState() & Qt::WindowFullScreen; + + switch (ev->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + case QEvent::HoverMove: + //fall through to show button + case QEvent::WindowStateChange: + setVisible(isFullScreen); + if (isFullScreen) + raise(); + // fall through + case QEvent::Resize: + if (isVisible()) { + move(parent->width() - width(), + parent->height() - height()); + timer.start(); + } + break; + default: + break; + } + + return QToolButton::eventFilter(obj, ev); +} + +#endif -- 1.7.9.5