Warning, /plasma/plasma-simplemenu/package/contents/ui/MenuRepresentation.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2014 Weng Xuetian <wengxt@gmail.com>
0003     SPDX-FileCopyrightText: 2013-2017 Eike Hein <hein@kde.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 import QtQuick 2.4
0009 import QtQuick.Layouts 1.1
0010 import QtQuick.Controls 2.12 as QQC2
0011 import org.kde.plasma.plasmoid 2.0
0012 import org.kde.plasma.core 2.0 as PlasmaCore
0013 import org.kde.plasma.components 2.0 as PlasmaComponents
0014 import org.kde.plasma.components 3.0 as PlasmaComponents3
0015 import org.kde.plasma.extras 2.0 as PlasmaExtras
0016 
0017 import org.kde.plasma.private.kicker 0.1 as Kicker
0018 
0019 PlasmaCore.Dialog {
0020     id: root
0021 
0022     objectName: "popupWindow"
0023     flags: Qt.WindowStaysOnTopHint
0024     location: PlasmaCore.Types.Floating
0025     hideOnWindowDeactivate: true
0026 
0027     property int iconSize: units.iconSizes.huge
0028     property int cellSize: iconSize + theme.mSize(theme.defaultFont).height
0029         + (2 * units.smallSpacing)
0030         + (2 * Math.max(highlightItemSvg.margins.top + highlightItemSvg.margins.bottom,
0031                         highlightItemSvg.margins.left + highlightItemSvg.margins.right))
0032     property bool searching: (searchField.text != "")
0033 
0034     onVisibleChanged: {
0035         if (!visible) {
0036             reset();
0037         } else {
0038             var pos = popupPosition(width, height);
0039             x = pos.x;
0040             y = pos.y;
0041             requestActivate();
0042         }
0043     }
0044 
0045     onHeightChanged: {
0046         var pos = popupPosition(width, height);
0047         x = pos.x;
0048         y = pos.y;
0049     }
0050 
0051     onWidthChanged: {
0052         var pos = popupPosition(width, height);
0053         x = pos.x;
0054         y = pos.y;
0055     }
0056 
0057     onSearchingChanged: {
0058         if (searching) {
0059             pageList.model = runnerModel;
0060             paginationBar.model = runnerModel;
0061         } else {
0062             reset();
0063         }
0064     }
0065 
0066     function reset() {
0067         if (!searching) {
0068             if (filterListScrollArea.visible) {
0069                 filterList.currentIndex = 0;
0070             } else {
0071                 pageList.model = rootModel.modelForRow(0);
0072                 paginationBar.model = rootModel.modelForRow(0);
0073             }
0074         }
0075 
0076         searchField.text = "";
0077 
0078         pageListScrollArea.focus = true;
0079         pageList.currentIndex = 0;
0080         pageList.currentItem.itemGrid.currentIndex = -1;
0081     }
0082 
0083     function popupPosition(width, height) {
0084         var screenAvail = plasmoid.availableScreenRect;
0085         var screenGeom = plasmoid.screenGeometry;
0086         //QtBug - QTBUG-64115
0087         var screen = Qt.rect(screenAvail.x + screenGeom.x,
0088                              screenAvail.y + screenGeom.y,
0089                              screenAvail.width,
0090                              screenAvail.height);
0091 
0092         var offset = units.gridUnit;
0093 
0094         // Fall back to bottom-left of screen area when the applet is on the desktop or floating.
0095         var x = offset;
0096         var y = screen.height - height - offset;
0097 
0098         if (plasmoid.location == PlasmaCore.Types.BottomEdge) {
0099             var horizMidPoint = screen.x + (screen.width / 2);
0100             var appletTopLeft = parent.mapToGlobal(0, 0);
0101             x = (appletTopLeft.x < horizMidPoint) ? screen.x + offset : (screen.x + screen.width) - width - offset;
0102             y = screen.height - height - offset - panelSvg.margins.top;
0103         } else if (plasmoid.location == PlasmaCore.Types.TopEdge) {
0104             var horizMidPoint = screen.x + (screen.width / 2);
0105             var appletBottomLeft = parent.mapToGlobal(0, parent.height);
0106             x = (appletBottomLeft.x < horizMidPoint) ? screen.x + offset : (screen.x + screen.width) - width - offset;
0107             y = parent.height + panelSvg.margins.bottom + offset;
0108         } else if (plasmoid.location == PlasmaCore.Types.LeftEdge) {
0109             var vertMidPoint = screen.y + (screen.height / 2);
0110             var appletTopLeft = parent.mapToGlobal(0, 0);
0111             x = parent.width + panelSvg.margins.right + offset;
0112             y = (appletTopLeft.y < vertMidPoint) ? screen.y + offset : (screen.y + screen.height) - height - offset;
0113         } else if (plasmoid.location == PlasmaCore.Types.RightEdge) {
0114             var vertMidPoint = screen.y + (screen.height / 2);
0115             var appletTopLeft = parent.mapToGlobal(0, 0);
0116             x = appletTopLeft.x - panelSvg.margins.left - offset - width;
0117             y = (appletTopLeft.y < vertMidPoint) ? screen.y + offset : (screen.y + screen.height) - height - offset;
0118         }
0119 
0120         return Qt.point(x, y);
0121     }
0122 
0123 
0124     FocusScope {
0125         Layout.minimumWidth: (cellSize * 6) + Math.max(systemFavoritesGrid.width, filterListScrollArea.width) + units.smallSpacing
0126         Layout.maximumWidth: (cellSize * 6) + Math.max(systemFavoritesGrid.width, filterListScrollArea.width) + units.smallSpacing
0127         Layout.minimumHeight: (cellSize * 4) + searchField.height + paginationBar.height + (2 * units.smallSpacing)
0128         Layout.maximumHeight: (cellSize * 4) + searchField.height + paginationBar.height + (2 * units.smallSpacing)
0129 
0130         focus: true
0131 
0132     PlasmaExtras.Heading {
0133         id: dummyHeading
0134 
0135         visible: false
0136 
0137         width: 0
0138 
0139         level: 5
0140     }
0141 
0142     TextMetrics {
0143         id: headingMetrics
0144 
0145         font: dummyHeading.font
0146     }
0147 
0148     ActionMenu {
0149         id: actionMenu
0150 
0151         onActionClicked: visualParent.actionTriggered(actionId, actionArgument)
0152 
0153         onClosed: {
0154             if (pageList.currentItem) {
0155                 pageList.currentItem.itemGrid.currentIndex = -1;
0156             }
0157         }
0158     }
0159 
0160     ColumnLayout {
0161         anchors.fill: parent
0162 
0163         PlasmaExtras.PlasmoidHeading {
0164             leftPadding: 0
0165             rightPadding: 0
0166 
0167             contentItem: RowLayout {
0168                 PlasmaComponents3.TextField {
0169                     id: searchField
0170 
0171                     Layout.fillWidth: true
0172 
0173                     placeholderText: i18n("Search...")
0174 
0175                     onTextChanged: {
0176                         runnerModel.query = text;
0177                     }
0178 
0179                     Keys.onPressed: {
0180                         if (event.key == Qt.Key_Down) {
0181                             event.accepted = true;
0182                             pageList.currentItem.itemGrid.tryActivate(0, 0);
0183                         } else if (event.key == Qt.Key_Right) {
0184                             if (cursorPosition == length) {
0185                                 event.accepted = true;
0186 
0187                                 if (pageList.currentItem.itemGrid.currentIndex == -1) {
0188                                     pageList.currentItem.itemGrid.tryActivate(0, 0);
0189                                 } else {
0190                                     pageList.currentItem.itemGrid.tryActivate(0, 1);
0191                                 }
0192                             }
0193                         } else if (event.key == Qt.Key_Return || event.key == Qt.Key_Enter) {
0194                             if (text != "" && pageList.currentItem.itemGrid.count > 0) {
0195                                 event.accepted = true;
0196                                 pageList.currentItem.itemGrid.tryActivate(0, 0);
0197                                 pageList.currentItem.itemGrid.model.trigger(0, "", null);
0198                                 root.visible = false;
0199                             }
0200                         } else if (event.key == Qt.Key_Tab) {
0201                             event.accepted = true;
0202                             systemFavoritesGrid.tryActivate(0, 0);
0203                         } else if (event.key == Qt.Key_Backtab) {
0204                             event.accepted = true;
0205 
0206                             if (!searching) {
0207                                 filterList.forceActiveFocus();
0208                             } else {
0209                                 systemFavoritesGrid.tryActivate(0, 0);
0210                             }
0211                         }
0212                     }
0213 
0214                     function backspace() {
0215                         if (!root.visible) {
0216                             return;
0217                         }
0218 
0219                         focus = true;
0220                         text = text.slice(0, -1);
0221                     }
0222 
0223                     function appendText(newText) {
0224                         if (!root.visible) {
0225                             return;
0226                         }
0227 
0228                         focus = true;
0229                         text = text + newText;
0230                     }
0231                 }
0232 
0233                 QQC2.ToolSeparator {
0234                     Layout.fillHeight: true
0235                 }
0236 
0237                 Item {
0238                     implicitWidth: plasmoid.configuration.showFilterList ? filterListScrollArea.Layout.preferredWidth : systemFavoritesGrid.cellWidth * 4
0239                     implicitHeight: systemFavoritesGrid.cellHeight
0240 
0241                     ItemGridView {
0242                         id: systemFavoritesGrid
0243 
0244                         anchors.horizontalCenter: parent.horizontalCenter
0245 
0246                         cellWidth: searchField.height
0247                         cellHeight: searchField.height
0248                         height: cellHeight
0249                         width: cellWidth * count
0250 
0251                         iconSize: height - units.smallSpacing
0252 
0253                         horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
0254                         verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
0255 
0256                         dragEnabled: true
0257                         showLabels: false
0258 
0259                         model: systemFavorites
0260 
0261                         onCurrentIndexChanged: {
0262                             focus = true;
0263                         }
0264 
0265                         onKeyNavLeft: {
0266                             currentIndex = -1;
0267                             searchField.focus = true;
0268                         }
0269 
0270                         onKeyNavDown: {
0271                             pageListScrollArea.focus = true;
0272 
0273                             if (pageList.currentItem) {
0274                                 pageList.currentItem.itemGrid.tryActivate(0, 0);
0275                             }
0276                         }
0277 
0278                         Keys.onPressed: {
0279                             if (event.key == Qt.Key_Tab) {
0280                                 event.accepted = true;
0281 
0282                                 currentIndex = -1;
0283 
0284                                 if (!searching) {
0285                                     filterList.forceActiveFocus();
0286                                 } else {
0287                                     searchField.focus = true;
0288                                 }
0289                             } else if (event.key == Qt.Key_Backtab) {
0290                                 event.accepted = true;
0291                                 currentIndex = -1;
0292                                 searchField.focus = true;
0293                             }
0294                         }
0295                     }
0296                 }
0297             }
0298         }
0299 
0300         RowLayout {
0301             Layout.fillWidth: true
0302             Layout.fillHeight: true
0303 
0304             ColumnLayout {
0305                 Layout.fillWidth: true
0306                 Layout.fillHeight: true
0307 
0308                 PlasmaExtras.ScrollArea {
0309                     id: pageListScrollArea
0310 
0311                     Layout.fillWidth: true
0312                     Layout.fillHeight: true
0313 
0314                     focus: true
0315                     frameVisible: false
0316 
0317                     horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
0318                     verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
0319 
0320                     ListView {
0321                         id: pageList
0322 
0323                         anchors.fill: parent
0324 
0325                         orientation: Qt.Horizontal
0326                         snapMode: ListView.SnapOneItem
0327 
0328                         currentIndex: 0
0329 
0330                         model: rootModel.modelForRow(0)
0331 
0332                         onCurrentIndexChanged: {
0333                             positionViewAtIndex(currentIndex, ListView.Contain);
0334                         }
0335 
0336                         onCurrentItemChanged: {
0337                             if (!currentItem) {
0338                                 return;
0339                             }
0340 
0341                             currentItem.itemGrid.focus = true;
0342                         }
0343 
0344                         onModelChanged: {
0345                             currentIndex = 0;
0346                         }
0347 
0348                         onFlickingChanged: {
0349                             if (!flicking) {
0350                                 var pos = mapToItem(contentItem, root.width / 2, root.height / 2);
0351                                 var itemIndex = indexAt(pos.x, pos.y);
0352                                 currentIndex = itemIndex;
0353                             }
0354                         }
0355 
0356                         function cycle() {
0357                             enabled = false;
0358                             enabled = true;
0359                         }
0360 
0361                         function activateNextPrev(next) {
0362                             if (next) {
0363                                 var newIndex = pageList.currentIndex + 1;
0364 
0365                                 if (newIndex == pageList.count) {
0366                                     newIndex = 0;
0367                                 }
0368 
0369                                 pageList.currentIndex = newIndex;
0370                             } else {
0371                                 var newIndex = pageList.currentIndex - 1;
0372 
0373                                 if (newIndex < 0) {
0374                                     newIndex = (pageList.count - 1);
0375                                 }
0376 
0377                                 pageList.currentIndex = newIndex;
0378                             }
0379                         }
0380 
0381                         delegate: Item {
0382                             width: cellSize * 6
0383                             height: cellSize * 4
0384 
0385                             property Item itemGrid: gridView
0386 
0387                             ItemGridView {
0388                                 id: gridView
0389 
0390                                 anchors.horizontalCenter: parent.horizontalCenter
0391                                 width: cellSize * 6
0392                                 height: cellSize * 4
0393 
0394                                 cellWidth: cellSize
0395                                 cellHeight: cellSize
0396 
0397                                 horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
0398                                 verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
0399 
0400                                 dragEnabled: (index == 0)
0401 
0402                                 model: searching ? runnerModel.modelForRow(index) : rootModel.modelForRow(filterListScrollArea.visible ? filterList.currentIndex : 0).modelForRow(index)
0403 
0404                                 onCurrentIndexChanged: {
0405                                     if (currentIndex != -1 && !searching) {
0406                                         pageListScrollArea.focus = true;
0407                                         focus = true;
0408                                     }
0409                                 }
0410 
0411                                 onCountChanged: {
0412                                     if (searching && index == 0) {
0413                                         currentIndex = 0;
0414                                     }
0415                                 }
0416 
0417                                 onKeyNavUp: {
0418                                     currentIndex = -1;
0419                                     searchField.focus = true;
0420                                 }
0421 
0422                                 onKeyNavRight: {
0423                                     var newIndex = pageList.currentIndex + 1;
0424                                     var cRow = currentRow();
0425 
0426                                     if (newIndex == pageList.count) {
0427                                         newIndex = 0;
0428                                     }
0429 
0430                                     pageList.currentIndex = newIndex;
0431                                     pageList.currentItem.itemGrid.tryActivate(cRow, 0);
0432                                 }
0433 
0434                                 onKeyNavLeft: {
0435                                     var newIndex = pageList.currentIndex - 1;
0436                                     var cRow = currentRow();
0437 
0438                                     if (newIndex < 0) {
0439                                         newIndex = (pageList.count - 1);
0440                                     }
0441 
0442                                     pageList.currentIndex = newIndex;
0443                                     pageList.currentItem.itemGrid.tryActivate(cRow, 5);
0444                                 }
0445                             }
0446 
0447                             Kicker.WheelInterceptor {
0448                                 anchors.fill: parent
0449                                 z: 1
0450 
0451                                 property int wheelDelta: 0
0452 
0453                                 function scrollByWheel(wheelDelta, eventDelta) {
0454                                     // magic number 120 for common "one click"
0455                                     // See: http://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop
0456                                     wheelDelta += eventDelta;
0457 
0458                                     var increment = 0;
0459 
0460                                     while (wheelDelta >= 120) {
0461                                         wheelDelta -= 120;
0462                                         increment++;
0463                                     }
0464 
0465                                     while (wheelDelta <= -120) {
0466                                         wheelDelta += 120;
0467                                         increment--;
0468                                     }
0469 
0470                                     while (increment != 0) {
0471                                         pageList.activateNextPrev(increment < 0);
0472                                         increment += (increment < 0) ? 1 : -1;
0473                                     }
0474 
0475                                     return wheelDelta;
0476                                 }
0477 
0478                                 onWheelMoved: {
0479                                     wheelDelta = scrollByWheel(wheelDelta, delta.y);
0480                                 }
0481                             }
0482                         }
0483                     }
0484                 }
0485 
0486                 ListView {
0487                     id: paginationBar
0488 
0489                     Layout.alignment: Qt.AlignHCenter
0490 
0491                     width: model.count * units.iconSizes.small
0492                     height: units.iconSizes.small
0493 
0494                     orientation: Qt.Horizontal
0495 
0496                     model: rootModel.modelForRow(0)
0497 
0498                     delegate: Item {
0499                         width: units.iconSizes.small
0500                         height: width
0501 
0502                         Rectangle {
0503                             id: pageDelegate
0504 
0505                             anchors {
0506                                 horizontalCenter: parent.horizontalCenter
0507                                 verticalCenter: parent.verticalCenter
0508                             }
0509 
0510                             width: parent.width / 2
0511                             height: width
0512 
0513                             property bool isCurrent: (pageList.currentIndex == index)
0514 
0515                             radius: width / 2
0516 
0517                             color: theme.textColor
0518                             opacity: 0.5
0519 
0520                             Behavior on width { SmoothedAnimation { duration: units.longDuration; velocity: 0.01 } }
0521                             Behavior on opacity { SmoothedAnimation { duration: units.longDuration; velocity: 0.01 } }
0522 
0523                             states: [
0524                                 State {
0525                                     when: pageDelegate.isCurrent
0526                                     PropertyChanges { target: pageDelegate; width: parent.width - (units.smallSpacing * 2) }
0527                                     PropertyChanges { target: pageDelegate; opacity: 0.8 }
0528                                 }
0529                             ]
0530                         }
0531 
0532                         MouseArea {
0533                             anchors.fill: parent
0534                             onClicked: pageList.currentIndex = index;
0535 
0536                             property int wheelDelta: 0
0537 
0538                             function scrollByWheel(wheelDelta, eventDelta) {
0539                                 // magic number 120 for common "one click"
0540                                 // See: http://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop
0541                                 wheelDelta += eventDelta;
0542 
0543                                 var increment = 0;
0544 
0545                                 while (wheelDelta >= 120) {
0546                                     wheelDelta -= 120;
0547                                     increment++;
0548                                 }
0549 
0550                                 while (wheelDelta <= -120) {
0551                                     wheelDelta += 120;
0552                                     increment--;
0553                                 }
0554 
0555                                 while (increment != 0) {
0556                                     pageList.activateNextPrev(increment < 0);
0557                                     increment += (increment < 0) ? 1 : -1;
0558                                 }
0559 
0560                                 return wheelDelta;
0561                             }
0562 
0563                             onWheel: {
0564                                 wheelDelta = scrollByWheel(wheelDelta, wheel.angleDelta.y);
0565                             }
0566                         }
0567                     }
0568                 }
0569             }
0570 
0571             QQC2.ToolSeparator {
0572                 Layout.fillHeight: true
0573             }
0574 
0575             PlasmaExtras.ScrollArea {
0576                 id: filterListScrollArea
0577 
0578                 property int desiredWidth: 0
0579 
0580                 Layout.fillHeight: true
0581                 Layout.preferredWidth: plasmoid.configuration.showFilterList ? desiredWidth : 0
0582 
0583                 enabled: !searching
0584                 visible: plasmoid.configuration.showFilterList
0585 
0586                 property alias currentIndex: filterList.currentIndex
0587 
0588                 opacity: root.visible ? (searching ? 0.30 : 1.0) : 0.3
0589 
0590                 Behavior on opacity { SmoothedAnimation { duration: units.longDuration; velocity: 0.01 } }
0591 
0592                 verticalScrollBarPolicy: (opacity == 1.0) ? Qt.ScrollBarAsNeeded : Qt.ScrollBarAlwaysOff
0593 
0594                 onEnabledChanged: {
0595                     if (!enabled) {
0596                         filterList.currentIndex = -1;
0597                     }
0598                 }
0599 
0600                 ListView {
0601                     id: filterList
0602 
0603                     focus: true
0604 
0605                     property bool allApps: false
0606                     property int eligibleWidth: width
0607                     property int hItemMargins: highlightItemSvg.margins.left + highlightItemSvg.margins.right
0608                     model: filterListScrollArea.visible ? rootModel : null
0609 
0610                     boundsBehavior: Flickable.StopAtBounds
0611                     snapMode: ListView.SnapToItem
0612                     spacing: 0
0613                     keyNavigationWraps: true
0614 
0615                     delegate: MouseArea {
0616                         id: item
0617 
0618                         property int textWidth: label.contentWidth
0619                         property int mouseCol
0620 
0621                         width: parent.width
0622                         height: label.paintedHeight + highlightItemSvg.margins.top + highlightItemSvg.margins.bottom
0623 
0624                         Accessible.role: Accessible.MenuItem
0625                         Accessible.name: model.display
0626 
0627                         acceptedButtons: Qt.LeftButton
0628 
0629                         hoverEnabled: true
0630 
0631                         onContainsMouseChanged: {
0632                             if (!containsMouse) {
0633                                 updateCurrentItemTimer.stop();
0634                             }
0635                         }
0636 
0637                         onPressed: {
0638                             if (!plasmoid.configuration.switchCategoriesOnHover) {
0639                                 ListView.view.currentIndex = index;
0640                             }
0641                         }
0642 
0643                         onPositionChanged: { // Lazy menu implementation.
0644                             if (!plasmoid.configuration.switchCategoriesOnHover) {
0645                                 return;
0646                             }
0647 
0648                             mouseCol = mouse.x;
0649 
0650                             if (index == ListView.view.currentIndex) {
0651                                 updateCurrentItem();
0652                             } else if ((index == ListView.view.currentIndex - 1) && mouse.y < (item.height - 6)
0653                                 || (index == ListView.view.currentIndex + 1) && mouse.y > 5) {
0654 
0655                                 if (mouse.x > ListView.view.eligibleWidth - 5) {
0656                                     updateCurrentItem();
0657                                 }
0658                             } else if (mouse.x > ListView.view.eligibleWidth) {
0659                                 updateCurrentItem();
0660                             }
0661 
0662                             updateCurrentItemTimer.start();
0663                         }
0664 
0665                         function updateCurrentItem() {
0666                             ListView.view.currentIndex = index;
0667                             ListView.view.eligibleWidth = Math.min(width, mouseCol);
0668                         }
0669 
0670                         Timer {
0671                             id: updateCurrentItemTimer
0672 
0673                             interval: 50
0674                             repeat: false
0675 
0676                             onTriggered: parent.updateCurrentItem()
0677                         }
0678 
0679                         PlasmaExtras.Heading {
0680                             id: label
0681 
0682                             anchors {
0683                                 fill: parent
0684                                 leftMargin: highlightItemSvg.margins.left
0685                                 rightMargin: highlightItemSvg.margins.right
0686                             }
0687 
0688                             elide: Text.ElideRight
0689                             wrapMode: Text.NoWrap
0690                             opacity: 1.0
0691 
0692                             level: 5
0693 
0694                             text: model.display
0695                         }
0696                     }
0697 
0698                     highlight: PlasmaComponents.Highlight {
0699                         anchors {
0700                             top: filterList.currentItem ? filterList.currentItem.top : undefined
0701                             left: filterList.currentItem ? filterList.currentItem.left : undefined
0702                             bottom: filterList.currentItem ? filterList.currentItem.bottom : undefined
0703                         }
0704 
0705                         opacity: filterListScrollArea.focus ? 1.0 : 0.7
0706 
0707                         width: (highlightItemSvg.margins.left
0708                             + filterList.currentItem.textWidth
0709                             + highlightItemSvg.margins.right
0710                             + units.smallSpacing)
0711 
0712                         visible: filterList.currentItem
0713                     }
0714 
0715                     highlightFollowsCurrentItem: false
0716                     highlightMoveDuration: 0
0717                     highlightResizeDuration: 0
0718 
0719                     onCurrentIndexChanged: applyFilter()
0720 
0721                     onCountChanged: {
0722                         var width = 0;
0723 
0724                         for (var i = 0; i < rootModel.count; ++i) {
0725                             headingMetrics.text = rootModel.labelForRow(i);
0726 
0727                             if (headingMetrics.width > width) {
0728                                 width = headingMetrics.width;
0729                             }
0730                         }
0731 
0732                         filterListScrollArea.desiredWidth = width + hItemMargins + units.gridUnit;
0733                     }
0734 
0735                     function applyFilter() {
0736                         if (filterListScrollArea.visible && !searching && currentIndex >= 0) {
0737                             pageList.model = rootModel.modelForRow(currentIndex);
0738                             paginationBar.model = pageList.model;
0739                         }
0740                     }
0741 
0742                     Keys.onPressed: {
0743                         if (event.key == Qt.Key_left) {
0744                             event.accepted = true;
0745 
0746                             var currentRow = Math.max(0, Math.ceil(currentItem.y / cellSize) - 1);
0747 
0748                             if (pageList.currentItem) {
0749                                 pageList.currentItem.itemGrid.tryActivate(currentRow, 5);
0750                             }
0751                         } else if (event.key == Qt.Key_Tab) {
0752                             event.accepted = true;
0753                             searchField.focus = true;
0754                         } else if (event.key == Qt.Key_Backtab) {
0755                             event.accepted = true;
0756                             systemFavoritesGrid.tryActivate(0, 0);
0757                         }
0758                     }
0759                 }
0760             }
0761         }
0762     }
0763 
0764     Keys.onPressed: {
0765         if (event.key == Qt.Key_Escape) {
0766             event.accepted = true;
0767 
0768             if (searching) {
0769                 reset();
0770             } else {
0771                 root.visible = false;
0772             }
0773 
0774             return;
0775         }
0776 
0777         if (searchField.focus) {
0778             return;
0779         }
0780 
0781         if (event.key == Qt.Key_Backspace) {
0782             event.accepted = true;
0783             searchField.backspace();
0784         } else if (event.key == Qt.Key_Tab || event.key == Qt.Key_Backtab) {
0785             if (pageListScrollArea.focus == true && pageList.currentItem.itemGrid.currentIndex == -1) {
0786                 event.accepted = true;
0787                 pageList.currentItem.itemGrid.tryActivate(0, 0);
0788             }
0789         } else if (event.text != "") {
0790             event.accepted = true;
0791             searchField.appendText(event.text);
0792         }
0793     }
0794 
0795     }
0796 
0797     Component.onCompleted: {
0798         kicker.reset.connect(reset);
0799         dragHelper.dropped.connect(pageList.cycle);
0800     }
0801 }