Compare commits
1 Commits
work/multi
...
work/ratij
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d08e989695 |
@@ -43,18 +43,13 @@ TextEdit {
|
|||||||
*/
|
*/
|
||||||
property bool spoilerRevealed: !hasSpoiler.test(textMessage)
|
property bool spoilerRevealed: !hasSpoiler.test(textMessage)
|
||||||
|
|
||||||
property bool isDelegate: false
|
|
||||||
|
|
||||||
ListView.onReused: Qt.binding(() => !hasSpoiler.test(textMessage))
|
ListView.onReused: Qt.binding(() => !hasSpoiler.test(textMessage))
|
||||||
|
|
||||||
persistentSelection: true
|
persistentSelection: true
|
||||||
|
|
||||||
// Work around QTBUG 93281
|
// Work around QTBUG 93281
|
||||||
Component.onCompleted: {
|
Component.onCompleted: if (text.includes("<img")) {
|
||||||
updateSelection()
|
Controller.forceRefreshTextDocument(root.textDocument, root)
|
||||||
if (text.includes("<img")) {
|
|
||||||
Controller.forceRefreshTextDocument(root.textDocument, root)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
text: "<style>
|
text: "<style>
|
||||||
@@ -121,26 +116,4 @@ a{
|
|||||||
enabled: !parent.hoveredLink && !spoilerRevealed
|
enabled: !parent.hoveredLink && !spoilerRevealed
|
||||||
onTapped: spoilerRevealed = true
|
onTapped: spoilerRevealed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: selectionArea
|
|
||||||
enabled: root.isDelegate
|
|
||||||
function onSelectionChanged() {
|
|
||||||
updateSelection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateSelection() {
|
|
||||||
if (index < selectionArea.lowerIndex || index > selectionArea.upperIndex) {
|
|
||||||
root.select(0, 0);
|
|
||||||
} else if (index > selectionArea.lowerIndex && index < selectionArea.upperIndex) {
|
|
||||||
root.selectAll();
|
|
||||||
} else if (index === selectionArea.selectionStartIndex && index === selectionArea.selectionEndIndex) {
|
|
||||||
root.select(selectionArea.upperPos, selectionArea.lowerPos);
|
|
||||||
} else if (index === selectionArea.upperIndex) {
|
|
||||||
root.select(selectionArea.upperPos, root.length);
|
|
||||||
} else if (index === selectionArea.lowerIndex) {
|
|
||||||
root.select(0, selectionArea.lowerPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,6 @@ import org.kde.neochat.config
|
|||||||
MessageDelegate {
|
MessageDelegate {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
function positionAt(x, y) {
|
|
||||||
let point = label.mapFromItem(root, x, y)
|
|
||||||
return label.positionAt(point.x, point.y)
|
|
||||||
}
|
|
||||||
|
|
||||||
property alias selectedText: label.selectedText
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The link preview properties.
|
* @brief The link preview properties.
|
||||||
*
|
*
|
||||||
@@ -62,7 +54,6 @@ MessageDelegate {
|
|||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onLongPressed: root.openContextMenu()
|
onLongPressed: root.openContextMenu()
|
||||||
}
|
}
|
||||||
isDelegate: true
|
|
||||||
}
|
}
|
||||||
Loader {
|
Loader {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|||||||
@@ -134,23 +134,25 @@ QQC2.ScrollView {
|
|||||||
implicitWidth: Kirigami.Units.gridUnit * 2
|
implicitWidth: Kirigami.Units.gridUnit * 2
|
||||||
implicitHeight: Kirigami.Units.gridUnit * 2
|
implicitHeight: Kirigami.Units.gridUnit * 2
|
||||||
|
|
||||||
|
display: QQC2.AbstractButton.IconOnly
|
||||||
|
focusPolicy: Qt.NoFocus
|
||||||
|
|
||||||
z: 2
|
z: 2
|
||||||
visible: root.currentRoom && root.currentRoom.hasUnreadMessages && root.currentRoom.readMarkerLoaded
|
visible: root.currentRoom && root.currentRoom.hasUnreadMessages && root.currentRoom.readMarkerLoaded
|
||||||
action: Kirigami.Action {
|
action: Kirigami.Action {
|
||||||
|
icon.name: "go-up"
|
||||||
|
shortcut: "Shift+PgUp"
|
||||||
|
text: i18n("Jump to first unread message")
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (!Kirigami.Settings.isMobile) {
|
if (!Kirigami.Settings.isMobile) {
|
||||||
root.focusChatBox();
|
root.focusChatBox();
|
||||||
}
|
}
|
||||||
messageListView.goToEvent(root.currentRoom.readMarkerEventId)
|
messageListView.goToEvent(root.currentRoom.readMarkerEventId)
|
||||||
}
|
}
|
||||||
icon.name: "go-up"
|
|
||||||
shortcut: "Shift+PgUp"
|
|
||||||
}
|
|
||||||
|
|
||||||
QQC2.ToolTip {
|
|
||||||
text: i18n("Jump to first unread message")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QQC2.RoundButton {
|
QQC2.RoundButton {
|
||||||
id: goMarkAsReadFab
|
id: goMarkAsReadFab
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
@@ -160,18 +162,19 @@ QQC2.ScrollView {
|
|||||||
implicitWidth: Kirigami.Units.gridUnit * 2
|
implicitWidth: Kirigami.Units.gridUnit * 2
|
||||||
implicitHeight: Kirigami.Units.gridUnit * 2
|
implicitHeight: Kirigami.Units.gridUnit * 2
|
||||||
|
|
||||||
|
display: QQC2.AbstractButton.IconOnly
|
||||||
|
focusPolicy: Qt.NoFocus
|
||||||
|
|
||||||
z: 2
|
z: 2
|
||||||
visible: !messageListView.atYEnd
|
visible: !messageListView.atYEnd
|
||||||
action: Kirigami.Action {
|
action: Kirigami.Action {
|
||||||
|
icon.name: "go-down"
|
||||||
|
text: i18n("Jump to latest message")
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
messageListView.goToLastMessage();
|
messageListView.goToLastMessage();
|
||||||
root.currentRoom.markAllMessagesAsRead();
|
root.currentRoom.markAllMessagesAsRead();
|
||||||
}
|
}
|
||||||
icon.name: "go-down"
|
|
||||||
}
|
|
||||||
|
|
||||||
QQC2.ToolTip {
|
|
||||||
text: i18n("Jump to latest message")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,66 +344,6 @@ QQC2.ScrollView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function indexAtRelative(x, y) {
|
|
||||||
return indexAt(x + contentX, y + contentY)
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: selectionArea
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
property int selectionStartIndex
|
|
||||||
property int selectionEndIndex
|
|
||||||
property int selectionStartPos
|
|
||||||
property int selectionEndPos
|
|
||||||
|
|
||||||
property int upperIndex: selectionStartIndex > selectionEndIndex ? selectionStartIndex : selectionEndIndex
|
|
||||||
property int upperPos: selectionStartIndex > selectionEndIndex ? selectionStartPos : (selectionStartIndex == selectionEndIndex ? (selectionStartPos > selectionEndPos ? selectionEndPos : selectionStartPos) : selectionEndPos)
|
|
||||||
property int lowerIndex: selectionStartIndex > selectionEndIndex ? selectionEndIndex : selectionStartIndex
|
|
||||||
property int lowerPos: selectionStartIndex > selectionEndIndex ? selectionEndPos : (selectionStartIndex == selectionEndIndex ? (selectionStartPos > selectionEndPos ? selectionStartPos : selectionEndPos) : selectionStartPos)
|
|
||||||
|
|
||||||
signal selectionChanged
|
|
||||||
|
|
||||||
function indexAndPos(x, y) {
|
|
||||||
const index = messageListView.indexAtRelative(x, y);
|
|
||||||
if (index == -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const item = messageListView.itemAtIndex(index);
|
|
||||||
const relItemY = item.y - messageListView.contentY;
|
|
||||||
const pos = item.positionAt(x, y - relItemY);
|
|
||||||
return [index, pos]
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: {
|
|
||||||
[selectionArea.selectionEndIndex, selectionArea.selectionEndPos] = selectionArea.indexAndPos(mouse.x, mouse.y);
|
|
||||||
[selectionArea.selectionStartIndex, selectionArea.selectionStartPos] = selectionArea.indexAndPos(mouse.x, mouse.y);
|
|
||||||
selectionChanged();
|
|
||||||
}
|
|
||||||
onPositionChanged: {
|
|
||||||
if (!pressed) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
[selectionEndIndex, selectionEndPos] = selectionArea.indexAndPos(mouse.x, mouse.y);
|
|
||||||
selectionChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Kirigami.Action {
|
|
||||||
onTriggered: {
|
|
||||||
var text = ""
|
|
||||||
for (let i = selectionArea.upperIndex; i >= selectionArea.lowerIndex; i--) {
|
|
||||||
text += messageListView.itemAtIndex(i).selectedText
|
|
||||||
if (i > selectionArea.lowerIndex) {
|
|
||||||
text += " "
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Clipboard.saveText(text)
|
|
||||||
}
|
|
||||||
shortcut: "Ctrl+C"
|
|
||||||
}
|
|
||||||
|
|
||||||
function showMaximizedMedia(index) {
|
function showMaximizedMedia(index) {
|
||||||
var popup = maximizeComponent.createObject(QQC2.ApplicationWindow.overlay, {
|
var popup = maximizeComponent.createObject(QQC2.ApplicationWindow.overlay, {
|
||||||
initialIndex: index
|
initialIndex: index
|
||||||
|
|||||||
Reference in New Issue
Block a user