shift-shell/shell/contents/applet/CompactApplet.qml

97 lines
2.9 KiB
QML
Raw Normal View History

/*
* Copyright 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.4
import QtQuick.Layouts 1.1
import QtQuick.Window 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.kquickcontrolsaddons 2.0
Item {
id: root
objectName: "org.kde.desktop-CompactApplet"
anchors.fill: parent
property Item fullRepresentation
property Item compactRepresentation
property Item expandedFeedback: expandedItem
onCompactRepresentationChanged: {
if (compactRepresentation) {
compactRepresentation.parent = root;
2015-06-05 04:14:18 +00:00
compactRepresentation.anchors.fill = root;
compactRepresentation.visible = true;
}
root.visible = true;
}
onFullRepresentationChanged: {
2015-06-21 17:16:20 +00:00
if (!fullRepresentation) {
return;
}
fullRepresentation.parent = appletParent;
fullRepresentation.anchors.fill = fullRepresentation.parent;
2015-06-21 00:29:24 +00:00
fullRepresentation.anchors.margins = appletParent.margins.top;
}
2015-04-25 15:30:08 +00:00
Rectangle {
id: expandedItem
2015-06-04 03:34:43 +00:00
anchors {
left: parent.left
right: parent.right
bottom: parent.top
2015-06-04 03:34:43 +00:00
}
2015-06-05 04:14:18 +00:00
height: units.smallSpacing
2015-04-25 15:30:08 +00:00
color: PlasmaCore.ColorScope.highlightColor
visible: plasmoid.expanded
}
2015-06-21 00:29:24 +00:00
PlasmaCore.FrameSvgItem {
id: appletParent
2015-06-21 00:29:24 +00:00
imagePath: "widgets/background"
2015-06-21 17:16:20 +00:00
//used only indesktop mode, not panel
visible: plasmoid.formFactor == PlasmaCore.Types.Planar
2015-06-21 00:29:24 +00:00
z: 99
opacity: plasmoid.expanded ? 1 : 0
2015-06-05 04:14:18 +00:00
anchors.top: parent.top
2015-06-04 03:34:43 +00:00
width: parent.width
height: units.gridUnit * 20 - units.iconSizes.medium
2015-06-21 17:16:20 +00:00
MouseArea {
visible: plasmoid.expanded
anchors {
fill: parent
topMargin: -appletParent.height
bottomMargin: -appletParent.height
}
z: -1
onClicked: plasmoid.expanded = false;
}
Behavior on opacity {
OpacityAnimator {
2015-06-04 03:34:43 +00:00
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
}
}