blob: 6f8ea0e55f840c3e29886112e4e32ee3932a20bf (
plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
pragma ComponentBehavior: Bound
import QtQuick
import QtApplicationManager.SystemUI
Window {
title: "Minidesk - QtApplicationManager Example"
width: 1024
height: 640
color: "whitesmoke"
Readme {}
Text {
anchors.bottom: parent.bottom
text: `${ApplicationManager.singleProcess ? "Single" : "Multi"}-process mode | ${PackageManager.architecture}`
}
// Application launcher panel
Column {
Repeater {
model: ApplicationManager
Image {
required property string icon
required property bool isRunning
required property ApplicationObject application
source: icon
opacity: isRunning ? 0.3 : 1.0
MouseArea {
anchors.fill: parent
onClicked: parent.isRunning ? parent.application.stop() : parent.application.start("documentUrl");
}
}
}
}
// System UI chrome for applications
Repeater {
model: ListModel { id: topLevelWindowsModel }
delegate: FocusScope {
id: winChrome
required property int index
required property WindowObject window
width: chromeImg.width
height: chromeImg.height
z: index
Image {
id: chromeImg
source: winChrome.activeFocus ? "chrome-active.png" : "chrome-bg.png"
Text {
anchors.horizontalCenter: parent.horizontalCenter
y: (25 - contentHeight) / 2
color: "white"
text: "Decoration: " + (winChrome.window.application?.names["en"] ?? 'External Application')
}
MouseArea {
width: chromeImg.width; height: 25
drag.target: winChrome
onPressed: winItem.forceActiveFocus();
}
Image {
source: "close.png"
MouseArea {
anchors.fill: parent
onClicked: winChrome.window.close();
}
}
}
WindowItem {
id: winItem
anchors.fill: parent
anchors.margins: 3
anchors.topMargin: 25
window: winChrome.window
Connections {
target: winChrome.window
function onContentStateChanged() {
if (winChrome.window.contentState === WindowObject.NoSurface)
topLevelWindowsModel.remove(winChrome.index, 1);
}
}
}
onFocusChanged: (focus) => {
if (focus)
topLevelWindowsModel.move(winChrome.index, topLevelWindowsModel.count - 1, 1);
}
Component.onCompleted: {
x = 300 + winChrome.index * 50;
y = 10 + winChrome.index * 30;
winItem.forceActiveFocus();
}
}
}
// System UI for a pop-up
WindowItem {
id: popUpContainer
z: 9998
width: 200; height: 60
anchors.centerIn: parent
Connections {
target: popUpContainer.window
function onContentStateChanged() {
if (popUpContainer.window.contentState === WindowObject.NoSurface)
popUpContainer.window = null;
}
}
}
// System UI for a notification
Text {
z: 9999
font.pixelSize: 46
anchors.centerIn: parent
text: NotificationManager.count > 0 ? NotificationManager.get(0).summary : ""
}
// Handler for WindowManager signals
Connections {
target: WindowManager
function onWindowAdded(window) {
if (window.windowProperty("type") === "pop-up") {
popUpContainer.window = window;
} else {
topLevelWindowsModel.append({"window": window});
window.setWindowProperty("propA", 42);
}
}
function onWindowPropertyChanged(window, name, value) {
console.log("SystemUI: OnWindowPropertyChanged [" + window + "] - " + name + ": " + value);
}
}
}
|