moment/src/gui/UI.qml

144 lines
3.6 KiB
QML
Raw Normal View History

2019-12-19 07:46:16 -04:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtQuick.Window 2.12
import QtGraphicalEffects 1.12
import "Base"
2019-12-10 15:17:41 -04:00
import "MainPane"
Item {
2019-04-27 21:07:20 -04:00
id: mainUI
property bool accountsPresent:
ModelStore.get("accounts").count > 0 || py.startupAnyAccountsSaved
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
}
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
readonly property alias pressAnimation: pressAnimation
readonly property alias fontMetrics: fontMetrics
2020-07-11 00:51:53 -04:00
readonly property alias idleManager: idleManager
function reloadSettings() {
py.loadSettings(() => { mainUI.pressAnimation.start() })
}
focus: true
Component.onCompleted: window.mainUI = mainUI
SequentialAnimation {
id: pressAnimation
2019-12-16 04:42:41 -04:00
HNumberAnimation {
target: mainUI; property: "scale"; from: 1.0; to: 0.9
}
HNumberAnimation {
target: mainUI; property: "scale"; from: 0.9; to: 1.0
}
}
2019-04-28 00:44:55 -04:00
HShortcut {
sequences: window.settings.keys.startPythonDebugger
onActivated: py.call("BRIDGE.pdb")
}
HShortcut {
sequences: window.settings.keys.reloadConfig
onActivated: reloadSettings()
}
HShortcut {
sequences: window.settings.keys.zoomIn
onActivated: theme.uiScale += 0.1
}
HShortcut {
sequences: window.settings.keys.zoomOut
onActivated: theme.uiScale = Math.max(0.1, theme.uiScale - 0.1)
}
HShortcut {
sequences: window.settings.keys.zoomReset
onActivated: theme.uiScale = 1
}
HShortcut {
sequences: window.settings.keys.toggleCompactMode
onActivated: {
settings.compactMode = ! settings.compactMode
settingsChanged()
}
}
FontMetrics {
id: fontMetrics
font.family: theme.fontFamily.sans
font.pixelSize: theme.fontSize.normal
font.pointSize: -1
}
DebugConsole {
id: debugConsole
target: mainUI
visible: false
}
2020-07-11 00:51:53 -04:00
IdleManager {
id: idleManager
}
LinearGradient {
id: mainUIGradient
2020-03-19 00:13:38 -04:00
visible: ! image.visible
anchors.fill: parent
start: theme.ui.gradientStart
end: theme.ui.gradientEnd
gradient: Gradient {
GradientStop { position: 0.0; color: theme.ui.gradientStartColor }
GradientStop { position: 1.0; color: theme.ui.gradientEndColor }
}
}
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
maximumSize: parent.width - theme.minimumSupportedWidth * 1.5
}
PageLoader {
id: pageLoader
anchors.fill: parent
anchors.leftMargin:
mainPane.requireDefaultSize &&
mainPane.minimumSize > mainPane.maximumSize ?
mainPane.calculatedSizeNoRequiredMinimum :
mainPane.visibleSize
visible: mainPane.visibleSize < mainUI.width
2019-09-17 16:30:04 -04:00
}
}