Reorder QML files to follow coding conventions

https://doc.qt.io/qt-5/qml-codingconventions.html#qml-object-declarations
This commit is contained in:
miruka
2020-07-12 00:25:57 -04:00
parent 229fbee298
commit 3c7b78d4ca
131 changed files with 1022 additions and 1122 deletions

View File

@@ -11,12 +11,10 @@ import "../../Dialogs"
HFlickableColumnPage {
id: page
property string userId
readonly property QtObject account: ModelStore.get("accounts").find(userId)
readonly property bool ready: account && account.profile_updated >= new Date(1)
function takeFocus() {
nameField.item.forceActiveFocus()
}
@@ -90,11 +88,11 @@ HFlickableColumnPage {
onKeyboardCancel: cancel()
onKeyboardAccept: applyChanges()
HUserAvatar {
id: avatar
property bool changed: Boolean(sourceOverride)
id: avatar
userId: page.userId
displayName: nameField.item.text
mxc: account ? account.avatar_url : ""
@@ -231,6 +229,8 @@ HFlickableColumnPage {
}
HLabeledItem {
id: aliasField
readonly property var aliases: window.settings.writeAliases
readonly property string currentAlias: aliases[userId] || ""
@@ -243,9 +243,6 @@ HFlickableColumnPage {
return ""
}
id: aliasField
label.text: qsTr("Composer alias:")
errorLabel.text:

View File

@@ -9,7 +9,6 @@ import "../../Base"
HPage {
id: page
property string userId

View File

@@ -9,7 +9,6 @@ import "../../Base/HTile"
HTile {
id: deviceTile
property HListView view
property string userId

View File

@@ -15,6 +15,7 @@ HRowLayout {
readonly property int sectionTotalCount:
deviceList.sectionItemCounts[section] || 0
HCheckBox {
id: checkBox
padding: theme.spacing

View File

@@ -8,10 +8,8 @@ import "../../Base/Buttons"
HFlickableColumnPage {
id: page
property string userId
function takeFocus() { exportButton.forceActiveFocus() }

View File

@@ -11,15 +11,6 @@ import "../../ShortcutBundles"
HColumnPage {
id: page
enabled: ModelStore.get("accounts").find(userId).presence !== "offline"
contentHeight: Math.min(
window.height,
Math.max(
deviceList.contentHeight + deviceList.bottomMargin,
busyIndicatorLoader.height + theme.spacing * 2,
)
)
property string userId
@@ -28,7 +19,6 @@ HColumnPage {
property Future loadFuture: null
function takeFocus() {} // TODO
function loadDevices() {
@@ -100,6 +90,15 @@ HColumnPage {
}
enabled: ModelStore.get("accounts").find(userId).presence !== "offline"
contentHeight: Math.min(
window.height,
Math.max(
deviceList.contentHeight + deviceList.bottomMargin,
busyIndicatorLoader.height + theme.spacing * 2,
)
)
footer: AutoDirectionLayout {
GroupButton {
id: refreshButton
@@ -126,7 +125,6 @@ HColumnPage {
Keys.forwardTo: [deviceList]
HListView {
id: deviceList

View File

@@ -20,7 +20,6 @@ HFlickableColumnPage {
}
}
HLabel {
wrapMode: Text.Wrap
horizontalAlignment: Qt.AlignHCenter

View File

@@ -21,7 +21,6 @@ HFlickableColumnPage {
}
}
HLabel {
wrapMode: Text.Wrap
horizontalAlignment: Qt.AlignHCenter

View File

@@ -8,7 +8,6 @@ import "../../Base/Buttons"
HFlickableColumnPage {
id: page
property var loginFuture: null
property string signInWith: "username"
@@ -17,7 +16,6 @@ HFlickableColumnPage {
serverField.item.text.trim() && idField.item.text.trim() &&
passwordField.item.text && ! serverField.item.error
function takeFocus() { idField.item.forceActiveFocus() }
function signIn() {
@@ -95,7 +93,6 @@ HFlickableColumnPage {
onKeyboardAccept: page.signIn()
onKeyboardCancel: page.cancel()
Timer {
id: signInTimeout
interval: 30 * 1000
@@ -190,11 +187,11 @@ HFlickableColumnPage {
Layout.fillWidth: true
HTextField {
readonly property string cleanText: text.toLowerCase().trim()
width: parent.width
text: "https://matrix.org"
error: ! /.+:\/\/.+/.test(cleanText)
readonly property string cleanText: text.toLowerCase().trim()
}
}

View File

@@ -7,7 +7,6 @@ import "../../Base"
HPage {
id: page
property string userId

View File

@@ -8,13 +8,10 @@ import "../../Base/Buttons"
HFlickableColumnPage {
id: page
enabled: account && account.presence !== "offline"
property string userId
readonly property QtObject account: ModelStore.get("accounts").find(userId)
function takeFocus() { nameField.item.forceActiveFocus() }
function create() {
@@ -52,6 +49,8 @@ HFlickableColumnPage {
}
enabled: account && account.presence !== "offline"
footer: AutoDirectionLayout {
ApplyButton {
id: applyButton
@@ -68,7 +67,6 @@ HFlickableColumnPage {
onKeyboardAccept: create()
onKeyboardCancel: cancel()
HRoomAvatar {
id: avatar
roomId: ""

View File

@@ -7,6 +7,7 @@ import "../../Base"
HUserAvatar {
property QtObject account
// userId: (set me)
displayName: account ? account.display_name : ""
mxc: account ? account.avatar_url : ""

View File

@@ -8,13 +8,10 @@ import "../../Base/Buttons"
HFlickableColumnPage {
id: page
enabled: account && account.presence !== "offline"
property string userId
readonly property QtObject account: ModelStore.get("accounts").find(userId)
function takeFocus() {
userField.item.forceActiveFocus()
}
@@ -64,6 +61,8 @@ HFlickableColumnPage {
}
enabled: account && account.presence !== "offline"
footer: AutoDirectionLayout {
ApplyButton {
id: applyButton
@@ -85,7 +84,6 @@ HFlickableColumnPage {
onKeyboardAccept: startChat()
onKeyboardCancel: cancel()
CurrentUserAvatar {
userId: page.userId
account: page.account

View File

@@ -5,11 +5,11 @@ import "../../Base"
HCheckBox {
text: qsTr("Encrypt messages")
subtitle.textFormat: Text.StyledText
subtitle.text:
qsTr("Only you and those you trust will be able to read the " +
"conversation") +
`<br><font color="${theme.colors.warningText}">` +
qsTr("Cannot be disabled later!") +
"</font>"
subtitle.textFormat: Text.StyledText
}

View File

@@ -8,13 +8,10 @@ import "../../Base/Buttons"
HFlickableColumnPage {
id: page
enabled: account && account.presence !== "offline"
property string userId
readonly property QtObject account: ModelStore.get("accounts").find(userId)
function takeFocus() {
roomField.item.forceActiveFocus()
}
@@ -57,6 +54,8 @@ HFlickableColumnPage {
}
enabled: account && account.presence !== "offline"
footer: AutoDirectionLayout {
ApplyButton {
id: joinButton
@@ -74,7 +73,6 @@ HFlickableColumnPage {
onKeyboardAccept: join()
onKeyboardCancel: cancel()
CurrentUserAvatar {
userId: page.userId
account: page.account

View File

@@ -6,8 +6,6 @@ import "../../../Base"
Rectangle {
id: banner
implicitHeight: childrenRect.height
color: theme.controls.box.background
property alias avatar: bannerAvatar
property alias icon: bannerIcon
@@ -15,6 +13,10 @@ Rectangle {
property alias buttonModel: bannerRepeater.model
property var buttonCallbacks: []
implicitHeight: childrenRect.height
color: theme.controls.box.background
HGridLayout {
id: bannerGrid
width: parent.width

View File

@@ -8,6 +8,7 @@ Banner {
property string inviterName: chat.roomInfo.inviter_name
property string inviterAvatar: chat.roomInfo.inviter_avatar
color: theme.chat.inviteBanner.background
avatar.userId: inviterId

View File

@@ -9,10 +9,6 @@ import "RoomPane"
Item {
id: chat
onFocusChanged: if (focus && loader.item) loader.item.composer.takeFocus()
onReadyChanged: longLoading = false
property string userId
property string roomId
@@ -33,6 +29,9 @@ Item {
Boolean(loader.item && loader.item.composer.hasFocus)
onFocusChanged: if (focus && loader.item) loader.item.composer.takeFocus()
onReadyChanged: longLoading = false
HShortcut {
sequences: window.settings.keys.leaveRoom
active: userInfo && userInfo.presence !== "offline"

View File

@@ -10,12 +10,6 @@ import "Timeline"
HColumnPage {
id: chatPage
padding: 0
column.spacing: 0
onLoadEventListChanged: if (loadEventList) loadedOnce = true
Component.onDestruction: if (loadMembersFuture) loadMembersFuture.cancel()
property bool loadedOnce: false
property var loadMembersFuture: null
@@ -26,6 +20,12 @@ HColumnPage {
! mainUI.mainPane.visible : ! pageLoader.appearAnimation.running
padding: 0
column.spacing: 0
onLoadEventListChanged: if (loadEventList) loadedOnce = true
Component.onDestruction: if (loadMembersFuture) loadMembersFuture.cancel()
Timer {
interval: 200
running: true

View File

@@ -8,7 +8,6 @@ Rectangle {
property alias eventList: messageArea.eventList
readonly property bool hasFocus: messageArea.activeFocus
function takeFocus() { messageArea.forceActiveFocus() }
@@ -17,7 +16,6 @@ Rectangle {
color: theme.chat.composer.background
HRowLayout {
anchors.fill: parent

View File

@@ -7,7 +7,6 @@ import "../../../Base"
HTextArea {
id: textArea
property HListView eventList
property string indent: " "
@@ -50,7 +49,6 @@ HTextArea {
return obj
}
function setTyping(typing) {
py.callClientCoro(
writingUserId, "room_typing", [chat.roomId, typing, 5000],

View File

@@ -19,7 +19,6 @@ HButton {
onClicked: sendFilePicker.dialog.open()
HShortcut {
sequences: window.settings.keys.sendFileFromPathInClipboard
onActivated: utils.sendFile(

View File

@@ -8,7 +8,6 @@ import "../../../Base"
HColumnLayout {
id: transfer
property bool cancelPending: false
property int msLeft: model.time_left
@@ -18,7 +17,6 @@ HColumnLayout {
readonly property string status: model.status
readonly property bool paused: model.paused
function cancel() {
cancelPending = true
// Python will delete this model item on cancel
@@ -51,6 +49,15 @@ HColumnLayout {
HLabel {
id: statusLabel
property bool expand: status === "Error"
readonly property string fileName:
model.filepath.split("/").slice(-1)[0]
readonly property string filePath:
model.filepath.replace(/^file:\/\//, "")
elide: expand ? Text.ElideNone : Text.ElideRight
wrapMode: expand ? Text.Wrap : Text.NoWrap
@@ -92,16 +99,6 @@ HColumnLayout {
Layout.fillWidth: true
property bool expand: status === "Error"
readonly property string fileName:
model.filepath.split("/").slice(-1)[0]
readonly property string filePath:
model.filepath.replace(/^file:\/\//, "")
HoverHandler { id: statusLabelHover }
HToolTip {

View File

@@ -5,13 +5,6 @@ import "../../.."
import "../../../Base"
Rectangle {
implicitWidth: 800
implicitHeight: firstDelegate ? firstDelegate.height : 0
color: theme.chat.fileTransfer.background
opacity: implicitHeight ? 1 : 0
clip: true
property int delegateHeight: 0
readonly property var firstDelegate:
@@ -20,6 +13,12 @@ Rectangle {
readonly property alias transferCount: transferList.count
implicitWidth: 800
implicitHeight: firstDelegate ? firstDelegate.height : 0
color: theme.chat.fileTransfer.background
opacity: implicitHeight ? 1 : 0
clip: true
Behavior on implicitHeight { HNumberAnimation {} }
HListView {

View File

@@ -5,15 +5,15 @@ import QtQuick.Layouts 1.12
import "../../Base"
Rectangle {
implicitHeight: label.text ? rowLayout.height : 0
opacity: implicitHeight ? 1 : 0
default property alias rowLayoutData: rowLayout.data
readonly property alias icon: icon
readonly property alias label: label
default property alias rowLayoutData: rowLayout.data
implicitHeight: label.text ? rowLayout.height : 0
opacity: implicitHeight ? 1 : 0
Behavior on implicitHeight { HNumberAnimation {} }
HRowLayout {

View File

@@ -5,6 +5,13 @@ import QtQuick.Layouts 1.12
import "../../Base"
InfoBar {
property string replyToEventId: ""
property string replyToUserId: ""
property string replyToDisplayName: ""
signal cancel()
color: theme.chat.replyBar.background
icon.svgName: "reply-to"
label.textFormat: Text.StyledText
@@ -13,15 +20,6 @@ InfoBar {
utils.coloredNameHtml(replyToDisplayName, replyToUserId) :
""
signal cancel()
property string replyToEventId: ""
property string replyToUserId: ""
property string replyToDisplayName: ""
HButton {
backgroundColor: "transparent"
icon.name: "reply-cancel"

View File

@@ -5,16 +5,15 @@ import QtQuick.Layouts 1.12
import "../../Base"
Rectangle {
implicitHeight: theme.baseElementsHeight
color: theme.chat.roomHeader.background
readonly property bool showPaneButtons: mainUI.mainPane.collapse
readonly property bool center:
showPaneButtons || window.settings.alwaysCenterRoomHeader
implicitHeight: theme.baseElementsHeight
color: theme.chat.roomHeader.background
HRowLayout {
id: row
anchors.fill: parent
@@ -113,16 +112,16 @@ Rectangle {
}
HToolTip {
visible: text && (nameHover.hovered || topicHover.hovered)
label.textFormat: Text.StyledText
text: name && topic ? (`${name}<br>${topic}`) : (name || topic)
readonly property string name:
nameLabel.truncated ?
(`<b>${chat.roomInfo.display_name}</b>`) : ""
readonly property string topic:
topicLabel.truncated ? chat.roomInfo.topic : ""
visible: text && (nameHover.hovered || topicHover.hovered)
label.textFormat: Text.StyledText
text: name && topic ? (`${name}<br>${topic}`) : (name || topic)
}
HSpacer {

View File

@@ -8,7 +8,6 @@ import "../../../../Base/Buttons"
HFlickableColumnPage {
id: page
property string deviceOwner
property string deviceOwnerDisplayName
property string deviceId
@@ -20,7 +19,6 @@ HFlickableColumnPage {
signal trustSet(bool trust)
function close() {
if (previouslyFocused) previouslyFocused.forceActiveFocus()
stackView.pop()
@@ -72,7 +70,6 @@ HFlickableColumnPage {
onKeyboardCancel: page.close()
HRowLayout {
HButton {
id: closeButton

View File

@@ -9,6 +9,7 @@ import "../../../../Popups"
HTile {
id: member
backgroundColor: theme.chat.roomPane.listView.member.background
contentOpacity:
model.invited ? theme.chat.roomPane.listView.member.invitedOpacity : 1
@@ -142,7 +143,6 @@ HTile {
}
}
Behavior on contentOpacity { HNumberAnimation {} }
Behavior on spacing { HNumberAnimation {} }

View File

@@ -8,13 +8,11 @@ import "../../../../Base"
HListView {
id: profile
property string userId
property string roomId
property QtObject member // RoomMember model item
property HStackView stackView
function loadDevices() {
py.callClientCoro(userId, "member_devices", [member.id], devices => {
profile.model.clear()
@@ -211,7 +209,6 @@ HListView {
}
Keys.onEscapePressed: stackView.pop()
Connections {
target: py.eventHandlers

View File

@@ -10,6 +10,7 @@ HColumnLayout {
readonly property var modelSyncId:
[chat.userId, chat.roomId, "filtered_members"]
HStackView {
id: stackView

View File

@@ -7,6 +7,22 @@ import "MemberView"
MultiviewPane {
id: roomPane
readonly property QtObject accountModel:
ModelStore.get("accounts").find(chat.roomInfo.for_account)
function toggleFocus() {
if (roomPane.activeFocus) {
if (roomPane.collapse) roomPane.close()
pageLoader.takeFocus()
return
}
roomPane.open()
swipeView.currentItem.keybindFocusItem.forceActiveFocus()
}
saveName: "roomPane"
edge: Qt.RightEdge
@@ -56,23 +72,6 @@ MultiviewPane {
}
}
readonly property QtObject accountModel:
ModelStore.get("accounts").find(chat.roomInfo.for_account)
function toggleFocus() {
if (roomPane.activeFocus) {
if (roomPane.collapse) roomPane.close()
pageLoader.takeFocus()
return
}
roomPane.open()
swipeView.currentItem.keybindFocusItem.forceActiveFocus()
}
Connections {
target: swipeView

View File

@@ -9,7 +9,6 @@ import "../../../Base/Buttons"
HFlickableColumnPage {
id: settingsView
property var saveFuture: null
readonly property bool anyChange:
@@ -19,7 +18,6 @@ HFlickableColumnPage {
readonly property Item keybindFocusItem: nameField.item
function save() {
if (saveFuture) saveFuture.cancel()
@@ -81,7 +79,6 @@ HFlickableColumnPage {
onKeyboardAccept: save()
onKeyboardCancel: cancel()
HRoomAvatar {
id: avatar
roomId: chat.roomId
@@ -117,13 +114,13 @@ HFlickableColumnPage {
Layout.fillWidth: true
HScrollView {
readonly property alias area: topicAreaIn
clip: true
width: parent.width
height:
Math.min(topicAreaIn.implicitHeight, settingsView.height / 2)
readonly property alias area: topicAreaIn
HTextArea {
id: topicAreaIn
placeholderText: qsTr("This room is about...")

View File

@@ -7,9 +7,6 @@ import "../../.."
HRowLayout {
id: eventContent
spacing: theme.chat.message.horizontalSpacing
layoutDirection: onRight ? Qt.RightToLeft: Qt.LeftToRight
readonly property var mentions: JSON.parse(model.mentions)
@@ -76,6 +73,9 @@ HRowLayout {
readonly property alias selectedText: contentLabel.selectedText
spacing: theme.chat.message.horizontalSpacing
layoutDirection: onRight ? Qt.RightToLeft: Qt.LeftToRight
Item {
id: avatarWrapper
opacity: collapseAvatar ? 0 : 1
@@ -187,6 +187,9 @@ HRowLayout {
PointHandler {
id: mousePointHandler
property bool checkedNow: false
acceptedButtons: Qt.LeftButton
acceptedModifiers: Qt.NoModifier
acceptedPointerTypes:
@@ -208,8 +211,6 @@ HRowLayout {
eventList.uncheck(model.index)
}
}
property bool checkedNow: false
}
PointHandler {

View File

@@ -8,10 +8,6 @@ import "../../../Base"
HColumnLayout {
id: eventDelegate
width: eventList.width - eventList.leftMargin - eventList.rightMargin
ListView.onRemove: eventList.uncheck(model.id)
enum Media { Page, File, Image, Video, Audio }
@@ -62,18 +58,6 @@ HColumnLayout {
readonly property alias eventContent: eventContent
// Needed because of eventList's MouseArea which steals the
// HSelectableLabel's MouseArea hover events
onCursorShapeChanged: eventList.cursorShape = cursorShape
Component.onCompleted: if (model.fetch_profile) py.callClientCoro(
chat.userId, "get_event_profiles", [chat.roomId, model.id],
)
Component.onDestruction:
if (fetchProfilesFuture) fetchProfilesFuture.cancel()
function json() {
let event = ModelStore.get(chat.userId, chat.roomId, "events")
.get(model.index)
@@ -93,6 +77,21 @@ HColumnLayout {
}
width: eventList.width - eventList.leftMargin - eventList.rightMargin
// Needed because of eventList's MouseArea which steals the
// HSelectableLabel's MouseArea hover events
onCursorShapeChanged: eventList.cursorShape = cursorShape
Component.onCompleted: if (model.fetch_profile) py.callClientCoro(
chat.userId, "get_event_profiles", [chat.roomId, model.id],
)
Component.onDestruction:
if (fetchProfilesFuture) fetchProfilesFuture.cancel()
ListView.onRemove: eventList.uncheck(model.id)
Item {
Layout.fillWidth: true
Layout.preferredHeight:
@@ -240,6 +239,16 @@ HColumnLayout {
}
HMenuItemPopupSpawner {
readonly property var events: {
eventList.selectedCount ?
eventList.redactableCheckedEvents :
eventList.canRedact(currentModel) ?
[model] :
[]
}
icon.name: "remove-message"
text: qsTr("Remove")
enabled: properties.eventSenderAndIds.length
@@ -254,16 +263,6 @@ HColumnLayout {
! chat.roomInfo.can_redact_all &&
events.length < eventList.selectedCount
})
readonly property var events: {
eventList.selectedCount ?
eventList.redactableCheckedEvents :
eventList.canRedact(currentModel) ?
[model] :
[]
}
}
HMenuItem {

View File

@@ -8,6 +8,15 @@ import "../../../Base/HTile"
HTile {
id: file
property EventMediaLoader loader
readonly property bool cryptDict:
JSON.parse(loader.singleMediaInfo.media_crypt_dict)
readonly property bool isEncrypted: ! utils.isEmptyObject(cryptDict)
width: Math.min(
eventDelegate.width,
eventContent.maxMessageWidth,
@@ -55,15 +64,6 @@ HTile {
]
}
property EventMediaLoader loader
readonly property bool cryptDict:
JSON.parse(loader.singleMediaInfo.media_crypt_dict)
readonly property bool isEncrypted: ! utils.isEmptyObject(cryptDict)
Binding on backgroundColor {
value: theme.chat.message.checkedBackground
when: eventDelegate.checked

View File

@@ -5,24 +5,6 @@ import "../../../Base"
HMxcImage {
id: image
width: fitSize.width
height: fitSize.height
horizontalAlignment: Image.AlignLeft
enabledAnimatedPausing: ! eventList.selectedCount
title: thumbnail ? loader.thumbnailTitle : loader.title
animated: loader.singleMediaInfo.media_mime === "image/gif" ||
utils.urlExtension(loader.mediaUrl).toLowerCase() === "gif"
thumbnail: ! animated && loader.thumbnailMxc
mxc: thumbnail ?
(loader.thumbnailMxc || loader.mediaUrl) :
(loader.mediaUrl || loader.thumbnailMxc)
cryptDict: JSON.parse(
thumbnail && loader.thumbnailMxc ?
loader.singleMediaInfo.thumbnail_crypt_dict :
loader.singleMediaInfo.media_crypt_dict
)
property EventMediaLoader loader
@@ -61,7 +43,6 @@ HMxcImage {
Math.max(maxHeight, theme.chat.message.thumbnailMinSize.height),
)
function getOpenUrl(callback) {
if (image.isEncrypted && loader.mediaUrl) {
loader.download(callback)
@@ -82,6 +63,24 @@ HMxcImage {
}
width: fitSize.width
height: fitSize.height
horizontalAlignment: Image.AlignLeft
enabledAnimatedPausing: ! eventList.selectedCount
title: thumbnail ? loader.thumbnailTitle : loader.title
animated: loader.singleMediaInfo.media_mime === "image/gif" ||
utils.urlExtension(loader.mediaUrl).toLowerCase() === "gif"
thumbnail: ! animated && loader.thumbnailMxc
mxc: thumbnail ?
(loader.thumbnailMxc || loader.mediaUrl) :
(loader.mediaUrl || loader.thumbnailMxc)
cryptDict: JSON.parse(
thumbnail && loader.thumbnailMxc ?
loader.singleMediaInfo.thumbnail_crypt_dict :
loader.singleMediaInfo.media_crypt_dict
)
TapHandler {
acceptedModifiers: Qt.NoModifier
onTapped:

View File

@@ -5,6 +5,7 @@ import "../../../Base"
HLabel {
id: bubble
anchors.margins: theme.spacing / 4
topPadding: theme.spacing / 2

View File

@@ -10,12 +10,11 @@ import "../../../PythonBridge"
import "../../../ShortcutBundles"
Rectangle {
color: theme.chat.eventList.background
property alias eventList: eventList
color: theme.chat.eventList.background
HShortcut {
sequences: window.settings.keys.unfocusOrDeselectAllMessages
onActivated: {
@@ -52,6 +51,27 @@ Rectangle {
}
HShortcut {
readonly property var events:
eventList.selectedCount ?
eventList.redactableCheckedEvents :
eventList.currentItem &&
eventList.canRedact(eventList.currentItem.currentModel) ?
[eventList.currentItem.currentModel] :
eventList.currentItem ?
[] :
null
function findLastRemovableDelegate() {
for (let i = 0; i < eventList.model.count && i <= 1000; i++) {
const event = eventList.model.get(i)
if (eventList.canRedact(event) &&
mainUI.accountIds.includes(event.sender_id)) return [event]
}
return []
}
enabled: (events && events.length > 0) || events === null
sequences: window.settings.keys.removeFocusedOrSelectedMessages
onActivated: utils.makePopup(
@@ -73,27 +93,6 @@ Rectangle {
events.length < eventList.selectedCount
}
)
readonly property var events:
eventList.selectedCount ?
eventList.redactableCheckedEvents :
eventList.currentItem &&
eventList.canRedact(eventList.currentItem.currentModel) ?
[eventList.currentItem.currentModel] :
eventList.currentItem ?
[] :
null
function findLastRemovableDelegate() {
for (let i = 0; i < eventList.model.count && i <= 1000; i++) {
const event = eventList.model.get(i)
if (eventList.canRedact(event) &&
mainUI.accountIds.includes(event.sender_id)) return [event]
}
return []
}
}
HShortcut {
@@ -181,67 +180,6 @@ Rectangle {
HListView {
id: eventList
anchors.fill: parent
clip: true
keyNavigationWraps: false
leftMargin: theme.spacing
rightMargin: theme.spacing
topMargin: theme.spacing
bottomMargin: theme.spacing
verticalLayoutDirection: ListView.BottomToTop
// Keep x scroll pages cached, to limit images having to be
// reloaded from network.
cacheBuffer: Screen.desktopAvailableHeight * 2
model: ModelStore.get(chat.userId, chat.roomId, "events")
delegate: EventDelegate {}
highlight: Rectangle {
color: theme.chat.message.focusedHighlight
opacity: theme.chat.message.focusedHighlightOpacity
}
// Since the list is BottomToTop, this is actually a header
footer: Item {
width: eventList.width
height: (button.height + theme.spacing * 2) * opacity
opacity: eventList.loading ? 1 : 0
visible: opacity > 0
Behavior on opacity { HNumberAnimation {} }
HButton {
readonly property bool offline:
chat.userInfo.presence === "offline"
id: button
width: Math.min(parent.width, implicitWidth)
anchors.centerIn: parent
loading: parent.visible && ! offline
icon.name: offline ? "feature-unavailable-offline" : ""
icon.color:
offline ?
theme.colors.negativeBackground :
theme.icons.colorize
text:
offline ?
qsTr("Cannot load history offline") :
qsTr("Loading previous messages...")
enableRadius: true
iconItem.small: true
}
}
onYPosChanged:
if (canLoad && yPos < 0.1) Qt.callLater(loadPastEvents)
// When an invited room becomes joined, we should now be able to
// fetch past events.
onInviterChanged: canLoad = true
property string inviter: chat.roomInfo.inviter || ""
property real yPos: visibleArea.yPosition
@@ -261,7 +199,6 @@ Rectangle {
readonly property var redactableCheckedEvents:
getSortedChecked().filter(ev => eventList.canRedact(ev))
function copySelectedDelegates() {
if (eventList.selectedText) {
Clipboard.text = eventList.selectedText
@@ -362,6 +299,67 @@ Rectangle {
return
}
}
anchors.fill: parent
clip: true
keyNavigationWraps: false
leftMargin: theme.spacing
rightMargin: theme.spacing
topMargin: theme.spacing
bottomMargin: theme.spacing
verticalLayoutDirection: ListView.BottomToTop
// Keep x scroll pages cached, to limit images having to be
// reloaded from network.
cacheBuffer: Screen.desktopAvailableHeight * 2
model: ModelStore.get(chat.userId, chat.roomId, "events")
delegate: EventDelegate {}
highlight: Rectangle {
color: theme.chat.message.focusedHighlight
opacity: theme.chat.message.focusedHighlightOpacity
}
// Since the list is BottomToTop, this is actually a header
footer: Item {
width: eventList.width
height: (button.height + theme.spacing * 2) * opacity
opacity: eventList.loading ? 1 : 0
visible: opacity > 0
Behavior on opacity { HNumberAnimation {} }
HButton {
readonly property bool offline:
chat.userInfo.presence === "offline"
id: button
width: Math.min(parent.width, implicitWidth)
anchors.centerIn: parent
loading: parent.visible && ! offline
icon.name: offline ? "feature-unavailable-offline" : ""
icon.color:
offline ?
theme.colors.negativeBackground :
theme.icons.colorize
text:
offline ?
qsTr("Cannot load history offline") :
qsTr("Loading previous messages...")
enableRadius: true
iconItem.small: true
}
}
onYPosChanged:
if (canLoad && yPos < 0.1) Qt.callLater(loadPastEvents)
// When an invited room becomes joined, we should now be able to
// fetch past events.
onInviterChanged: canLoad = true
}
Timer {

View File

@@ -5,21 +5,6 @@ import "../../../Base"
HLoader {
id: loader
visible: Boolean(item)
x: eventContent.spacing
onTypeChanged: {
if (type === EventDelegate.Media.Image) {
var file = "EventImage.qml"
} else if (type !== EventDelegate.Media.Page) {
var file = "EventFile.qml"
} else { return }
loader.setSource(file, {loader})
}
property QtObject singleMediaInfo
property string mediaUrl
@@ -87,7 +72,6 @@ HLoader {
readonly property string thumbnailMxc: singleMediaInfo.thumbnail_url
function download(callback) {
if (! loader.mediaUrl.startsWith("mxc://")) {
downloadedPath = loader.mediaUrl
@@ -109,4 +93,20 @@ HLoader {
callback(path)
})
}
visible: Boolean(item)
x: eventContent.spacing
onTypeChanged: {
if (type === EventDelegate.Media.Image) {
var file = "EventImage.qml"
} else if (type !== EventDelegate.Media.Page) {
var file = "EventFile.qml"
} else { return }
loader.setSource(file, {loader})
}
}

View File

@@ -5,6 +5,9 @@ import QtQuick.Layouts 1.12
import "../../Base"
InfoBar {
property var typingMembers: []
color: theme.chat.typingMembers.background
icon.svgName: "typing" // TODO: animate
label.textFormat: Text.StyledText
@@ -17,7 +20,4 @@ InfoBar {
return qsTr("%1 and %2 are typing...")
.arg(tm.slice(0, -1).join(", ")).arg(tm.slice(-1)[0])
}
property var typingMembers: []
}