emojier/app: switch to required properties

Emojier uses injected properties for its delegates. This is not
recommended and causes linter warnings.

This change switches this to required properties, which also allows
us to use ComponentBehavior: Bound to further reduce linter warnings.
This commit is contained in:
Christoph Wolk 2025-12-10 01:21:01 +01:00
parent de680e193d
commit 128455fb60
3 changed files with 16 additions and 7 deletions

View file

@ -8,7 +8,7 @@ import QtQml
import org.kde.kirigami as Kirigami
Kirigami.Action {
property string category
required property string category
checked: window.pageStack.get(0).title === text
text: i18ndc("org.kde.plasma.emojier", "Emoji Category", category)

View file

@ -3,6 +3,7 @@
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
@ -130,7 +131,7 @@ Kirigami.ScrollablePage {
QQC2.Menu {
id: menu
required property Text label
required property QQC2.ItemDelegate label
onClosed: destroy()
@ -175,26 +176,31 @@ Kirigami.ScrollablePage {
delegate: QQC2.ItemDelegate {
id: emojiLabel
required property var model
required property string toolTip
width: emojiView.cellWidth
height: emojiView.cellHeight
text: model.display
highlighted: GridView.isCurrentItem
contentItem: QQC2.Label {
font.pointSize: 25
font.family: 'emoji' // Avoid monochrome fonts like DejaVu Sans
fontSizeMode: model.display.length > 5 ? Text.Fit : Text.FixedSize
fontSizeMode: emojiLabel.text.length > 5 ? Text.Fit : Text.FixedSize
minimumPointSize: 10
text: model.display
text: emojiLabel.text
textFormat: Text.PlainText
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
Accessible.name: model.toolTip
Accessible.name: emojiLabel.toolTip
Accessible.onPressAction: tapHandler.action()
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.text: model.toolTip
QQC2.ToolTip.text: emojiLabel.toolTip
QQC2.ToolTip.visible: hoverHandler.hovered
Keys.onMenuPressed: event => contextMenuHandler.action()
@ -207,7 +213,7 @@ Kirigami.ScrollablePage {
TapHandler {
id: tapHandler
function action() {
window.report(model.display, model.toolTip);
window.report(emojiLabel.text, emojiLabel.toolTip);
}
onTapped: (eventPoint, button) => action()
}

View file

@ -3,6 +3,7 @@
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
@ -130,6 +131,8 @@ Kirigami.ApplicationWindow {
model: emoji.categories
delegate: CategoryAction {
required property string modelData
category: modelData
icon.name: drawer.getIcon(category)
}