Spectral/qml/main.qml

170 lines
4.3 KiB
QML
Raw Normal View History

import QtQuick 2.11
import QtQuick.Controls 2.4
2018-07-09 02:45:26 +00:00
import QtQuick.Layouts 1.11
import QtQuick.Controls.Material 2.4
2018-02-23 14:39:14 +00:00
import QtGraphicalEffects 1.0
import Qt.labs.settings 1.0
import Qt.labs.platform 1.0 as Platform
2018-02-23 14:39:14 +00:00
import Matrique 0.1
import "component"
import "form"
2018-02-23 14:39:14 +00:00
ApplicationWindow {
id: window
visible: true
width: 960
height: 640
minimumWidth: 320
minimumHeight: 320
2018-02-23 14:39:14 +00:00
title: qsTr("Matrique")
FontLoader { id: materialFont; source: "qrc:/asset/font/material.ttf" }
Settings {
id: setting
property alias homeserver: matriqueController.homeserver
property alias userID: matriqueController.userID
property alias token: matriqueController.token
}
2018-07-09 02:45:26 +00:00
// Platform.SystemTrayIcon {
// visible: true
// iconSource: "qrc:/asset/img/icon.png"
2018-07-09 02:45:26 +00:00
// onActivated: {
// window.show()
// window.raise()
// window.requestActivate()
// }
// }
2018-02-23 14:39:14 +00:00
2018-02-27 11:07:50 +00:00
Controller {
id: matriqueController
onErrorOccured: {
errorDialog.text = err;
errorDialog.open();
}
2018-02-26 12:41:20 +00:00
}
2018-02-23 14:39:14 +00:00
Popup {
property bool busy: matriqueController.busy
id: busyPopup
x: (window.width - width) / 2
y: (window.height - height) / 2
modal: true
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
BusyIndicator { running: true }
onBusyChanged: {
if(busyPopup.busy) { busyPopup.open(); }
else { busyPopup.close(); }
}
2018-03-02 11:58:55 +00:00
}
2018-02-23 14:39:14 +00:00
Dialog {
property alias text: errorLabel.text
id: errorDialog
width: 360
modal: true
title: "ERROR"
x: (window.width - width) / 2
y: (window.height - height) / 2
2018-03-02 11:58:55 +00:00
standardButtons: Dialog.Ok
Label {
id: errorLabel
width: parent.width
text: "Label"
wrapMode: Text.Wrap
}
2018-03-02 11:58:55 +00:00
}
2018-02-23 14:39:14 +00:00
Component {
id: loginPage
2018-02-23 14:39:14 +00:00
Login { controller: matriqueController }
}
Room {
id: roomPage
connection: matriqueController.connection
}
2018-02-23 14:39:14 +00:00
RowLayout {
anchors.fill: parent
spacing: 0
2018-02-23 14:39:14 +00:00
SideNav {
id: sideNav
Layout.preferredWidth: 80
Layout.fillHeight: true
2018-02-23 14:39:14 +00:00
ColumnLayout {
anchors.fill: parent
spacing: 0
2018-03-02 15:05:32 +00:00
SideNavButton {
id: statusNavButton
contentItem: ImageStatus {
anchors.fill: parent
anchors.margins: 15
2018-07-10 04:18:21 +00:00
source: matriqueController.isLogin ? matriqueController.connection.localUser && matriqueController.connection.localUser.avatarUrl ? "image://mxc/" + matriqueController.connection.localUser.avatarUrl : "" : "qrc:/asset/img/avatar.png"
2018-07-09 02:45:26 +00:00
displayText: matriqueController.connection.localUser && matriqueController.connection.localUser.displayText ? matriqueController.connection.localUser.displayText : "N"
opaqueBackground: false
}
page: roomPage
2018-03-02 15:05:32 +00:00
}
Rectangle {
color: "transparent"
Layout.fillHeight: true
2018-03-02 15:05:32 +00:00
}
2018-02-23 14:39:14 +00:00
SideNavButton {
contentItem: MaterialIcon { icon: "\ue8b8"; color: "white" }
onClicked: matriqueController.logout()
2018-02-23 14:39:14 +00:00
}
SideNavButton {
contentItem: MaterialIcon { icon: "\ue879"; color: "white" }
2018-07-07 11:06:13 +00:00
onClicked: {
Qt.quit();
}
}
2018-02-23 14:39:14 +00:00
}
}
2018-02-23 14:39:14 +00:00
StackView {
id: stackView
initialItem: roomPage
2018-02-23 14:39:14 +00:00
Layout.fillWidth: true
Layout.fillHeight: true
2018-02-23 14:39:14 +00:00
}
}
Component.onCompleted: {
imageProvider.connection = matriqueController.connection
console.log(matriqueController.homeserver, matriqueController.userID, matriqueController.token)
2018-07-09 02:45:26 +00:00
if (matriqueController.userID && matriqueController.token) {
console.log("Perform auto-login.");
matriqueController.login();
} else {
stackView.replace(loginPage);
}
2018-02-23 14:39:14 +00:00
}
}