diff --git a/containments/panel/package/contents/ui/SlidingPanel.qml b/containments/panel/package/contents/ui/SlidingPanel.qml index 6dd906e..192d561 100644 --- a/containments/panel/package/contents/ui/SlidingPanel.qml +++ b/containments/panel/package/contents/ui/SlidingPanel.qml @@ -1,216 +1,216 @@ /* * Copyright 2014 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.0 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.private.nanoshell 2.0 as NanoShell NanoShell.FullScreenOverlay { id: window property int offset: 0 property int peekHeight property bool userInteracting: false property bool expanded: false readonly property bool wideScreen: width > units.gridUnit * 45 readonly property int drawerWidth: wideScreen ? units.gridUnit * 25 : width property int drawerX: 0 color: Qt.rgba(0, 0, 0, 0.6 * Math.min(1, offset/contentArea.height)) property alias contents: contentArea.data property int headerHeight width: Screen.width height: Screen.height property alias fixedArea: fixedArea function open() { window.showFullScreen(); peekAnim.running = true; } function close() { closeAnim.running = true; } function updateState() { if (expanded) { openAnim.running = true; } else if (offset < peekHeight / 2) { close(); } else if (offset < peekHeight) { open(); } else if (mainFlickable.contentY < 0) { openAnim.running = true; } } Timer { id: updateStateTimer interval: 0 onTriggered: updateState() } onActiveChanged: { if (!active) { close(); } } onVisibleChanged: { if (visible) { window.width = Screen.width; window.height = Screen.height; window.requestActivate(); } else { window.expanded = false; } } SequentialAnimation { id: closeAnim PropertyAnimation { target: window duration: units.longDuration easing.type: Easing.InOutQuad properties: "offset" from: window.offset to: 0 } ScriptAction { script: { window.visible = false; } } } PropertyAnimation { id: peekAnim target: window duration: units.longDuration easing.type: Easing.InOutQuad properties: "offset" from: window.offset to: window.peekHeight - headerHeight } PropertyAnimation { id: openAnim target: window duration: units.longDuration easing.type: Easing.InOutQuad properties: "offset" from: window.offset to: contentArea.height } PlasmaCore.ColorScope { anchors.fill: parent y: Math.min(0, -height + window.offset) - colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + //colorGroup: PlasmaCore.Theme.ComplementaryColorGroup Rectangle { x: drawerX anchors.top: parent.top height: contentArea.height - mainFlickable.contentY color: PlasmaCore.ColorScope.backgroundColor width: drawerWidth } Flickable { id: mainFlickable anchors.fill: parent interactive: !window.expanded Binding { target: mainFlickable property: "contentY" value: -window.offset + contentArea.height - window.headerHeight when: !mainFlickable.moving && !mainFlickable.dragging && !mainFlickable.flicking } //no loop as those 2 values compute to exactly the same onContentYChanged: { window.offset = -contentY + contentArea.height - window.headerHeight if (contentY > contentArea.height - headerHeight) { contentY = contentArea.height - headerHeight; } } contentWidth: window.width contentHeight: window.height*2 bottomMargin: window.height onMovementStarted: window.userInteracting = true; onFlickStarted: window.userInteracting = true; onMovementEnded: { window.userInteracting = false; window.updateState(); } onFlickEnded: { window.userInteracting = true; window.updateState(); } MouseArea { width: parent.width height: mainItem.height onClicked: window.close(); Item { id: mainItem x: drawerX width: drawerWidth height: Math.max(contentArea.height, window.height*2) Item { id: contentArea anchors { left: parent.left right: parent.right } height: children[0].implicitHeight onHeightChanged: { if (!window.userInteracting) { updateStateTimer.restart() } } } Rectangle { height: units.smallSpacing anchors { left: parent.left right: parent.right top: contentArea.bottom } gradient: Gradient { GradientStop { position: 0.0 color: Qt.rgba(0, 0, 0, 0.6) } GradientStop { position: 0.5 color: Qt.rgba(0, 0, 0, 0.2) } GradientStop { position: 1.0 color: "transparent" } } } } } } Item { id: fixedArea anchors.top: parent.top x: drawerX width: drawerWidth height: childrenRect.height } } } diff --git a/containments/panel/package/contents/ui/main.qml b/containments/panel/package/contents/ui/main.qml index e0d1d00..c5555c7 100644 --- a/containments/panel/package/contents/ui/main.qml +++ b/containments/panel/package/contents/ui/main.qml @@ -1,248 +1,248 @@ /* * Copyright 2015 Marco Martin * * 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.1 import QtQuick.Layouts 1.3 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.workspace.components 2.0 as PlasmaWorkspace import "LayoutManager.js" as LayoutManager import "quicksettings" PlasmaCore.ColorScope { id: root width: 480 height: 640 - colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + //colorGroup: PlasmaCore.Theme.ComplementaryColorGroup property Item toolBox property int buttonHeight: width/4 property bool reorderingApps: false property var layoutManager: LayoutManager Containment.onAppletAdded: { addApplet(applet, x, y); LayoutManager.save(); } function addApplet(applet, x, y) { var container = appletContainerComponent.createObject(appletIconsRow) print("Applet added: " + applet + " " + applet.title) container.width = units.iconSizes.medium container.height = container.height applet.parent = container; container.applet = applet; applet.anchors.fill = container; applet.visible = true; container.visible = true; if (applet.pluginName == "org.kde.phone.notifications") { //FIXME: make a way to instantiate fullRepresentationItem without the open/close dance applet.expanded = true applet.expanded = false applet.fullRepresentationItem.parent = notificationsParent; notificationsParent.applet = applet; applet.fullRepresentationItem.anchors.fill = notificationsParent; } else { applet.preferredRepresentation = applet.compactRepresentation applet.switchWidth = -1; applet.switchHeight = -1; } } Component.onCompleted: { LayoutManager.plasmoid = plasmoid; LayoutManager.root = root; LayoutManager.layout = appletsLayout; LayoutManager.restore(); } PlasmaCore.DataSource { id: statusNotifierSource engine: "statusnotifieritem" interval: 0 onSourceAdded: { connectSource(source) } Component.onCompleted: { connectedSources = sources } } RowLayout { id: appletsLayout Layout.minimumHeight: Math.max(root.height, Math.round(Layout.preferredHeight / root.height) * root.height) } Component { id: appletContainerComponent Item { //not used yet property bool animationsEnabled: false property Item applet Layout.fillHeight: true Layout.minimumWidth: applet && applet.compactRepresentationItem ? Math.max(applet.compactRepresentationItem.Layout.minimumWidth, appletIconsRow.height) : appletIconsRow.height Layout.maximumWidth: Layout.minimumWidth } } PlasmaCore.DataSource { id: timeSource engine: "time" connectedSources: ["Local"] interval: 60 * 1000 } Rectangle { z: 1 parent: slidingPanel.visible && !slidingPanel.wideScreen ? panelContents : root anchors { left: parent.left right: parent.right bottom: parent.bottom } height: root.height color: PlasmaCore.ColorScope.backgroundColor Loader { id: strengthLoader height: parent.height width: item ? item.width : 0 source: Qt.resolvedUrl("SignalStrength.qml") } Row { id: sniRow anchors.left: strengthLoader.right height: parent.height Repeater { id: statusNotifierRepeater model: PlasmaCore.SortFilterModel { id: filteredStatusNotifiers filterRole: "Title" sourceModel: PlasmaCore.DataModel { dataSource: statusNotifierSource } } delegate: TaskWidget { } } } PlasmaComponents.Label { id: clock anchors.fill: parent text: Qt.formatTime(timeSource.data.Local.DateTime, "hh:mm") color: PlasmaCore.ColorScope.textColor horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter font.pixelSize: height / 2 } RowLayout { id: appletIconsRow anchors { bottom: parent.bottom right: parent.right } height: parent.height } } MouseArea { z: 99 property int oldMouseY: 0 anchors.fill: parent onPressed: { slidingPanel.drawerX = Math.min(Math.max(0, mouse.x - slidingPanel.drawerWidth/2), slidingPanel.width - slidingPanel.drawerWidth) slidingPanel.userInteracting = true; oldMouseY = mouse.y; slidingPanel.showFullScreen(); } onPositionChanged: { //var factor = (mouse.y - oldMouseY > 0) ? (1 - Math.max(0, (slidingArea.y + slidingPanel.overShoot) / slidingPanel.overShoot)) : 1 var factor = 1; slidingPanel.offset = slidingPanel.offset + (mouse.y - oldMouseY) * factor; oldMouseY = mouse.y; } onReleased: { slidingPanel.userInteracting = false; slidingPanel.updateState(); } } SlidingPanel { id: slidingPanel width: plasmoid.availableScreenRect.width height: plasmoid.availableScreenRect.height peekHeight: quickSettingsParent.height + notificationsParent.minimumHeight + root.height headerHeight: root.height onExpandedChanged: { modeSwitchAnim.running = false; modeSwitchAnim.to = expanded ? width : 0 modeSwitchAnim.running = true; } contents: Item { id: panelContents anchors.fill: parent implicitHeight: slidingPanel.expanded ? (slidingPanel.height-slidingPanel.headerHeight)*0.8 : (quickSettingsParent.height + notificationsParent.height + root.height) Rectangle { id: quickSettingsParent parent: slidingPanel.fixedArea color: PlasmaCore.ColorScope.backgroundColor z: 2 width: parent.width y: Math.min(0, slidingPanel.offset - height - root.height) height: quickSettings.Layout.minimumHeight QuickSettings { id: quickSettings anchors.fill: parent } Rectangle { anchors { left: parent.left right: parent.right bottom:parent.bottom } height: units.devicePixelRatio color: PlasmaCore.ColorScope.textColor opacity: 0.2 visible: slidingPanel.offset + slidingPanel.headerHeight < panelContents.height } } Item { id: notificationsParent anchors { left: parent.left bottom: parent.bottom right: parent.right bottomMargin: root.height } property var applet height: applet ? applet.fullRepresentationItem.Layout.maximumHeight : 0 property int minimumHeight: applet ? applet.fullRepresentationItem.Layout.minimumHeight : 0 } } } } diff --git a/containments/taskpanel/package/contents/ui/main.qml b/containments/taskpanel/package/contents/ui/main.qml index 6396c17..d2fcb0e 100644 --- a/containments/taskpanel/package/contents/ui/main.qml +++ b/containments/taskpanel/package/contents/ui/main.qml @@ -1,157 +1,157 @@ /* * Copyright 2015 Marco Martin * * 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.2 import org.kde.taskmanager 0.1 as TaskManager import org.kde.plasma.plasmoid 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 PlasmaCore.ColorScope { id: root width: 600 height: 480 - colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + //colorGroup: PlasmaCore.Theme.ComplementaryColorGroup Plasmoid.backgroundHints: plasmoid.configuration.PanelButtonsVisible ? PlasmaCore.Types.StandardBackground : PlasmaCore.Types.NoBackground property QtObject taskSwitcher: taskSwitcherLoader.item ? taskSwitcherLoader.item : null Loader { id: taskSwitcherLoader } //FIXME: why it crashes on startup if TaskSwitcher is loaded immediately? Timer { running: true interval: 200 onTriggered: taskSwitcherLoader.source = Qt.resolvedUrl("TaskSwitcher.qml") } MouseArea { id: mainMouseArea anchors.fill: parent property int oldMouseY: 0 property int startMouseY: 0 property bool isDragging: false drag.filterChildren: true function managePressed(mouse) { startMouseY = oldMouseY = mouse.y; taskSwitcher.offset = -taskSwitcher.height } onPressed: managePressed(mouse); onPositionChanged: { if (!isDragging && Math.abs(startMouseY - oldMouseY) < root.height) { oldMouseY = mouse.y; return; } else { isDragging = true; } taskSwitcher.offset = taskSwitcher.offset - (mouse.y - oldMouseY); oldMouseY = mouse.y; if (taskSwitcher.visibility == Window.Hidden && taskSwitcher.offset > -taskSwitcher.height + units.gridUnit && taskSwitcher.tasksCount) { taskSwitcher.visible = true; } } onReleased: { if (!isDragging) { return; } if (taskSwitcher.visibility == Window.Hidden) { return; } if (taskSwitcher.offset > -taskSwitcher.height/2) { taskSwitcher.currentTaskIndex = -1 taskSwitcher.show(); } else { taskSwitcher.hide(); taskSwitcher.setSingleActiveWindow(taskSwitcher.currentTaskIndex); } } Rectangle { anchors.fill: parent color: root.backgroundColor visible: plasmoid.configuration.PanelButtonsVisible property Item toolBox Button { anchors.left: parent.left height: parent.height width: parent.width/3 enabled: taskSwitcher.tasksCount > 0; iconSource: "box" onClicked: { plasmoid.nativeInterface.showDesktop = false; taskSwitcher.visible ? taskSwitcher.hide() : taskSwitcher.show(); } onPressed: mainMouseArea.managePressed(mouse); onPositionChanged: mainMouseArea.positionChanged(mouse); onReleased: mainMouseArea.released(mouse); } Button { id: showDesktopButton height: parent.height width: parent.width/3 anchors.horizontalCenter: parent.horizontalCenter iconSource: "start-here-kde" enabled: taskSwitcher.tasksCount > 0 checkable: true onCheckedChanged: { taskSwitcher.hide(); plasmoid.nativeInterface.showDesktop = checked; } onPressed: mainMouseArea.managePressed(mouse); onPositionChanged: mainMouseArea.positionChanged(mouse); onReleased: mainMouseArea.released(mouse); Connections { target: root.taskSwitcher onCurrentTaskIndexChanged: { if (root.taskSwitcher.currentTaskIndex < 0) { showDesktopButton.checked = false; } } } } Button { height: parent.height width: parent.width/3 anchors.right: parent.right iconSource: "paint-none" //FIXME:Qt.UserRole+9 is IsWindow Qt.UserRole+15 is IsClosable. We can't reach that enum from QML enabled: plasmoid.nativeInterface.hasCloseableActiveWindow onClicked: { var index = taskSwitcher.model.activeTask; if (index) { taskSwitcher.model.requestClose(index); } } onPressed: mainMouseArea.managePressed(mouse); onPositionChanged: mainMouseArea.positionChanged(mouse); onReleased: mainMouseArea.released(mouse); } } } }