From 2c22fb82b18239106af59e9ba1b29351fdd033c2 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 24 Jan 2019 16:18:16 -0800 Subject: [PATCH 1/2] keep log window on top option --- interface/src/Application.cpp | 16 +++++++++++++++- interface/src/Application.h | 3 +++ interface/src/ui/BaseLogDialog.cpp | 4 ++-- interface/src/ui/LogDialog.cpp | 14 ++++++++++++++ interface/src/ui/LogDialog.h | 1 + 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2695b298cc..34f29d2164 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -8107,7 +8107,8 @@ void Application::toggleLogDialog() { return; } if (! _logDialog) { - _logDialog = new LogDialog(nullptr, getLogger()); + bool shouldSetParent = _keepLogWindowOnTop.get(); + _logDialog = new LogDialog(shouldSetParent ? qApp->getWindow() : nullptr, getLogger()); } if (_logDialog->isVisible()) { @@ -8117,6 +8118,19 @@ void Application::toggleLogDialog() { } } + void Application::recreateLogWindow(int keepOnTop) { + _keepLogWindowOnTop.set(keepOnTop != 0); + if (_logDialog) { + bool toggle = _logDialog->isVisible(); + _logDialog->close(); + _logDialog = nullptr; + + if (toggle) { + toggleLogDialog(); + } + } + } + void Application::toggleEntityScriptServerLogDialog() { if (! _entityScriptServerLogDialog) { _entityScriptServerLogDialog = new EntityScriptServerLogDialog(nullptr); diff --git a/interface/src/Application.h b/interface/src/Application.h index 05d6135a93..576283f5a3 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -217,6 +217,7 @@ public: void setDesktopTabletScale(float desktopTabletScale); bool getDesktopTabletBecomesToolbarSetting() { return _desktopTabletBecomesToolbarSetting.get(); } + bool getLogWindowOnTopSetting() { return _keepLogWindowOnTop.get(); } void setDesktopTabletBecomesToolbarSetting(bool value); bool getHmdTabletBecomesToolbarSetting() { return _hmdTabletBecomesToolbarSetting.get(); } void setHmdTabletBecomesToolbarSetting(bool value); @@ -365,6 +366,7 @@ public slots: Q_INVOKABLE void loadDialog(); Q_INVOKABLE void loadScriptURLDialog() const; void toggleLogDialog(); + void recreateLogWindow(int); void toggleEntityScriptServerLogDialog(); Q_INVOKABLE void showAssetServerWidget(QString filePath = ""); Q_INVOKABLE void loadAddAvatarBookmarkDialog() const; @@ -654,6 +656,7 @@ private: Setting::Handle _constrainToolbarPosition; Setting::Handle _preferredCursor; Setting::Handle _miniTabletEnabledSetting; + Setting::Handle _keepLogWindowOnTop { "keepLogWindowOnTop", false }; float _scaleMirror; float _mirrorYawOffset; diff --git a/interface/src/ui/BaseLogDialog.cpp b/interface/src/ui/BaseLogDialog.cpp index e27b622262..e648dc222a 100644 --- a/interface/src/ui/BaseLogDialog.cpp +++ b/interface/src/ui/BaseLogDialog.cpp @@ -20,9 +20,9 @@ #include const int TOP_BAR_HEIGHT = 124; -const int INITIAL_WIDTH = 720; +const int INITIAL_WIDTH = 800; const int INITIAL_HEIGHT = 480; -const int MINIMAL_WIDTH = 700; +const int MINIMAL_WIDTH = 780; const int SEARCH_BUTTON_LEFT = 25; const int SEARCH_BUTTON_WIDTH = 20; const int SEARCH_TOGGLE_BUTTON_WIDTH = 50; diff --git a/interface/src/ui/LogDialog.cpp b/interface/src/ui/LogDialog.cpp index 26a5a24de8..f89df985ed 100644 --- a/interface/src/ui/LogDialog.cpp +++ b/interface/src/ui/LogDialog.cpp @@ -19,6 +19,9 @@ #include +#include "Application.h" +#include "MainWindow.h" + const int REVEAL_BUTTON_WIDTH = 122; const int ALL_LOGS_BUTTON_WIDTH = 90; const int MARGIN_LEFT = 25; @@ -148,6 +151,12 @@ LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : BaseLog _messageCount->setObjectName("messageCount"); _messageCount->show(); + _keepOnTopBox = new QCheckBox(" Keep window on top", this); + bool isOnTop = qApp-> getLogWindowOnTopSetting(); + _keepOnTopBox->setCheckState(isOnTop ? Qt::Checked : Qt::Unchecked); + connect(_keepOnTopBox, &QCheckBox::stateChanged, qApp, &Application::recreateLogWindow); + _keepOnTopBox->show(); + _extraDebuggingBox = new QCheckBox("Extra debugging", this); if (_logger->extraDebugging()) { _extraDebuggingBox->setCheckState(Qt::Checked); @@ -183,6 +192,11 @@ void LogDialog::resizeEvent(QResizeEvent* event) { THIRD_ROW, COMBOBOX_WIDTH, ELEMENT_HEIGHT); + + _keepOnTopBox->setGeometry(width() - ELEMENT_MARGIN - COMBOBOX_WIDTH - ELEMENT_MARGIN - ALL_LOGS_BUTTON_WIDTH - ELEMENT_MARGIN - COMBOBOX_WIDTH - ELEMENT_MARGIN, + THIRD_ROW, + COMBOBOX_WIDTH, + ELEMENT_HEIGHT); _messageCount->setGeometry(_leftPad, THIRD_ROW, COMBOBOX_WIDTH, diff --git a/interface/src/ui/LogDialog.h b/interface/src/ui/LogDialog.h index eb92d4b381..139ccb2240 100644 --- a/interface/src/ui/LogDialog.h +++ b/interface/src/ui/LogDialog.h @@ -55,6 +55,7 @@ protected: private: QCheckBox* _extraDebuggingBox; + QCheckBox* _keepOnTopBox; QPushButton* _revealLogButton; QPushButton* _allLogsButton; QCheckBox* _debugPrintBox; From db581739772b6cd0f87816cf0a5615c03bcc00de Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 25 Jan 2019 15:10:53 -0800 Subject: [PATCH 2/2] fix mac issue --- interface/src/Application.cpp | 14 ++++++++++++-- interface/src/Application.h | 1 + interface/src/ui/LogDialog.cpp | 21 +++++++++++++++++++++ interface/src/ui/LogDialog.h | 1 + 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 34f29d2164..4d7d102fef 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -8107,8 +8107,18 @@ void Application::toggleLogDialog() { return; } if (! _logDialog) { - bool shouldSetParent = _keepLogWindowOnTop.get(); - _logDialog = new LogDialog(shouldSetParent ? qApp->getWindow() : nullptr, getLogger()); + + bool keepOnTop =_keepLogWindowOnTop.get(); +#ifdef Q_OS_WIN + _logDialog = new LogDialog(keepOnTop ? qApp->getWindow() : nullptr, getLogger()); +#else + _logDialog = new LogDialog(nullptr, getLogger()); + + if (keepOnTop) { + Qt::WindowFlags flags = _logDialog->windowFlags() | Qt::Tool; + _logDialog->setWindowFlags(flags); + } +#endif } if (_logDialog->isVisible()) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 576283f5a3..ef41d8afb0 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -218,6 +218,7 @@ public: bool getDesktopTabletBecomesToolbarSetting() { return _desktopTabletBecomesToolbarSetting.get(); } bool getLogWindowOnTopSetting() { return _keepLogWindowOnTop.get(); } + void setLogWindowOnTopSetting(bool keepOnTop) { _keepLogWindowOnTop.set(keepOnTop); } void setDesktopTabletBecomesToolbarSetting(bool value); bool getHmdTabletBecomesToolbarSetting() { return _hmdTabletBecomesToolbarSetting.get(); } void setHmdTabletBecomesToolbarSetting(bool value); diff --git a/interface/src/ui/LogDialog.cpp b/interface/src/ui/LogDialog.cpp index f89df985ed..1eaad05e33 100644 --- a/interface/src/ui/LogDialog.cpp +++ b/interface/src/ui/LogDialog.cpp @@ -154,7 +154,11 @@ LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : BaseLog _keepOnTopBox = new QCheckBox(" Keep window on top", this); bool isOnTop = qApp-> getLogWindowOnTopSetting(); _keepOnTopBox->setCheckState(isOnTop ? Qt::Checked : Qt::Unchecked); +#ifdef Q_OS_WIN connect(_keepOnTopBox, &QCheckBox::stateChanged, qApp, &Application::recreateLogWindow); +#else + connect(_keepOnTopBox, &QCheckBox::stateChanged, this, &LogDialog::handleKeepWindowOnTop); +#endif _keepOnTopBox->show(); _extraDebuggingBox = new QCheckBox("Extra debugging", this); @@ -248,6 +252,23 @@ void LogDialog::handleInfoPrintBox(int state) { printLogFile(); } +void LogDialog::handleKeepWindowOnTop(int state) { + bool keepOnTop = (state != 0); + + Qt::WindowFlags flags = windowFlags(); + + if (keepOnTop) { + flags |= Qt::Tool; + } else { + flags &= ~Qt::Tool; + } + + setWindowFlags(flags); + qApp->setLogWindowOnTopSetting(keepOnTop); + + show(); +} + void LogDialog::handleCriticalPrintBox(int state) { _logger->setCriticalPrint(state != 0); printLogFile(); diff --git a/interface/src/ui/LogDialog.h b/interface/src/ui/LogDialog.h index 139ccb2240..d3ee81ca7e 100644 --- a/interface/src/ui/LogDialog.h +++ b/interface/src/ui/LogDialog.h @@ -34,6 +34,7 @@ public slots: private slots: void handleRevealButton(); void handleExtraDebuggingCheckbox(int); + void handleKeepWindowOnTop(int); void handleDebugPrintBox(int); void handleInfoPrintBox(int); void handleCriticalPrintBox(int);