Make sure the default menu of textArea isn't thrown for non editable TextComponents.

Note: I know this is horrible but it's all we got until discussions in QQC2-Desktop-Style are resolved.
This commit is contained in:
James Graham
2026-02-22 12:27:06 +00:00
parent 1dc566f9a9
commit 8e516422b7

View File

@@ -44,6 +44,7 @@ QQC2.TextArea {
* @brief Whether the component should be editable.
*/
required property bool editable
onEditableChanged: manageDefaultMenus()
/**
* @brief The attributes of the component.
@@ -126,8 +127,7 @@ QQC2.TextArea {
(QQC2.ApplicationWindow.window as Main).hoverLinkIndicator.text = "";
}
// To prevent the dfault QQC2 desktop style menu inconjuction with https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/507
onPressed: event => event.accepted = true;
Component.onCompleted: manageDefaultMenus()
HoverHandler {
cursorShape: root.hoveredLink || (!(root.componentAttributes?.spoilerRevealed ?? false) && root.hasSpoiler) ? Qt.PointingHandCursor : Qt.IBeamCursor
@@ -158,5 +158,17 @@ QQC2.TextArea {
RoomManager.viewEventMenu(root.QQC2.Overlay.overlay, event, root.Message.room, root.Message.selectedText, root.Message.hoveredLink);
}
// TODO - Remove this once the state of TextArea is sorted in QQC2
// This is horrible I know I hate it but currently seemingly the only way to stop the default
// menus in TextArea see https://invent.kde.org/frameworks/qqc2-desktop-style/-/issues/15
function manageDefaultMenus(): void {
for (let i = 0; i < resources.length; i++) {
if (resources[i] instanceof TapHandler) {
(resources[i] as TapHandler).enabled = root.editable;
return;
}
}
}
background: null
}