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-08-24 05:25:41 +00:00
|
|
|
import Qt.labs.settings 1.0
|
2018-10-01 08:07:48 +00:00
|
|
|
|
|
|
|
import Spectral.Component 2.0
|
|
|
|
import Spectral.Page 2.0
|
|
|
|
|
2018-09-17 13:01:02 +00:00
|
|
|
import Spectral 0.1
|
2018-10-01 08:07:48 +00:00
|
|
|
import Spectral.Setting 0.1
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-09-13 03:58:02 +00:00
|
|
|
import "qrc:/js/util.js" as Util
|
2018-07-07 09:38:20 +00:00
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
ApplicationWindow {
|
2018-09-09 13:13:43 +00:00
|
|
|
readonly property var currentConnection: accountListView.currentConnection ? accountListView.currentConnection : null
|
2018-07-20 14:36:19 +00:00
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
width: 960
|
|
|
|
height: 640
|
2018-09-15 11:07:38 +00:00
|
|
|
minimumWidth: 720
|
|
|
|
minimumHeight: 360
|
2018-09-04 13:13:14 +00:00
|
|
|
|
|
|
|
id: window
|
|
|
|
|
|
|
|
visible: true
|
2018-09-17 13:01:02 +00:00
|
|
|
title: qsTr("Spectral")
|
2018-07-07 09:38:20 +00:00
|
|
|
|
2018-08-24 05:25:41 +00:00
|
|
|
Material.theme: MSettings.darkTheme ? Material.Dark : Material.Light
|
2018-07-20 05:50:25 +00:00
|
|
|
|
2018-09-17 13:01:02 +00:00
|
|
|
Material.accent: spectralController.color(currentConnection ? currentConnection.localUserId : "")
|
2018-09-10 07:01:01 +00:00
|
|
|
|
2018-02-27 11:07:50 +00:00
|
|
|
Controller {
|
2018-09-17 13:01:02 +00:00
|
|
|
id: spectralController
|
2018-08-19 06:51:09 +00:00
|
|
|
|
2018-09-14 04:16:25 +00:00
|
|
|
onShowWindow: {
|
|
|
|
window.show()
|
|
|
|
window.raise()
|
|
|
|
window.requestActivate()
|
2018-09-06 13:00:58 +00:00
|
|
|
}
|
2018-09-14 04:16:25 +00:00
|
|
|
onHideWindow: window.hide()
|
2018-09-20 00:23:42 +00:00
|
|
|
onErrorOccured: {
|
2018-09-20 05:43:47 +00:00
|
|
|
errorDialog.error = error
|
|
|
|
errorDialog.detail = detail
|
2018-09-20 00:23:42 +00:00
|
|
|
errorDialog.open()
|
|
|
|
}
|
2018-02-26 12:41:20 +00:00
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-09-09 13:13:43 +00:00
|
|
|
AccountListModel {
|
|
|
|
id: accountListModel
|
2018-09-17 13:01:02 +00:00
|
|
|
controller: spectralController
|
2018-09-09 13:13:43 +00:00
|
|
|
}
|
|
|
|
|
2018-09-20 00:23:42 +00:00
|
|
|
Dialog {
|
2018-09-20 05:43:47 +00:00
|
|
|
property string error
|
|
|
|
property string detail
|
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
x: (window.width - width) / 2
|
|
|
|
y: (window.height - height) / 2
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2018-09-20 00:23:42 +00:00
|
|
|
id: errorDialog
|
2018-09-20 05:43:47 +00:00
|
|
|
|
|
|
|
title: error + " Error"
|
2018-09-20 08:58:28 +00:00
|
|
|
contentItem: Label { text: errorDialog.detail }
|
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-09-17 13:01:02 +00:00
|
|
|
Login { controller: spectralController }
|
2018-07-07 09:38:20 +00:00
|
|
|
}
|
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-09-09 13:13:43 +00:00
|
|
|
connection: currentConnection
|
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-09-09 13:13:43 +00:00
|
|
|
|
|
|
|
listModel: accountListModel
|
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-08-24 05:25:41 +00:00
|
|
|
Rectangle {
|
2018-09-02 13:26:42 +00:00
|
|
|
Layout.preferredWidth: 64
|
2018-07-07 09:38:20 +00:00
|
|
|
Layout.fillHeight: true
|
2018-09-04 13:13:14 +00:00
|
|
|
|
|
|
|
id: sideNav
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
color: Material.primary
|
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-10-15 01:56:30 +00:00
|
|
|
AutoListView {
|
2018-09-09 02:12:45 +00:00
|
|
|
property var currentConnection: null
|
|
|
|
|
2018-09-02 13:26:42 +00:00
|
|
|
Layout.fillWidth: true
|
2018-09-09 02:12:45 +00:00
|
|
|
Layout.fillHeight: true
|
2018-09-02 13:26:42 +00:00
|
|
|
|
2018-09-09 02:12:45 +00:00
|
|
|
id: accountListView
|
2018-07-07 09:38:20 +00:00
|
|
|
|
2018-09-09 13:13:43 +00:00
|
|
|
model: accountListModel
|
2018-07-07 09:38:20 +00:00
|
|
|
|
2018-09-09 02:12:45 +00:00
|
|
|
spacing: 0
|
2018-03-02 15:05:32 +00:00
|
|
|
|
2018-09-10 08:22:45 +00:00
|
|
|
clip: true
|
|
|
|
|
2018-09-22 14:28:47 +00:00
|
|
|
delegate: Column {
|
|
|
|
property bool expanded: accountListView.currentConnection === connection
|
|
|
|
|
2018-09-09 02:12:45 +00:00
|
|
|
width: parent.width
|
|
|
|
|
2018-09-22 14:28:47 +00:00
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
SideNavButton {
|
|
|
|
width: parent.width
|
|
|
|
height: width
|
|
|
|
|
|
|
|
selected: stackView.currentItem === page && currentConnection === connection
|
|
|
|
|
|
|
|
ImageItem {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 12
|
|
|
|
|
|
|
|
hint: user.displayName
|
|
|
|
image: user.avatar
|
|
|
|
}
|
2018-09-11 05:14:56 +00:00
|
|
|
|
2018-09-22 14:28:47 +00:00
|
|
|
highlightColor: spectralController.color(user.id)
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2018-09-22 14:28:47 +00:00
|
|
|
page: roomPage
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
accountListView.currentConnection = connection
|
|
|
|
roomPage.filter = 0
|
|
|
|
}
|
2018-09-09 02:12:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-22 14:28:47 +00:00
|
|
|
Column {
|
|
|
|
width: parent.width
|
|
|
|
height: expanded ? implicitHeight : 0
|
|
|
|
|
|
|
|
spacing: 0
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
SideNavButton {
|
|
|
|
width: parent.width
|
|
|
|
height: width
|
|
|
|
|
|
|
|
MaterialIcon {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
icon: "\ue7f7"
|
|
|
|
color: "white"
|
|
|
|
}
|
2018-09-10 08:22:45 +00:00
|
|
|
|
2018-09-22 14:28:47 +00:00
|
|
|
onClicked: roomPage.filter = 1
|
|
|
|
}
|
2018-09-09 02:12:45 +00:00
|
|
|
|
2018-09-22 14:28:47 +00:00
|
|
|
SideNavButton {
|
|
|
|
width: parent.width
|
|
|
|
height: width
|
|
|
|
|
|
|
|
MaterialIcon {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
icon: "\ue7fd"
|
|
|
|
color: "white"
|
|
|
|
}
|
|
|
|
|
|
|
|
onClicked: roomPage.filter = 2
|
|
|
|
}
|
|
|
|
|
|
|
|
SideNavButton {
|
|
|
|
width: parent.width
|
|
|
|
height: width
|
|
|
|
|
|
|
|
MaterialIcon {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2018-10-19 05:36:36 +00:00
|
|
|
icon: "\ue7fb"
|
2018-09-22 14:28:47 +00:00
|
|
|
color: "white"
|
|
|
|
}
|
|
|
|
|
|
|
|
onClicked: roomPage.filter = 3
|
|
|
|
}
|
|
|
|
|
|
|
|
Behavior on height {
|
|
|
|
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
|
|
|
|
}
|
|
|
|
}
|
2018-09-09 02:12:45 +00:00
|
|
|
}
|
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 {
|
2018-09-02 13:26:42 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: width
|
|
|
|
|
|
|
|
MaterialIcon {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
icon: "\ue145"
|
|
|
|
color: "white"
|
|
|
|
}
|
|
|
|
|
2018-10-14 23:29:55 +00:00
|
|
|
enabled: !addRoomMenu.opened
|
2018-08-01 12:26:29 +00:00
|
|
|
onClicked: addRoomMenu.popup()
|
|
|
|
|
|
|
|
Menu {
|
|
|
|
id: addRoomMenu
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
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 {
|
2018-10-16 00:16:54 +00:00
|
|
|
AutoTextField {
|
2018-08-01 12:26:29 +00:00
|
|
|
width: parent.width
|
|
|
|
|
2018-09-04 13:13:14 +00:00
|
|
|
id: addRoomDialogNameTextField
|
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
placeholderText: "Name"
|
|
|
|
}
|
2018-10-16 00:16:54 +00:00
|
|
|
AutoTextField {
|
2018-08-01 12:26:29 +00:00
|
|
|
width: parent.width
|
2018-09-04 13:13:14 +00:00
|
|
|
|
|
|
|
id: addRoomDialogTopicTextField
|
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
placeholderText: "Topic"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-17 13:01:02 +00:00
|
|
|
onAccepted: spectralController.createRoom(currentConnection, addRoomDialogNameTextField.text, addRoomDialogTopicTextField.text)
|
2018-08-01 12:26:29 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-13 10:54:33 +00:00
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
MenuItem {
|
|
|
|
text: "Join Room"
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
onTriggered: joinRoomDialog.open()
|
|
|
|
|
|
|
|
Dialog {
|
|
|
|
x: (window.width - width) / 2
|
|
|
|
y: (window.height - height) / 2
|
|
|
|
width: 360
|
|
|
|
|
2018-09-04 13:13:14 +00:00
|
|
|
id: joinRoomDialog
|
|
|
|
|
|
|
|
parent: ApplicationWindow.overlay
|
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
title: "Input Room Alias or ID"
|
|
|
|
modal: true
|
|
|
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
|
|
|
|
2018-10-16 00:16:54 +00:00
|
|
|
contentItem: AutoTextField {
|
2018-08-01 12:26:29 +00:00
|
|
|
id: joinRoomDialogTextField
|
2018-08-09 11:58:19 +00:00
|
|
|
placeholderText: "#matrix:matrix.org"
|
2018-08-01 12:26:29 +00:00
|
|
|
}
|
|
|
|
|
2018-09-17 13:01:02 +00:00
|
|
|
onAccepted: spectralController.joinRoom(currentConnection, joinRoomDialogTextField.text)
|
2018-08-01 12:26:29 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-02 13:26:42 +00:00
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
MenuItem {
|
|
|
|
text: "Direct Chat"
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
onTriggered: directChatDialog.open()
|
|
|
|
|
|
|
|
Dialog {
|
|
|
|
x: (window.width - width) / 2
|
|
|
|
y: (window.height - height) / 2
|
|
|
|
width: 360
|
|
|
|
|
2018-09-04 13:13:14 +00:00
|
|
|
id: directChatDialog
|
|
|
|
|
|
|
|
parent: ApplicationWindow.overlay
|
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
title: "Input User ID"
|
|
|
|
modal: true
|
|
|
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
|
|
|
|
2018-10-16 00:16:54 +00:00
|
|
|
contentItem: AutoTextField {
|
2018-08-01 12:26:29 +00:00
|
|
|
id: directChatDialogTextField
|
2018-08-09 11:58:19 +00:00
|
|
|
placeholderText: "@bot:matrix.org"
|
2018-08-01 12:26:29 +00:00
|
|
|
}
|
|
|
|
|
2018-10-13 10:54:33 +00:00
|
|
|
onAccepted: spectralController.createDirectChat(currentConnection, directChatDialogTextField.text)
|
2018-08-01 12:26:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
SideNavButton {
|
2018-09-09 02:12:45 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: width
|
|
|
|
|
|
|
|
MaterialIcon {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
icon: "\ue8b8"
|
|
|
|
color: "white"
|
2018-09-02 13:26:42 +00:00
|
|
|
}
|
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 {
|
2018-09-02 13:26:42 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: width
|
|
|
|
|
|
|
|
MaterialIcon {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2018-09-16 12:56:47 +00:00
|
|
|
icon: "\ue8ac"
|
2018-09-02 13:26:42 +00:00
|
|
|
color: "white"
|
|
|
|
}
|
|
|
|
|
2018-10-15 01:01:53 +00:00
|
|
|
onClicked: MSettings.confirmOnExit ? confirmExitDialog.open() : Qt.quit()
|
|
|
|
|
|
|
|
Dialog {
|
|
|
|
x: (window.width - width) / 2
|
|
|
|
y: (window.height - height) / 2
|
|
|
|
width: 360
|
|
|
|
|
|
|
|
id: confirmExitDialog
|
|
|
|
|
|
|
|
parent: ApplicationWindow.overlay
|
|
|
|
|
|
|
|
title: "Exit"
|
|
|
|
modal: true
|
|
|
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
|
|
|
|
|
|
|
contentItem: Column {
|
|
|
|
Label { text: "Exit?" }
|
|
|
|
CheckBox {
|
|
|
|
text: "Do not ask next time"
|
|
|
|
checked: !MSettings.confirmOnExit
|
|
|
|
|
|
|
|
onCheckedChanged: MSettings.confirmOnExit = !checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onAccepted: 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 {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2018-09-04 13:13:14 +00:00
|
|
|
|
|
|
|
id: stackView
|
|
|
|
|
2018-09-10 00:06:32 +00:00
|
|
|
initialItem: roomPage
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-09 02:12:45 +00:00
|
|
|
Binding {
|
|
|
|
target: imageProvider
|
|
|
|
property: "connection"
|
2018-09-09 13:13:43 +00:00
|
|
|
value: currentConnection
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
2018-09-13 00:22:41 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
2018-09-17 13:01:02 +00:00
|
|
|
spectralController.initiated.connect(function() {
|
|
|
|
if (spectralController.accountCount == 0) stackView.push(loginPage)
|
2018-09-13 00:22:41 +00:00
|
|
|
})
|
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|