Files
clide/qml/ClideLogger.qml

60 lines
1.3 KiB
QML
Raw Normal View History

2026-02-01 20:20:39 -05:00
// SPDX-FileCopyrightText: 2026, Shaun Reed <shaunrd0@gmail.com>
//
// SPDX-License-Identifier: GNU General Public License v3.0 or later
import QtQuick
import QtQuick.Controls
import clide.module 1.0
import Logger 1.0
2026-02-08 14:26:26 -05:00
Rectangle {
color: "#111"
radius: 10
2026-02-02 18:08:37 -05:00
ListModel {
id: model
2026-02-01 20:20:39 -05:00
}
ListView {
id: listView
function getLogColor(level) {
switch (level) {
2026-02-02 18:08:37 -05:00
case "INFO":
return RustColors.info_log;
case "DEBUG":
return RustColors.debug_log;
case "WARN":
return RustColors.warn_log;
case "ERROR":
return RustColors.error_log;
case "TRACE":
return RustColors.trace_log;
default:
return RustColors.info_log;
2026-02-01 20:20:39 -05:00
}
}
2026-02-02 18:08:37 -05:00
anchors.fill: parent
model: model
2026-02-01 20:20:39 -05:00
delegate: Text {
color: listView.getLogColor(level)
2026-02-02 18:08:37 -05:00
font.family: "monospace"
text: `[${level}] ${message}`
2026-02-01 20:20:39 -05:00
}
2026-02-04 18:35:43 -05:00
onCountChanged: Qt.callLater(positionViewAtEnd)
2026-02-01 20:20:39 -05:00
}
Connections {
function onLogged(level, message) {
2026-02-02 18:08:37 -05:00
model.append({
level,
message
});
2026-02-01 20:20:39 -05:00
}
2026-02-02 18:08:37 -05:00
target: Logger
2026-02-01 20:20:39 -05:00
}
}