diff --git a/applets/systemtray/package/contents/ui/ExpandedRepresentation.qml b/applets/systemtray/package/contents/ui/ExpandedRepresentation.qml index 328d0ff28..3c80dafcd 100644 --- a/applets/systemtray/package/contents/ui/ExpandedRepresentation.qml +++ b/applets/systemtray/package/contents/ui/ExpandedRepresentation.qml @@ -1,148 +1,162 @@ /* * Copyright 2016 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.12 import QtQuick.Layouts 1.12 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras -ColumnLayout { - id: expandedRepresentation - //set width/height to avoid an useless Dialog resize - width: Layout.minimumWidth - height: Layout.minimumHeight - Layout.minimumWidth: units.gridUnit * 24 - Layout.minimumHeight: units.gridUnit * 21 - Layout.preferredWidth: Layout.minimumWidth - Layout.preferredHeight: Layout.minimumHeight - Layout.maximumWidth: Layout.minimumWidth - Layout.maximumHeight: Layout.minimumHeight - spacing: 0 // avoid gap between title and content +Item { + width: expandedRepresentation.width + height: expandedRepresentation.height property alias activeApplet: container.activeApplet property alias hiddenLayout: hiddenItemsView.layout PlasmaExtras.PlasmoidHeading { + id: plasmoidHeading + anchors { + top: parent.top + left: parent.left + right: parent.right + } + height: trayHeading.height + bottomPadding + container.headingHeight + } + + ColumnLayout { + id: expandedRepresentation + //set width/height to avoid an useless Dialog resize + width: Layout.minimumWidth + height: Layout.minimumHeight + Layout.minimumWidth: units.gridUnit * 24 + Layout.minimumHeight: units.gridUnit * 21 + Layout.preferredWidth: Layout.minimumWidth + Layout.preferredHeight: Layout.minimumHeight + Layout.maximumWidth: Layout.minimumWidth + Layout.maximumHeight: Layout.minimumHeight + spacing: plasmoidHeading.bottomPadding RowLayout { - anchors.fill: parent + id: trayHeading PlasmaExtras.Heading { id: heading Layout.fillWidth: true level: 1 Layout.leftMargin: { //Menu mode if (!activeApplet && hiddenItemsView.visible && !LayoutMirroring.enabled) { return units.smallSpacing; //applet open, sidebar } else if (activeApplet && hiddenItemsView.visible && !LayoutMirroring.enabled) { return hiddenItemsView.width + units.largeSpacing; //applet open, no sidebar } else { return units.smallSpacing; } } Layout.rightMargin: { //Menu mode if (!activeApplet && hiddenItemsView.visible && LayoutMirroring.enabled) { return units.smallSpacing; //applet open, sidebar } else if (activeApplet && hiddenItemsView.visible && LayoutMirroring.enabled) { return hiddenItemsView.width + units.largeSpacing; //applet open, no sidebar } else { return 0; } } visible: activeApplet text: activeApplet ? activeApplet.title : "" MouseArea { anchors.fill: parent onClicked: { if (activeApplet) { activeApplet.expanded = false; dialog.visible = true; } } } } PlasmaExtras.Heading { id: noAppletHeading visible: !activeApplet Layout.fillWidth: true level: 1 text: i18n("Status and Notifications") } PlasmaComponents.ToolButton { id: pinButton checkable: true checked: plasmoid.configuration.pin onToggled: plasmoid.configuration.pin = checked icon.name: "window-pin" PlasmaComponents.ToolTip { text: i18n("Keep Open") } } } - } - RowLayout { - spacing: 0 // must be 0 so that the separator is as close to the indicator as possible + RowLayout { + spacing: 0 // must be 0 so that the separator is as close to the indicator as possible - HiddenItemsView { - id: hiddenItemsView - Layout.fillWidth: !activeApplet - Layout.fillHeight: true - } + HiddenItemsView { + id: hiddenItemsView + Layout.fillWidth: !activeApplet + Layout.fillHeight: true + Layout.topMargin: container.headingHeight + } - PlasmaCore.SvgItem { - visible: hiddenItemsView.visible && activeApplet - Layout.fillHeight: true - Layout.preferredWidth: lineSvg.elementSize("vertical-line").width - elementId: "vertical-line" - svg: PlasmaCore.Svg { - id: lineSvg; - imagePath: "widgets/line" + PlasmaCore.SvgItem { + visible: hiddenItemsView.visible && activeApplet + Layout.fillHeight: true + Layout.preferredWidth: lineSvg.elementSize("vertical-line").width + Layout.topMargin: container.headingHeight + elementId: "vertical-line" + svg: PlasmaCore.Svg { + id: lineSvg; + imagePath: "widgets/line" + } } - } - PlasmoidPopupsContainer { - id: container - visible: activeApplet - Layout.fillWidth: true - Layout.fillHeight: true - // We need to add our own margins on the top and left (when the - // hidden items view is visible, at least) so it matches the - // dialog's own margins and content is centered correctly - Layout.topMargin: dialog.margins.top - Layout.leftMargin: hiddenItemsView.visible && activeApplet && !LayoutMirroring.enabled ? dialog.margins.left : 0 - Layout.rightMargin: hiddenItemsView.visible && activeApplet && LayoutMirroring.enabled ? dialog.margins.right : 0 + PlasmoidPopupsContainer { + id: container + visible: activeApplet + Layout.fillWidth: true + Layout.fillHeight: true + // We need to add our own margins on the top and left (when the + // hidden items view is visible, at least) so it matches the + // dialog's own margins and content is centered correctly + Layout.topMargin: mergeHeadings ? 0 : dialog.margins.top + Layout.leftMargin: hiddenItemsView.visible && activeApplet && !LayoutMirroring.enabled ? dialog.margins.left : 0 + Layout.rightMargin: hiddenItemsView.visible && activeApplet && LayoutMirroring.enabled ? dialog.margins.right : 0 + } } } } diff --git a/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml b/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml index 4654de08e..eb4536d5c 100644 --- a/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml +++ b/applets/systemtray/package/contents/ui/PlasmoidPopupsContainer.qml @@ -1,103 +1,119 @@ /* * Copyright 2015 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.4 import QtQuick.Layouts 1.1 import QtQuick.Controls 1.4 //needed for units import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 3.0 as PlasmaComponents3 +import org.kde.plasma.extras 2.0 as PlasmaExtras StackView { id: mainStack clip: true focus: true Layout.minimumWidth: units.gridUnit * 12 Layout.minimumHeight: units.gridUnit * 12 property Item activeApplet + property bool appletHasHeading: false + property bool appletHeadingShown: appletHasHeading && activeApplet.fullRepresentationItem.header.visible + property bool mergeHeadings: appletHasHeading && appletHeadingShown + property int headingHeight: mergeHeadings ? activeApplet.fullRepresentationItem.header.height : 0 onActiveAppletChanged: { if (activeApplet != null) { //reset any potential anchor activeApplet.fullRepresentationItem.anchors.left = undefined; activeApplet.fullRepresentationItem.anchors.top = undefined; activeApplet.fullRepresentationItem.anchors.right = undefined; activeApplet.fullRepresentationItem.anchors.bottom = undefined; activeApplet.fullRepresentationItem.anchors.centerIn = undefined; activeApplet.fullRepresentationItem.anchors.fill = undefined; + if (activeApplet.fullRepresentationItem instanceof PlasmaComponents3.Page + && activeApplet.fullRepresentationItem.header instanceof PlasmaExtras.PlasmoidHeading + ) { + mainStack.appletHasHeading = true + activeApplet.fullRepresentationItem.header.background.visible = false + } else { + mainStack.appletHasHeading = false + } + mainStack.replace({item: activeApplet.fullRepresentationItem, immediate: !dialog.visible, properties: {focus: true}}); } else { + mainStack.appletHasHeading = false mainStack.replace(emptyPage); } } Connections { target: plasmoid onAppletRemoved: { if (applet == root.activeApplet) { mainStack.clear() } } } //used to animate away to nothing Item { id: emptyPage } delegate: StackViewDelegate { function transitionFinished(properties) { properties.exitItem.opacity = 1 } replaceTransition: StackViewTransition { ParallelAnimation { PropertyAnimation { target: enterItem property: "x" from: enterItem.width to: 0 duration: units.longDuration } PropertyAnimation { target: enterItem property: "opacity" from: 0 to: 1 duration: units.longDuration } } ParallelAnimation { PropertyAnimation { target: exitItem property: "x" from: 0 to: -exitItem.width duration: units.longDuration } PropertyAnimation { target: exitItem property: "opacity" from: 1 to: 0 duration: units.longDuration } } } } }