kwin/kcmkwin/kwindecoration/qml/main.qml
Martin Gräßlin 1674824e79 [kcmdeco] Introduce a new PreviewItem for rendering QWidget based decos in QML
Using a QQuickPaintedItem for the rendering. The item gets the library
name from the model and loads the decoration with its own decoration
plugin. Thus each preview has its own plugin which eliminates the need to
constantly recreate the decoration as it is done with the preview.

Having a QQuickItem gives new possibilities. The item accepts hover
events and forwards them as enter and leave events to the widgets inside
the decoration. By that the mouse interaction of e.g. Oxygen is still
functional. If the decoration uses the new update approach the bridge is
forwarding the updates to the item and triggering a repaint so we even
have animations in the preview although the widget is never shown.
2013-11-14 09:41:52 +01:00

64 lines
2 KiB
QML

/********************************************************************
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
Copyright (C) 2012 Nuno Pinheiro <nuno@oxygen-icons.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
import org.kde.kwin.kcmdecoration 0.1
ListView {
id: listView
x: 0
y: 0
model: decorationModel
highlight: Rectangle {
width: listView.width
height: 150
color: highlightColor
opacity: 0.5
}
highlightMoveDuration: 250
boundsBehavior: Flickable.StopAtBounds
delegate: Item {
objectName: "decorationItem"
width: listView.width
height: 150
PreviewItem {
id: preview
anchors.fill: parent
visible: type == 0
Component.onCompleted: {
if (type == 0) {
preview.library = model.library;
}
}
}
Loader {
source: type == 1 ? "AuroraePreview.qml" : ""
anchors.fill: parent
}
Loader {
source: type == 2 ? "DecorationPreview.qml" : ""
anchors.fill: parent
}
MouseArea {
hoverEnabled: false
anchors.fill: parent
onClicked: {
listView.currentIndex = index;
}
}
}
}