Code reformatting && tooltip.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Controls.Material 2.3
|
||||
import QtQuick.Controls 2.4
|
||||
import QtQuick.Controls.Material 2.4
|
||||
import Qt.labs.settings 1.0
|
||||
import "qrc:/qml/component"
|
||||
|
||||
@@ -60,13 +60,13 @@ Page {
|
||||
id: mainCol
|
||||
width: parent.width
|
||||
|
||||
ImageStatus {
|
||||
Layout.preferredWidth: 96
|
||||
Layout.preferredHeight: 96
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
// ImageStatus {
|
||||
// Layout.preferredWidth: 96
|
||||
// Layout.preferredHeight: 96
|
||||
// Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
source: "qrc:/asset/img/avatar.png"
|
||||
}
|
||||
// source: "qrc:/asset/img/avatar.png"
|
||||
// }
|
||||
|
||||
TextField {
|
||||
id: serverField
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls 2.4
|
||||
import QtQuick.Layouts 1.11
|
||||
import Matrique 0.1
|
||||
|
||||
import "qrc:/qml/form"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import QtQuick 2.3
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
|
||||
ItemDelegate {
|
||||
id: itemDelegate
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick.Controls.Material 2.4
|
||||
|
||||
Item {
|
||||
property bool opaqueBackground: false
|
||||
property alias source: avatar.source
|
||||
property bool round: true
|
||||
property string source: ""
|
||||
property string displayText: ""
|
||||
readonly property bool showImage: source
|
||||
readonly property bool showInitial: !showImage && displayText
|
||||
|
||||
id: item
|
||||
|
||||
Rectangle {
|
||||
width: item.width
|
||||
height: item.width
|
||||
radius: item.width / 2
|
||||
radius: round ? item.width / 2 : 0
|
||||
color: "white"
|
||||
visible: opaqueBackground
|
||||
}
|
||||
@@ -20,6 +25,8 @@ Item {
|
||||
id: avatar
|
||||
width: item.width
|
||||
height: item.width
|
||||
visible: showImage
|
||||
source: item.source
|
||||
|
||||
mipmap: true
|
||||
layer.enabled: true
|
||||
@@ -35,9 +42,42 @@ Item {
|
||||
anchors.centerIn: parent
|
||||
width: avatar.width
|
||||
height: avatar.width
|
||||
radius: avatar.width / 2
|
||||
radius: round? avatar.width / 2 : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
anchors.fill: parent
|
||||
color: "white"
|
||||
visible: showInitial
|
||||
text: showInitial ? getInitials(displayText)[0] : ""
|
||||
font.pixelSize: 22
|
||||
font.bold: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
background: Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: round? width / 2 : 0
|
||||
color: showInitial ? stringToColor(displayText) : Material.accent
|
||||
}
|
||||
}
|
||||
|
||||
function getInitials(text) {
|
||||
return text.toUpperCase().replace(/[^a-zA-Z- ]/g, "").match(/\b\w/g);
|
||||
}
|
||||
|
||||
function stringToColor(str) {
|
||||
var hash = 0;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
||||
}
|
||||
var colour = '#';
|
||||
for (var i = 0; i < 3; i++) {
|
||||
var value = (hash >> (i * 8)) & 0xFF;
|
||||
colour += ('00' + value.toString(16)).substr(-2);
|
||||
}
|
||||
return colour;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls.Material 2.3
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtQuick.Controls.Material 2.4
|
||||
|
||||
Item {
|
||||
property alias icon: iconText.text
|
||||
@@ -17,5 +17,5 @@ Item {
|
||||
color: item.color
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls.Material 2.3
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtQuick.Controls.Material 2.4
|
||||
|
||||
Item {
|
||||
Rectangle {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls.Material 2.3
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtQuick.Controls.Material 2.4
|
||||
|
||||
Item {
|
||||
property var page
|
||||
@@ -29,7 +29,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
|
||||
onClicked: {
|
||||
if(page != null && stackView.currentItem !== page) {
|
||||
if(!page && stackView.currentItem !== page) {
|
||||
if(stackView.depth === 1) {
|
||||
stackView.replace(page)
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls.Material 2.3
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
import QtQuick.Layouts 1.4
|
||||
import QtQuick.Controls.Material 2.4
|
||||
import "qrc:/qml/component"
|
||||
|
||||
Item {
|
||||
|
||||
@@ -2,8 +2,8 @@ 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 QtQuick.Controls.Material 2.4
|
||||
import QtQml.Models 2.4
|
||||
import Matrique 0.1
|
||||
|
||||
import "qrc:/qml/component"
|
||||
@@ -27,6 +27,10 @@ Item {
|
||||
height: 80
|
||||
onClicked: listView.currentIndex = index
|
||||
|
||||
ToolTip.visible: pressed
|
||||
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
|
||||
ToolTip.text: name
|
||||
|
||||
contentItem: RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 16
|
||||
@@ -36,7 +40,8 @@ Item {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
|
||||
source: avatar == null || avatar == "" ? "qrc:/asset/img/avatar.png" : "image://mxc/" + avatar
|
||||
source: avatar ? "image://mxc/" + avatar : ""
|
||||
displayText: name
|
||||
opaqueBackground: true
|
||||
}
|
||||
|
||||
@@ -52,10 +57,10 @@ Item {
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: {
|
||||
if (name != "") {
|
||||
if (name) {
|
||||
return name;
|
||||
}
|
||||
if (alias != "") {
|
||||
if (alias) {
|
||||
return alias;
|
||||
}
|
||||
return id
|
||||
@@ -69,7 +74,7 @@ Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: topic === "" ? "No topic yet." : topic
|
||||
text: topic ? topic : "No topic yet."
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
@@ -133,7 +138,7 @@ Item {
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: searchField.activeFocus || searchField.text != "" ? parent.width : 0
|
||||
width: searchField.activeFocus || searchField.text ? parent.width : 0
|
||||
height: parent.height
|
||||
color: "white"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls.Material 2.3
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtQuick.Controls.Material 2.4
|
||||
import QtGraphicalEffects 1.0
|
||||
import Matrique 0.1
|
||||
import "qrc:/qml/component"
|
||||
@@ -16,7 +16,7 @@ Item {
|
||||
|
||||
background: Item {
|
||||
anchors.fill: parent
|
||||
visible: currentRoom == null
|
||||
visible: !currentRoom
|
||||
Pane {
|
||||
anchors.fill: parent
|
||||
}
|
||||
@@ -32,7 +32,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
|
||||
visible: currentRoom != null
|
||||
visible: currentRoom
|
||||
|
||||
Pane {
|
||||
z: 10
|
||||
@@ -52,7 +52,8 @@ Item {
|
||||
ImageStatus {
|
||||
Layout.preferredWidth: parent.height
|
||||
Layout.fillHeight: true
|
||||
source: currentRoom != null && currentRoom.avatarUrl != "" ? "image://mxc/" + currentRoom.avatarUrl : "qrc:/asset/img/avatar.png"
|
||||
source: currentRoom && currentRoom.avatarUrl != "" ? "image://mxc/" + currentRoom.avatarUrl : null
|
||||
displayText: currentRoom ? currentRoom.displayName : ""
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
@@ -61,7 +62,7 @@ Item {
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: currentRoom != null ? currentRoom.displayName : ""
|
||||
text: currentRoom ? currentRoom.displayName : ""
|
||||
font.pointSize: 16
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
@@ -69,7 +70,7 @@ Item {
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: currentRoom != null ? currentRoom.topic : ""
|
||||
text: currentRoom ? currentRoom.topic : ""
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
@@ -88,12 +89,14 @@ Item {
|
||||
displayMarginEnd: 40
|
||||
verticalLayoutDirection: ListView.BottomToTop
|
||||
spacing: 12
|
||||
|
||||
model: MessageEventModel{
|
||||
id: messageEventModel
|
||||
room: currentRoom
|
||||
|
||||
onModelReset: currentRoom.getPreviousContent(50)
|
||||
}
|
||||
|
||||
delegate: Row {
|
||||
readonly property bool sentByMe: author === currentRoom.localUser
|
||||
|
||||
@@ -102,18 +105,28 @@ Item {
|
||||
anchors.right: sentByMe ? parent.right : undefined
|
||||
spacing: 6
|
||||
|
||||
Image {
|
||||
ImageStatus {
|
||||
id: avatar
|
||||
width: height
|
||||
height: 40
|
||||
mipmap: true
|
||||
round: false
|
||||
visible: !sentByMe
|
||||
source: author.avatarUrl != "" ? "image://mxc/" + author.avatarUrl : "qrc:/asset/img/avatar.png"
|
||||
source: author.avatarUrl != "" ? "image://mxc/" + author.avatarUrl : null
|
||||
displayText: author.displayName
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
|
||||
ToolTip.visible: pressed
|
||||
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
|
||||
ToolTip.text: author.displayName
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: Math.min(messageText.implicitWidth + 24,
|
||||
messageListView.width - (!sentByMe ? avatar.width + messageRow.spacing : 0))
|
||||
messageListView.width - (!sentByMe ? avatar.width + messageRow.spacing : 0))
|
||||
height: messageText.implicitHeight + 24
|
||||
color: sentByMe ? "lightgrey" : Material.accent
|
||||
|
||||
@@ -121,6 +134,7 @@ Item {
|
||||
id: messageText
|
||||
text: display
|
||||
color: sentByMe ? "black" : "white"
|
||||
linkColor: sentByMe ? Material.accent : "white"
|
||||
anchors.fill: parent
|
||||
anchors.margins: 12
|
||||
wrapMode: Label.Wrap
|
||||
|
||||
25
qml/main.qml
25
qml/main.qml
@@ -1,6 +1,6 @@
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
import QtQuick.Layouts 1.4
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtQuick.Controls.Material 2.4
|
||||
import QtGraphicalEffects 1.0
|
||||
import Qt.labs.settings 1.0
|
||||
@@ -28,16 +28,16 @@ ApplicationWindow {
|
||||
property alias token: matriqueController.token
|
||||
}
|
||||
|
||||
// Platform.SystemTrayIcon {
|
||||
// visible: true
|
||||
// iconSource: "qrc:/asset/img/icon.png"
|
||||
// Platform.SystemTrayIcon {
|
||||
// visible: true
|
||||
// iconSource: "qrc:/asset/img/icon.png"
|
||||
|
||||
// onActivated: {
|
||||
// window.show()
|
||||
// window.raise()
|
||||
// window.requestActivate()
|
||||
// }
|
||||
// }
|
||||
// onActivated: {
|
||||
// window.show()
|
||||
// window.raise()
|
||||
// window.requestActivate()
|
||||
// }
|
||||
// }
|
||||
|
||||
Controller {
|
||||
id: matriqueController
|
||||
@@ -118,7 +118,8 @@ ApplicationWindow {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 15
|
||||
|
||||
source: matriqueController.connection.localUser != null ? "image://mxc/" + matriqueController.connection.localUser.avatarUrl : "qrc:/asset/img/avatar.png"
|
||||
source: matriqueController.connection.localUser && matriqueController.connection.localUser.avatarUrl ? "image://mxc/" + matriqueController.connection.localUser.avatarUrl : ""
|
||||
displayText: matriqueController.connection.localUser && matriqueController.connection.localUser.displayText ? matriqueController.connection.localUser.displayText : "N"
|
||||
opaqueBackground: false
|
||||
}
|
||||
|
||||
@@ -158,7 +159,7 @@ ApplicationWindow {
|
||||
imageProvider.connection = matriqueController.connection
|
||||
|
||||
console.log(matriqueController.homeserver, matriqueController.userID, matriqueController.token)
|
||||
if (matriqueController.userID != "" && matriqueController.token != "") {
|
||||
if (matriqueController.userID && matriqueController.token) {
|
||||
console.log("Perform auto-login.");
|
||||
matriqueController.login();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user