EvanZhu0721 / 公开仓库
SBMS
SBMS complete the calculation rules for the default logical desktop topology relationship and the physical dimensions of the displays in the Windows multi-screen collaboration system.
文件
../ diagnostics.slint8.2 KBgeometry.slint10.0 KBmain.slint54.1 KBscreen-size.slint9.3 KBstream.slint9.4 KBui/pages/diagnostics.slint8.2 KB
1
import { ScrollView } from "std-widgets.slint";2
import { BackButton, FullWidthPrimaryButton } from "../controls.slint";3
import { MdTokens } from "../theme.slint";4
5
export component DiagnosticsPage inherits FocusScope {6
in property <string> diagnostic-summary: "";7
in property <string> diagnostic-text: "No diagnostic records are available.";8
in property <string> diagnostic-path: "";9
in property <string> diagnostic-action-error: "";10
11
callback close-diagnostics();12
callback open-log-folder();13
14
key-pressed(event) => {15
if event.text == Key.Escape {16
root.close-diagnostics();17
return accept;18
}19
return reject;20
}21
22
Rectangle {23
width: parent.width;24
height: parent.height;25
background: MdTokens.surface;26
27
VerticalLayout {28
padding: MdTokens.space-2;29
spacing: MdTokens.space-1;30
31
HorizontalLayout {32
height: MdTokens.target;33
spacing: MdTokens.space-1;34
35
BackButton {36
accessible-label: "Back to quick access";37
clicked => { root.close-diagnostics(); }38
}39
40
Text {41
text: "Diagnostics";42
color: MdTokens.on-surface;43
font-size: MdTokens.type-title-large;44
font-weight: MdTokens.weight-medium;45
vertical-alignment: center;46
}47
}48
49
if root.diagnostic-summary != "" : Rectangle {50
height: 88px;51
background: MdTokens.error-container;52
border-radius: MdTokens.shape-medium;53
54
VerticalLayout {55
padding: 12px;56
spacing: 4px;57
58
Text {59
text: "Last recorded error";60
color: MdTokens.on-error-container;61
font-size: MdTokens.type-title-medium;62
font-weight: MdTokens.weight-medium;63
}64
65
TextInput {66
text: root.diagnostic-summary;67
read-only: true;68
single-line: false;69
wrap: word-wrap;70
color: MdTokens.on-error-container;71
selection-background-color: MdTokens.on-error-container;72
selection-foreground-color: MdTokens.error-container;73
font-size: MdTokens.type-body-small;74
}75
}76
}77
78
HorizontalLayout {79
height: 24px;80
spacing: MdTokens.space-1;81
82
Text {83
horizontal-stretch: 1;84
text: "Recent activity";85
color: MdTokens.on-surface;86
font-size: MdTokens.type-body-medium;87
font-weight: MdTokens.weight-medium;88
vertical-alignment: center;89
}90
91
Text {92
width: 176px;93
text: root.diagnostic-path;94
color: MdTokens.on-surface-variant;95
font-size: MdTokens.type-body-small;96
horizontal-alignment: right;97
vertical-alignment: center;98
overflow: elide;99
accessible-label: "Log file " + root.diagnostic-path;100
}101
}102
103
Rectangle {104
vertical-stretch: 1;105
background: MdTokens.surface-container;106
border-radius: 4px;107
border-width: 1px;108
border-color: log-input.has-focus ? MdTokens.primary : MdTokens.outline-variant;109
clip: true;110
111
ContextMenuArea {112
Menu {113
MenuItem {114
title: "Copy";115
activated => { log-input.copy(); }116
}117
MenuItem {118
title: "Select All";119
activated => { log-input.select-all(); }120
}121
}122
123
log-scroll := ScrollView {124
// Drag selects text; the wheel and scrollbar still scroll.125
mouse-drag-pan-enabled: false;126
viewport-width: self.visible-width;127
viewport-height: max(self.visible-height, log-input.preferred-height + 16px);128
129
log-input := TextInput {130
x: 8px;131
y: 8px;132
width: log-scroll.visible-width - 16px;133
text: root.diagnostic-text;134
read-only: true;135
single-line: false;136
wrap: word-wrap;137
page-height: log-scroll.visible-height;138
font-size: MdTokens.type-body-small;139
font-family: "Cascadia Mono";140
color: MdTokens.on-surface;141
selection-background-color: MdTokens.primary-container;142
selection-foreground-color: MdTokens.on-primary-container;143
accessible-label: "Recent diagnostic records. Text can be selected and copied.";144
145
cursor-position-changed(cpos) => {146
if (cpos.y + self.y + log-scroll.viewport-y < 0px) {147
log-scroll.viewport-y = min(148
0px,149
max(log-scroll.visible-height - log-scroll.viewport-height, -(cpos.y + self.y)),150
);151
} else if (cpos.y + self.y + log-scroll.viewport-y > log-scroll.visible-height - 20px) {152
log-scroll.viewport-y = min(153
0px,154
max(log-scroll.visible-height - log-scroll.viewport-height, log-scroll.visible-height - (cpos.y + self.y) - 20px),155
);156
}157
}158
}159
}160
}161
}162
163
Text {164
height: root.diagnostic-action-error == "" ? 0px : 18px;165
visible: root.diagnostic-action-error != "";166
text: root.diagnostic-action-error;167
color: MdTokens.error;168
font-size: MdTokens.type-body-small;169
overflow: elide;170
}171
172
FullWidthPrimaryButton {173
text: "Open log folder";174
accessible-label: "Open the SBMS diagnostic log folder";175
clicked => { root.open-log-folder(); }176
}177
}178
}179
}180