Support Qt 5.11 and fix image provider.
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import "qrc:/qml/form"
|
||||
|
||||
Page {
|
||||
property var contactListModel
|
||||
|
||||
ListForm {
|
||||
id: roomListForm
|
||||
height: parent.height
|
||||
width: 320
|
||||
listModel: contactListModel
|
||||
}
|
||||
|
||||
DetailForm {
|
||||
id: detailForm
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: roomListForm.width
|
||||
}
|
||||
}
|
||||
@@ -9,18 +9,6 @@ import "qrc:/qml/component"
|
||||
Page {
|
||||
property var controller
|
||||
|
||||
property alias homeserver: settings.server
|
||||
property alias username: settings.user
|
||||
property alias password: settings.pass
|
||||
|
||||
Settings {
|
||||
id: settings
|
||||
|
||||
property alias server: serverField.text
|
||||
property alias user: usernameField.text
|
||||
property alias pass: passwordField.text
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
|
||||
@@ -68,29 +56,33 @@ Page {
|
||||
height: parent.height
|
||||
padding: 64
|
||||
|
||||
Column {
|
||||
id: main_col
|
||||
spacing: 8
|
||||
anchors.fill: parent
|
||||
ColumnLayout {
|
||||
id: mainCol
|
||||
width: parent.width
|
||||
|
||||
ImageStatus {
|
||||
width: 96
|
||||
height: width
|
||||
Layout.preferredWidth: 96
|
||||
Layout.preferredHeight: 96
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
source: "qrc:/asset/img/avatar.png"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: serverField
|
||||
width: parent.width
|
||||
height: 48
|
||||
placeholderText: "Server"
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
leftPadding: 16
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
|
||||
placeholderText: "Server"
|
||||
|
||||
background: Rectangle {
|
||||
color: "#eaeaea"
|
||||
implicitHeight: 48
|
||||
|
||||
color: Material.theme == Material.Light ? "#eaeaea" : "#242424"
|
||||
border.color: parent.activeFocus ? Material.accent : "transparent"
|
||||
border.width: 2
|
||||
}
|
||||
@@ -98,15 +90,19 @@ Page {
|
||||
|
||||
TextField {
|
||||
id: usernameField
|
||||
width: parent.width
|
||||
height: 48
|
||||
placeholderText: "Username"
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
leftPadding: 16
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
|
||||
placeholderText: "Username"
|
||||
|
||||
background: Rectangle {
|
||||
color: "#eaeaea"
|
||||
implicitHeight: 48
|
||||
|
||||
color: Material.theme == Material.Light ? "#eaeaea" : "#242424"
|
||||
border.color: parent.activeFocus ? Material.accent : "transparent"
|
||||
border.width: 2
|
||||
}
|
||||
@@ -114,15 +110,20 @@ Page {
|
||||
|
||||
TextField {
|
||||
id: passwordField
|
||||
width: parent.width
|
||||
height: 48
|
||||
placeholderText: "Password"
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
leftPadding: 16
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
|
||||
placeholderText: "Password"
|
||||
echoMode: TextInput.Password
|
||||
|
||||
background: Rectangle {
|
||||
color: "#eaeaea"
|
||||
implicitHeight: 48
|
||||
|
||||
color: Material.theme == Material.Light ? "#eaeaea" : "#242424"
|
||||
border.color: parent.activeFocus ? Material.accent : "transparent"
|
||||
border.width: 2
|
||||
}
|
||||
@@ -130,20 +131,13 @@ Page {
|
||||
|
||||
Button {
|
||||
id: loginButton
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
text: "LOGIN"
|
||||
highlighted: true
|
||||
width: parent.width
|
||||
|
||||
onClicked: controller.login(homeserver, username, password)
|
||||
}
|
||||
|
||||
Button {
|
||||
id: logoutButton
|
||||
text: "LOGOUT"
|
||||
flat: true
|
||||
width: parent.width
|
||||
|
||||
onClicked: controller.logout()
|
||||
onClicked: controller.loginWithCredentials(serverField.text, usernameField.text, passwordField.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
47
qml/Room.qml
47
qml/Room.qml
@@ -1,24 +1,47 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import Matrique 0.1
|
||||
|
||||
import "qrc:/qml/form"
|
||||
|
||||
import Matrique 0.1
|
||||
|
||||
Page {
|
||||
property RoomListModel roomListModel
|
||||
property alias connection: roomListModel.connection
|
||||
|
||||
ListForm {
|
||||
id: roomListForm
|
||||
height: parent.height
|
||||
width: 320
|
||||
listModel: roomListModel
|
||||
id: page
|
||||
|
||||
RoomListModel {
|
||||
id: roomListModel
|
||||
}
|
||||
|
||||
RoomForm {
|
||||
id: roomForm
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: roomListForm.width
|
||||
roomIndex: roomListForm.currentIndex
|
||||
spacing: 0
|
||||
|
||||
ListForm {
|
||||
id: roomListForm
|
||||
|
||||
Layout.fillHeight: true
|
||||
// Layout.preferredWidth: {
|
||||
// if (page.width > 560) {
|
||||
// return page.width * 0.4;
|
||||
// } else {
|
||||
// return 80;
|
||||
// }
|
||||
// }
|
||||
Layout.preferredWidth: 320
|
||||
Layout.maximumWidth: 360
|
||||
|
||||
listModel: roomListModel
|
||||
}
|
||||
|
||||
RoomForm {
|
||||
id: roomForm
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
currentRoom: roomListForm.currentIndex != -1 ? roomListModel.roomAt(roomListForm.currentIndex) : null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Controls.Material 2.3
|
||||
|
||||
Page {
|
||||
property alias theme: themeSwitch.checked
|
||||
header: TabBar {
|
||||
id: settingBar
|
||||
width: parent.width
|
||||
z: 10
|
||||
currentIndex: settingBar.currentIndex
|
||||
|
||||
TabButton {
|
||||
text: qsTr("Overview")
|
||||
}
|
||||
|
||||
TabButton {
|
||||
text: qsTr("Interface")
|
||||
}
|
||||
|
||||
TabButton {
|
||||
text: qsTr("Network")
|
||||
}
|
||||
|
||||
TabButton {
|
||||
text: qsTr("Sync")
|
||||
}
|
||||
}
|
||||
|
||||
SwipeView {
|
||||
id: settingSwipe
|
||||
|
||||
currentIndex: settingBar.currentIndex
|
||||
anchors.fill: parent
|
||||
|
||||
Page {
|
||||
|
||||
}
|
||||
|
||||
Page {
|
||||
Column {
|
||||
width: parent.width
|
||||
Switch {
|
||||
id: themeSwitch
|
||||
text: qsTr("Dark Theme")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Page {
|
||||
|
||||
}
|
||||
|
||||
Page {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property Connection currentConnection: null
|
||||
property var currentRoom: null
|
||||
|
||||
function setRoom(room) {
|
||||
currentRoom = room
|
||||
messageModel.changeRoom(room)
|
||||
}
|
||||
|
||||
function setConnection(conn) {
|
||||
currentConnection = conn
|
||||
messageModel.setConnection(conn)
|
||||
}
|
||||
|
||||
function sendLine(text) {
|
||||
if(!currentRoom || !currentConnection) return
|
||||
currentConnection.postMessage(currentRoom, "m.text", text)
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: chatView
|
||||
anchors.fill: parent
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
verticalLayoutDirection: ListView.BottomToTop
|
||||
model: MessageEventModel { id: messageModel }
|
||||
|
||||
delegate: Row {
|
||||
id: message
|
||||
width: parent.width
|
||||
spacing: 8
|
||||
|
||||
Label {
|
||||
id: timelabel
|
||||
text: time.toLocaleTimeString("hh:mm:ss")
|
||||
color: "grey"
|
||||
}
|
||||
Label {
|
||||
width: 64
|
||||
elide: Text.ElideRight
|
||||
text: eventType == "message" ? author : "***"
|
||||
color: eventType == "message" ? "grey" : "lightgrey"
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
Label {
|
||||
text: content
|
||||
wrapMode: Text.Wrap
|
||||
width: parent.width - (x - parent.x) - spacing
|
||||
color: eventType == "message" ? "black" : "lightgrey"
|
||||
}
|
||||
}
|
||||
|
||||
section {
|
||||
property: "date"
|
||||
labelPositioning: ViewSection.CurrentLabelAtStart
|
||||
delegate: Rectangle {
|
||||
width: parent.width
|
||||
height: childrenRect.height
|
||||
Label {
|
||||
width: parent.width
|
||||
text: section.toLocaleString(Qt.locale())
|
||||
color: "grey"
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onAtYBeginningChanged: {
|
||||
if(currentRoom && atYBeginning) currentRoom.getPreviousContent()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,31 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
Item {
|
||||
property bool statusIndicator: false
|
||||
property bool opaqueBackground: false
|
||||
property alias source: avatar.source
|
||||
|
||||
id: item
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: parent.width
|
||||
radius: parent.width / 2
|
||||
width: item.width
|
||||
height: item.width
|
||||
radius: item.width / 2
|
||||
color: "white"
|
||||
visible: opaqueBackground
|
||||
}
|
||||
|
||||
Image {
|
||||
id: avatar
|
||||
width: parent.width
|
||||
height: parent.width
|
||||
width: item.width
|
||||
height: item.width
|
||||
|
||||
mipmap: true
|
||||
layer.enabled: true
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
sourceSize.width: parent.width
|
||||
sourceSize.height: parent.width
|
||||
sourceSize.width: item.width
|
||||
sourceSize.height: item.width
|
||||
|
||||
layer.effect: OpacityMask {
|
||||
maskSource: Item {
|
||||
@@ -38,15 +39,5 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: parent.width
|
||||
radius: parent.width / 2
|
||||
color: "transparent"
|
||||
border.color: "#4caf50"
|
||||
border.width: 4
|
||||
visible: statusIndicator
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls.Material 2.3
|
||||
|
||||
Item {
|
||||
property alias icon: iconText.text
|
||||
property var color: "white"
|
||||
property var color: Material.theme == Material.Light ? "black" : "white"
|
||||
|
||||
id: item
|
||||
|
||||
|
||||
@@ -3,15 +3,9 @@ import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls.Material 2.3
|
||||
|
||||
Drawer {
|
||||
property SwipeView swipeView
|
||||
|
||||
interactive: false
|
||||
position: 1.0
|
||||
visible: true
|
||||
modal: false
|
||||
|
||||
background: Rectangle {
|
||||
Item {
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Material.accent
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls.Material 2.3
|
||||
|
||||
Item {
|
||||
property Item page
|
||||
property var page
|
||||
property alias contentItem: buttonDelegate.contentItem
|
||||
signal clicked
|
||||
|
||||
|
||||
@@ -50,28 +50,14 @@ Item {
|
||||
width: parent.height
|
||||
height: parent.height
|
||||
|
||||
contentItem: Text {
|
||||
text: "\ue0b7"
|
||||
font.pointSize: 16
|
||||
font.family: materialFont.name
|
||||
color: "white"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
contentItem: MaterialIcon { icon: "\ue0b7" }
|
||||
}
|
||||
|
||||
ItemDelegate {
|
||||
width: parent.height
|
||||
height: parent.height
|
||||
|
||||
contentItem: Text {
|
||||
text: "\ue62e"
|
||||
font.pointSize: 16
|
||||
font.family: materialFont.name
|
||||
color: "white"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
contentItem: MaterialIcon { icon: "\ue62e" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,97 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick.Controls.Material 2.3
|
||||
import QtQml.Models 2.3
|
||||
import Matrique 0.1
|
||||
|
||||
import "qrc:/qml/component"
|
||||
|
||||
Item {
|
||||
property var listModel
|
||||
property alias listModel: delegateModel.model
|
||||
property alias currentIndex: listView.currentIndex
|
||||
readonly property bool mini: width <= 80 // Used as an indicator of whether the listform should be displayed as "Mini mode".
|
||||
|
||||
DelegateModel {
|
||||
id: delegateModel
|
||||
groups: [
|
||||
DelegateModelGroup {
|
||||
name: "filterGroup"; includeByDefault: true
|
||||
}
|
||||
]
|
||||
filterOnGroup: "filterGroup"
|
||||
|
||||
delegate: ItemDelegate {
|
||||
width: parent.width
|
||||
height: 80
|
||||
onClicked: listView.currentIndex = index
|
||||
|
||||
contentItem: RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 16
|
||||
spacing: 16
|
||||
|
||||
ImageStatus {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
|
||||
source: avatar == null || avatar == "" ? "qrc:/asset/img/avatar.png" : "image://mxc/" + avatar
|
||||
opaqueBackground: true
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: {
|
||||
if (name != "") {
|
||||
return name;
|
||||
}
|
||||
if (alias != "") {
|
||||
return alias;
|
||||
}
|
||||
return id
|
||||
}
|
||||
font.pointSize: 16
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: topic === "" ? "No topic yet." : topic
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function applyFilter(filterName){
|
||||
var roomCount = listModel.rowCount();
|
||||
for (var i = 0; i < roomCount; i++){
|
||||
var roomName = "";
|
||||
if (listModel.roomAt(i).name != "") {
|
||||
roomName = listModel.roomAt(i).name;
|
||||
} else if (model.alias != "") {
|
||||
roomName = listModel.roomAt(i).alias;
|
||||
} else {
|
||||
roomName = listModel.roomAt(i).id;
|
||||
}
|
||||
if (roomName.toLowerCase().indexOf(filterName.toLowerCase()) !== -1) {
|
||||
items.addGroups(i, 1, "filterGroup");
|
||||
} else {items.removeGroups(i, 1, "filterGroup");}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
@@ -22,10 +106,10 @@ Item {
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: serverField
|
||||
id: searchField
|
||||
width: parent.width
|
||||
height: 36
|
||||
leftPadding: 16
|
||||
leftPadding: mini ? 4 : 16
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@@ -34,19 +118,17 @@ Item {
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
|
||||
Text {
|
||||
width: parent.height
|
||||
height: parent.height
|
||||
text: "\ue8b6"
|
||||
font.pointSize: 16
|
||||
font.family: materialFont.name
|
||||
MaterialIcon {
|
||||
icon: "\ue8b6"
|
||||
color: "white"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
width: mini ? parent.width : parent.height
|
||||
height: parent.height
|
||||
}
|
||||
|
||||
Text {
|
||||
height: parent.height
|
||||
visible: !mini
|
||||
text: "Search"
|
||||
color: "white"
|
||||
font.pointSize: 12
|
||||
@@ -56,15 +138,19 @@ Item {
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: serverField.activeFocus || serverField.text != "" ? parent.width : 0
|
||||
width: searchField.activeFocus || searchField.text != "" ? parent.width : 0
|
||||
height: parent.height
|
||||
color: "white"
|
||||
|
||||
Behavior on width {
|
||||
PropertyAnimation { easing.type: Easing.InOutQuad; duration: 200 }
|
||||
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onTextChanged: {
|
||||
delegateModel.applyFilter(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,13 +163,12 @@ Item {
|
||||
anchors.fill: parent
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#eaeaea"
|
||||
color: Material.theme == Material.Light ? "#eaeaea" : "#242424"
|
||||
}
|
||||
|
||||
Text {
|
||||
Label {
|
||||
z: 10
|
||||
text: "Here? No, not here."
|
||||
color: "#424242"
|
||||
text: mini ? "Empty" : "Here? No, not here."
|
||||
anchors.centerIn: parent
|
||||
visible: listView.count === 0
|
||||
}
|
||||
@@ -94,53 +179,15 @@ Item {
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
|
||||
model: listModel
|
||||
|
||||
highlight: Rectangle {
|
||||
color: Material.accent
|
||||
opacity: 0.2
|
||||
}
|
||||
highlightMoveDuration: 250
|
||||
|
||||
ScrollBar.vertical: ScrollBar { id: scrollBar }
|
||||
|
||||
delegate: ItemDelegate {
|
||||
width: parent.width
|
||||
height: 80
|
||||
onClicked: listView.currentIndex = index
|
||||
|
||||
contentItem: Row {
|
||||
width: parent.width - 32
|
||||
height: parent.height - 32
|
||||
spacing: 16
|
||||
|
||||
ImageStatus {
|
||||
width: parent.height
|
||||
height: parent.height
|
||||
source: avatar == "" ? "qrc:/asset/img/avatar.png" : "image://mxc/" + avatar
|
||||
opaqueBackground: true
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width - parent.height - parent.spacing
|
||||
height: parent.height
|
||||
Text {
|
||||
width: parent.width
|
||||
text: name
|
||||
color: "#424242"
|
||||
font.pointSize: 16
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
Text {
|
||||
width: parent.width
|
||||
text: value
|
||||
color: "#424242"
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
model: delegateModel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,123 +3,171 @@ import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls.Material 2.3
|
||||
import QtGraphicalEffects 1.0
|
||||
import Matrique 0.1
|
||||
import "qrc:/qml/component"
|
||||
|
||||
Item {
|
||||
property int roomIndex
|
||||
id: item
|
||||
property var currentRoom
|
||||
|
||||
ColumnLayout {
|
||||
Pane {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
padding: 0
|
||||
|
||||
Pane {
|
||||
z: 10
|
||||
padding: 16
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 80
|
||||
|
||||
background: Rectangle {
|
||||
color: "#eaeaea"
|
||||
background: Item {
|
||||
anchors.fill: parent
|
||||
visible: currentRoom == null
|
||||
Pane {
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
spacing: 16
|
||||
|
||||
ImageStatus {
|
||||
width: parent.height
|
||||
height: parent.height
|
||||
source: "qrc:/asset/img/avatar.png"
|
||||
}
|
||||
|
||||
Column {
|
||||
height: parent.height
|
||||
Text {
|
||||
text: "Astolfo"
|
||||
font.pointSize: 18
|
||||
color: "#424242"
|
||||
}
|
||||
Text {
|
||||
text: "Rider of Black"
|
||||
color: "#424242"
|
||||
}
|
||||
}
|
||||
Label {
|
||||
z: 10
|
||||
text: "Please choose a room."
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
||||
Pane {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
|
||||
Pane {
|
||||
z: 10
|
||||
padding: 16
|
||||
visible: currentRoom != null
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 80
|
||||
Pane {
|
||||
z: 10
|
||||
padding: 16
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 80
|
||||
|
||||
ItemDelegate {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
background: Rectangle {
|
||||
color: Material.theme == Material.Light ? "#eaeaea" : "#242424"
|
||||
}
|
||||
|
||||
contentItem: Text {
|
||||
text: "\ue226"
|
||||
// color: "#424242"
|
||||
font.pointSize: 16
|
||||
font.family: materialFont.name
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 16
|
||||
|
||||
ImageStatus {
|
||||
Layout.preferredWidth: parent.height
|
||||
Layout.fillHeight: true
|
||||
source: "qrc:/asset/img/avatar.png"
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: currentRoom != null ? currentRoom.name : ""
|
||||
font.pointSize: 16
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: currentRoom != null ? currentRoom.topic : ""
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: messageListView
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
displayMarginBeginning: 40
|
||||
displayMarginEnd: 40
|
||||
verticalLayoutDirection: ListView.BottomToTop
|
||||
spacing: 12
|
||||
// model: MessageEventModel{ currentRoom: item.currentRoom }
|
||||
model: 10
|
||||
delegate: Row {
|
||||
readonly property bool sentByMe: index % 2 == 0
|
||||
|
||||
id: messageRow
|
||||
|
||||
height: 40
|
||||
anchors.right: sentByMe ? parent.right : undefined
|
||||
spacing: 6
|
||||
|
||||
Rectangle {
|
||||
id: avatar
|
||||
width: height
|
||||
height: parent.height
|
||||
color: "grey"
|
||||
visible: !sentByMe
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: Math.min(messageText.implicitWidth + 24,
|
||||
messageListView.width - (!sentByMe ? avatar.width + messageRow.spacing : 0))
|
||||
height: parent.height
|
||||
color: sentByMe ? "lightgrey" : Material.accent
|
||||
|
||||
Label {
|
||||
id: messageText
|
||||
text: index
|
||||
color: sentByMe ? "black" : "white"
|
||||
anchors.fill: parent
|
||||
anchors.margins: 12
|
||||
wrapMode: Label.Wrap
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextField {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
placeholderText: "Send a Message"
|
||||
leftPadding: 16
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
ScrollBar.vertical: ScrollBar { /*anchors.left: messageListView.right*/ }
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: "#eaeaea"
|
||||
}
|
||||
}
|
||||
Pane {
|
||||
z: 10
|
||||
padding: 16
|
||||
|
||||
ItemDelegate {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 80
|
||||
|
||||
contentItem: Text {
|
||||
text: "\ue24e"
|
||||
// color: parent.pressed ? Material.accent : "#424242"
|
||||
font.pointSize: 16
|
||||
font.family: materialFont.name
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
|
||||
ItemDelegate {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
|
||||
contentItem: MaterialIcon { icon: "\ue226" }
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: "#eaeaea"
|
||||
TextField {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
placeholderText: "Send a Message"
|
||||
leftPadding: 16
|
||||
topPadding: 0
|
||||
bottomPadding: 0
|
||||
selectByMouse: true
|
||||
|
||||
background: Rectangle {
|
||||
color: Material.theme == Material.Light ? "#eaeaea" : "#242424"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemDelegate {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
ItemDelegate {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
|
||||
contentItem: Text {
|
||||
text: "\ue163"
|
||||
// color: "#424242"
|
||||
font.pointSize: 16
|
||||
font.family: materialFont.name
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
contentItem: MaterialIcon { icon: "\ue24e" }
|
||||
|
||||
background: Rectangle {
|
||||
color: Material.theme == Material.Light ? "#eaeaea" : "#242424"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
261
qml/main.qml
261
qml/main.qml
@@ -1,138 +1,167 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls.Material 2.2
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
import QtQuick.Layouts 1.4
|
||||
import QtQuick.Controls.Material 2.4
|
||||
import QtGraphicalEffects 1.0
|
||||
import Qt.labs.settings 1.0
|
||||
|
||||
import "qrc:/qml/component"
|
||||
import "qrc:/qml/form"
|
||||
|
||||
import Qt.labs.platform 1.0 as Platform
|
||||
import Matrique 0.1
|
||||
|
||||
import "component"
|
||||
import "form"
|
||||
|
||||
ApplicationWindow {
|
||||
id: window
|
||||
visible: true
|
||||
width: 960
|
||||
height: 640
|
||||
minimumWidth: 320
|
||||
minimumHeight: 320
|
||||
title: qsTr("Matrique")
|
||||
Material.theme: settingPage.theme ? Material.Dark : Material.Light
|
||||
|
||||
Controller {
|
||||
id: matrixController
|
||||
connection: m_connection
|
||||
}
|
||||
|
||||
RoomListModel {
|
||||
id: roomListModel
|
||||
connection: m_connection
|
||||
}
|
||||
|
||||
Settings {
|
||||
id: settings
|
||||
|
||||
property alias userID: matrixController.userID
|
||||
property alias token: matrixController.token
|
||||
}
|
||||
|
||||
FontLoader { id: materialFont; source: "qrc:/asset/font/material.ttf" }
|
||||
|
||||
SideNav {
|
||||
id: sideNav
|
||||
width: 80
|
||||
height: window.height
|
||||
Settings {
|
||||
id: setting
|
||||
property alias homeserver: matriqueController.homeserver
|
||||
property alias userID: matriqueController.userID
|
||||
property alias token: matriqueController.token
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
// Platform.SystemTrayIcon {
|
||||
// visible: true
|
||||
// iconSource: "qrc:/asset/img/icon.png"
|
||||
|
||||
SideNavButton {
|
||||
contentItem: ImageStatus {
|
||||
width: parent.width
|
||||
height: parent.width
|
||||
source: "qrc:/asset/img/avatar.png"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
statusIndicator: true
|
||||
opaqueBackground: false
|
||||
}
|
||||
// onActivated: {
|
||||
// window.show()
|
||||
// window.raise()
|
||||
// window.requestActivate()
|
||||
// }
|
||||
// }
|
||||
|
||||
page: Room {
|
||||
id: roomPage
|
||||
roomListModel: roomListModel
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: "transparent"
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
SideNavButton {
|
||||
contentItem: Text {
|
||||
text: "\ue853"
|
||||
font.pointSize: 16
|
||||
font.family: materialFont.name
|
||||
color: "white"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
page: Login {
|
||||
id: loginPage
|
||||
controller: matrixController
|
||||
}
|
||||
}
|
||||
|
||||
SideNavButton {
|
||||
contentItem: Text {
|
||||
text: "\ue5d2"
|
||||
font.pointSize: 16
|
||||
font.family: materialFont.name
|
||||
color: "white"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
page: Contact {
|
||||
id: contactPage
|
||||
contactListModel: roomListModel
|
||||
}
|
||||
}
|
||||
|
||||
SideNavButton {
|
||||
contentItem: Text {
|
||||
text: "\ue8b8"
|
||||
font.pointSize: 16
|
||||
font.family: materialFont.name
|
||||
color: "white"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
page: Setting {
|
||||
id: settingPage
|
||||
}
|
||||
}
|
||||
|
||||
SideNavButton {
|
||||
contentItem: Text {
|
||||
text: "\ue879"
|
||||
font.pointSize: 16
|
||||
font.family: materialFont.name
|
||||
color: "white"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
onClicked: Qt.quit()
|
||||
}
|
||||
Controller {
|
||||
id: matriqueController
|
||||
onErrorOccured: {
|
||||
errorDialog.text = err;
|
||||
errorDialog.open();
|
||||
}
|
||||
}
|
||||
|
||||
StackView {
|
||||
id: stackView
|
||||
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(); }
|
||||
}
|
||||
}
|
||||
|
||||
Dialog {
|
||||
property alias text: errorLabel.text
|
||||
|
||||
id: errorDialog
|
||||
width: 360
|
||||
modal: true
|
||||
title: "ERROR"
|
||||
|
||||
x: (window.width - width) / 2
|
||||
y: (window.height - height) / 2
|
||||
|
||||
standardButtons: Dialog.Ok
|
||||
|
||||
Label {
|
||||
id: errorLabel
|
||||
width: parent.width
|
||||
text: "Label"
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: loginPage
|
||||
|
||||
Login { controller: matriqueController }
|
||||
}
|
||||
|
||||
Room {
|
||||
id: roomPage
|
||||
connection: matriqueController.connection
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: sideNav.width
|
||||
initialItem: roomPage
|
||||
spacing: 0
|
||||
|
||||
SideNav {
|
||||
id: sideNav
|
||||
Layout.preferredWidth: 80
|
||||
Layout.fillHeight: true
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
|
||||
SideNavButton {
|
||||
id: statusNavButton
|
||||
contentItem: ImageStatus {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 15
|
||||
|
||||
source: "qrc:/asset/img/avatar.png"
|
||||
opaqueBackground: false
|
||||
}
|
||||
|
||||
page: roomPage
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: "transparent"
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
SideNavButton {
|
||||
contentItem: MaterialIcon { icon: "\ue8b8"; color: "white" }
|
||||
|
||||
onClicked: matriqueController.logout()
|
||||
}
|
||||
|
||||
SideNavButton {
|
||||
contentItem: MaterialIcon { icon: "\ue879"; color: "white" }
|
||||
onClicked: Qt.quit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StackView {
|
||||
id: stackView
|
||||
initialItem: roomPage
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
imageProvider.setConnection(matriqueController.connection)
|
||||
imageProvider.connection = matriqueController.connection
|
||||
|
||||
console.log(matriqueController.homeserver, matriqueController.userID, matriqueController.token)
|
||||
if (matriqueController.userID != "" && matriqueController.token != "") {
|
||||
console.log("Perform auto-login.");
|
||||
matriqueController.login();
|
||||
} else {
|
||||
stackView.replace(loginPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user