applets/kicker: more linting

Another pass of relatively simple linting changes, including
- avoiding ids and properties with the same name
- avoiding var in favor of const/let
- a few unused imports, unqualified accesses to members of parents, etc.
  that have crept in.
This commit is contained in:
Christoph Wolk 2026-06-29 14:01:53 +02:00
parent 1fa28aee7c
commit ab2bd1d83f
9 changed files with 91 additions and 92 deletions

View file

@ -360,7 +360,8 @@ Kicker.DashboardWindow {
target: searchField.targetGrid
enabled: launchMatchTimer.running
function onCurrentItemChanged() : void {
if (searchField.targetGrid.currentItem?.text.toLowerCase().includes(root.runnerModel.query.toLowerCase())) {
const targetItem = searchField.targetGrid.currentItem as ItemGridDelegate
if (targetItem?.text.toLowerCase().includes(root.runnerModel.query.toLowerCase())) {
launchMatchTimer.stop()
launchMatchTimer.triggered()
}
@ -889,18 +890,18 @@ Kicker.DashboardWindow {
keyNavigationWraps: true
delegate: ItemAbstractDelegate {
id: item
id: filterDelegate
property var m: model
property int textWidth: label.contentWidth
width: ListView.view.width
width: filterList.width
height: implicitHeight
hoverEnabled: !hoverBlock.enabled
baseModel: filterList.model
favoritesModel: baseModel.favoritesModel
onClicked: ListView.view.applyFilter()
onClicked: filterList.applyFilter()
onHoveredChanged: {
if (hovered && !isSeparator && !ActionMenu.opened) {
@ -932,7 +933,7 @@ Kicker.DashboardWindow {
level: 1
text: item.model.display
text: filterDelegate.model.display
textFormat: Text.PlainText
}
@ -942,7 +943,7 @@ Kicker.DashboardWindow {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
visible: active
active: item.isNewlyInstalled ?? false
active: filterDelegate.isNewlyInstalled ?? false
sourceComponent: Kirigami.Badge {
text: ""
@ -984,7 +985,7 @@ Kicker.DashboardWindow {
preloadAllAppsTimer.stop();
}
var model = root.rootModel.modelForRow(currentIndex);
const model = root.rootModel.modelForRow(currentIndex);
if (model.description === "KICKER_ALL_MODEL") {
allAppsGrid.model = model;

View file

@ -13,10 +13,10 @@ import org.kde.ksvg as KSvg
import org.kde.plasma.components as PlasmaComponents3
ItemAbstractDelegate {
id: item
id: root
property alias iconSize: icon.implicitWidth
property int itemIndex: item.index
property int itemIndex: root.index
property var m: model
property bool showUnfavoritePlaceholder: false
property bool isDraggableFavorite: false
@ -24,7 +24,7 @@ ItemAbstractDelegate {
width: GridView.view.cellWidth
height: width
enabled: !item.disabled
enabled: !root.disabled
favoritesModel: GridView.view.model.favoritesModel
baseModel: GridView.view.model
dragActive: dragHandler.active
@ -36,26 +36,26 @@ ItemAbstractDelegate {
id: dragHandler
target: null
onActiveChanged: if (active) {
item.contentItem.grabToImage(function(result) {
item.Drag.imageSource = result.url
item.Drag.active = true
root.contentItem.grabToImage(function(result) {
root.Drag.imageSource = result.url
root.Drag.active = true
})
} else {
item.Drag.active = false
root.Drag.active = false
}
}
Drag.dragType: Drag.Automatic
Drag.mimeData: item.isDraggableFavorite ? {
Drag.mimeData: root.isDraggableFavorite ? {
'favoritedrag': '',
"text/uri-list" : [item.url]
"text/uri-list" : [root.url]
} : {
"text/uri-list" : [item.url]
"text/uri-list" : [root.url]
}
background.visible: false // we want the default background's spacing, but not the base color
contentItem: ColumnLayout {
spacing: Kirigami.Units.smallSpacing
visible: !item.showUnfavoritePlaceholder
visible: !root.showUnfavoritePlaceholder
Kirigami.Icon {
id: icon
@ -66,16 +66,16 @@ ItemAbstractDelegate {
animated: false
source: item.model.decoration
source: root.model.decoration
Loader {
anchors {
right: parent.right
rightMargin: -item.rightPadding
rightMargin: -root.rightPadding
top: parent.top
}
visible: active
active: item.isNewlyInstalled ?? false
active: root.isNewlyInstalled ?? false
sourceComponent: Kirigami.Badge {
text: i18nc("@label Newly-installed app, badge, keep short", "New!")
@ -97,13 +97,13 @@ ItemAbstractDelegate {
elide: Text.ElideMiddle
wrapMode: Text.Wrap
text: item.model.display ?? ""
text: root.model.display ?? ""
textFormat: Text.PlainText
}
}
Loader {
active: item.showUnfavoritePlaceholder
active: root.showUnfavoritePlaceholder
anchors.fill: parent
sourceComponent: Item {
@ -118,7 +118,7 @@ ItemAbstractDelegate {
Kirigami.Icon {
anchors.centerIn: parent
width: item.iconSize
width: root.iconSize
height: width
source: "list-remove"
@ -129,7 +129,7 @@ ItemAbstractDelegate {
}
PlasmaComponents3.ToolTip {
text: item.model.description ?? ""
visible: item.hovered && !ActionMenu.opened
text: root.model.description ?? ""
visible: root.hovered && !ActionMenu.opened
}
}

View file

@ -86,8 +86,8 @@ FocusScope {
anchors.fill: parent
active: false
onActiveChanged: {
if (!active && "dropPlaceHolderIndex" in model) {
model.dropPlaceHolderIndex = -1;
if (!active && "dropPlaceHolderIndex" in itemGrid.model) {
itemGrid.model.dropPlaceHolderIndex = -1;
}
}
@ -357,8 +357,8 @@ FocusScope {
// Fix moveCurrentIndexDown()'s lack of proper spatial nav down
// into partial columns.
event.accepted = true;
var columns = Math.floor(width / cellWidth);
var newIndex = currentIndex + columns;
const columns = Math.floor(width / cellWidth);
const newIndex = currentIndex + columns;
currentIndex = Math.min(newIndex, count - 1);
positionViewAtIndex(currentIndex, GridView.Contain);
} else {

View file

@ -16,7 +16,7 @@ import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasmoid
ItemAbstractDelegate {
id: item
id: root
required property bool showIcons
@ -41,8 +41,8 @@ ItemAbstractDelegate {
: i18nc("@action:inmenu accessible description for opening app or file", "Launch")
onHasChildrenChanged: {
if (!hasChildren && ListView.view.currentItem === item) {
ListView.view.currentIndex = -1;
if (!hasChildren && root.ListView.isCurrentItem) {
root.ListView.view.currentIndex = -1;
}
}
@ -60,19 +60,19 @@ ItemAbstractDelegate {
implicitWidth: Kirigami.Units.iconSizes.small
implicitHeight: implicitWidth
visible: item.showIcons & !item.isSeparator
visible: root.showIcons & !root.isSeparator
animated: false
selected: item.iconAndLabelsShouldlookSelected
source: item.model.decoration
selected: root.iconAndLabelsShouldlookSelected
source: root.model.decoration
}
PlasmaComponents3.Label {
id: label
enabled: !item.isParent || (item.isParent && item.hasChildren)
enabled: !root.isParent || (root.isParent && root.hasChildren)
LayoutMirroring.enabled: (Application.layoutDirection === Qt.RightToLeft)
visible: !item.isSeparator
visible: !root.isSeparator
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
@ -82,21 +82,21 @@ ItemAbstractDelegate {
textFormat: Text.PlainText
wrapMode: Text.NoWrap
elide: Text.ElideRight
color: item.iconAndLabelsShouldlookSelected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
color: root.iconAndLabelsShouldlookSelected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
text: item.model.display ?? ""
text: root.model.display ?? ""
}
Loader {
visible: active
active: item.isNewlyInstalled ?? false
active: root.isNewlyInstalled ?? false
sourceComponent: Kirigami.Badge {
text: item.hasChildren ? "" : Accessible.name
text: root.hasChildren ? "" : Accessible.name
type: Kirigami.Badge.Type.Positive
Accessible.name: i18nc("Newly-installed app, badge, keep short", "New!")
Accessible.description: item.hasChildren ? i18nc("@info:whatsthis Accessible description for badge", "There is a newly-installed application in this category")
: i18nc("@info:whatsthis Accessible description for badge", "Newly-installed application")
Accessible.description: root.hasChildren ? i18nc("@info:whatsthis Accessible description for badge", "There is a newly-installed application in this category")
: i18nc("@info:whatsthis Accessible description for badge", "Newly-installed application")
}
}
@ -108,10 +108,10 @@ ItemAbstractDelegate {
implicitWidth: visible ? Kirigami.Units.iconSizes.small : 0
implicitHeight: implicitWidth
visible: item.hasChildren && !item.isSeparator
opacity: (item.ListView.view.currentIndex === item.index) ? 1.0 : 0.4
selected: item.iconAndLabelsShouldlookSelected
source: item.dialogDefaultRight
visible: root.hasChildren && !root.isSeparator
opacity: (root.ListView.view.currentIndex === root.index) ? 1.0 : 0.4
selected: root.iconAndLabelsShouldlookSelected
source: root.dialogDefaultRight
? "go-next-symbolic"
: "go-next-rtl-symbolic"
}
@ -122,7 +122,7 @@ ItemAbstractDelegate {
Layout.alignment: Qt.AlignVCenter
Layout.fillWidth: true
active: item.isSeparator
active: root.isSeparator
visible: active
asynchronous: false
@ -133,18 +133,18 @@ ItemAbstractDelegate {
DragHandler {
id: dragHandler
target: null
enabled: (item.url && item.url.toString() !== "") || (item.favoriteId != "")
enabled: (root.url && root.url.toString() !== "") || (root.favoriteId != "")
onActiveChanged: {
if (active) {
// we need dragHelper and can't use attached Drag; submenus are destroyed too soon and Plasma crashes
if (!item.favoriteId) {
dragHelper.startDrag(kicker, item.url, item.decoration)
if (!root.favoriteId) {
dragHelper.startDrag(kicker, root.url, root.decoration)
} else {
let type = item.favoritesModel instanceof Kicker.SimpleFavoritesModel
let type = root.favoritesModel instanceof Kicker.SimpleFavoritesModel
? "text/xx-kicker-simplefavorite-id"
: "text/xx-kicker-kastatsfavorite-id"
dragHelper.startDrag(kicker, item.url, item.decoration,
type, item.favoriteId)
dragHelper.startDrag(kicker, root.url, root.decoration,
type, root.favoriteId)
}
}
}
@ -166,13 +166,13 @@ ItemAbstractDelegate {
// needs to be ToolTipArea, as ItemListDialog will clip (attached) ToolTip if the submenu
// has very few entries (and makes it feel glitchy then)
anchors.fill: parent
active: label.truncated || item.showDescriptionInTooltip
active: label.truncated || root.showDescriptionInTooltip
mainText: {
// if it's name (description) or description (name), we split them on separate lines
// but only if the compactName is available (e.g. for search results it's not)
let name = (Plasmoid.configuration.appNameFormat > 1 && item.compactName.length > 1) ? item.compactName : item.text
let name = (Plasmoid.configuration.appNameFormat > 1 && root.compactName.length > 1) ? root.compactName : root.text
return label.truncated ? name ?? "" : ""
}
subText: item.showDescriptionInTooltip || Plasmoid.configuration.appNameFormat > 1 ? item.description ?? "" : ""
subText: root.showDescriptionInTooltip || Plasmoid.configuration.appNameFormat > 1 ? root.description ?? "" : ""
}
}

View file

@ -8,7 +8,6 @@ pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasmoid
import org.kde.plasma.private.kicker as Kicker

View file

@ -237,7 +237,7 @@ PlasmaComponents.ScrollView {
onKeyNavDown: {
if (gridDelegate.index < repeater.count - 1) {
for (var i = gridDelegate.index + 1; i < repeater.count; i++) {
for (let i = gridDelegate.index + 1; i < repeater.count; i++) {
if (itemMultiGrid.subGridAt(i).count > 0) {
itemMultiGrid.subGridAt(i).tryActivate(0, currentCol());
break;

View file

@ -44,8 +44,8 @@ RowLayout {
onIsFirstColumnChanged: setDefaultCurrentIndex()
Connections {
target: model
function onQueryingChanged() { setDefaultCurrentIndex() }
target: runnerResultsList.model
function onQueryingChanged() { runnerResultsList.setDefaultCurrentIndex() }
}
spacing: Kirigami.Units.smallSpacing

View file

@ -13,14 +13,14 @@ import org.kde.plasma.extras as PlasmaExtras
import org.kde.ksvg as KSvg
ItemAbstractDelegate {
id: item
id: root
readonly property int itemIndex: model.index
readonly property bool isDropPlaceHolder: "dropPlaceholderIndex" in item.baseModel && item.itemIndex === item.baseModel.dropPlaceholderIndex
readonly property bool isDropPlaceHolder: "dropPlaceholderIndex" in root.baseModel && root.itemIndex === root.baseModel.dropPlaceholderIndex
property bool showUnfavoritePlaceholder: false
Accessible.role: Accessible.ListItem
icon.source: item.decoration
icon.source: root.decoration
icon.width: Kirigami.Units.iconSizes.medium
icon.height: Kirigami.Units.iconSizes.medium
hoverEnabled: true
@ -28,15 +28,15 @@ ItemAbstractDelegate {
background.visible: false // we want the default background's spacing, but not the base color
contentItem: Kirigami.Icon {
visible: !item.showUnfavoritePlaceholder && !item.isDropPlaceHolder
active: item.hovered
width: item.icon.width
height: item.icon.height
source: item.icon.source
visible: !root.showUnfavoritePlaceholder && !root.isDropPlaceHolder
active: root.hovered
width: root.icon.width
height: root.icon.height
source: root.icon.source
}
Loader {
active: item.hovered || item.visualFocus || dragHandler.active || item.isDropPlaceHolder || item.showUnfavoritePlaceholder
active: root.hovered || root.visualFocus || dragHandler.active || root.isDropPlaceHolder || root.showUnfavoritePlaceholder
anchors.fill: parent
sourceComponent: Item {
@ -46,15 +46,15 @@ ItemAbstractDelegate {
PlasmaExtras.Highlight {
anchors.fill: parent
visible: !item.isDropPlaceHolder && !item.showUnfavoritePlaceholder
visible: !root.isDropPlaceHolder && !root.showUnfavoritePlaceholder
hovered: true
pressed: item.pressed
pressed: root.pressed
}
KSvg.FrameSvgItem {
anchors.fill: parent
visible: item.isDropPlaceHolder || item.showUnfavoritePlaceholder
visible: root.isDropPlaceHolder || root.showUnfavoritePlaceholder
imagePath: "widgets/viewitem"
prefix: "selected"
@ -64,10 +64,10 @@ ItemAbstractDelegate {
Kirigami.Icon {
anchors.centerIn: parent
width: item.icon.width
width: root.icon.width
height: width
source: item.isDropPlaceHolder ? "list-add" : "list-remove"
source: root.isDropPlaceHolder ? "list-add" : "list-remove"
active: false
}
}
@ -78,21 +78,21 @@ ItemAbstractDelegate {
id: dragHandler
target: null
onActiveChanged: if (active) {
item.contentItem.grabToImage(function(result) {
item.Drag.imageSource = result.url
item.Drag.active = true // using a binding can cause loop warnings when unexpanding
root.contentItem.grabToImage(function(result) {
root.Drag.imageSource = result.url
root.Drag.active = true // using a binding can cause loop warnings when unexpanding
})
} else {
item.Drag.active = false
root.Drag.active = false
}
}
Drag.dragType: Drag.Automatic
Drag.mimeData: {
'favoritedrag': '',
"text/uri-list" : [item.url]
"text/uri-list" : [root.url]
}
PC3.ToolTip {
text: item.text
text: root.text
}
}

View file

@ -9,7 +9,6 @@ import QtQuick
import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.plasma.components as PlasmaComponents3
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasmoid
import org.kde.plasma.private.kicker as Kicker
@ -37,8 +36,8 @@ PlasmoidItem {
ItemListDialog {}
}
property Kicker.KAStatsFavoritesModel globalFavorites: rootModel.favoritesModel as Kicker.KAStatsFavoritesModel
property Kicker.SimpleFavoritesModel systemFavorites: rootModel.systemFavoritesModel as Kicker.SimpleFavoritesModel
property Kicker.KAStatsFavoritesModel globalFavorites: rootModelInstance.favoritesModel as Kicker.KAStatsFavoritesModel
property Kicker.SimpleFavoritesModel systemFavorites: rootModelInstance.systemFavoritesModel as Kicker.SimpleFavoritesModel
Plasmoid.icon: Plasmoid.configuration.useCustomButtonImage ? Plasmoid.configuration.customButtonImage : Plasmoid.configuration.icon
@ -65,8 +64,8 @@ PlasmoidItem {
MenuRepresentation {
globalFavorites: kicker.globalFavorites
systemFavorites: kicker.systemFavorites
rootModel: rootModel
runnerModel: runnerModel
rootModel: rootModelInstance
runnerModel: runnerModelInstance
onInteractionConcluded: kicker.expanded = false
}
}
@ -76,14 +75,14 @@ PlasmoidItem {
DashboardRepresentation {
globalFavorites: kicker.globalFavorites
systemFavorites: kicker.systemFavorites
rootModel: rootModel
runnerModel: runnerModel
rootModel: rootModelInstance
runnerModel: runnerModelInstance
onInteractionConcluded: toggle()
}
}
Kicker.RootModel {
id: rootModel
id: rootModelInstance
autoPopulate: false
@ -145,7 +144,7 @@ PlasmoidItem {
}
Kicker.RunnerModel {
id: runnerModel
id: runnerModelInstance
appletInterface: kicker
@ -201,6 +200,6 @@ PlasmoidItem {
Plasmoid.activationTogglesExpanded = !kicker.isDash
}
rootModel.refreshed.connect(modelRefreshed);
rootModelInstance.refreshed.connect(modelRefreshed);
}
}