From c1720bbaa74de8e19834f362cf1e8a9571ba03e1 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Fri, 6 Feb 2026 14:45:03 +0100 Subject: [PATCH] Fix various qml warnings --- .../BaseMessageComponentChooser.qml | 2 ++ src/messagecontent/ChatBarComponent.qml | 20 +++++++++---------- .../ReplyMessageComponentChooser.qml | 4 ++++ src/roominfo/RoomDrawer.qml | 2 ++ src/roominfo/RoomDrawerPage.qml | 5 +++-- src/settings/AccountsPage.qml | 8 +++++--- src/settings/GlobalNotificationsPage.qml | 19 +++++++++--------- src/settings/IgnoredUsersDialog.qml | 8 ++++++-- src/settings/SelectSpacesDialog.qml | 7 +++++-- src/timeline/EventDelegate.qml | 7 ++----- src/timeline/MessageDelegate.qml | 2 ++ 11 files changed, 50 insertions(+), 34 deletions(-) diff --git a/src/messagecontent/BaseMessageComponentChooser.qml b/src/messagecontent/BaseMessageComponentChooser.qml index 66cab0f76..0aacb1d3f 100644 --- a/src/messagecontent/BaseMessageComponentChooser.qml +++ b/src/messagecontent/BaseMessageComponentChooser.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2024 James Graham // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Layouts import Qt.labs.qmlmodels diff --git a/src/messagecontent/ChatBarComponent.qml b/src/messagecontent/ChatBarComponent.qml index f83fb966b..90c6281d0 100644 --- a/src/messagecontent/ChatBarComponent.qml +++ b/src/messagecontent/ChatBarComponent.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023 James Graham // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL +pragma ComponentBehavior: Bound + import QtCore import QtQuick import QtQuick.Controls as QQC2 @@ -34,7 +36,7 @@ QQC2.Control { Layout.fillWidth: true Layout.margins: Kirigami.Units.largeSpacing - Layout.preferredHeight: active ? item.implicitHeight : 0 + Layout.preferredHeight: active ? (item as Item).implicitHeight : 0 active: visible visible: root.chatBarCache.replyId.length > 0 || root.chatBarCache.attachmentPath.length > 0 @@ -71,7 +73,7 @@ QQC2.Control { root.chatBarCache.text = text; } - Keys.onEnterPressed: { + Keys.onEnterPressed: event => { if (completionMenu.visible) { completionMenu.complete(); } else if (event.modifiers & Qt.ShiftModifier) { @@ -80,7 +82,7 @@ QQC2.Control { _private.post(); } } - Keys.onReturnPressed: { + Keys.onReturnPressed: event => { if (completionMenu.visible) { completionMenu.complete(); } else if (event.modifiers & Qt.ShiftModifier) { @@ -108,7 +110,7 @@ QQC2.Control { height: implicitHeight y: -height - 5 z: 10 - connection: root.Message.room.connection + connection: root.Message.room.connection as NeoChatConnection chatDocumentHandler: documentHandler margins: 0 Behavior on height { @@ -165,7 +167,7 @@ QQC2.Control { text: i18nc("@action:button", "Attach an image or file") icon.name: "mail-attachment" onClicked: { - let dialog = (Clipboard.hasImage ? attachDialog : openFileDialog).createObject(QQC2.Overlay.overlay); + let dialog = (Clipboard.hasImage ? attachDialog : openFileDialog).createObject(QQC2.Overlay.overlay) as QQC2.Dialog; dialog.chosen.connect(path => root.chatBarCache.attachmentPath = path); dialog.open(); } @@ -225,8 +227,6 @@ QQC2.Control { Message.maxContentWidth: paneLoader.item.width } QQC2.Button { - id: cancelButton - anchors.top: parent.top anchors.right: parent.right @@ -261,9 +261,9 @@ QQC2.Control { function updateText() { // This could possibly be undefined due to some esoteric QtQuick issue. Referencing it somewhere in JS is enough. documentHandler.document; - if (chatBarCache?.isEditing && chatBarCache.relationMessage.length > 0) { - textArea.text = chatBarCache.relationMessage; - documentHandler.updateMentions(chatBarCache.editId); + if (root.chatBarCache?.isEditing && root.chatBarCache.relationMessage.length > 0) { + textArea.text = root.chatBarCache.relationMessage; + documentHandler.updateMentions(root.chatBarCache.editId); textArea.forceActiveFocus(); textArea.cursorPosition = textArea.text.length; } diff --git a/src/messagecontent/ReplyMessageComponentChooser.qml b/src/messagecontent/ReplyMessageComponentChooser.qml index 0b1874d6f..2c3ace194 100644 --- a/src/messagecontent/ReplyMessageComponentChooser.qml +++ b/src/messagecontent/ReplyMessageComponentChooser.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2024 James Graham // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Layouts import Qt.labs.qmlmodels @@ -117,6 +119,7 @@ DelegateChooser { DelegateChoice { roleValue: MessageComponentType.Location delegate: MimeComponent { + required property string display mimeIconSource: "mark-location" label: display } @@ -125,6 +128,7 @@ DelegateChooser { DelegateChoice { roleValue: MessageComponentType.LiveLocation delegate: MimeComponent { + required property string display mimeIconSource: "mark-location" label: display } diff --git a/src/roominfo/RoomDrawer.qml b/src/roominfo/RoomDrawer.qml index 5130244d2..cde4abab1 100644 --- a/src/roominfo/RoomDrawer.qml +++ b/src/roominfo/RoomDrawer.qml @@ -2,6 +2,8 @@ // SPDX-FileCopyrightText: 2020 Carl Schwan // SPDX-License-Identifier: GPL-3.0-only +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Controls as QQC2 import QtQuick.Layouts diff --git a/src/roominfo/RoomDrawerPage.qml b/src/roominfo/RoomDrawerPage.qml index cd4f048c7..ac15fd0e6 100644 --- a/src/roominfo/RoomDrawerPage.qml +++ b/src/roominfo/RoomDrawerPage.qml @@ -1,8 +1,9 @@ // SPDX-FileCopyrightText: 2023 James Graham // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL +pragma ComponentBehavior: Bound + import QtQuick -import QtQuick.Layouts import org.kde.kirigami as Kirigami @@ -103,7 +104,7 @@ Kirigami.Page { Connections { target: root.Kirigami.PageStack.pageStack - onWideModeChanged: { + function onWideModeChanged(): void { if ((root.Kirigami.PageStack.pageStack as Kirigami.PageRow).wideMode) { root.Kirigami.PageStack.pop(); } diff --git a/src/settings/AccountsPage.qml b/src/settings/AccountsPage.qml index c80782248..348e5d5f9 100644 --- a/src/settings/AccountsPage.qml +++ b/src/settings/AccountsPage.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2020 Tobias Fella // SPDX-License-Identifier: GPL-2.0-or-later +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Controls as QQC2 import QtQuick.Layouts @@ -44,7 +46,7 @@ FormCard.FormCardPage { id: accountDelegate required property NeoChatConnection connection Layout.fillWidth: true - onClicked: root.QQC2.ApplicationWindow.window.pageStack.layers.push(Qt.createComponent('org.kde.neochat.settings', 'AccountEditorPage'), { + onClicked: (root.Kirigami.PageStack.pageStack as Kirigami.PageRow).layers.push(Qt.createComponent('org.kde.neochat.settings', 'AccountEditorPage'), { connection: accountDelegate.connection }, { title: i18n("Account editor") @@ -124,8 +126,8 @@ FormCard.FormCardPage { property Connections connections: Connections { target: Controller function onConnectionAdded() { - if (pageStack.layers.depth > 2) { - pageStack.layers.pop(); + if ((root.Kirigami.PageStack.pageStack as Kirigami.PageRow).layers.depth > 2) { + (root.Kirigami.PageStack.pageStack as Kirigami.PageRow).layers.pop(); } } } diff --git a/src/settings/GlobalNotificationsPage.qml b/src/settings/GlobalNotificationsPage.qml index f3979fa3c..d7b9ab01e 100644 --- a/src/settings/GlobalNotificationsPage.qml +++ b/src/settings/GlobalNotificationsPage.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2022 James Graham // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Controls as QQC2 import QtQuick.Layouts @@ -27,8 +29,8 @@ FormCard.FormCardPage { FormCard.FormCheckDelegate { text: i18n("Enable notifications for this account") description: { - if (connection.pushNotificationsAvailable) { - if (connection.enablePushNotifications) { + if (root.connection.pushNotificationsAvailable) { + if (root.connection.enablePushNotifications) { return i18n("Notifications can appear even when NeoChat isn't running."); } else { return i18n("Push notifications are available but could not be enabled."); @@ -52,8 +54,6 @@ FormCard.FormCardPage { spacing: Kirigami.Units.largeSpacing Kirigami.Icon { source: "data-information" - width: Kirigami.Units.iconSizes.sizeForLabels - height: Kirigami.Units.iconSizes.sizeForLabels } QQC2.Label { text: i18nc("@info", "These are the default notification settings for all rooms. You can customize notifications per-room in the room list or room settings.") @@ -78,7 +78,7 @@ FormCard.FormCardPage { } } - delegate: ruleDelegate + delegate: root.ruleDelegate } } @@ -95,7 +95,7 @@ FormCard.FormCardPage { } } - delegate: ruleDelegate + delegate: root.ruleDelegate } } @@ -113,7 +113,7 @@ FormCard.FormCardPage { } } - delegate: ruleDelegate + delegate: root.ruleDelegate } FormCard.AbstractFormDelegate { Layout.fillWidth: true @@ -176,7 +176,7 @@ FormCard.FormCardPage { } } - delegate: ruleDelegate + delegate: root.ruleDelegate } } @@ -197,12 +197,11 @@ FormCard.FormCardPage { } } - delegate: ruleDelegate + delegate: root.ruleDelegate } } property Component ruleDelegate: Component { - id: ruleDelegate NotificationRuleItem { onDeleteRule: { root.pushRuleModel.removeKeyword(id); diff --git a/src/settings/IgnoredUsersDialog.qml b/src/settings/IgnoredUsersDialog.qml index 381cfda75..61e2f46f9 100644 --- a/src/settings/IgnoredUsersDialog.qml +++ b/src/settings/IgnoredUsersDialog.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2024 Tobias Fella // SPDX-License-Identifier: GPL-2.0-or-later +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Controls as QQC2 import QtQuick.Layouts @@ -37,6 +39,8 @@ FormCard.FormCardPage { id: repeater model: root.connection.ignoredUsers() delegate: FormCard.AbstractFormDelegate { + id: ignoredUserDelegate + required property string modelData topPadding: Kirigami.Units.smallSpacing bottomPadding: Kirigami.Units.smallSpacing @@ -46,7 +50,7 @@ FormCard.FormCardPage { QQC2.Label { Layout.fillWidth: true - text: modelData + text: ignoredUserDelegate.modelData elide: Text.ElideRight Accessible.ignored: true // base class sets this text on root already } @@ -54,7 +58,7 @@ FormCard.FormCardPage { QQC2.ToolButton { text: i18nc("@action:button", "Unignore this user") icon.name: "list-remove-symbolic" - onClicked: root.connection.removeFromIgnoredUsers(modelData) + onClicked: root.connection.removeFromIgnoredUsers(ignoredUserDelegate.modelData) display: QQC2.Button.IconOnly QQC2.ToolTip.text: text QQC2.ToolTip.visible: hovered diff --git a/src/settings/SelectSpacesDialog.qml b/src/settings/SelectSpacesDialog.qml index c93e87ba1..005f52644 100644 --- a/src/settings/SelectSpacesDialog.qml +++ b/src/settings/SelectSpacesDialog.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023 James Graham // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Controls as QQC2 import QtQuick.Layouts @@ -56,6 +58,7 @@ Kirigami.Dialog { model: root.room.parentObjects(true) delegate: FormCard.FormCheckDelegate { + id: parentDelegate required property var modelData text: modelData.displayName @@ -67,8 +70,8 @@ Kirigami.Dialog { Layout.preferredWidth: Kirigami.Units.gridUnit * 2 Layout.preferredHeight: Kirigami.Units.gridUnit * 2 - source: modelData.avatarUrl.toString().length > 0 ? connection.makeMediaUrl(modelData.avatarUrl) : "" - name: modelData.displayName + source: parentDelegate.modelData.avatarUrl.toString().length > 0 ? root.room.connection.makeMediaUrl(parentDelegate.modelData.avatarUrl) : "" + name: parentDelegate.modelData.displayName } } } diff --git a/src/timeline/EventDelegate.qml b/src/timeline/EventDelegate.qml index 74815cd01..bf9991e68 100644 --- a/src/timeline/EventDelegate.qml +++ b/src/timeline/EventDelegate.qml @@ -3,7 +3,6 @@ // SPDX-License-Identifier: GPL-3.0-only import QtQuick -import QtQuick.Layouts import Qt.labs.qmlmodels @@ -63,12 +62,10 @@ DelegateChooser { roleValue: DelegateType.Other delegate: NeoChatConfig.showAllEvents ? hiddenDelegate : emptyDelegate - Component { - id: hiddenDelegate + property Component hiddenDelegate : Component { HiddenDelegate {} } - Component { - id: emptyDelegate + property Component emptyDelegate : Component { Item {} } } diff --git a/src/timeline/MessageDelegate.qml b/src/timeline/MessageDelegate.qml index 7f501924e..e9c40fa2b 100644 --- a/src/timeline/MessageDelegate.qml +++ b/src/timeline/MessageDelegate.qml @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2020 Black Hat // SPDX-License-Identifier: GPL-3.0-only +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Controls as QQC2