2019-07-08 13:52:41 +10:00
|
|
|
// Copyright 2019 miruka
|
|
|
|
// This file is part of harmonyqml, licensed under LGPLv3.
|
|
|
|
|
2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-05-01 17:25:58 +10:00
|
|
|
import QtQuick.Window 2.7
|
2019-04-29 05:18:36 +10:00
|
|
|
import "Base"
|
|
|
|
import "SidePane"
|
2019-04-28 08:54:33 +10:00
|
|
|
|
2019-07-24 16:14:34 +10:00
|
|
|
HRectangle {
|
2019-04-28 11:07:20 +10:00
|
|
|
id: mainUI
|
2019-07-24 16:14:34 +10:00
|
|
|
color: theme.ui.background
|
2019-07-25 07:40:06 +10:00
|
|
|
Component.onCompleted: window.mainUI = mainUI
|
|
|
|
|
|
|
|
property alias pressAnimation: _pressAnimation
|
|
|
|
|
|
|
|
SequentialAnimation {
|
|
|
|
id: _pressAnimation
|
|
|
|
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 14:44:55 +10:00
|
|
|
|
2019-07-03 03:59:52 +10:00
|
|
|
Connections {
|
|
|
|
target: py
|
2019-07-18 17:13:34 +10:00
|
|
|
onWillLoadAccounts: will => {
|
2019-07-21 22:57:17 +10:00
|
|
|
if (! will) {
|
|
|
|
pageStack.showPage("SignIn")
|
|
|
|
return
|
|
|
|
}
|
2019-07-21 22:54:32 +10:00
|
|
|
|
|
|
|
let page = window.uiState.page
|
|
|
|
let props = window.uiState.pageProperties
|
|
|
|
|
|
|
|
if (page == "Chat/Chat.qml") {
|
|
|
|
pageStack.showRoom(props.userId, props.category, props.roomId)
|
|
|
|
} else {
|
|
|
|
pageStack.show(page, props)
|
|
|
|
}
|
2019-07-03 03:59:52 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-29 08:12:45 +10:00
|
|
|
property bool accountsPresent:
|
2019-07-05 06:01:44 +10:00
|
|
|
accounts.count > 0 || py.loadingAccounts
|
2019-06-27 16:31:03 +10:00
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HImage {
|
2019-07-25 04:58:16 +10:00
|
|
|
visible: Boolean(Qt.resolvedUrl(source))
|
2019-04-28 14:44:55 +10:00
|
|
|
id: mainUIBackground
|
|
|
|
fillMode: Image.PreserveAspectCrop
|
2019-07-25 04:58:16 +10:00
|
|
|
source: theme.ui.image
|
2019-05-01 17:25:58 +10:00
|
|
|
sourceSize.width: Screen.width
|
|
|
|
sourceSize.height: Screen.height
|
2019-04-28 14:44:55 +10:00
|
|
|
anchors.fill: parent
|
2019-06-27 16:31:03 +10:00
|
|
|
asynchronous: false
|
2019-04-28 14:44:55 +10:00
|
|
|
}
|
2019-04-28 08:54:33 +10:00
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HSplitView {
|
2019-05-13 05:57:18 +10:00
|
|
|
id: uiSplitView
|
2019-04-28 08:54:33 +10:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2019-07-18 03:34:02 +10:00
|
|
|
onAnyResizingChanged: if (anyResizing) {
|
|
|
|
sidePane.manuallyResizing = true
|
|
|
|
} else {
|
|
|
|
sidePane.manuallyResizing = false
|
|
|
|
sidePane.manuallyResized = true
|
|
|
|
sidePane.manualWidth = sidePane.width
|
|
|
|
}
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
SidePane {
|
2019-05-13 06:13:00 +10:00
|
|
|
id: sidePane
|
2019-05-13 05:57:18 +10:00
|
|
|
|
2019-07-17 07:08:06 +10:00
|
|
|
// Initial width until user manually resizes
|
|
|
|
width: implicitWidth
|
2019-07-16 23:27:38 +10:00
|
|
|
Layout.minimumWidth: reduce ? 0 : theme.sidePane.collapsedWidth
|
2019-07-18 03:34:02 +10:00
|
|
|
Layout.maximumWidth:
|
|
|
|
window.width -theme.minimumSupportedWidthPlusSpacing
|
2019-07-16 23:27:38 +10:00
|
|
|
|
2019-07-18 03:34:02 +10:00
|
|
|
Behavior on Layout.minimumWidth { HNumberAnimation {} }
|
2019-04-28 08:54:33 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
StackView {
|
2019-04-28 14:44:55 +10:00
|
|
|
id: pageStack
|
2019-07-19 13:59:05 +10:00
|
|
|
property bool isWide: width > theme.contentIsWideAbove
|
2019-04-28 14:44:55 +10:00
|
|
|
|
2019-07-21 21:14:16 +10:00
|
|
|
function show(componentUrl, properties={}) {
|
|
|
|
pageStack.replace(componentUrl, properties)
|
|
|
|
}
|
|
|
|
|
2019-07-18 17:35:30 +10:00
|
|
|
function showPage(name, properties={}) {
|
2019-07-21 22:54:32 +10:00
|
|
|
let path = "Pages/" + name + ".qml"
|
|
|
|
show(path, properties)
|
|
|
|
|
|
|
|
window.uiState.page = path
|
|
|
|
window.uiState.pageProperties = properties
|
|
|
|
window.uiStateChanged()
|
2019-04-28 08:54:33 +10:00
|
|
|
}
|
|
|
|
|
2019-05-03 04:20:21 +10:00
|
|
|
function showRoom(userId, category, roomId) {
|
2019-07-21 22:38:49 +10:00
|
|
|
let roomInfo = rooms.find(userId, category, roomId)
|
|
|
|
show("Chat/Chat.qml", {roomInfo})
|
2019-07-21 22:54:32 +10:00
|
|
|
|
|
|
|
window.uiState.page = "Chat/Chat.qml"
|
|
|
|
window.uiState.pageProperties = {userId, category, roomId}
|
|
|
|
window.uiStateChanged()
|
2019-04-28 14:44:55 +10:00
|
|
|
}
|
2019-04-28 08:54:33 +10:00
|
|
|
|
|
|
|
onCurrentItemChanged: if (currentItem) {
|
|
|
|
currentItem.forceActiveFocus()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Buggy
|
|
|
|
replaceExit: null
|
|
|
|
popExit: null
|
|
|
|
pushExit: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|