Commit 64aa8043 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[kicker] Fix some unqualified root property access

Summary: Those will break in Qt 6. Apply suggestions from qmllint

Test Plan: Did kicker/dashboard things

Reviewers: #plasma, hein

Reviewed By: #plasma, hein

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26406
parent c4dc4bd4
......@@ -70,7 +70,7 @@ FocusScope {
return -1;
}
return Math.floor(currentIndex / Math.floor(width / cellWidth));
return Math.floor(currentIndex / Math.floor(width / itemGrid.cellWidth));
}
function currentCol() {
......@@ -78,17 +78,17 @@ FocusScope {
return -1;
}
return currentIndex - (currentRow() * Math.floor(width / cellWidth));
return currentIndex - (currentRow() * Math.floor(width / itemGrid.cellWidth));
}
function lastRow() {
var columns = Math.floor(width / cellWidth);
var columns = Math.floor(width / itemGrid.cellWidth);
return Math.ceil(count / columns) - 1;
}
function tryActivate(row, col) {
if (count) {
var columns = Math.floor(width / cellWidth);
var columns = Math.floor(width / itemGrid.cellWidth);
var rows = Math.ceil(count / columns);
row = Math.min(row, rows - 1);
col = Math.min(col, columns - 1);
......@@ -118,11 +118,11 @@ FocusScope {
anchors.fill: parent
onDragMove: {
if (!dropEnabled || gridView.animating || !kicker.dragSource) {
if (!itemGrid.dropEnabled || gridView.animating || !kicker.dragSource) {
return;
}
var x = Math.max(0, event.x - (width % cellWidth));
var x = Math.max(0, event.x - (width % itemGrid.cellWidth));
var cPos = mapToItem(gridView.contentItem, x, event.y);
var item = gridView.itemAt(cPos.x, cPos.y);
......@@ -131,42 +131,42 @@ FocusScope {
if (item !== kicker.dragSource) {
item.GridView.view.model.moveRow(dragSource.itemIndex, item.itemIndex);
}
} else if (kicker.dragSource.GridView.view.model.favoritesModel === model
&& !model.isFavorite(kicker.dragSource.favoriteId)) {
var hasPlaceholder = (model.dropPlaceholderIndex !== -1);
} else if (kicker.dragSource.GridView.view.model.favoritesModel === itemGrid.model
&& !itemGrid.model.isFavorite(kicker.dragSource.favoriteId)) {
var hasPlaceholder = (itemGrid.model.dropPlaceholderIndex !== -1);
model.dropPlaceholderIndex = item.itemIndex;
itemGrid.model.dropPlaceholderIndex = item.itemIndex;
if (!hasPlaceholder) {
gridView.currentIndex = (item.itemIndex - 1);
}
}
} else if (kicker.dragSource.parent !== gridView.contentItem
&& kicker.dragSource.GridView.view.model.favoritesModel === model
&& !model.isFavorite(kicker.dragSource.favoriteId)) {
var hasPlaceholder = (model.dropPlaceholderIndex !== -1);
&& kicker.dragSource.GridView.view.model.favoritesModel === itemGrid.model
&& !itemGrid.model.isFavorite(kicker.dragSource.favoriteId)) {
var hasPlaceholder = (itemGrid.model.dropPlaceholderIndex !== -1);
model.dropPlaceholderIndex = hasPlaceholder ? model.count - 1 : model.count;
itemGrid.model.dropPlaceholderIndex = hasPlaceholder ? itemGrid.model.count - 1 : itemGrid.model.count;
if (!hasPlaceholder) {
gridView.currentIndex = (model.count - 1);
gridView.currentIndex = (itemGrid.model.count - 1);
}
} else {
model.dropPlaceholderIndex = -1;
itemGrid.model.dropPlaceholderIndex = -1;
gridView.currentIndex = -1;
}
}
onDragLeave: {
if ("dropPlaceholderIndex" in model) {
model.dropPlaceholderIndex = -1;
if ("dropPlaceholderIndex" in itemGrid.model) {
itemGrid.model.dropPlaceholderIndex = -1;
gridView.currentIndex = -1;
}
}
onDrop: {
if (kicker.dragSource && kicker.dragSource.parent !== gridView.contentItem && kicker.dragSource.GridView.view.model.favoritesModel === model) {
model.addFavorite(kicker.dragSource.favoriteId, model.dropPlaceholderIndex);
if (kicker.dragSource && kicker.dragSource.parent !== gridView.contentItem && kicker.dragSource.GridView.view.model.favoritesModel === itemGrid.model) {
itemGrid.model.addFavorite(kicker.dragSource.favoriteId, itemGrid.model.dropPlaceholderIndex);
gridView.currentIndex = -1;
}
}
......@@ -201,7 +201,7 @@ FocusScope {
property int iconSize: units.iconSizes.huge
property bool animating: false
property int animationDuration: dropEnabled ? resetAnimationDurationTimer.interval : 0
property int animationDuration: itemGrid.dropEnabled ? resetAnimationDurationTimer.interval : 0
focus: true
......@@ -243,11 +243,11 @@ FocusScope {
boundsBehavior: Flickable.StopAtBounds
delegate: ItemGridDelegate {
showLabel: showLabels
showLabel: itemGrid.showLabels
}
highlight: Item {
property bool isDropPlaceHolder: "dropPlaceholderIndex" in model && currentIndex === model.dropPlaceholderIndex
property bool isDropPlaceHolder: "dropPlaceholderIndex" in itemGrid.model && itemGrid.currentIndex === itemGrid.model.dropPlaceholderIndex
PlasmaComponents.Highlight {
visible: gridView.currentItem && !isDropPlaceHolder
......@@ -302,7 +302,7 @@ FocusScope {
}
Keys.onLeftPressed: {
if (currentCol() !== 0) {
if (itemGrid.currentCol() !== 0) {
event.accepted = true;
moveCurrentIndexLeft();
} else {
......@@ -313,7 +313,7 @@ FocusScope {
Keys.onRightPressed: {
var columns = Math.floor(width / cellWidth);
if (currentCol() !== columns - 1 && currentIndex != count -1) {
if (itemGrid.currentCol() !== columns - 1 && currentIndex != count -1) {
event.accepted = true;
moveCurrentIndexRight();
} else {
......@@ -322,7 +322,7 @@ FocusScope {
}
Keys.onUpPressed: {
if (currentRow() !== 0) {
if (itemGrid.currentRow() !== 0) {
event.accepted = true;
moveCurrentIndexUp();
positionViewAtIndex(currentIndex, GridView.Contain);
......@@ -332,7 +332,7 @@ FocusScope {
}
Keys.onDownPressed: {
if (currentRow() < itemGrid.lastRow()) {
if (itemGrid.currentRow() < itemGrid.lastRow()) {
// Fix moveCurrentIndexDown()'s lack of proper spatial nav down
// into partial columns.
event.accepted = true;
......@@ -397,7 +397,7 @@ FocusScope {
pressedItem = null;
} else {
gridView.currentIndex = item.itemIndex;
itemGrid.focus = (currentIndex != -1)
itemGrid.focus = (itemGrid.currentIndex != -1)
}
return item;
......@@ -450,7 +450,7 @@ FocusScope {
var item = pressedItem? pressedItem : updatePositionProperties(mouse.x, mouse.y);
if (gridView.currentIndex != -1) {
if (dragEnabled && pressX != -1 && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) {
if (itemGrid.dragEnabled && pressX != -1 && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) {
if ("pluginName" in item.m) {
dragHelper.startDrag(kicker, item.url, item.icon,
"text/x-plasmoidservicename", item.m.pluginName);
......
......@@ -53,7 +53,7 @@ Item {
}
onAboutToShowActionMenu: {
var actionList = hasActionList ? model.actionList : [];
var actionList = item.hasActionList ? model.actionList : [];
Tools.fillActionMenu(i18n, actionMenu, actionList, ListView.view.model.favoritesModel, model.favoriteId);
}
......@@ -73,7 +73,7 @@ Item {
id: actionMenu
onActionClicked: {
actionTriggered(actionId, actionArgument);
item.actionTriggered(actionId, actionArgument);
}
}
......@@ -98,8 +98,8 @@ Item {
onPressed: {
if (mouse.buttons & Qt.RightButton) {
if (hasActionList) {
openActionMenu(mouseArea, mouse.x, mouse.y);
if (item.hasActionList) {
item.openActionMenu(mouseArea, mouse.x, mouse.y);
}
} else {
pressed = true;
......@@ -109,7 +109,7 @@ Item {
}
onReleased: {
if (pressed && !hasChildren) {
if (pressed && !item.hasChildren) {
item.ListView.view.model.trigger(index, "", null);
plasmoid.expanded = false;
}
......@@ -130,7 +130,7 @@ Item {
}
// FIXME: Correct escape angle calc for right screen edge.
if (justOpenedTimer.running || !hasChildren) {
if (justOpenedTimer.running || !item.hasChildren) {
item.ListView.view.currentIndex = index;
} else {
mouseCol = mouse.x;
......@@ -140,11 +140,11 @@ Item {
} else if ((index == item.ListView.view.currentIndex - 1) && mouse.y < (itemHeight - 6)
|| (index == item.ListView.view.currentIndex + 1) && mouse.y > 5) {
if ((childDialog != null && childDialog.facingLeft)
if ((item.childDialog != null && item.childDialog.facingLeft)
? mouse.x > item.ListView.view.eligibleWidth - 5 : mouse.x < item.ListView.view.eligibleWidth + 5) {
updateCurrentItem();
}
} else if ((childDialog != null && childDialog.facingLeft)
} else if ((item.childDialog != null && item.childDialog.facingLeft)
? mouse.x > item.ListView.view.eligibleWidth : mouse.x < item.ListView.view.eligibleWidth) {
updateCurrentItem();
}
......@@ -211,7 +211,7 @@ Item {
PlasmaComponents.Label {
id: label
enabled: !isParent || (isParent && hasChildren)
enabled: !isParent || (isParent && item.hasChildren)
anchors.verticalCenter: parent.verticalCenter
......@@ -234,7 +234,7 @@ Item {
width: visible ? units.iconSizes.small : 0
height: width
visible: hasChildren
visible: item.hasChildren
opacity: (item.ListView.view.currentIndex === index) ? 1.0 : 0.4
svg: arrows
......@@ -263,18 +263,18 @@ Item {
anchors.rightMargin: highlightItemSvg.margins.right
anchors.verticalCenter: parent.verticalCenter
active: isSeparator
active: item.isSeparator
asynchronous: false
sourceComponent: separatorComponent
}
Keys.onPressed: {
if (event.key === Qt.Key_Menu && hasActionList) {
if (event.key === Qt.Key_Menu && item.hasActionList) {
event.accepted = true;
openActionMenu(mouseArea);
} else if ((event.key === Qt.Key_Enter || event.key === Qt.Key_Return) && !hasChildren) {
if (!hasChildren) {
item.openActionMenu(mouseArea);
} else if ((event.key === Qt.Key_Enter || event.key === Qt.Key_Return) && !item.hasChildren) {
if (!item.hasChildren) {
event.accepted = true;
item.ListView.view.model.trigger(index, "", null);
plasmoid.expanded = false;
......
......@@ -48,10 +48,10 @@ Kicker.SubMenu {
mainItem: ItemListView {
id: itemListView
height: model !== undefined ? Math.min(((Math.floor((itemDialog.availableScreenRectForItem(itemListView).height
height: itemDialog.model !== undefined ? Math.min(((Math.floor((itemDialog.availableScreenRectForItem(itemListView).height
- itemDialog.margins.top - itemDialog.margins.bottom) / itemHeight) - 1)
* itemHeight) - (model.separatorCount * itemHeight) + (model.separatorCount * separatorHeight),
((model.count - model.separatorCount) * itemHeight) + (model.separatorCount * separatorHeight)) : 0
* itemHeight) - (itemDialog.model.separatorCount * itemHeight) + (itemDialog.model.separatorCount * separatorHeight),
((itemDialog.model.count - itemDialog.model.separatorCount) * itemHeight) + (itemDialog.model.separatorCount * separatorHeight)) : 0
iconsEnabled: true
......
......@@ -72,26 +72,26 @@ FocusScope {
return;
}
if (childDialog != null) {
childDialog.delayedDestroy();
if (itemList.childDialog != null) {
itemList.childDialog.delayedDestroy();
}
// Gets reenabled after the dialog spawn causes a focus-in on the dialog window.
plasmoid.hideOnWindowDeactivate = false;
childDialog = itemListDialogComponent.createObject(itemList);
childDialog.focusParent = itemList;
childDialog.visualParent = listView.currentItem;
childDialog.model = model.modelForRow(listView.currentIndex);
childDialog.visible = true;
itemList.childDialog = itemListDialogComponent.createObject(itemList);
itemList.childDialog.focusParent = itemList;
itemList.childDialog.visualParent = listView.currentItem;
itemList.childDialog.model = model.modelForRow(listView.currentIndex);
itemList.childDialog.visible = true;
windowSystem.forceActive(childDialog.mainItem);
childDialog.mainItem.focus = true;
windowSystem.forceActive(itemList.childDialog.mainItem);
itemList.childDialog.mainItem.focus = true;
if (focusOnSpawn) {
childDialog.mainItem.showChildDialogs = false;
childDialog.mainItem.currentIndex = 0;
childDialog.mainItem.showChildDialogs = true;
itemList.childDialog.mainItem.showChildDialogs = false;
itemList.childDialog.mainItem.currentIndex = 0;
itemList.childDialog.mainItem.showChildDialogs = true;
}
}
}
......@@ -103,7 +103,7 @@ FocusScope {
repeat: false
onTriggered: {
if (focus && (!childDialog || !childDialog.mainItem.containsMouse)) {
if (focus && (!itemList.childDialog || !itemList.childDialog.mainItem.containsMouse)) {
currentIndex = -1;
itemList.exited();
}
......@@ -123,7 +123,7 @@ FocusScope {
if (containsMouse) {
resetIndexTimer.stop();
itemList.forceActiveFocus();
} else if ((!childDialog || !dialog)
} else if ((!itemList.childDialog || !dialog)
&& (!currentItem || !currentItem.menu.opened)) {
resetIndexTimer.start();
}
......@@ -165,13 +165,13 @@ FocusScope {
onCurrentIndexChanged: {
if (currentIndex != -1) {
if (childDialog) {
if (itemList.childDialog) {
if (currentItem && currentItem.hasChildren) {
childDialog.mainItem.width = itemList.minimumWidth;
childDialog.model = model.modelForRow(currentIndex);
childDialog.visualParent = listView.currentItem;
itemList.childDialog.mainItem.width = itemList.minimumWidth;
itemList.childDialog.model = model.modelForRow(currentIndex);
itemList.childDialog.visualParent = listView.currentItem;
} else {
childDialog.delayedDestroy();
itemList.childDialog.delayedDestroy();
}
return;
......@@ -187,9 +187,9 @@ FocusScope {
dialogSpawnTimer.focusOnSpawn = false;
dialogSpawnTimer.restart();
}
} else if (childDialog != null) {
childDialog.delayedDestroy();
childDialog = null;
} else if (itemList.childDialog != null) {
itemList.childDialog.delayedDestroy();
itemList.childDialog = null;
}
}
......@@ -234,11 +234,11 @@ FocusScope {
}
showChildDialogs = true;
} else if ((event.key === Qt.Key_Right || event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && childDialog != null) {
windowSystem.forceActive(childDialog.mainItem);
childDialog.mainItem.focus = true;
childDialog.mainItem.currentIndex = 0;
} else if ((event.key === Qt.Key_Right || event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && childDialog == null
} else if ((event.key === Qt.Key_Right || event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && itemList.childDialog != null) {
windowSystem.forceActive(itemList.childDialog.mainItem);
itemList.childDialog.mainItem.focus = true;
itemList.childDialog.mainItem.currentIndex = 0;
} else if ((event.key === Qt.Key_Right || event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && itemList.childDialog == null
&& currentItem != null && currentItem.hasChildren) {
dialogSpawnTimer.focusOnSpawn = true;
dialogSpawnTimer.restart();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment