-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
87 lines (74 loc) · 2.67 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.1
ApplicationWindow {
visible: true
width: 800
height: 400
title: "应用监控"
property var windowManagerModel
Component.onCompleted: {
windowManagerModel = windowManager; // 假设 windowManager 是 WindowManager 实例
}
Column {
anchors.fill: parent
// 前端应用表头
Row {
spacing: 10
width: parent.width
height: 40
Text { text: "应用名称"; width: parent.width / 2 }
Text { text: "窗口id"; width: parent.width / 4}
Text { text: "运行时长"; width: parent.width / 4 }
}
ListView {
id: listView
anchors.fill: parent;
anchors.topMargin: 30
model: windowManagerModel
delegate: Item {
width: listView.width
height: 30
property var startTime: model.startTime
Timer {
id: timer
interval: 1000
running: true
repeat: true
onTriggered: {
var now = new Date();
var elapsedTime = now - startTime;
var hours = Math.floor(elapsedTime / (1000 * 60 * 60));
elapsedTime %= (1000 * 60 * 60);
var minutes = Math.floor(elapsedTime / (1000 * 60));
elapsedTime %= (1000 * 60);
var seconds = Math.floor(elapsedTime / 1000);
var displayText = "";
displayText += (hours < 10 ? "0" + hours : hours) + "h:";
displayText += (minutes < 10 ? "0" + minutes : minutes) + "m:";
displayText += (seconds < 10 ? "0" + seconds : seconds) + "s";
elapsedTimeText.text = displayText;
}
}
Row {
width: parent.width
height: parent.height
spacing: 10
Text {
text: name // 使用模型角色
width: listView.width / 2
}
Text {
text: id // 使用模型角色
width: listView.width / 4
}
Text {
id: elapsedTimeText
text: "00h:00m:00s"
width: listView.width / 4
}
}
}
}
}
}