From af84795c78ff732e6354f1f2a6f8be7d00c6b050 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Mon, 20 Oct 2014 17:13:37 -0400 Subject: [PATCH 1/2] Try to hide cursor in output window, when desired --- MainWindow.cpp | 9 +++++++++ MainWindow.h | 1 + OutputGLWindow.cpp | 34 +++++++++++++++++++++++++++------- OutputGLWindow.h | 6 ++++++ 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/MainWindow.cpp b/MainWindow.cpp index 6bcd60a..70e08ea 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -1180,6 +1180,14 @@ void MainWindow::createActions() // Output window should be displayed for full screen option to be available. connect(displayOutputWindow, SIGNAL(toggled(bool)), outputWindowFullScreen, SLOT(setEnabled(bool))); + + outputWindowHasCursor = new QAction(tr("O&utput window has cursor"), this); + outputWindowHasCursor->setStatusTip(tr("Show cursor in output window")); + outputWindowHasCursor->setIconVisibleInMenu(false); + outputWindowHasCursor->setCheckable(true); + outputWindowHasCursor->setChecked(true); + connect(outputWindowHasCursor, SIGNAL(toggled(bool)), outputWindow, SLOT(setFullScreen(bool))); + // Toggle display of canvas controls. displayCanvasControls = new QAction(tr("&Display canvas controls"), this); // displayCanvasControls->setShortcut(tr("Ctrl+E")); @@ -1254,6 +1262,7 @@ void MainWindow::createMenus() viewMenu->addAction(outputWindowFullScreen); viewMenu->addAction(displayCanvasControls); viewMenu->addAction(stickyVertices); + viewMenu->addAction(outputWindowHasCursor); // Run. runMenu = menuBar->addMenu(tr("&Run")); diff --git a/MainWindow.h b/MainWindow.h index 5df305d..33443cc 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -256,6 +256,7 @@ private: QAction *rewindAction; QAction *displayOutputWindow; + QAction *outputWindowHasCursor; QAction *outputWindowFullScreen; QAction *displayCanvasControls; QAction *stickyVertices; diff --git a/OutputGLWindow.cpp b/OutputGLWindow.cpp index e9ce620..f446628 100644 --- a/OutputGLWindow.cpp +++ b/OutputGLWindow.cpp @@ -36,6 +36,24 @@ OutputGLWindow::OutputGLWindow(MainWindow* mainWindow, QWidget* parent, const QG // Save window geometry. _geometry = saveGeometry(); + + _pointerIsVisible = true; +} + +void OutputGLWindow::setCursorVisible(bool visible) +{ + _pointerIsVisible = visible; + + if (_pointerIsVisible) + { + this->setCursor(Qt::BlankCursor); + _pointerIsVisible = false; + } + else + { + this->setCursor(Qt::ArrowCursor); + _pointerIsVisible = true; + } } void OutputGLWindow::closeEvent(QCloseEvent *event) @@ -47,14 +65,16 @@ void OutputGLWindow::closeEvent(QCloseEvent *event) void OutputGLWindow::keyPressEvent(QKeyEvent *event) { // Escape from full screen mode. - if (isFullScreen() && event->key() == Qt::Key_Escape) + if (event->key() == Qt::Key_Escape) { - setFullScreen(false); - emit fullScreenToggled(false); - } - else if (event->key() == Qt::Key_Escape) - { - // pass + if (isFullScreen()) + { + setFullScreen(false); + emit fullScreenToggled(false); + } else { + setFullScreen(true); + emit fullScreenToggled(true); + } } else { diff --git a/OutputGLWindow.h b/OutputGLWindow.h index 8c85572..afaa678 100644 --- a/OutputGLWindow.h +++ b/OutputGLWindow.h @@ -2,6 +2,7 @@ * OutputGLWindow.h * * (c) 2014 Sofian Audry -- info(@)sofianaudry(.)com + * (c) 2014 Alexandre Quessy -- alexandre(@)quessy(.)net * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +23,7 @@ #include #include +#include #include "DestinationGLCanvas.h" // TODO: add SLOT for mySetVisible @@ -36,6 +38,7 @@ public: public slots: void setFullScreen(bool fullScreen); + void setCursorVisible(bool visible); protected: void closeEvent(QCloseEvent* event); @@ -47,10 +50,13 @@ signals: public: DestinationGLCanvas* getCanvas() const { return canvas; } + void setPointerHasMoved(); private: DestinationGLCanvas* canvas; QByteArray _geometry; + + bool _pointerIsVisible; }; #endif /* OutputGLWINDOW_H_ */ From afc84bb692985da1e4765852b9adc179acb69518 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Tue, 21 Oct 2014 01:52:03 -0400 Subject: [PATCH 2/2] Fix logic in setCursorVisible + make it visible if controls are --- MainWindow.cpp | 14 +++++++------- MainWindow.h | 2 +- OutputGLWindow.cpp | 8 ++++---- OutputGLWindow.h | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/MainWindow.cpp b/MainWindow.cpp index 70e08ea..4b5cee8 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -1181,12 +1181,12 @@ void MainWindow::createActions() connect(displayOutputWindow, SIGNAL(toggled(bool)), outputWindowFullScreen, SLOT(setEnabled(bool))); - outputWindowHasCursor = new QAction(tr("O&utput window has cursor"), this); - outputWindowHasCursor->setStatusTip(tr("Show cursor in output window")); - outputWindowHasCursor->setIconVisibleInMenu(false); - outputWindowHasCursor->setCheckable(true); - outputWindowHasCursor->setChecked(true); - connect(outputWindowHasCursor, SIGNAL(toggled(bool)), outputWindow, SLOT(setFullScreen(bool))); + // outputWindowHasCursor = new QAction(tr("O&utput window has cursor"), this); + // outputWindowHasCursor->setStatusTip(tr("Show cursor in output window")); + // outputWindowHasCursor->setIconVisibleInMenu(false); + // outputWindowHasCursor->setCheckable(true); + // outputWindowHasCursor->setChecked(true); + // connect(outputWindowHasCursor, SIGNAL(toggled(bool)), outputWindow, SLOT(setFullScreen(bool))); // Toggle display of canvas controls. displayCanvasControls = new QAction(tr("&Display canvas controls"), this); @@ -1262,7 +1262,7 @@ void MainWindow::createMenus() viewMenu->addAction(outputWindowFullScreen); viewMenu->addAction(displayCanvasControls); viewMenu->addAction(stickyVertices); - viewMenu->addAction(outputWindowHasCursor); + //viewMenu->addAction(outputWindowHasCursor); // Run. runMenu = menuBar->addMenu(tr("&Run")); diff --git a/MainWindow.h b/MainWindow.h index 33443cc..54ac351 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -256,7 +256,7 @@ private: QAction *rewindAction; QAction *displayOutputWindow; - QAction *outputWindowHasCursor; + //QAction *outputWindowHasCursor; QAction *outputWindowFullScreen; QAction *displayCanvasControls; QAction *stickyVertices; diff --git a/OutputGLWindow.cpp b/OutputGLWindow.cpp index f446628..4a58770 100644 --- a/OutputGLWindow.cpp +++ b/OutputGLWindow.cpp @@ -46,13 +46,13 @@ void OutputGLWindow::setCursorVisible(bool visible) if (_pointerIsVisible) { - this->setCursor(Qt::BlankCursor); - _pointerIsVisible = false; + this->setCursor(Qt::ArrowCursor); + _pointerIsVisible = true; } else { - this->setCursor(Qt::ArrowCursor); - _pointerIsVisible = true; + this->setCursor(Qt::BlankCursor); + _pointerIsVisible = false; } } diff --git a/OutputGLWindow.h b/OutputGLWindow.h index afaa678..768df62 100644 --- a/OutputGLWindow.h +++ b/OutputGLWindow.h @@ -38,7 +38,6 @@ public: public slots: void setFullScreen(bool fullScreen); - void setCursorVisible(bool visible); protected: void closeEvent(QCloseEvent* event); @@ -51,6 +50,7 @@ signals: public: DestinationGLCanvas* getCanvas() const { return canvas; } void setPointerHasMoved(); + void setCursorVisible(bool visible); private: DestinationGLCanvas* canvas;