2020-09-23 19:57:54 -04:00
|
|
|
// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
|
2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-07-13 05:39:01 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2020-03-16 09:04:59 -04:00
|
|
|
import QtQuick.Window 2.12
|
2019-08-30 19:21:51 -04:00
|
|
|
import QtGraphicalEffects 1.12
|
2021-02-28 10:53:19 -04:00
|
|
|
import "."
|
2019-04-28 15:18:36 -04:00
|
|
|
import "Base"
|
2019-12-10 15:17:41 -04:00
|
|
|
import "MainPane"
|
2021-04-14 15:15:51 -04:00
|
|
|
import "Popups"
|
2019-04-27 18:54:33 -04:00
|
|
|
|
2019-08-30 19:09:21 -04:00
|
|
|
Item {
|
2019-04-27 21:07:20 -04:00
|
|
|
id: mainUI
|
2019-12-18 17:00:02 -04:00
|
|
|
|
2021-02-28 10:53:19 -04:00
|
|
|
enum NotificationLevel { Mute, HighlightsOnly, Enable }
|
|
|
|
|
|
|
|
property int notificationLevel:
|
|
|
|
settings.Notifications.start_level === "highlights_only" ?
|
|
|
|
UI.NotificationLevel.HighlightsOnly :
|
|
|
|
settings.Notifications.start_level === "mute" ?
|
|
|
|
UI.NotificationLevel.Mute :
|
|
|
|
UI.NotificationLevel.Enable
|
|
|
|
|
2019-12-18 17:00:02 -04:00
|
|
|
property bool accountsPresent:
|
2019-12-02 16:29:29 -04:00
|
|
|
ModelStore.get("accounts").count > 0 || py.startupAnyAccountsSaved
|
2019-12-18 17:00:02 -04:00
|
|
|
|
2020-04-03 06:13:45 -04:00
|
|
|
readonly property var accountIds: {
|
|
|
|
const ids = []
|
|
|
|
const model = ModelStore.get("accounts")
|
|
|
|
|
|
|
|
for (let i = 0; i < model.count; i++)
|
|
|
|
ids.push(model.get(i).id)
|
|
|
|
|
|
|
|
return ids
|
|
|
|
}
|
|
|
|
|
2020-03-28 07:18:00 -04:00
|
|
|
readonly property alias debugConsole: debugConsole
|
2019-12-10 15:17:41 -04:00
|
|
|
readonly property alias mainPane: mainPane
|
2019-09-17 16:30:04 -04:00
|
|
|
readonly property alias pageLoader: pageLoader
|
2021-04-14 15:15:51 -04:00
|
|
|
readonly property alias unexpectedErrorPopup: unexpectedErrorPopup
|
2020-05-16 14:28:29 -04:00
|
|
|
readonly property alias fontMetrics: fontMetrics
|
2020-07-11 00:51:53 -04:00
|
|
|
readonly property alias idleManager: idleManager
|
2019-12-18 17:00:02 -04:00
|
|
|
|
2020-07-12 00:25:57 -04:00
|
|
|
focus: true
|
|
|
|
Component.onCompleted: window.mainUI = mainUI
|
|
|
|
|
2020-03-28 07:18:00 -04:00
|
|
|
HShortcut {
|
2020-10-07 20:12:32 -04:00
|
|
|
sequences: window.settings.Keys.python_debugger
|
2020-03-28 07:18:00 -04:00
|
|
|
onActivated: py.call("BRIDGE.pdb")
|
2019-12-19 13:41:57 -04:00
|
|
|
}
|
|
|
|
|
2021-01-16 08:15:49 -04:00
|
|
|
HShortcut {
|
|
|
|
sequences: window.settings.Keys.python_remote_debugger
|
|
|
|
onActivated: py.call("BRIDGE.pdb", [[], true])
|
|
|
|
}
|
|
|
|
|
2020-03-28 07:18:00 -04:00
|
|
|
HShortcut {
|
2020-10-07 20:12:32 -04:00
|
|
|
sequences: window.settings.Keys.zoom_in
|
2020-09-01 14:19:40 -04:00
|
|
|
onActivated: {
|
2020-10-07 20:12:32 -04:00
|
|
|
window.settings.General.zoom += 0.1
|
|
|
|
window.saveSettings()
|
2020-09-01 14:19:40 -04:00
|
|
|
}
|
2020-03-28 07:18:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
2020-10-07 20:12:32 -04:00
|
|
|
sequences: window.settings.Keys.zoom_out
|
2020-09-01 14:19:40 -04:00
|
|
|
onActivated: {
|
2020-10-07 20:12:32 -04:00
|
|
|
window.settings.General.zoom =
|
|
|
|
Math.max(0.1, window.settings.General.zoom - 0.1)
|
|
|
|
|
|
|
|
window.saveSettings()
|
2020-09-01 14:19:40 -04:00
|
|
|
}
|
2020-03-28 07:18:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
2020-10-07 20:12:32 -04:00
|
|
|
sequences: window.settings.Keys.reset_zoom
|
2020-09-01 14:19:40 -04:00
|
|
|
onActivated: {
|
2020-10-07 20:12:32 -04:00
|
|
|
window.settings.General.zoom = 1
|
|
|
|
window.saveSettings()
|
2020-09-01 14:19:40 -04:00
|
|
|
}
|
2020-03-28 07:18:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
2020-10-07 20:12:32 -04:00
|
|
|
sequences: window.settings.Keys.compact
|
2020-03-28 07:18:00 -04:00
|
|
|
onActivated: {
|
2020-10-07 20:12:32 -04:00
|
|
|
window.settings.General.compact = ! window.settings.General.compact
|
2021-01-19 12:16:05 -04:00
|
|
|
window.saveSettings()
|
2020-03-28 07:18:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-31 01:20:59 +02:00
|
|
|
HShortcut {
|
|
|
|
sequences: window.settings.Keys.quit
|
|
|
|
onActivated: Qt.quit()
|
|
|
|
}
|
|
|
|
|
2021-02-28 10:53:19 -04:00
|
|
|
HShortcut {
|
|
|
|
sequences: window.settings.Keys.notifications_highlights_only
|
|
|
|
onActivated:
|
|
|
|
mainUI.notificationLevel =
|
|
|
|
mainUI.notificationLevel ===
|
|
|
|
UI.NotificationLevel.HighlightsOnly ?
|
|
|
|
UI.NotificationLevel.Enable :
|
|
|
|
UI.NotificationLevel.HighlightsOnly
|
|
|
|
}
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
sequences: window.settings.Keys.notifications_mute
|
|
|
|
onActivated:
|
|
|
|
mainUI.notificationLevel =
|
|
|
|
mainUI.notificationLevel === UI.NotificationLevel.Mute ?
|
|
|
|
UI.NotificationLevel.Enable :
|
|
|
|
UI.NotificationLevel.Mute
|
|
|
|
}
|
|
|
|
|
2020-05-16 14:28:29 -04:00
|
|
|
FontMetrics {
|
|
|
|
id: fontMetrics
|
|
|
|
font.family: theme.fontFamily.sans
|
|
|
|
font.pixelSize: theme.fontSize.normal
|
|
|
|
font.pointSize: -1
|
|
|
|
}
|
|
|
|
|
2020-07-11 00:51:53 -04:00
|
|
|
IdleManager {
|
|
|
|
id: idleManager
|
|
|
|
}
|
|
|
|
|
2021-02-28 13:59:36 -04:00
|
|
|
DebugConsole {
|
|
|
|
id: debugConsole
|
|
|
|
target: mainUI
|
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
|
2019-08-30 19:21:51 -04:00
|
|
|
LinearGradient {
|
2019-08-28 19:34:50 -04:00
|
|
|
id: mainUIGradient
|
2020-03-19 00:13:38 -04:00
|
|
|
visible: ! image.visible
|
2019-08-28 19:34:50 -04:00
|
|
|
anchors.fill: parent
|
2019-08-30 19:21:51 -04:00
|
|
|
start: theme.ui.gradientStart
|
|
|
|
end: theme.ui.gradientEnd
|
|
|
|
|
2019-08-28 19:34:50 -04:00
|
|
|
gradient: Gradient {
|
2019-08-30 19:21:51 -04:00
|
|
|
GradientStop { position: 0.0; color: theme.ui.gradientStartColor }
|
|
|
|
GradientStop { position: 1.0; color: theme.ui.gradientEndColor }
|
2019-08-28 19:34:50 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-19 00:13:38 -04:00
|
|
|
HImage {
|
|
|
|
id: image
|
|
|
|
visible: Boolean(Qt.resolvedUrl(source))
|
|
|
|
fillMode: Image.PreserveAspectCrop
|
2020-07-17 07:26:31 -04:00
|
|
|
animatedFillMode: AnimatedImage.PreserveAspectCrop
|
2020-03-19 00:13:38 -04:00
|
|
|
source: theme.ui.image
|
|
|
|
sourceSize.width: Screen.width
|
|
|
|
sourceSize.height: Screen.height
|
|
|
|
anchors.fill: parent
|
|
|
|
asynchronous: false
|
|
|
|
}
|
|
|
|
|
2019-12-10 15:17:41 -04:00
|
|
|
MainPane {
|
|
|
|
id: mainPane
|
2019-12-21 13:12:02 -04:00
|
|
|
maximumSize: parent.width - theme.minimumSupportedWidth * 1.5
|
2021-04-09 01:55:12 -04:00
|
|
|
|
|
|
|
// Drawers (side panes) are actually Popups, which are considered to be
|
|
|
|
// different "layer". Input handlers will only get events occuring
|
|
|
|
// in the layer they were declared in.
|
|
|
|
GlobalTapHandlers { pageLoader: pageLoader }
|
2019-12-08 14:43:41 -04:00
|
|
|
}
|
2019-04-27 18:54:33 -04:00
|
|
|
|
2019-12-18 17:00:02 -04:00
|
|
|
PageLoader {
|
2019-12-08 14:43:41 -04:00
|
|
|
id: pageLoader
|
|
|
|
anchors.fill: parent
|
2020-07-14 03:31:01 -04:00
|
|
|
anchors.leftMargin:
|
|
|
|
mainPane.requireDefaultSize &&
|
|
|
|
mainPane.minimumSize > mainPane.maximumSize ?
|
2020-07-14 16:01:51 -04:00
|
|
|
mainPane.calculatedSizeNoRequiredMinimum :
|
2020-07-14 03:31:01 -04:00
|
|
|
mainPane.visibleSize
|
|
|
|
|
2020-07-14 03:56:58 -04:00
|
|
|
visible: mainPane.visibleSize < mainUI.width
|
2021-04-09 01:55:12 -04:00
|
|
|
|
|
|
|
GlobalTapHandlers { pageLoader: parent }
|
2019-09-17 16:30:04 -04:00
|
|
|
}
|
2021-04-14 15:15:51 -04:00
|
|
|
|
|
|
|
UnexpectedErrorPopup {
|
|
|
|
id: unexpectedErrorPopup
|
|
|
|
}
|
2019-04-27 18:54:33 -04:00
|
|
|
}
|