2018-12-07 01:18:42 +00:00
|
|
|
import QtQuick 2.12
|
2018-12-22 14:25:03 +00:00
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import QtQuick.Controls.Material 2.12
|
2018-08-24 05:25:41 +00:00
|
|
|
import Qt.labs.settings 1.0
|
2018-10-21 02:17:21 +00:00
|
|
|
import Qt.labs.platform 1.0 as Platform
|
2018-10-01 08:07:48 +00:00
|
|
|
|
2018-11-16 16:04:51 +00:00
|
|
|
import Spectral.Panel 2.0
|
2018-10-01 08:07:48 +00:00
|
|
|
import Spectral.Component 2.0
|
2019-04-26 11:59:01 +00:00
|
|
|
import Spectral.Dialog 2.0
|
2018-10-01 08:07:48 +00:00
|
|
|
import Spectral.Page 2.0
|
2018-11-16 16:04:51 +00:00
|
|
|
import Spectral.Effect 2.0
|
2018-10-01 08:07:48 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
ApplicationWindow {
|
2019-04-21 12:39:38 +00:00
|
|
|
readonly property bool inPortrait: window.width < window.height
|
|
|
|
|
2018-12-16 02:47:58 +00:00
|
|
|
Material.theme: MPalette.theme
|
|
|
|
Material.background: MPalette.background
|
2018-11-16 12:30:42 +00:00
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
width: 960
|
|
|
|
height: 640
|
2019-04-21 12:39:38 +00:00
|
|
|
minimumWidth: 480
|
2018-09-15 11:07:38 +00:00
|
|
|
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-12-16 02:47:58 +00:00
|
|
|
background: Rectangle {
|
|
|
|
color: MSettings.darkTheme ? "#303030" : "#FFFFFF"
|
|
|
|
}
|
|
|
|
|
2018-10-21 02:17:21 +00:00
|
|
|
Platform.SystemTrayIcon {
|
|
|
|
visible: MSettings.showTray
|
|
|
|
iconSource: "qrc:/assets/img/icon.png"
|
|
|
|
|
|
|
|
menu: Platform.Menu {
|
|
|
|
Platform.MenuItem {
|
2019-04-26 11:59:01 +00:00
|
|
|
text: qsTr("Toggle Window")
|
|
|
|
onTriggered: window.visible ? hideWindow() : showWindow()
|
2018-10-21 02:17:21 +00:00
|
|
|
}
|
|
|
|
Platform.MenuItem {
|
|
|
|
text: qsTr("Quit")
|
|
|
|
onTriggered: Qt.quit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-10-21 02:17:21 +00:00
|
|
|
quitOnLastWindowClosed: !MSettings.showTray
|
|
|
|
|
2018-10-19 14:02:12 +00:00
|
|
|
onNotificationClicked: {
|
2018-11-17 13:12:56 +00:00
|
|
|
roomListForm.enteredRoom = spectralController.connection.room(roomId)
|
2018-11-17 12:52:17 +00:00
|
|
|
roomForm.goToEvent(eventId)
|
2018-10-19 14:02:12 +00:00
|
|
|
showWindow()
|
|
|
|
}
|
2018-09-20 00:23:42 +00:00
|
|
|
onErrorOccured: {
|
2018-11-16 16:04:51 +00:00
|
|
|
roomListForm.errorControl.error = error
|
|
|
|
roomListForm.errorControl.detail = detail
|
|
|
|
roomListForm.errorControl.visible = true
|
2018-09-20 00:23:42 +00:00
|
|
|
}
|
2018-11-16 16:04:51 +00:00
|
|
|
onSyncDone: roomListForm.errorControl.visible = false
|
2018-02-26 12:41:20 +00:00
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-11-22 12:35:49 +00:00
|
|
|
Shortcut {
|
|
|
|
sequence: StandardKey.Quit
|
|
|
|
onActivated: Qt.quit()
|
|
|
|
}
|
|
|
|
|
2019-04-21 04:41:53 +00:00
|
|
|
Dialog {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
2019-04-21 12:39:38 +00:00
|
|
|
width: 480
|
|
|
|
|
|
|
|
id: detailDialog
|
|
|
|
|
|
|
|
contentItem: Column {
|
|
|
|
id: detailColumn
|
|
|
|
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: AccountListModel{
|
|
|
|
controller: spectralController
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: Item {
|
|
|
|
width: detailColumn.width
|
|
|
|
height: 72
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 12
|
|
|
|
|
|
|
|
spacing: 12
|
|
|
|
|
|
|
|
Avatar {
|
|
|
|
Layout.preferredWidth: height
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
source: user.avatarMediaId
|
|
|
|
hint: user.displayName || "No Name"
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
text: user.displayName || "No Name"
|
|
|
|
color: MPalette.foreground
|
|
|
|
font.pixelSize: 16
|
|
|
|
font.bold: true
|
|
|
|
elide: Text.ElideRight
|
|
|
|
wrapMode: Text.NoWrap
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
text: connection === spectralController.connection ? "Active" : "Online"
|
|
|
|
color: MPalette.lighter
|
|
|
|
font.pixelSize: 13
|
|
|
|
elide: Text.ElideRight
|
|
|
|
wrapMode: Text.NoWrap
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Menu {
|
|
|
|
id: contextMenu
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: "Logout"
|
|
|
|
|
|
|
|
onClicked: spectralController.logout(connection)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RippleEffect {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
onPrimaryClicked: spectralController.connection = connection
|
|
|
|
onSecondaryClicked: contextMenu.popup()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
MenuSeparator {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolButton {
|
|
|
|
Layout.preferredWidth: 48
|
|
|
|
Layout.preferredHeight: 48
|
|
|
|
|
|
|
|
contentItem: MaterialIcon {
|
|
|
|
icon: "\ue145"
|
|
|
|
color: MPalette.lighter
|
|
|
|
}
|
|
|
|
|
2019-04-26 11:59:01 +00:00
|
|
|
onClicked: loginDialog.createObject(ApplicationWindow.overlay).open()
|
2019-04-21 12:39:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Control {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
contentItem: RowLayout {
|
|
|
|
MaterialIcon {
|
|
|
|
Layout.preferredWidth: 48
|
|
|
|
Layout.preferredHeight: 48
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
color: MPalette.foreground
|
2019-04-21 12:39:38 +00:00
|
|
|
icon: "\ue7ff"
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
color: MPalette.foreground
|
2019-04-21 12:39:38 +00:00
|
|
|
text: "Start a Chat"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RippleEffect {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2019-04-26 11:59:01 +00:00
|
|
|
onPrimaryClicked: joinRoomDialog.createObject(ApplicationWindow.overlay).open()
|
2019-04-21 12:39:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Control {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
contentItem: RowLayout {
|
|
|
|
MaterialIcon {
|
|
|
|
Layout.preferredWidth: 48
|
|
|
|
Layout.preferredHeight: 48
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
color: MPalette.foreground
|
2019-04-21 12:39:38 +00:00
|
|
|
icon: "\ue7fc"
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
color: MPalette.foreground
|
2019-04-21 12:39:38 +00:00
|
|
|
text: "Create a Room"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RippleEffect {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2019-04-26 11:59:01 +00:00
|
|
|
onPrimaryClicked: createRoomDialog.createObject(ApplicationWindow.overlay).open()
|
2019-04-21 12:39:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuSeparator {
|
|
|
|
width: parent.width
|
|
|
|
}
|
|
|
|
|
|
|
|
Control {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
contentItem: RowLayout {
|
|
|
|
MaterialIcon {
|
|
|
|
Layout.preferredWidth: 48
|
|
|
|
Layout.preferredHeight: 48
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
color: MPalette.foreground
|
2019-04-21 12:39:38 +00:00
|
|
|
icon: "\ue3a9"
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
color: MPalette.foreground
|
2019-04-21 12:39:38 +00:00
|
|
|
text: "Night Mode"
|
|
|
|
}
|
|
|
|
|
|
|
|
Switch {
|
|
|
|
id: darkThemeSwitch
|
|
|
|
|
|
|
|
checked: MSettings.darkTheme
|
|
|
|
onCheckedChanged: MSettings.darkTheme = checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RippleEffect {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
onPrimaryClicked: darkThemeSwitch.checked = !darkThemeSwitch.checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Control {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
contentItem: RowLayout {
|
|
|
|
MaterialIcon {
|
|
|
|
Layout.preferredWidth: 48
|
|
|
|
Layout.preferredHeight: 48
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
color: MPalette.foreground
|
2019-04-21 12:39:38 +00:00
|
|
|
icon: "\ue5d2"
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
color: MPalette.foreground
|
2019-04-21 12:39:38 +00:00
|
|
|
text: "Enable System Tray"
|
|
|
|
}
|
|
|
|
|
|
|
|
Switch {
|
|
|
|
id: trayIconSwitch
|
|
|
|
|
|
|
|
checked: MSettings.showTray
|
|
|
|
onCheckedChanged: MSettings.showTray = checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RippleEffect {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
onPrimaryClicked: trayIconSwitch.checked = !trayIconSwitch.checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Control {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
contentItem: RowLayout {
|
|
|
|
MaterialIcon {
|
|
|
|
Layout.preferredWidth: 48
|
|
|
|
Layout.preferredHeight: 48
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
color: MPalette.foreground
|
2019-04-21 12:39:38 +00:00
|
|
|
icon: "\ue7f5"
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
color: MPalette.foreground
|
2019-04-21 12:39:38 +00:00
|
|
|
text: "Enable Notifications"
|
|
|
|
}
|
|
|
|
|
|
|
|
Switch {
|
|
|
|
id: notificationsSwitch
|
|
|
|
|
|
|
|
checked: MSettings.showNotification
|
|
|
|
onCheckedChanged: MSettings.showNotification = checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RippleEffect {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
onPrimaryClicked: notificationsSwitch.checked = !notificationsSwitch.checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-26 11:59:01 +00:00
|
|
|
Component {
|
|
|
|
id: loginDialog
|
2019-04-21 12:39:38 +00:00
|
|
|
|
2019-04-26 11:59:01 +00:00
|
|
|
LoginDialog {}
|
|
|
|
}
|
2019-04-21 12:39:38 +00:00
|
|
|
|
2019-04-26 11:59:01 +00:00
|
|
|
Component {
|
|
|
|
id: joinRoomDialog
|
2019-04-21 12:39:38 +00:00
|
|
|
|
2019-04-26 11:59:01 +00:00
|
|
|
JoinRoomDialog {}
|
2019-04-21 12:39:38 +00:00
|
|
|
}
|
|
|
|
|
2019-04-26 11:59:01 +00:00
|
|
|
Component {
|
2019-04-21 12:39:38 +00:00
|
|
|
id: createRoomDialog
|
|
|
|
|
2019-04-26 11:59:01 +00:00
|
|
|
CreateRoomDialog {}
|
2019-04-21 04:41:53 +00:00
|
|
|
}
|
|
|
|
|
2019-04-21 12:39:38 +00:00
|
|
|
Drawer {
|
2019-04-22 11:49:22 +00:00
|
|
|
width: Math.min((inPortrait ? 0.67 : 0.3) * window.width, 360)
|
2019-04-21 12:39:38 +00:00
|
|
|
height: window.height
|
|
|
|
modal: inPortrait
|
|
|
|
interactive: inPortrait
|
|
|
|
position: inPortrait ? 0 : 1
|
|
|
|
visible: !inPortrait
|
|
|
|
|
2019-04-21 13:21:48 +00:00
|
|
|
id: roomListDrawer
|
2018-09-22 14:28:47 +00:00
|
|
|
|
2018-11-16 16:04:51 +00:00
|
|
|
RoomListPanel {
|
2019-04-21 12:39:38 +00:00
|
|
|
anchors.fill: parent
|
2018-09-22 14:28:47 +00:00
|
|
|
|
2018-11-16 16:04:51 +00:00
|
|
|
id: roomListForm
|
2018-09-22 14:28:47 +00:00
|
|
|
|
2018-11-16 16:04:51 +00:00
|
|
|
clip: true
|
2018-09-22 14:28:47 +00:00
|
|
|
|
2019-04-29 07:03:11 +00:00
|
|
|
connection: spectralController.connection
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-11-16 16:04:51 +00:00
|
|
|
onLeaveRoom: roomForm.saveReadMarker(room)
|
2018-07-07 09:38:20 +00:00
|
|
|
}
|
2019-04-21 12:39:38 +00:00
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2019-04-21 12:39:38 +00:00
|
|
|
RoomPanel {
|
|
|
|
anchors.fill: parent
|
2019-04-21 13:21:48 +00:00
|
|
|
anchors.leftMargin: !inPortrait ? roomListDrawer.width : undefined
|
2019-04-21 12:39:38 +00:00
|
|
|
anchors.rightMargin: !inPortrait && roomDrawer.visible ? roomDrawer.width : undefined
|
2018-11-16 16:04:51 +00:00
|
|
|
|
2019-04-21 12:39:38 +00:00
|
|
|
id: roomForm
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2019-04-21 12:39:38 +00:00
|
|
|
clip: true
|
2018-09-04 13:13:14 +00:00
|
|
|
|
2019-04-21 12:39:38 +00:00
|
|
|
currentRoom: roomListForm.enteredRoom
|
|
|
|
}
|
|
|
|
|
|
|
|
RoomDrawer {
|
2019-04-22 11:49:22 +00:00
|
|
|
width: Math.min((inPortrait ? 0.67 : 0.3) * window.width, 360)
|
2019-04-21 12:39:38 +00:00
|
|
|
height: window.height
|
|
|
|
modal: inPortrait
|
|
|
|
interactive: inPortrait
|
|
|
|
|
|
|
|
edge: Qt.RightEdge
|
|
|
|
|
|
|
|
id: roomDrawer
|
|
|
|
|
|
|
|
room: roomListForm.enteredRoom
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
|
|
|
|
2018-09-09 02:12:45 +00:00
|
|
|
Binding {
|
|
|
|
target: imageProvider
|
|
|
|
property: "connection"
|
2018-11-16 16:04:51 +00:00
|
|
|
value: spectralController.connection
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|
2018-09-13 00:22:41 +00:00
|
|
|
|
2018-10-21 02:17:21 +00:00
|
|
|
function showWindow() {
|
|
|
|
window.show()
|
|
|
|
window.raise()
|
|
|
|
window.requestActivate()
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideWindow() {
|
|
|
|
window.hide()
|
|
|
|
}
|
|
|
|
|
2019-04-21 04:41:53 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
spectralController.initiated.connect(function() {
|
2019-04-29 07:03:11 +00:00
|
|
|
if (spectralController.accountCount == 0) loginDialog.createObject(window).open()
|
2019-04-21 04:41:53 +00:00
|
|
|
})
|
|
|
|
}
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|