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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
|
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import Qt.labs.platform 1.1 as Pf
import Theme 1.0
import QFlipper 1.0
Item {
id: mainWindow
signal expandStarted
signal expandFinished
signal collapseStarted
signal collapseFinished
signal resizeStarted
signal resizeFinished
property alias controls: windowControls
readonly property int baseWidth: 830
readonly property int baseHeight: 500
readonly property int logHeight: 200
readonly property int minimumLogHeight: 200
readonly property int shadowSize: 16
readonly property int shadowOffset: 4
readonly property var deviceState: Backend.deviceState
readonly property var deviceInfo: deviceState ? deviceState.info : undefined
Component.onCompleted: {
if(App.updateStatus === App.CanUpdate) {
askForSelfUpdate();
} else {
App.updateStatusChanged.connect(askForSelfUpdate);
}
}
width: baseWidth
height: baseHeight
x: shadowSize
y: shadowSize - shadowOffset
Pf.Menu {
Pf.MenuItem {
text: qsTr("Check for updates")
role: Pf.MenuItem.ApplicationSpecificRole
shortcut: "Ctrl+U"
onTriggered: App.checkForUpdates()
}
Pf.MenuItem {
text: qsTr("Refresh firmware")
role: Pf.MenuItem.ApplicationSpecificRole
shortcut: "Ctrl+R"
onTriggered: Backend.checkFirmwareUpdates()
}
}
PropertyAnimation {
id: logExpand
duration: 500
target: mainWindow
property: "height"
to: target.baseHeight + logHeight
easing.type: Easing.InOutQuad
onStarted: mainWindow.expandStarted()
onFinished: mainWindow.expandFinished()
}
PropertyAnimation {
id: logCollapse
target: logExpand.target
easing: logExpand.easing
duration: logExpand.duration
property: logExpand.property
to: target.baseHeight
onStarted: mainWindow.collapseStarted()
onFinished: mainWindow.collapseFinished()
}
ConfirmationDialog {
id: confirmationDialog
radius: bg.radius
parent: bg
}
SelfUpdateDialog {
id: selfUpdateDialog
radius: bg.radius
parent: bg
}
WindowShadow {
id: shadow
anchors.fill: mainWindow
anchors.margins: -mainWindow.shadowSize
anchors.topMargin: -(mainWindow.shadowSize - mainWindow.shadowOffset)
anchors.bottomMargin: -(mainWindow.shadowSize + mainWindow.shadowOffset)
opacity: 0.75
}
Rectangle {
id: blackBorder
anchors.fill: parent
anchors.margins: -1
radius: bg.radius + 1
opacity: 0.5
color: "black"
}
Rectangle {
id: bg
radius: 10
anchors.fill: parent
color: "black"
border.color: Theme.color.mediumorange3
border.width: 2
}
WindowControls {
id: windowControls
closeEnabled: Backend.backendState <= ApplicationBackend.ScreenStreaming ||
Backend.backendState >= ApplicationBackend.Finished
controlPath: "qrc:/assets/gfx/controls"
anchors.top: mainWindow.top
anchors.left: mainContent.left
anchors.right: mainContent.right
anchors.bottom: mainContent.top
anchors.topMargin: bg.border.width
}
GridBackground {
id: mainContent
anchors.horizontalCenter: parent.horizontalCenter
y: 38
width: 800 + border.width * 2
height: 390 + border.width * 2
TextLabel {
id: versionLabel
anchors.top: parent.top
anchors.right: parent.right
anchors.margins: 10
anchors.rightMargin: 16
color: Theme.color.lightorange2
opacity: 0.5
font.family: "ProggySquareTT"
font.pixelSize: 16
text: App.version
// TODO: Implement copy version to clipboard
}
DeviceWidget {
id: deviceWidget
opacity: Backend.backendState !== ApplicationBackend.ScreenStreaming &&
Backend.backendState !== ApplicationBackend.ErrorOccured ? 1 : 0
x: Backend.backendState === ApplicationBackend.Ready ? Math.round(mainContent.width / 2) : 216
y: 82
onScreenStreamRequested: Backend.startFullScreenStreaming()
}
NoDeviceOverlay {
id: noDeviceOverlay
anchors.fill: parent
opacity: Backend.backendState === ApplicationBackend.WaitingForDevices ? 1 : 0
}
HomeOverlay {
id: homeOverlay
backgroundRect: bg
anchors.fill: parent
opacity: Backend.backendState === ApplicationBackend.Ready ? 1 : 0
}
UpdateOverlay {
id: updateOverlay
backgroundRect: bg
anchors.fill: parent
opacity: Backend.backendState > ApplicationBackend.ScreenStreaming &&
Backend.backendState < ApplicationBackend.Finished ? 1 : 0
}
FinishOverlay {
id: finishOverlay
backgroundRect: bg
anchors.fill: parent
opacity: Backend.backendState === ApplicationBackend.Finished ||
Backend.backendState === ApplicationBackend.ErrorOccured ? 1 : 0
}
StreamOverlay {
id: streamOverlay
anchors.fill: parent
opacity: Backend.backendState === ApplicationBackend.ScreenStreaming ? 1 : 0
}
}
RowLayout {
id: footerLayour
width: mainContent.width
height: 42
spacing: 15
anchors.horizontalCenter: mainContent.horizontalCenter
anchors.top: mainContent.bottom
anchors.topMargin: 13
Button {
id: logButton
text: qsTr("LOGS")
Layout.preferredWidth: 110
Layout.fillHeight: true
icon.source: checked ? "qrc:/assets/gfx/symbolic/arrow-up.svg" :
"qrc:/assets/gfx/symbolic/arrow-down.svg"
icon.width: 24
icon.height: 24
checkable: true
Image {
x: parent.width - width / 2 - 1
y: -height / 2 + 1
source: "qrc:/assets/gfx/images/alert-badge.svg"
sourceSize: Qt.size(18, 18)
visible: Logger.errorCount > 0 && !logButton.checked
}
onCheckedChanged: {
Logger.errorCount = 0;
if(checked) {
if(!logCollapse.running) {
logExpand.start();
} else {
checked = false;
}
} else {
if(!logExpand.running) {
logCollapse.start();
} else {
checked = true;
}
}
}
}
StatusBar {
id: statusBar
Layout.fillWidth: true
Layout.fillHeight: true
}
}
TextView {
id: logView
visible: height > 0
anchors.top: footerLayour.bottom
anchors.left: mainContent.left
anchors.right: mainContent.right
anchors.bottom: parent.bottom
anchors.topMargin: 14
anchors.bottomMargin: 28
content.textFormat: TextArea.RichText
content.text: Logger.logText
menu: Menu {
id: logMenu
width: 170
MenuItem {
text: "Select all"
onTriggered: logView.content.selectAll()
}
MenuItem {
text: "Copy to clipboard"
onTriggered: logView.content.copy()
}
MenuItem {
text: "Browse all logs..."
onTriggered: Qt.openUrlExternally(Logger.logsPath)
}
}
}
MouseArea {
id: resizer
property int prevMouseY
width: parent.width
height: 28
visible: logView.visible && !logCollapse.running && !logExpand.running
cursorShape: Qt.SizeVerCursor
anchors.bottom: parent.bottom
preventStealing: true
onPressed: {
prevMouseY = mouseY;
mainWindow.resizeStarted();
}
onReleased: mainWindow.resizeFinished()
onMouseYChanged: {
const dy = mouseY - prevMouseY;
mainWindow.height = Math.max(mainWindow.height + dy, mainWindow.baseHeight + mainWindow.minimumLogHeight);
}
}
Text {
id: fullLogButton
visible: opacity
opacity: resizer.visible
text: "<a href=\"#\">%1</a>".arg(qsTr("Open Full Log"))
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 6
font.pixelSize: 14
font.family: "Share Tech"
font.capitalization: Font.AllUppercase
color: Theme.color.lightorange2
linkColor: Theme.color.lightorange2
onLinkActivated: Qt.openUrlExternally(Logger.logsFile)
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
cursorShape: Qt.PointingHandCursor
}
Behavior on opacity {
PropertyAnimation {
duration: 200
easing.type: Easing.OutCubic
}
}
}
function askForSelfUpdate() {
if(App.updateStatus === App.CanUpdate) {
selfUpdateDialog.open();
}
}
}
|