2013-11-05 09:57:25 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2011 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
Copyright (C) 2013 Marco Martin <mart@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
import QtQuick 2.0
|
2014-05-16 09:48:24 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
2013-11-05 09:57:25 +00:00
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
|
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
|
|
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
2014-03-25 16:13:43 +00:00
|
|
|
import org.kde.kquickcontrolsaddons 2.0
|
2013-12-12 06:50:04 +00:00
|
|
|
import org.kde.kwin 2.0 as KWin
|
2013-11-05 09:57:25 +00:00
|
|
|
|
2013-12-12 06:50:04 +00:00
|
|
|
KWin.Switcher {
|
|
|
|
id: tabBox
|
|
|
|
property real screenFactor: screenGeometry.width/screenGeometry.height
|
2014-05-16 12:14:10 +00:00
|
|
|
currentIndex: thumbnailListView.currentIndex
|
2013-11-05 09:57:25 +00:00
|
|
|
|
2014-05-16 09:48:24 +00:00
|
|
|
// just to get the margin sizes
|
|
|
|
PlasmaCore.FrameSvgItem {
|
|
|
|
id: hoverItem
|
|
|
|
imagePath: "widgets/viewitem"
|
|
|
|
prefix: "hover"
|
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
|
2013-12-12 06:50:04 +00:00
|
|
|
PlasmaCore.Dialog {
|
|
|
|
id: dialog
|
|
|
|
location: PlasmaCore.Types.Floating
|
|
|
|
visible: tabBox.visible
|
2014-01-03 10:33:14 +00:00
|
|
|
flags: Qt.X11BypassWindowManagerHint
|
2014-01-03 11:59:14 +00:00
|
|
|
x: screenGeometry.x
|
|
|
|
y: screenGeometry.y
|
2013-11-05 09:57:25 +00:00
|
|
|
|
2014-05-16 09:48:24 +00:00
|
|
|
mainItem: PlasmaExtras.ScrollArea {
|
2013-12-12 06:50:04 +00:00
|
|
|
id: dialogMainItem
|
2013-11-05 09:57:25 +00:00
|
|
|
|
2013-12-12 06:50:04 +00:00
|
|
|
property bool canStretchX: false
|
|
|
|
property bool canStretchY: false
|
2014-05-16 09:48:24 +00:00
|
|
|
width: tabBox.screenGeometry.width * 0.15
|
2013-12-12 06:50:04 +00:00
|
|
|
height: tabBox.screenGeometry.height
|
|
|
|
clip: true
|
|
|
|
focus: true
|
2013-11-05 09:57:25 +00:00
|
|
|
|
2014-05-16 09:48:24 +00:00
|
|
|
ListView {
|
|
|
|
id: thumbnailListView
|
|
|
|
orientation: ListView.Vertical
|
|
|
|
model: tabBox.model
|
|
|
|
anchors.fill: parent
|
|
|
|
property int delegateWidth: thumbnailListView.width
|
|
|
|
spacing: 5
|
|
|
|
highlightMoveDuration: 250
|
2013-11-08 09:01:24 +00:00
|
|
|
|
2014-05-16 09:48:24 +00:00
|
|
|
clip: true
|
|
|
|
delegate: Item {
|
|
|
|
id: delegateItem
|
|
|
|
width: thumbnailListView.delegateWidth
|
2014-05-16 12:11:24 +00:00
|
|
|
height: Math.round(thumbnailItem.height + label.height + 30)
|
2014-05-16 09:48:24 +00:00
|
|
|
Item {
|
|
|
|
id: thumbnailItem
|
|
|
|
width: parent.width - hoverItem.margins.left - hoverItem.margins.right
|
2014-05-16 12:11:24 +00:00
|
|
|
height: Math.round(thumbnailListView.delegateWidth*(1.0/screenFactor) - hoverItem.margins.top)
|
2014-05-16 09:48:24 +00:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
left: parent.left
|
|
|
|
leftMargin: hoverItem.margins.left
|
|
|
|
rightMargin: hoverItem.margins.right
|
|
|
|
topMargin: hoverItem.margins.top
|
|
|
|
}
|
2013-12-12 06:50:04 +00:00
|
|
|
KWin.ThumbnailItem {
|
|
|
|
wId: windowId
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
2013-11-05 09:57:25 +00:00
|
|
|
}
|
2014-05-16 09:48:24 +00:00
|
|
|
RowLayout {
|
|
|
|
id: label
|
|
|
|
spacing: 4
|
2014-05-16 12:20:21 +00:00
|
|
|
|
2014-05-16 09:48:24 +00:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
2014-05-16 12:20:21 +00:00
|
|
|
right: parent.right
|
2014-05-16 09:48:24 +00:00
|
|
|
bottom: parent.bottom
|
|
|
|
leftMargin: hoverItem.margins.left
|
2014-05-16 12:20:21 +00:00
|
|
|
rightMargin: hoverItem.margins.right
|
2014-05-16 09:48:24 +00:00
|
|
|
bottomMargin: hoverItem.margins.bottom
|
|
|
|
}
|
|
|
|
QIconItem {
|
|
|
|
id: iconItem
|
|
|
|
icon: model.icon
|
|
|
|
property int iconSize: 32
|
|
|
|
width: iconSize
|
|
|
|
height: iconSize
|
|
|
|
Layout.preferredHeight: iconSize
|
|
|
|
Layout.preferredWidth: iconSize
|
|
|
|
}
|
|
|
|
PlasmaComponents.Label {
|
|
|
|
text: model.caption
|
|
|
|
elide: Text.ElideMiddle
|
2014-05-16 12:20:21 +00:00
|
|
|
|
2014-05-16 09:48:24 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.maximumWidth: label.maximumWidth - iconItem.iconSize - label.spacing * 2
|
|
|
|
}
|
2013-11-05 09:57:25 +00:00
|
|
|
}
|
2014-05-16 09:48:24 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
thumbnailListView.currentIndex = index;
|
|
|
|
}
|
2013-11-05 09:57:25 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-16 09:48:24 +00:00
|
|
|
highlight: PlasmaCore.FrameSvgItem {
|
|
|
|
id: highlightItem
|
|
|
|
imagePath: "widgets/viewitem"
|
|
|
|
prefix: "hover"
|
|
|
|
width: thumbnailListView.currentItem.width
|
|
|
|
height: thumbnailListView.currentItem.height
|
|
|
|
}
|
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
|
|
Connections {
|
|
|
|
target: tabBox
|
2014-05-16 12:07:44 +00:00
|
|
|
onCurrentIndexChanged: {
|
|
|
|
thumbnailListView.currentIndex = tabBox.currentIndex;
|
|
|
|
thumbnailListView.positionViewAtIndex(thumbnailListView.currentIndex, ListView.Contain);
|
|
|
|
}
|
2014-05-16 09:48:24 +00:00
|
|
|
}
|
2013-11-05 09:57:25 +00:00
|
|
|
}
|
|
|
|
|
2013-12-12 06:50:04 +00:00
|
|
|
/*
|
|
|
|
* Key navigation on outer item for two reasons:
|
|
|
|
* @li we have to emit the change signal
|
|
|
|
* @li on multiple invocation it does not work on the list view. Focus seems to be lost.
|
|
|
|
**/
|
|
|
|
Keys.onPressed: {
|
|
|
|
if (event.key == Qt.Key_Up) {
|
|
|
|
thumbnailListView.decrementCurrentIndex();
|
|
|
|
} else if (event.key == Qt.Key_Down) {
|
|
|
|
thumbnailListView.incrementCurrentIndex();
|
|
|
|
}
|
|
|
|
}
|
2013-11-05 09:57:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|