Compare commits
1 Commits
work/runne
...
work/multi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be429dc25f |
@@ -80,4 +80,3 @@ X-Plasma-DBusRunner-Service=org.kde.neochat
|
||||
X-Plasma-DBusRunner-Path=/RoomRunner
|
||||
X-Plasma-Request-Actions-Once=true
|
||||
X-Plasma-Runner-Min-Letter-Count=3
|
||||
X-Plasma-Runner-Has-Activation=true
|
||||
|
||||
@@ -43,13 +43,18 @@ TextEdit {
|
||||
*/
|
||||
property bool spoilerRevealed: !hasSpoiler.test(textMessage)
|
||||
|
||||
property bool isDelegate: false
|
||||
|
||||
ListView.onReused: Qt.binding(() => !hasSpoiler.test(textMessage))
|
||||
|
||||
persistentSelection: true
|
||||
|
||||
// Work around QTBUG 93281
|
||||
Component.onCompleted: if (text.includes("<img")) {
|
||||
Controller.forceRefreshTextDocument(root.textDocument, root)
|
||||
Component.onCompleted: {
|
||||
updateSelection()
|
||||
if (text.includes("<img")) {
|
||||
Controller.forceRefreshTextDocument(root.textDocument, root)
|
||||
}
|
||||
}
|
||||
|
||||
text: "<style>
|
||||
@@ -116,4 +121,26 @@ a{
|
||||
enabled: !parent.hoveredLink && !spoilerRevealed
|
||||
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,6 +17,14 @@ import org.kde.neochat.config
|
||||
MessageDelegate {
|
||||
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.
|
||||
*
|
||||
@@ -54,6 +62,7 @@ MessageDelegate {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onLongPressed: root.openContextMenu()
|
||||
}
|
||||
isDelegate: true
|
||||
}
|
||||
Loader {
|
||||
Layout.fillWidth: true
|
||||
|
||||
@@ -341,6 +341,66 @@ 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) {
|
||||
var popup = maximizeComponent.createObject(QQC2.ApplicationWindow.overlay, {
|
||||
initialIndex: index
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
#include <QDBusMetaType>
|
||||
|
||||
#include <KWindowSystem>
|
||||
|
||||
#include "controller.h"
|
||||
#include "neochatroom.h"
|
||||
#include "roommanager.h"
|
||||
@@ -82,12 +80,10 @@ RemoteMatches Runner::Match(const QString &searchTerm)
|
||||
return matches;
|
||||
}
|
||||
|
||||
void Runner::Run(const QString &id, const QString &actionId, const QString &activationToken)
|
||||
void Runner::Run(const QString &id, const QString &actionId)
|
||||
{
|
||||
Q_UNUSED(actionId);
|
||||
|
||||
KWindowSystem::setCurrentXdgActivationToken(activationToken);
|
||||
|
||||
NeoChatRoom *room = qobject_cast<NeoChatRoom *>(Controller::instance().activeConnection()->room(id));
|
||||
|
||||
if (!room) {
|
||||
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
/**
|
||||
* @brief Handle action calls.
|
||||
*/
|
||||
Q_SCRIPTABLE void Run(const QString &id, const QString &actionId, const QString &activationToken = QString());
|
||||
Q_SCRIPTABLE void Run(const QString &id, const QString &actionId);
|
||||
|
||||
private:
|
||||
RemoteImage serializeImage(const QImage &image);
|
||||
|
||||
Reference in New Issue
Block a user