From c875ed064e09637cc0ad3328162a220e939d2b54 Mon Sep 17 00:00:00 2001 From: Christian Pulvermacher Date: Wed, 27 Oct 2010 18:15:38 +0200 Subject: [PATCH] reduce header dependencies --- src/fullscreenexitbutton.h | 22 ++++++++-------------- src/mainwindow.cpp | 5 ++++- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/fullscreenexitbutton.h b/src/fullscreenexitbutton.h index 7ebc8ea..60be21c 100644 --- a/src/fullscreenexitbutton.h +++ b/src/fullscreenexitbutton.h @@ -42,8 +42,6 @@ #ifndef FULLSCREENEXITBUTTON_H #define FULLSCREENEXITBUTTON_H -#include "mainwindow.h" - #include #include #include @@ -52,7 +50,7 @@ class FullScreenExitButton : public QToolButton { Q_OBJECT public: - inline explicit FullScreenExitButton(MainWindow *parent); + inline explicit FullScreenExitButton(QWidget *parent); protected: inline bool eventFilter(QObject *obj, QEvent *ev); @@ -61,7 +59,7 @@ private: QTimer timer; }; -FullScreenExitButton::FullScreenExitButton(MainWindow *parent) +FullScreenExitButton::FullScreenExitButton(QWidget *parent) : QToolButton(parent) { Q_ASSERT(parent); @@ -82,9 +80,6 @@ FullScreenExitButton::FullScreenExitButton(MainWindow *parent) // 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); @@ -102,8 +97,8 @@ bool FullScreenExitButton::eventFilter(QObject *obj, QEvent *ev) if (obj != parent()) return QToolButton::eventFilter(obj, ev); - QWidget *parent = parentWidget(); - bool isFullScreen = parent->windowState() & Qt::WindowFullScreen; + const QWidget *parent = parentWidget(); + const bool isFullScreen = parent->windowState() & Qt::WindowFullScreen; switch (ev->type()) { case QEvent::MouseButtonPress: @@ -117,11 +112,10 @@ bool FullScreenExitButton::eventFilter(QObject *obj, QEvent *ev) raise(); // fall through case QEvent::Resize: - if (isVisible()) { - move(parent->width() - width(), - parent->height() - height()); - timer.start(); - } + if (isVisible()) { + move(parent->width() - width(), parent->height() - height()); + timer.start(); + } break; default: break; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 46737d4..b63faa1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -119,7 +119,10 @@ MainWindow::MainWindow(QString url, int quality): this, SLOT(updateScreenSpaceDelayed())); setCentralWidget(scroll_area); - new FullScreenExitButton(this); + + FullScreenExitButton* fullscreen_exit_button = new FullScreenExitButton(this); + connect(fullscreen_exit_button, SIGNAL(clicked()), + this, SLOT(toggleFullscreen())); grabZoomKeys(true); reloadSettings(); -- 1.7.9.5