diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 47250a1215..12f10ae954 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -8246,7 +8246,18 @@ void Application::toggleLogDialog() { return; } if (! _logDialog) { + + 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()) { @@ -8256,6 +8267,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 fbf6e8bc9c..de79e91cb2 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -217,6 +217,8 @@ public: void setDesktopTabletScale(float desktopTabletScale); 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); @@ -365,6 +367,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; @@ -656,6 +659,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..1eaad05e33 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,16 @@ 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); +#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); if (_logger->extraDebugging()) { _extraDebuggingBox->setCheckState(Qt::Checked); @@ -183,6 +196,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, @@ -234,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 eb92d4b381..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); @@ -55,6 +56,7 @@ protected: private: QCheckBox* _extraDebuggingBox; + QCheckBox* _keepOnTopBox; QPushButton* _revealLogButton; QPushButton* _allLogsButton; QCheckBox* _debugPrintBox;