Start implementing new message selection system
This commit is contained in:
@@ -110,6 +110,9 @@ HRowLayout {
|
||||
HSelectableLabel {
|
||||
id: contentLabel
|
||||
visible: ! pureMedia
|
||||
enableLinkActivation: ! eventList.selectedCount
|
||||
|
||||
// selectByMouse: eventDelegate.checked XXX
|
||||
|
||||
topPadding: theme.chat.message.verticalSpacing
|
||||
bottomPadding: topPadding
|
||||
@@ -165,6 +168,13 @@ HRowLayout {
|
||||
|
||||
HoverHandler { id: contentHover }
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onTapped:
|
||||
if (! parent.hoveredLink || ! parent.enableLinkActivation)
|
||||
eventDelegate.toggleChecked()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: Math.max(
|
||||
parent.paintedWidth +
|
||||
@@ -176,7 +186,9 @@ HRowLayout {
|
||||
height: contentColumn.height
|
||||
radius: theme.chat.message.radius
|
||||
z: -100
|
||||
color: isOwn?
|
||||
color: eventDelegate.checked ?
|
||||
"blue" : // XXX
|
||||
isOwn?
|
||||
theme.chat.message.ownBackground :
|
||||
theme.chat.message.background
|
||||
|
||||
|
@@ -10,6 +10,8 @@ HColumnLayout {
|
||||
id: eventDelegate
|
||||
width: eventList.width
|
||||
|
||||
ListView.onRemove: eventList.delegatesUnchecked(model.id)
|
||||
|
||||
|
||||
enum Media { Page, File, Image, Video, Audio }
|
||||
|
||||
@@ -20,6 +22,7 @@ HColumnLayout {
|
||||
readonly property var nextModel: eventList.model.get(model.index - 1)
|
||||
readonly property QtObject currentModel: model
|
||||
|
||||
property bool checked: model.id in eventList.checkedDelegates
|
||||
property bool compact: window.settings.compactMode
|
||||
property bool isOwn: chat.userId === model.sender_id
|
||||
property bool onRight: eventList.ownEventsOnRight && isOwn
|
||||
@@ -73,9 +76,14 @@ HColumnLayout {
|
||||
contextMenu.popup()
|
||||
}
|
||||
|
||||
function toggleChecked() {
|
||||
eventDelegate.checked ?
|
||||
eventList.delegatesUnchecked(model.index) :
|
||||
eventList.delegatesChecked(model.index)
|
||||
}
|
||||
|
||||
|
||||
Item {
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight:
|
||||
model.event_type === "RoomCreateEvent" ? 0 : separationSpacing
|
||||
@@ -103,6 +111,10 @@ HColumnLayout {
|
||||
Behavior on x { HNumberAnimation {} }
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onTapped: toggleChecked()
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.RightButton
|
||||
@@ -123,6 +135,19 @@ HColumnLayout {
|
||||
|
||||
onClosed: { media = []; link = "" }
|
||||
|
||||
HMenuItem {
|
||||
icon.name: "toggle-select-message"
|
||||
text: eventDelegate.checked ? qsTr("Unselect") : qsTr("Select")
|
||||
onTriggered: eventDelegate.toggleChecked()
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
visible: eventList.selectedCount >= 2
|
||||
icon.name: "unselect-all-messages"
|
||||
text: qsTr("Unselect all")
|
||||
onTriggered: eventList.checkedDelegates = {}
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
id: copyMedia
|
||||
icon.name: "copy-link"
|
||||
@@ -161,10 +186,21 @@ HColumnLayout {
|
||||
HMenuItem {
|
||||
icon.name: "copy-text"
|
||||
text: qsTr("Copy text")
|
||||
visible: enabled || (! copyLink.visible && ! copyMedia.visible)
|
||||
enabled: Boolean(selectableLabelContainer.joinedSelection)
|
||||
onTriggered:
|
||||
Clipboard.text = selectableLabelContainer.joinedSelection
|
||||
visible: ! copyLink.visible && ! copyMedia.visible
|
||||
onTriggered: {
|
||||
if (! eventList.selectedCount) {
|
||||
Clipboard.text = JSON.parse(model.source).body
|
||||
return
|
||||
}
|
||||
|
||||
const contents = []
|
||||
|
||||
for (const model of eventList.getSortedCheckedDelegates()) {
|
||||
contents.push(JSON.parse(model.source).body)
|
||||
}
|
||||
|
||||
Clipboard.text = contents.join("\n\n")
|
||||
}
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
|
@@ -22,8 +22,10 @@ HTile {
|
||||
svgName: "download"
|
||||
}
|
||||
|
||||
onLeftClicked: download(Qt.openUrlExternally)
|
||||
onRightClicked: eventDelegate.openContextMenu()
|
||||
onLeftClicked:
|
||||
eventList.selectedCount ?
|
||||
eventDelegate.toggleChecked() : download(Qt.openUrlExternally)
|
||||
|
||||
onHoveredChanged: {
|
||||
if (! hovered) {
|
||||
@@ -44,4 +46,10 @@ HTile {
|
||||
JSON.parse(loader.singleMediaInfo.media_crypt_dict)
|
||||
|
||||
readonly property bool isEncrypted: ! utils.isEmptyObject(cryptDict)
|
||||
|
||||
|
||||
Binding on backgroundColor {
|
||||
value: "blue" // XXX
|
||||
when: eventDelegate.checked
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ 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" ||
|
||||
@@ -82,8 +83,11 @@ HMxcImage {
|
||||
|
||||
|
||||
TapHandler {
|
||||
onTapped: if (! image.animated) getOpenUrl(Qt.openUrlExternally)
|
||||
onDoubleTapped: getOpenUrl(Qt.openUrlExternally)
|
||||
onTapped:
|
||||
eventList.selectedCount ?
|
||||
eventDelegate.toggleChecked() : getOpenUrl(Qt.openUrlExternally)
|
||||
|
||||
gesturePolicy: TapHandler.ReleaseWithinBounds
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
@@ -123,4 +127,12 @@ HMxcImage {
|
||||
|
||||
Behavior on opacity { HNumberAnimation {} }
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
visible: eventDelegate.checked
|
||||
// XXX
|
||||
color: "blue"
|
||||
opacity: 0.2
|
||||
}
|
||||
}
|
||||
|
@@ -10,10 +10,14 @@ Rectangle {
|
||||
color: theme.chat.eventList.background
|
||||
|
||||
|
||||
property Item selectableLabelContainer: Item {}
|
||||
property alias eventList: eventList
|
||||
|
||||
|
||||
HShortcut {
|
||||
sequence: "Escape"
|
||||
onActivated: eventList.checkedDelegates = {}
|
||||
}
|
||||
|
||||
HListView {
|
||||
id: eventList
|
||||
clip: true
|
||||
@@ -136,6 +140,7 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HNoticePage {
|
||||
text: qsTr("No messages to show yet")
|
||||
|
||||
@@ -150,7 +155,7 @@ Rectangle {
|
||||
const left = centroid.pressedButtons & Qt.LeftButton
|
||||
const vel = centroid.velocity.y
|
||||
const pos = centroid.position.y
|
||||
const dist = Math.min(selectableLabelContainer.height / 4, 50)
|
||||
const dist = Math.min(eventList.height / 4, 50)
|
||||
const boost = 20 * (pos < dist ? -pos : -(height - pos))
|
||||
|
||||
dragFlicker.speed =
|
||||
|
Reference in New Issue
Block a user