2018-07-12 01:44:41 +00:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtQuick.Controls.Material 2.2
|
2018-02-23 14:39:14 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
2018-07-18 14:16:03 +00:00
|
|
|
import Qt.labs.settings 1.0 as Settings
|
2018-07-07 09:38:20 +00:00
|
|
|
import Qt.labs.platform 1.0 as Platform
|
2018-02-23 14:39:14 +00:00
|
|
|
import Matrique 0.1
|
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
import "component"
|
|
|
|
import "form"
|
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
ApplicationWindow {
|
2018-07-22 14:16:53 +00:00
|
|
|
readonly property var connection: matriqueController.connection
|
2018-07-20 14:36:19 +00:00
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
id: window
|
|
|
|
visible: true
|
|
|
|
width: 960
|
|
|
|
height: 640
|
2018-08-01 12:26:29 +00:00
|
|
|
minimumWidth: 800
|
2018-07-20 05:50:25 +00:00
|
|
|
minimumHeight: 480
|
2018-02-23 14:39:14 +00:00
|
|
|
title: qsTr("Matrique")
|
2018-07-07 09:38:20 +00:00
|
|
|
|
2018-07-20 05:50:25 +00:00
|
|
|
Material.theme: setting.darkTheme ? Material.Dark : Material.Light
|
2018-07-20 04:14:02 +00:00
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
FontLoader { id: materialFont; source: "qrc:/asset/font/material.ttf" }
|
|
|
|
|
2018-07-18 14:16:03 +00:00
|
|
|
Settings.Settings {
|
2018-07-07 09:38:20 +00:00
|
|
|
id: setting
|
2018-07-20 05:50:25 +00:00
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
property alias homeserver: matriqueController.homeserver
|
|
|
|
property alias userID: matriqueController.userID
|
|
|
|
property alias token: matriqueController.token
|
2018-07-20 05:50:25 +00:00
|
|
|
|
|
|
|
property alias darkTheme: settingPage.darkTheme
|
|
|
|
property alias miniMode: settingPage.miniMode
|
2018-07-07 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-07-19 08:04:09 +00:00
|
|
|
Platform.SystemTrayIcon {
|
|
|
|
id: trayIcon
|
2018-07-11 08:07:04 +00:00
|
|
|
|
2018-07-19 08:04:09 +00:00
|
|
|
visible: true
|
|
|
|
iconSource: "qrc:/asset/img/icon.png"
|
2018-07-11 08:07:04 +00:00
|
|
|
|
2018-07-20 05:50:25 +00:00
|
|
|
menu: Platform.Menu {
|
|
|
|
MenuItem {
|
|
|
|
text: "Hide/Show"
|
|
|
|
onTriggered: window.active ? window.hide() : raiseWindow()
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: "Quit"
|
|
|
|
onTriggered: Qt.quit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onActivated: window.active ? window.hide() : raiseWindow()
|
|
|
|
|
|
|
|
function raiseWindow() {
|
2018-07-19 08:04:09 +00:00
|
|
|
window.show()
|
|
|
|
window.raise()
|
|
|
|
window.requestActivate()
|
|
|
|
}
|
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-02-27 11:07:50 +00:00
|
|
|
Controller {
|
2018-07-07 09:38:20 +00:00
|
|
|
id: matriqueController
|
|
|
|
onErrorOccured: {
|
|
|
|
errorDialog.text = err;
|
|
|
|
errorDialog.open();
|
|
|
|
}
|
2018-02-26 12:41:20 +00:00
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-07 09:38:20 +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
|
|
|
|
2018-07-07 09:38:20 +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
|
|
|
|
2018-07-07 09:38:20 +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
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
Component {
|
|
|
|
id: loginPage
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
Login { controller: matriqueController }
|
|
|
|
}
|
2018-03-01 11:15:04 +00:00
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
Room {
|
|
|
|
id: roomPage
|
2018-07-22 12:31:52 +00:00
|
|
|
|
|
|
|
parent: null
|
|
|
|
|
2018-07-20 14:36:19 +00:00
|
|
|
connection: window.connection
|
2018-07-07 09:38:20 +00:00
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-19 05:54:59 +00:00
|
|
|
Setting {
|
|
|
|
id: settingPage
|
2018-07-22 12:31:52 +00:00
|
|
|
|
|
|
|
parent: null
|
|
|
|
|
2018-07-20 14:36:19 +00:00
|
|
|
connection: window.connection
|
2018-07-19 05:54:59 +00:00
|
|
|
}
|
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
SideNav {
|
|
|
|
id: sideNav
|
|
|
|
Layout.preferredWidth: 80
|
|
|
|
Layout.fillHeight: true
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
2018-03-02 15:05:32 +00:00
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
SideNavButton {
|
|
|
|
id: statusNavButton
|
|
|
|
contentItem: ImageStatus {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 15
|
|
|
|
|
2018-07-23 14:41:18 +00:00
|
|
|
source: matriqueController.isLogin ? connection.localUser && connection.localUser.avatarUrl ? "image://mxc/" + connection.localUser.avatarUrl : "" : "qrc:/asset/img/avatar.png"
|
|
|
|
displayText: matriqueController.isLogin && connection.localUser.displayName ? connection.localUser.displayName : "N"
|
2018-07-07 09:38:20 +00:00
|
|
|
opaqueBackground: false
|
|
|
|
}
|
|
|
|
|
|
|
|
page: roomPage
|
2018-03-02 15:05:32 +00:00
|
|
|
}
|
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
Rectangle {
|
|
|
|
color: "transparent"
|
|
|
|
Layout.fillHeight: true
|
2018-03-02 15:05:32 +00:00
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
SideNavButton {
|
|
|
|
contentItem: MaterialIcon { icon: "\ue145"; color: "white" }
|
|
|
|
onClicked: addRoomMenu.popup()
|
|
|
|
|
|
|
|
Menu {
|
|
|
|
id: addRoomMenu
|
|
|
|
MenuItem {
|
|
|
|
text:"New Room"
|
|
|
|
onTriggered: addRoomDialog.open()
|
|
|
|
|
|
|
|
Dialog {
|
|
|
|
id: addRoomDialog
|
|
|
|
parent: ApplicationWindow.overlay
|
|
|
|
|
|
|
|
x: (window.width - width) / 2
|
|
|
|
y: (window.height - height) / 2
|
|
|
|
width: 360
|
|
|
|
|
|
|
|
title: "New Room"
|
|
|
|
modal: true
|
|
|
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
|
|
|
|
|
|
|
contentItem: Column {
|
|
|
|
TextField {
|
|
|
|
id: addRoomDialogNameTextField
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
placeholderText: "Name"
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: addRoomDialogTopicTextField
|
|
|
|
width: parent.width
|
|
|
|
placeholderText: "Topic"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onAccepted: matriqueController.createRoom(addRoomDialogNameTextField.text, addRoomDialogTopicTextField.text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: "Join Room"
|
|
|
|
onTriggered: joinRoomDialog.open()
|
|
|
|
|
|
|
|
Dialog {
|
|
|
|
id: joinRoomDialog
|
|
|
|
parent: ApplicationWindow.overlay
|
|
|
|
|
|
|
|
x: (window.width - width) / 2
|
|
|
|
y: (window.height - height) / 2
|
|
|
|
width: 360
|
|
|
|
|
|
|
|
title: "Input Room Alias or ID"
|
|
|
|
modal: true
|
|
|
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
|
|
|
|
|
|
|
contentItem: TextField {
|
|
|
|
id: joinRoomDialogTextField
|
|
|
|
}
|
|
|
|
|
|
|
|
onAccepted: matriqueController.joinRoom(joinRoomDialogTextField.text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: "Direct Chat"
|
|
|
|
onTriggered: directChatDialog.open()
|
|
|
|
|
|
|
|
Dialog {
|
|
|
|
id: directChatDialog
|
|
|
|
parent: ApplicationWindow.overlay
|
|
|
|
|
|
|
|
x: (window.width - width) / 2
|
|
|
|
y: (window.height - height) / 2
|
|
|
|
width: 360
|
|
|
|
|
|
|
|
title: "Input User ID"
|
|
|
|
modal: true
|
|
|
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
|
|
|
|
|
|
|
contentItem: TextField {
|
|
|
|
id: directChatDialogTextField
|
|
|
|
}
|
|
|
|
|
|
|
|
onAccepted: matriqueController.createDirectChat(directChatDialogTextField.text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
SideNavButton {
|
|
|
|
contentItem: MaterialIcon { icon: "\ue8b8"; color: "white" }
|
2018-07-19 05:54:59 +00:00
|
|
|
page: settingPage
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
2018-03-01 11:15:04 +00:00
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
SideNavButton {
|
|
|
|
contentItem: MaterialIcon { icon: "\ue879"; color: "white" }
|
2018-08-01 12:26:29 +00:00
|
|
|
onClicked: Qt.quit()
|
2018-03-01 11:15:04 +00:00
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
2018-07-07 09:38:20 +00:00
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
StackView {
|
|
|
|
id: stackView
|
|
|
|
initialItem: roomPage
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
imageProvider.connection = matriqueController.connection
|
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
if (matriqueController.userID && matriqueController.token) {
|
2018-07-07 09:38:20 +00:00
|
|
|
matriqueController.login();
|
|
|
|
} else {
|
|
|
|
stackView.replace(loginPage);
|
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
}
|