From 579d9a864070f81043a1e1b5e2cde0c3dd0c3e68 Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Thu, 1 Feb 2018 00:48:03 +0300 Subject: [PATCH 1/2] fix slots invocation --- libraries/ui/src/QmlWindowClass.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/ui/src/QmlWindowClass.cpp b/libraries/ui/src/QmlWindowClass.cpp index 1209d39dcf..0825d238bc 100644 --- a/libraries/ui/src/QmlWindowClass.cpp +++ b/libraries/ui/src/QmlWindowClass.cpp @@ -227,7 +227,7 @@ bool QmlWindowClass::isVisible() { glm::vec2 QmlWindowClass::getPosition() { if (QThread::currentThread() != thread()) { vec2 result; - BLOCKING_INVOKE_METHOD(this, "getPosition", Q_RETURN_ARG(vec2, result)); + BLOCKING_INVOKE_METHOD(this, "getPosition", Q_RETURN_ARG(glm::vec2, result)); return result; } @@ -241,7 +241,7 @@ glm::vec2 QmlWindowClass::getPosition() { void QmlWindowClass::setPosition(const glm::vec2& position) { if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setPosition", Q_ARG(vec2, position)); + QMetaObject::invokeMethod(this, "setPosition", Q_ARG(const glm::vec2&, position)); return; } @@ -262,7 +262,7 @@ glm::vec2 toGlm(const QSizeF& size) { glm::vec2 QmlWindowClass::getSize() { if (QThread::currentThread() != thread()) { vec2 result; - BLOCKING_INVOKE_METHOD(this, "getSize", Q_RETURN_ARG(vec2, result)); + BLOCKING_INVOKE_METHOD(this, "getSize", Q_RETURN_ARG(glm::vec2, result)); return result; } @@ -275,7 +275,7 @@ glm::vec2 QmlWindowClass::getSize() { void QmlWindowClass::setSize(const glm::vec2& size) { if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setSize", Q_ARG(vec2, size)); + QMetaObject::invokeMethod(this, "setSize", Q_ARG(const glm::vec2&, size)); return; } From 1ed7d164c45dcb45be34d8a0633372bbe47502dc Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Thu, 1 Feb 2018 01:15:03 +0300 Subject: [PATCH 2/2] FB11511 - position of log windows should be persistent between invocations of interface --- interface/src/ui/LogDialog.cpp | 12 ++++++- interface/src/ui/LogDialog.h | 4 +++ scripts/developer/debugging/debugWindow.js | 37 ++++++++++++++++++++-- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/LogDialog.cpp b/interface/src/ui/LogDialog.cpp index 00dc9be959..108edbfd39 100644 --- a/interface/src/ui/LogDialog.cpp +++ b/interface/src/ui/LogDialog.cpp @@ -38,7 +38,7 @@ const QString FATAL_TEXT = "[FATAL]"; const QString SUPPRESS_TEXT = "[SUPPRESS]"; const QString UNKNOWN_TEXT = "[UNKNOWN]"; -LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : BaseLogDialog(parent) { +LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : BaseLogDialog(parent), _windowGeometry("logDialogGeometry", QRect()) { _logger = logger; setWindowTitle("Log"); @@ -155,6 +155,11 @@ LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : BaseLog _clearFilterButton->show(); connect(_clearFilterButton, &QPushButton::clicked, this, &LogDialog::handleClearFilterButton); handleClearFilterButton(); + + auto windowGeometry = _windowGeometry.get(); + if (windowGeometry.isValid()) { + setGeometry(windowGeometry); + } } void LogDialog::resizeEvent(QResizeEvent* event) { @@ -173,6 +178,11 @@ void LogDialog::resizeEvent(QResizeEvent* event) { ELEMENT_HEIGHT); } +void LogDialog::closeEvent(QCloseEvent* event) { + BaseLogDialog::closeEvent(event); + _windowGeometry.set(geometry()); +} + void LogDialog::handleRevealButton() { _logger->locateLog(); } diff --git a/interface/src/ui/LogDialog.h b/interface/src/ui/LogDialog.h index 5e4e084d5a..3cc7584fe8 100644 --- a/interface/src/ui/LogDialog.h +++ b/interface/src/ui/LogDialog.h @@ -13,6 +13,7 @@ #define hifi_LogDialog_h #include "BaseLogDialog.h" +#include class QCheckBox; class QPushButton; @@ -44,6 +45,8 @@ private slots: protected: void resizeEvent(QResizeEvent* event) override; + void closeEvent(QCloseEvent* event) override; + QString getCurrentLog() override; void printLogFile(); @@ -62,6 +65,7 @@ private: QString _filterSelection; AbstractLoggerInterface* _logger; + Setting::Handle _windowGeometry; }; #endif // hifi_LogDialog_h diff --git a/scripts/developer/debugging/debugWindow.js b/scripts/developer/debugging/debugWindow.js index 068efb351b..9522676007 100644 --- a/scripts/developer/debugging/debugWindow.js +++ b/scripts/developer/debugging/debugWindow.js @@ -22,14 +22,37 @@ if (scripts.length >= 2) { // Set up the qml ui var qml = Script.resolvePath('debugWindow.qml'); +var HMD_DEBUG_WINDOW_GEOMETRY_KEY = 'hmdDebugWindowGeometry'; +var hmdDebugWindowGeometryValue = Settings.getValue(HMD_DEBUG_WINDOW_GEOMETRY_KEY) + +var windowWidth = 400; +var windowHeight = 900; + +var hasPosition = false; +var windowX = 0; +var windowY = 0; + +if (hmdDebugWindowGeometryValue !== '') { + var geometry = JSON.parse(hmdDebugWindowGeometryValue); + + windowWidth = geometry.width + windowHeight = geometry.height + windowX = geometry.x + windowY = geometry.y + hasPosition = true; +} + var window = new OverlayWindow({ title: 'Debug Window', source: qml, - width: 400, height: 900, + width: windowWidth, height: windowHeight, }); -window.setPosition(25, 50); -window.closed.connect(function() { Script.stop(); }); +if (hasPosition) { + window.setPosition(windowX, windowY); +} + +window.closed.connect(function () { Script.stop(); }); var getFormattedDate = function() { var date = new Date(); @@ -65,6 +88,14 @@ ScriptDiscoveryService.clearDebugWindow.connect(function() { }); Script.scriptEnding.connect(function () { + var geometry = JSON.stringify({ + x: window.position.x, + y: window.position.y, + width: window.size.x, + height: window.size.y + }) + + Settings.setValue(HMD_DEBUG_WINDOW_GEOMETRY_KEY, geometry); window.close(); })