Fix various qml warnings

This commit is contained in:
Tobias Fella
2026-02-06 14:45:03 +01:00
parent 692ce82717
commit c1720bbaa7
11 changed files with 50 additions and 34 deletions

View File

@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com> // SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import Qt.labs.qmlmodels import Qt.labs.qmlmodels

View File

@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com> // SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
pragma ComponentBehavior: Bound
import QtCore import QtCore
import QtQuick import QtQuick
import QtQuick.Controls as QQC2 import QtQuick.Controls as QQC2
@@ -34,7 +36,7 @@ QQC2.Control {
Layout.fillWidth: true Layout.fillWidth: true
Layout.margins: Kirigami.Units.largeSpacing Layout.margins: Kirigami.Units.largeSpacing
Layout.preferredHeight: active ? item.implicitHeight : 0 Layout.preferredHeight: active ? (item as Item).implicitHeight : 0
active: visible active: visible
visible: root.chatBarCache.replyId.length > 0 || root.chatBarCache.attachmentPath.length > 0 visible: root.chatBarCache.replyId.length > 0 || root.chatBarCache.attachmentPath.length > 0
@@ -71,7 +73,7 @@ QQC2.Control {
root.chatBarCache.text = text; root.chatBarCache.text = text;
} }
Keys.onEnterPressed: { Keys.onEnterPressed: event => {
if (completionMenu.visible) { if (completionMenu.visible) {
completionMenu.complete(); completionMenu.complete();
} else if (event.modifiers & Qt.ShiftModifier) { } else if (event.modifiers & Qt.ShiftModifier) {
@@ -80,7 +82,7 @@ QQC2.Control {
_private.post(); _private.post();
} }
} }
Keys.onReturnPressed: { Keys.onReturnPressed: event => {
if (completionMenu.visible) { if (completionMenu.visible) {
completionMenu.complete(); completionMenu.complete();
} else if (event.modifiers & Qt.ShiftModifier) { } else if (event.modifiers & Qt.ShiftModifier) {
@@ -108,7 +110,7 @@ QQC2.Control {
height: implicitHeight height: implicitHeight
y: -height - 5 y: -height - 5
z: 10 z: 10
connection: root.Message.room.connection connection: root.Message.room.connection as NeoChatConnection
chatDocumentHandler: documentHandler chatDocumentHandler: documentHandler
margins: 0 margins: 0
Behavior on height { Behavior on height {
@@ -165,7 +167,7 @@ QQC2.Control {
text: i18nc("@action:button", "Attach an image or file") text: i18nc("@action:button", "Attach an image or file")
icon.name: "mail-attachment" icon.name: "mail-attachment"
onClicked: { 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.chosen.connect(path => root.chatBarCache.attachmentPath = path);
dialog.open(); dialog.open();
} }
@@ -225,8 +227,6 @@ QQC2.Control {
Message.maxContentWidth: paneLoader.item.width Message.maxContentWidth: paneLoader.item.width
} }
QQC2.Button { QQC2.Button {
id: cancelButton
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
@@ -261,9 +261,9 @@ QQC2.Control {
function updateText() { function updateText() {
// This could possibly be undefined due to some esoteric QtQuick issue. Referencing it somewhere in JS is enough. // This could possibly be undefined due to some esoteric QtQuick issue. Referencing it somewhere in JS is enough.
documentHandler.document; documentHandler.document;
if (chatBarCache?.isEditing && chatBarCache.relationMessage.length > 0) { if (root.chatBarCache?.isEditing && root.chatBarCache.relationMessage.length > 0) {
textArea.text = chatBarCache.relationMessage; textArea.text = root.chatBarCache.relationMessage;
documentHandler.updateMentions(chatBarCache.editId); documentHandler.updateMentions(root.chatBarCache.editId);
textArea.forceActiveFocus(); textArea.forceActiveFocus();
textArea.cursorPosition = textArea.text.length; textArea.cursorPosition = textArea.text.length;
} }

View File

@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com> // SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import Qt.labs.qmlmodels import Qt.labs.qmlmodels
@@ -117,6 +119,7 @@ DelegateChooser {
DelegateChoice { DelegateChoice {
roleValue: MessageComponentType.Location roleValue: MessageComponentType.Location
delegate: MimeComponent { delegate: MimeComponent {
required property string display
mimeIconSource: "mark-location" mimeIconSource: "mark-location"
label: display label: display
} }
@@ -125,6 +128,7 @@ DelegateChooser {
DelegateChoice { DelegateChoice {
roleValue: MessageComponentType.LiveLocation roleValue: MessageComponentType.LiveLocation
delegate: MimeComponent { delegate: MimeComponent {
required property string display
mimeIconSource: "mark-location" mimeIconSource: "mark-location"
label: display label: display
} }

View File

@@ -2,6 +2,8 @@
// SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu> // SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import QtQuick.Controls as QQC2 import QtQuick.Controls as QQC2
import QtQuick.Layouts import QtQuick.Layouts

View File

@@ -1,8 +1,9 @@
// SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com> // SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import QtQuick.Layouts
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
@@ -103,7 +104,7 @@ Kirigami.Page {
Connections { Connections {
target: root.Kirigami.PageStack.pageStack target: root.Kirigami.PageStack.pageStack
onWideModeChanged: { function onWideModeChanged(): void {
if ((root.Kirigami.PageStack.pageStack as Kirigami.PageRow).wideMode) { if ((root.Kirigami.PageStack.pageStack as Kirigami.PageRow).wideMode) {
root.Kirigami.PageStack.pop(); root.Kirigami.PageStack.pop();
} }

View File

@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: 2020 Tobias Fella <tobias.fella@kde.org> // SPDX-FileCopyrightText: 2020 Tobias Fella <tobias.fella@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import QtQuick.Controls as QQC2 import QtQuick.Controls as QQC2
import QtQuick.Layouts import QtQuick.Layouts
@@ -44,7 +46,7 @@ FormCard.FormCardPage {
id: accountDelegate id: accountDelegate
required property NeoChatConnection connection required property NeoChatConnection connection
Layout.fillWidth: true 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 connection: accountDelegate.connection
}, { }, {
title: i18n("Account editor") title: i18n("Account editor")
@@ -124,8 +126,8 @@ FormCard.FormCardPage {
property Connections connections: Connections { property Connections connections: Connections {
target: Controller target: Controller
function onConnectionAdded() { function onConnectionAdded() {
if (pageStack.layers.depth > 2) { if ((root.Kirigami.PageStack.pageStack as Kirigami.PageRow).layers.depth > 2) {
pageStack.layers.pop(); (root.Kirigami.PageStack.pageStack as Kirigami.PageRow).layers.pop();
} }
} }
} }

View File

@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com> // SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import QtQuick.Controls as QQC2 import QtQuick.Controls as QQC2
import QtQuick.Layouts import QtQuick.Layouts
@@ -27,8 +29,8 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate { FormCard.FormCheckDelegate {
text: i18n("Enable notifications for this account") text: i18n("Enable notifications for this account")
description: { description: {
if (connection.pushNotificationsAvailable) { if (root.connection.pushNotificationsAvailable) {
if (connection.enablePushNotifications) { if (root.connection.enablePushNotifications) {
return i18n("Notifications can appear even when NeoChat isn't running."); return i18n("Notifications can appear even when NeoChat isn't running.");
} else { } else {
return i18n("Push notifications are available but could not be enabled."); return i18n("Push notifications are available but could not be enabled.");
@@ -52,8 +54,6 @@ FormCard.FormCardPage {
spacing: Kirigami.Units.largeSpacing spacing: Kirigami.Units.largeSpacing
Kirigami.Icon { Kirigami.Icon {
source: "data-information" source: "data-information"
width: Kirigami.Units.iconSizes.sizeForLabels
height: Kirigami.Units.iconSizes.sizeForLabels
} }
QQC2.Label { 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.") 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 { FormCard.AbstractFormDelegate {
Layout.fillWidth: true 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 { property Component ruleDelegate: Component {
id: ruleDelegate
NotificationRuleItem { NotificationRuleItem {
onDeleteRule: { onDeleteRule: {
root.pushRuleModel.removeKeyword(id); root.pushRuleModel.removeKeyword(id);

View File

@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: 2024 Tobias Fella <tobias.fella@kde.org> // SPDX-FileCopyrightText: 2024 Tobias Fella <tobias.fella@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import QtQuick.Controls as QQC2 import QtQuick.Controls as QQC2
import QtQuick.Layouts import QtQuick.Layouts
@@ -37,6 +39,8 @@ FormCard.FormCardPage {
id: repeater id: repeater
model: root.connection.ignoredUsers() model: root.connection.ignoredUsers()
delegate: FormCard.AbstractFormDelegate { delegate: FormCard.AbstractFormDelegate {
id: ignoredUserDelegate
required property string modelData
topPadding: Kirigami.Units.smallSpacing topPadding: Kirigami.Units.smallSpacing
bottomPadding: Kirigami.Units.smallSpacing bottomPadding: Kirigami.Units.smallSpacing
@@ -46,7 +50,7 @@ FormCard.FormCardPage {
QQC2.Label { QQC2.Label {
Layout.fillWidth: true Layout.fillWidth: true
text: modelData text: ignoredUserDelegate.modelData
elide: Text.ElideRight elide: Text.ElideRight
Accessible.ignored: true // base class sets this text on root already Accessible.ignored: true // base class sets this text on root already
} }
@@ -54,7 +58,7 @@ FormCard.FormCardPage {
QQC2.ToolButton { QQC2.ToolButton {
text: i18nc("@action:button", "Unignore this user") text: i18nc("@action:button", "Unignore this user")
icon.name: "list-remove-symbolic" icon.name: "list-remove-symbolic"
onClicked: root.connection.removeFromIgnoredUsers(modelData) onClicked: root.connection.removeFromIgnoredUsers(ignoredUserDelegate.modelData)
display: QQC2.Button.IconOnly display: QQC2.Button.IconOnly
QQC2.ToolTip.text: text QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered QQC2.ToolTip.visible: hovered

View File

@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com> // SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import QtQuick.Controls as QQC2 import QtQuick.Controls as QQC2
import QtQuick.Layouts import QtQuick.Layouts
@@ -56,6 +58,7 @@ Kirigami.Dialog {
model: root.room.parentObjects(true) model: root.room.parentObjects(true)
delegate: FormCard.FormCheckDelegate { delegate: FormCard.FormCheckDelegate {
id: parentDelegate
required property var modelData required property var modelData
text: modelData.displayName text: modelData.displayName
@@ -67,8 +70,8 @@ Kirigami.Dialog {
Layout.preferredWidth: Kirigami.Units.gridUnit * 2 Layout.preferredWidth: Kirigami.Units.gridUnit * 2
Layout.preferredHeight: Kirigami.Units.gridUnit * 2 Layout.preferredHeight: Kirigami.Units.gridUnit * 2
source: modelData.avatarUrl.toString().length > 0 ? connection.makeMediaUrl(modelData.avatarUrl) : "" source: parentDelegate.modelData.avatarUrl.toString().length > 0 ? root.room.connection.makeMediaUrl(parentDelegate.modelData.avatarUrl) : ""
name: modelData.displayName name: parentDelegate.modelData.displayName
} }
} }
} }

View File

@@ -3,7 +3,6 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
import QtQuick import QtQuick
import QtQuick.Layouts
import Qt.labs.qmlmodels import Qt.labs.qmlmodels
@@ -63,12 +62,10 @@ DelegateChooser {
roleValue: DelegateType.Other roleValue: DelegateType.Other
delegate: NeoChatConfig.showAllEvents ? hiddenDelegate : emptyDelegate delegate: NeoChatConfig.showAllEvents ? hiddenDelegate : emptyDelegate
Component { property Component hiddenDelegate : Component {
id: hiddenDelegate
HiddenDelegate {} HiddenDelegate {}
} }
Component { property Component emptyDelegate : Component {
id: emptyDelegate
Item {} Item {}
} }
} }

View File

@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: 2020 Black Hat <bhat@encom.eu.org> // SPDX-FileCopyrightText: 2020 Black Hat <bhat@encom.eu.org>
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import QtQuick.Controls as QQC2 import QtQuick.Controls as QQC2