Organize qml files a bit

This commit is contained in:
Nicolas Werner 2019-10-27 22:01:40 +01:00
parent e52ff609ed
commit 2055c75f8b
13 changed files with 35 additions and 37 deletions

View file

@ -70,6 +70,7 @@ include(LMDB)
# Discover Qt dependencies. # Discover Qt dependencies.
# #
find_package(Qt5 COMPONENTS Core Widgets LinguistTools Concurrent Svg Multimedia Qml QuickControls2 REQUIRED) find_package(Qt5 COMPONENTS Core Widgets LinguistTools Concurrent Svg Multimedia Qml QuickControls2 REQUIRED)
find_package(Qt5QuickCompiler)
find_package(Qt5DBus) find_package(Qt5DBus)
if (APPLE) if (APPLE)

View file

@ -21,4 +21,9 @@ if(NOT EXISTS ${_qrc})
endif() endif()
qt5_add_resources(LANG_QRC ${_qrc}) qt5_add_resources(LANG_QRC ${_qrc})
#qt5_add_resources(QRC resources/res.qrc)
if(Qt5QuickCompiler_FOUND)
qtquick_compiler_add_resources(QRC resources/res.qrc)
else()
qt5_add_resources(QRC resources/res.qrc) qt5_add_resources(QRC resources/res.qrc)
endif()

View file

@ -30,6 +30,7 @@ Rectangle {
id: img id: img
anchors.fill: parent anchors.fill: parent
asynchronous: true asynchronous: true
fillMode: Image.PreserveAspectCrop
layer.enabled: true layer.enabled: true
layer.effect: OpacityMask { layer.effect: OpacityMask {

View file

@ -6,29 +6,22 @@ import QtQuick.Window 2.2
import com.github.nheko 1.0 import com.github.nheko 1.0
import ".." import "./delegates"
RowLayout { RowLayout {
property var view: undefined property var view: chat
default property alias data: contentItem.data
height: kid.height // TODO: fix this, we shouldn't need to give the child of contentItem this id!
anchors.leftMargin: avatarSize + 4 anchors.leftMargin: avatarSize + 4
anchors.rightMargin: scrollbar.width
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: scrollbar.width
function isFullyVisible() { height: contentItem.height
return (y - view.contentY - 1) + height < view.height
}
function getIndex() {
return index;
}
Item { MessageDelegate {
id: contentItem
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
id: contentItem
} }
StatusIndicator { StatusIndicator {

View file

@ -90,14 +90,13 @@ Rectangle {
onMovementEnded: updatePosition() onMovementEnded: updatePosition()
spacing: 4 spacing: 4
delegate: RowDelegateChooser { delegate: TimelineRow {
function isFullyVisible() { function isFullyVisible() {
return height > 1 && (y - chat.contentY - 1) + height < chat.height return height > 1 && (y - chat.contentY - 1) + height < chat.height
} }
function getIndex() { function getIndex() {
return index; return index;
} }
} }
section { section {

View file

@ -5,7 +5,7 @@ Rectangle {
radius: 10 radius: 10
color: colors.dark color: colors.dark
height: row.height + 24 height: row.height + 24
width: parent.width width: parent ? parent.width : undefined
RowLayout { RowLayout {
id: row id: row

View file

@ -3,7 +3,7 @@ import QtQuick 2.6
import com.github.nheko 1.0 import com.github.nheko 1.0
Item { Item {
width: Math.min(parent.width, model.width) width: Math.min(parent ? parent.width : undefined, model.width)
height: width * model.proportionalHeight height: width * model.proportionalHeight
Image { Image {

View file

@ -2,50 +2,49 @@ import QtQuick 2.6
import Qt.labs.qmlmodels 1.0 import Qt.labs.qmlmodels 1.0
import com.github.nheko 1.0 import com.github.nheko 1.0
import "./delegates"
DelegateChooser { DelegateChooser {
//role: "type" //< not supported in our custom implementation, have to use roleValue //role: "type" //< not supported in our custom implementation, have to use roleValue
width: chat.width
roleValue: model.type roleValue: model.type
width: parent.width
DelegateChoice { DelegateChoice {
roleValue: MtxEvent.TextMessage roleValue: MtxEvent.TextMessage
TimelineRow { view: chat; TextMessage { id: kid } } TextMessage {}
} }
DelegateChoice { DelegateChoice {
roleValue: MtxEvent.NoticeMessage roleValue: MtxEvent.NoticeMessage
TimelineRow { view: chat; NoticeMessage { id: kid } } NoticeMessage {}
} }
DelegateChoice { DelegateChoice {
roleValue: MtxEvent.EmoteMessage roleValue: MtxEvent.EmoteMessage
TimelineRow { view: chat; TextMessage { id: kid } } TextMessage {}
} }
DelegateChoice { DelegateChoice {
roleValue: MtxEvent.ImageMessage roleValue: MtxEvent.ImageMessage
TimelineRow { view: chat; ImageMessage { id: kid } } ImageMessage {}
} }
DelegateChoice { DelegateChoice {
roleValue: MtxEvent.Sticker roleValue: MtxEvent.Sticker
TimelineRow { view: chat; ImageMessage { id: kid } } ImageMessage {}
} }
DelegateChoice { DelegateChoice {
roleValue: MtxEvent.FileMessage roleValue: MtxEvent.FileMessage
TimelineRow { view: chat; FileMessage { id: kid } } FileMessage {}
} }
DelegateChoice { DelegateChoice {
roleValue: MtxEvent.VideoMessage roleValue: MtxEvent.VideoMessage
TimelineRow { view: chat; PlayableMediaMessage { id: kid } } PlayableMediaMessage {}
} }
DelegateChoice { DelegateChoice {
roleValue: MtxEvent.AudioMessage roleValue: MtxEvent.AudioMessage
TimelineRow { view: chat; PlayableMediaMessage { id: kid } } PlayableMediaMessage {}
} }
DelegateChoice { DelegateChoice {
roleValue: MtxEvent.Redacted roleValue: MtxEvent.Redacted
TimelineRow { view: chat; Redacted { id: kid } } Redacted {}
} }
DelegateChoice { DelegateChoice {
TimelineRow { view: chat; Placeholder { id: kid } } Placeholder {}
} }
} }

View file

@ -5,7 +5,7 @@ TextEdit {
textFormat: TextEdit.RichText textFormat: TextEdit.RichText
readOnly: true readOnly: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
width: parent.width width: parent ? parent.width : undefined
selectByMouse: true selectByMouse: true
font.italic: true font.italic: true
color: inactiveColors.text color: inactiveColors.text

View file

@ -5,6 +5,6 @@ Label {
text: qsTr("unimplemented event: ") + model.type text: qsTr("unimplemented event: ") + model.type
textFormat: Text.PlainText textFormat: Text.PlainText
wrapMode: Text.Wrap wrapMode: Text.Wrap
width: parent.width width: parent ? parent.width : undefined
color: inactiveColors.text color: inactiveColors.text
} }

View file

@ -10,7 +10,7 @@ Rectangle {
radius: 10 radius: 10
color: colors.dark color: colors.dark
height: content.height + 24 height: content.height + 24
width: parent.width width: parent ? parent.width : undefined
Column { Column {
id: content id: content

View file

@ -5,7 +5,7 @@ TextEdit {
textFormat: TextEdit.RichText textFormat: TextEdit.RichText
readOnly: true readOnly: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
width: parent.width width: parent ? parent.width : undefined
selectByMouse: true selectByMouse: true
color: colors.text color: colors.text
} }

View file

@ -116,11 +116,11 @@
</qresource> </qresource>
<qresource prefix="/"> <qresource prefix="/">
<file>qml/TimelineView.qml</file> <file>qml/TimelineView.qml</file>
<file>qml/RowDelegateChooser.qml</file>
<file>qml/Avatar.qml</file> <file>qml/Avatar.qml</file>
<file>qml/StatusIndicator.qml</file> <file>qml/StatusIndicator.qml</file>
<file>qml/EncryptionIndicator.qml</file> <file>qml/EncryptionIndicator.qml</file>
<file>qml/delegates/TimelineRow.qml</file> <file>qml/TimelineRow.qml</file>
<file>qml/delegates/MessageDelegate.qml</file>
<file>qml/delegates/TextMessage.qml</file> <file>qml/delegates/TextMessage.qml</file>
<file>qml/delegates/NoticeMessage.qml</file> <file>qml/delegates/NoticeMessage.qml</file>
<file>qml/delegates/ImageMessage.qml</file> <file>qml/delegates/ImageMessage.qml</file>