feat(general): Initial setup for app monitoring tool

Closes: #8786
This commit is contained in:
Michał Cieślak 2023-01-04 17:05:07 +01:00 committed by Michał
parent 766496575e
commit e3e99c6a48
7 changed files with 141 additions and 1 deletions

View File

@ -147,6 +147,12 @@ else
DOTHERSIDE_BUILD_CMD := cmake --build . --config Release $(HANDLE_OUTPUT) DOTHERSIDE_BUILD_CMD := cmake --build . --config Release $(HANDLE_OUTPUT)
endif endif
MONITORING ?= false
ifneq ($(MONITORING), false)
DOTHERSIDE_CMAKE_PARAMS := ${DOTHERSIDE_CMAKE_PARAMS} -DMONITORING:BOOL=ON -DMONITORING_QML_ENTRY_POINT:STRING="/../monitoring/Main.qml"
endif
# Qt5 dirs (we can't indent with tabs here) # Qt5 dirs (we can't indent with tabs here)
ifneq ($(detected_OS),Windows) ifneq ($(detected_OS),Windows)
QT5_LIBDIR := $(shell qmake -query QT_INSTALL_LIBS 2>/dev/null) QT5_LIBDIR := $(shell qmake -query QT_INSTALL_LIBS 2>/dev/null)

View File

@ -0,0 +1,44 @@
import QtQuick 2.14
QtObject {
id: root
property string source
property bool rethrowErrors: true
readonly property alias component: d.component
readonly property alias errors: d.errors // QQmlError
onSourceChanged: d.createComponent()
readonly property QtObject _d: QtObject {
id: d
property Component component
property var errors: null
function createComponent() {
if (component) {
component.destroy()
component = null
}
try {
component = Qt.createQmlObject(root.source,
this,
"HotComponentFromSource_dynamicSnippet"
)
d.errors = null
} catch (e) {
d.errors = e
if (root.rethrowErrors)
throw e
}
}
}
Component.onCompleted: {
if (root.source)
d.createComponent()
}
}

13
monitoring/HotLoader.qml Normal file
View File

@ -0,0 +1,13 @@
import QtQuick 2.14
Loader {
sourceComponent: hotComponent.component
property alias source: hotComponent.source
property alias rethrowErrors: hotComponent.rethrowErrors
readonly property alias errors: hotComponent.errors
HotComponentFromSource {
id: hotComponent
}
}

35
monitoring/Main.qml Normal file
View File

@ -0,0 +1,35 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
ApplicationWindow {
id: monitorRoot
width: 800
height: 600
visible: true
title: "Status Monitor"
Timer {
interval: 1000
running: true
repeat: true
onTriggered: {
const xhr = new XMLHttpRequest()
xhr.open("GET", "MonitorEntryPoint.qml", false)
xhr.send()
const content = xhr.responseText
if (loader.source != content)
loader.source = content
}
}
HotLoader {
id: loader
anchors.fill: parent
}
}

View File

@ -0,0 +1,40 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import Monitoring 1.0
Component {
ColumnLayout {
anchors.fill: parent
anchors.margins: 10
spacing: 15
Label {
Layout.fillWidth: true
text: "Context properties:"
font.bold: true
}
ListView {
id: lv
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
model: Monitor.contexPropertiesNames
spacing: 5
delegate: Text {
text: modelData
}
}
}
}

View File

@ -16,6 +16,7 @@ lupdate_only{
SOURCES += $$files("$$PWD/*qmldir", true) SOURCES += $$files("$$PWD/*qmldir", true)
SOURCES += $$files("$$PWD/*.qml", true) SOURCES += $$files("$$PWD/*.qml", true)
SOURCES += $$files("$$PWD/*.js", true) SOURCES += $$files("$$PWD/*.js", true)
SOURCES += $$files("$$PWD/../monitoring/*.qml", true)
} }
# Other *.ts files will be provided by Lokalise platform # Other *.ts files will be provided by Lokalise platform
@ -28,6 +29,7 @@ OTHER_FILES += $$files("$$PWD/*qmldir", true)
OTHER_FILES += $$files("$$PWD/*.qml", true) OTHER_FILES += $$files("$$PWD/*.qml", true)
OTHER_FILES += $$files("$$PWD/*.js", true) OTHER_FILES += $$files("$$PWD/*.js", true)
OTHER_FILES += $$files("$$PWD/../src/*.nim", true) OTHER_FILES += $$files("$$PWD/../src/*.nim", true)
OTHER_FILES += $$files("$$PWD/../monitoring/*.qml", true)
# Additional import path used to resolve QML modules in Qt Creator's code model # Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH = $$PWD/imports \ QML_IMPORT_PATH = $$PWD/imports \

2
vendor/DOtherSide vendored

@ -1 +1 @@
Subproject commit 742a139b07338f23390b5d6ee84924424bbc8974 Subproject commit 7f2dd438325925ae3db073e19eec63a49253e735