Code reformatting && tooltip.

This commit is contained in:
Black Hat
2018-07-09 10:45:26 +08:00
parent d6b5cba61f
commit 6bd059ce63
22 changed files with 826 additions and 854 deletions

View File

@@ -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 {

View File

@@ -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"

View File

@@ -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