From adba281d59587fb450041653c99572af429e8558 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 27 May 2015 15:29:44 +0200 Subject: [PATCH] move title and arrow in default compactrepresentation --- containments/panel/contents/ui/main.qml | 17 +++++- shell/contents/applet/CompactApplet.qml | 58 ++++++++----------- .../applet/DefaultCompactRepresentation.qml | 18 +----- 3 files changed, 42 insertions(+), 51 deletions(-) diff --git a/containments/panel/contents/ui/main.qml b/containments/panel/contents/ui/main.qml index bb9a8bfd..a6e3a838 100644 --- a/containments/panel/contents/ui/main.qml +++ b/containments/panel/contents/ui/main.qml @@ -57,7 +57,7 @@ PlasmaCore.ColorScope { //applet.anchors.fill = container; applet.anchors.left = container.left; applet.anchors.right = container.right; - applet.height = units.iconSizes.medium + applet.height = units.iconSizes.medium; applet.visible = true; container.visible = true; @@ -119,6 +119,7 @@ PlasmaCore.ColorScope { Component { id: appletContainerComponent Item { + id: containerItem property Item applet Layout.fillWidth: true clip: true @@ -133,9 +134,13 @@ PlasmaCore.ColorScope { easing.type: Easing.InOutQuad } } + Rectangle { + id: bah + } Connections { target: applet onExpandedChanged: { + if (!applet.expanded && root.expandedApplet == applet) { root.expandedApplet = null; return; @@ -146,6 +151,16 @@ PlasmaCore.ColorScope { root.expandedApplet = applet; } } + + MouseArea { + id: mouseArea + + property bool wasExpanded: false + + anchors.fill: parent + onPressed: wasExpanded = applet.expanded + onClicked: applet.expanded = !wasExpanded + } } } diff --git a/shell/contents/applet/CompactApplet.qml b/shell/contents/applet/CompactApplet.qml index f7d61a27..13afafa2 100644 --- a/shell/contents/applet/CompactApplet.qml +++ b/shell/contents/applet/CompactApplet.qml @@ -23,16 +23,11 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 -PlasmaCore.ToolTipArea { +Item { id: root objectName: "org.kde.desktop-CompactApplet" anchors.fill: parent - icon: plasmoid.icon - mainText: plasmoid.toolTipMainText - subText: plasmoid.toolTipSubText - location: plasmoid.location - active: !plasmoid.expanded property Item fullRepresentation property Item compactRepresentation property Item expandedFeedback: expandedItem @@ -40,7 +35,10 @@ PlasmaCore.ToolTipArea { onCompactRepresentationChanged: { if (compactRepresentation) { compactRepresentation.parent = root; - compactRepresentation.anchors.fill = root; + compactRepresentation.anchors.left = root.left; + compactRepresentation.anchors.top = root.top; + compactRepresentation.width = units.iconSizes.medium; + compactRepresentation.height = compactRepresentation.width; compactRepresentation.visible = true; } root.visible = true; @@ -51,31 +49,31 @@ PlasmaCore.ToolTipArea { if (!fullRepresentation) { return; } - /* //if the fullRepresentation size was restored to a stored size, or if is dragged from the desktop, restore popup size - if (fullRepresentation.width > 0) { - appletParent.width = fullRepresentation.width; - } else if (fullRepresentation.Layout && fullRepresentation.Layout.preferredWidth > 0) { - appletParent.width = fullRepresentation.Layout.preferredWidth - } else if (fullRepresentation.implicitWidth > 0) { - appletParent.width = fullRepresentation.implicitWidth - } else { - appletParent.width = theme.mSize(theme.defaultFont).width * 35 - } - - if (fullRepresentation.height > 0) { - appletParent.height = fullRepresentation.height; - } else if (fullRepresentation.Layout && fullRepresentation.Layout.preferredHeight > 0) { - appletParent.height = fullRepresentation.Layout.preferredHeight - } else if (fullRepresentation.implicitHeight > 0) { - appletParent.height = fullRepresentation.implicitHeight - } else { - appletParent.height = theme.mSize(theme.defaultFont).height * 25 - }*/ fullRepresentation.parent = appletParent; fullRepresentation.anchors.fill = fullRepresentation.parent; } + Row { + height: units.iconSizes.medium + anchors.left: compactRepresentation ? compactRepresentation.right : undefined + PlasmaCore.SvgItem { + svg: PlasmaCore.Svg { + id: arrowSvg + imagePath: "widgets/arrows" + colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + } + width: units.iconSizes.smallMedium + height: width + elementId: plasmoid.expanded ? "up-arrow" : "down-arrow" + anchors.verticalCenter: parent.verticalCenter + } + PlasmaComponents.Label { + text: plasmoid.title + anchors.verticalCenter: parent.verticalCenter + } + } + Rectangle { id: expandedItem anchors.fill: parent @@ -88,12 +86,6 @@ PlasmaCore.ToolTipArea { } } } - - Timer { - id: expandedSync - interval: 100 - onTriggered: plasmoid.expanded = popupWindow.visible; - } Item { id: appletParent diff --git a/shell/contents/applet/DefaultCompactRepresentation.qml b/shell/contents/applet/DefaultCompactRepresentation.qml index 80b864fa..25264a72 100644 --- a/shell/contents/applet/DefaultCompactRepresentation.qml +++ b/shell/contents/applet/DefaultCompactRepresentation.qml @@ -21,9 +21,8 @@ import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents -Row { +Item { id: main - spacing: units.largeSpacing Layout.minimumWidth: { switch (plasmoid.formFactor) { @@ -54,21 +53,6 @@ Row { colorGroup: PlasmaCore.Theme.ComplementaryColorGroup anchors.verticalCenter: parent.verticalCenter } - PlasmaCore.SvgItem { - svg: PlasmaCore.Svg { - id: arrowSvg - imagePath: "widgets/arrows" - colorGroup: PlasmaCore.Theme.ComplementaryColorGroup - } - width: units.iconSizes.smallMedium - height: width - elementId: plasmoid.expanded ? "up-arrow" : "down-arrow" - anchors.verticalCenter: parent.verticalCenter - } - PlasmaComponents.Label { - text: plasmoid.title - anchors.verticalCenter: parent.verticalCenter - } MouseArea { id: mouseArea