diff --git a/lookandfeel/contents/windowswitcher/WindowSwitcher.qml b/lookandfeel/contents/windowswitcher/WindowSwitcher.qml --- a/lookandfeel/contents/windowswitcher/WindowSwitcher.qml +++ b/lookandfeel/contents/windowswitcher/WindowSwitcher.qml @@ -41,82 +41,107 @@ x: screenGeometry.x + (Qt.application.layoutDirection === Qt.RightToLeft ? screenGeometry.width - width : 0) y: screenGeometry.y - mainItem: PlasmaExtras.ScrollArea { - id: dialogMainItem - - focus: true - - width: tabBox.screenGeometry.width * 0.15 + (__verticalScrollBar.visible ? __verticalScrollBar.width : 0) + mainItem: Item { + width: tabBox.screenGeometry.width * 0.15 + (thumbnailScrollArea.__verticalScrollBar.visible ? thumbnailScrollArea.__verticalScrollBar.width : 0) height: tabBox.screenGeometry.height - dialog.margins.top - dialog.margins.bottom LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true - ListView { - id: thumbnailListView - model: tabBox.model - spacing: units.smallSpacing - highlightMoveDuration: 250 - highlightResizeDuration: 0 - - Connections { - target: tabBox - onCurrentIndexChanged: { - thumbnailListView.currentIndex = tabBox.currentIndex; - thumbnailListView.positionViewAtIndex(thumbnailListView.currentIndex, ListView.Contain) + PlasmaExtras.ScrollArea { + id: thumbnailScrollArea + anchors.fill: parent + + focus: true + + ListView { + id: thumbnailListView + model: tabBox.model + spacing: units.smallSpacing + highlightMoveDuration: 250 + highlightResizeDuration: 0 + keyNavigationWraps: true + + Connections { + target: tabBox + onCurrentIndexChanged: { + thumbnailListView.currentIndex = tabBox.currentIndex; + thumbnailListView.positionViewAtIndex(thumbnailListView.currentIndex, ListView.Contain) + } } - } - - delegate: MouseArea { - width: thumbnailListView.width - height: delegateColumn.implicitHeight + 2 * delegateColumn.y - onClicked: thumbnailListView.currentIndex = index + delegate: MouseArea { + width: thumbnailListView.width + height: delegateColumn.implicitHeight + 2 * delegateColumn.y - ColumnLayout { - id: delegateColumn - anchors.horizontalCenter: parent.horizontalCenter - // anchors.centerIn causes layouting glitches - y: units.smallSpacing - width: parent.width - 2 * units.smallSpacing - spacing: units.smallSpacing - - Item { - Layout.fillWidth: true - Layout.preferredHeight: Math.round(width / tabBox.screenFactor) - - KWin.ThumbnailItem { - anchors.fill: parent - wId: windowId - } - } + onClicked: thumbnailListView.currentIndex = index - RowLayout { + ColumnLayout { + id: delegateColumn + anchors.horizontalCenter: parent.horizontalCenter + // anchors.centerIn causes layouting glitches + y: units.smallSpacing + width: parent.width - 2 * units.smallSpacing spacing: units.smallSpacing - Layout.fillWidth: true - PlasmaCore.IconItem { - Layout.preferredHeight: units.iconSizes.medium - Layout.preferredWidth: units.iconSizes.medium - source: model.icon - usesPlasmaTheme: false + Item { + Layout.fillWidth: true + Layout.preferredHeight: Math.round(width / tabBox.screenFactor) + + KWin.ThumbnailItem { + anchors.fill: parent + wId: windowId + } } - PlasmaExtras.Heading { + RowLayout { + spacing: units.smallSpacing Layout.fillWidth: true - height: undefined - level: 4 - text: model.caption - elide: Text.ElideRight - wrapMode: Text.WrapAtWordBoundaryOrAnywhere - maximumLineCount: 2 - lineHeight: 0.95 + + PlasmaCore.IconItem { + Layout.preferredHeight: units.iconSizes.medium + Layout.preferredWidth: units.iconSizes.medium + source: model.icon + usesPlasmaTheme: false + } + + PlasmaExtras.Heading { + Layout.fillWidth: true + height: undefined + level: 4 + text: model.caption + elide: Text.ElideRight + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + maximumLineCount: 2 + lineHeight: 0.95 + } } } } + + highlight: PlasmaComponents.Highlight {} } + } - highlight: PlasmaComponents.Highlight {} + MouseArea { + property int wheelDelta: 0 + + anchors.fill: parent + acceptedButtons: Qt.NoButton + onWheel: { + var delta = wheel.angleDelta.y || wheel.angleDelta.x + wheelDelta += delta; + // magic number 120 for common "one click" + // See: http://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop + while (wheelDelta >= 120) { + wheelDelta -= 120; + thumbnailListView.decrementCurrentIndex() + } + while (wheelDelta <= -120) { + wheelDelta += 120; + thumbnailListView.incrementCurrentIndex() + } + } } } }