mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
simplify a lot top panel
This commit is contained in:
parent
592481da73
commit
2dbb5e7d83
5 changed files with 82 additions and 133 deletions
36
containments/panel/package/contents/ui/DrawerBackground.qml
Normal file
36
containments/panel/package/contents/ui/DrawerBackground.qml
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019 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.6
|
||||||
|
import QtQuick.Layouts 1.4
|
||||||
|
import QtQuick.Controls 2.4 as QQC2
|
||||||
|
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
|
||||||
|
|
||||||
|
QQC2.Control {
|
||||||
|
id: root
|
||||||
|
leftPadding: background.margins.left
|
||||||
|
topPadding: background.margins.top
|
||||||
|
rightPadding: background.margins.right
|
||||||
|
bottomPadding: background.margins.bottom
|
||||||
|
|
||||||
|
background: PlasmaCore.FrameSvgItem {
|
||||||
|
imagePath: "widgets/background"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,42 +21,40 @@ import QtQuick 2.0
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
||||||
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
|
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
|
||||||
|
|
||||||
NanoShell.FullScreenOverlay {
|
NanoShell.FullScreenOverlay {
|
||||||
id: window
|
id: window
|
||||||
|
|
||||||
property int offset: 0
|
property int offset: 0
|
||||||
property int peekHeight
|
property int openThreshold
|
||||||
property bool userInteracting: false
|
property bool userInteracting: false
|
||||||
property bool expanded: false
|
|
||||||
readonly property bool wideScreen: width > units.gridUnit * 45
|
readonly property bool wideScreen: width > units.gridUnit * 45
|
||||||
readonly property int drawerWidth: wideScreen ? units.gridUnit * 25 : width
|
readonly property int drawerWidth: wideScreen ? units.gridUnit * 25 : width
|
||||||
|
readonly property int drawerHeight: contentArea.height + headerHeight
|
||||||
property int drawerX: 0
|
property int drawerX: 0
|
||||||
|
|
||||||
color: Qt.rgba(0, 0, 0, 0.6 * Math.min(1, offset/contentArea.height))
|
color: Qt.rgba(0, 0, 0, 0.6 * Math.min(1, offset/drawerHeight))
|
||||||
property alias contents: contentArea.data
|
property alias contentItem: contentArea.contentItem
|
||||||
property int headerHeight
|
property int headerHeight
|
||||||
|
|
||||||
width: Screen.width
|
width: Screen.width
|
||||||
height: Screen.height
|
height: Screen.height
|
||||||
|
|
||||||
property alias fixedArea: fixedArea
|
|
||||||
function open() {
|
function open() {
|
||||||
window.showFullScreen();
|
window.showFullScreen();
|
||||||
peekAnim.running = true;
|
open.running = true;
|
||||||
}
|
}
|
||||||
function close() {
|
function close() {
|
||||||
closeAnim.running = true;
|
closeAnim.running = true;
|
||||||
}
|
}
|
||||||
function updateState() {
|
function updateState() {
|
||||||
if (expanded) {
|
print("SUKUNNU"+offset + " "+openThreshold)
|
||||||
openAnim.running = true;
|
if (offset < openThreshold) {
|
||||||
} else if (offset < peekHeight / 2) {
|
|
||||||
close();
|
close();
|
||||||
} else if (offset < peekHeight) {
|
} else {
|
||||||
open();
|
|
||||||
} else if (mainFlickable.contentY < 0) {
|
|
||||||
openAnim.running = true;
|
openAnim.running = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,8 +73,6 @@ NanoShell.FullScreenOverlay {
|
||||||
window.width = Screen.width;
|
window.width = Screen.width;
|
||||||
window.height = Screen.height;
|
window.height = Screen.height;
|
||||||
window.requestActivate();
|
window.requestActivate();
|
||||||
} else {
|
|
||||||
window.expanded = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
|
|
@ -95,15 +91,6 @@ NanoShell.FullScreenOverlay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PropertyAnimation {
|
|
||||||
id: peekAnim
|
|
||||||
target: window
|
|
||||||
duration: units.longDuration
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
properties: "offset"
|
|
||||||
from: window.offset
|
|
||||||
to: window.peekHeight - headerHeight
|
|
||||||
}
|
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
id: openAnim
|
id: openAnim
|
||||||
target: window
|
target: window
|
||||||
|
|
@ -111,38 +98,27 @@ NanoShell.FullScreenOverlay {
|
||||||
easing.type: Easing.InOutQuad
|
easing.type: Easing.InOutQuad
|
||||||
properties: "offset"
|
properties: "offset"
|
||||||
from: window.offset
|
from: window.offset
|
||||||
to: contentArea.height
|
to: drawerHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaCore.ColorScope {
|
PlasmaCore.ColorScope {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
y: Math.min(0, -height + window.offset)
|
|
||||||
//colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
x: drawerX
|
|
||||||
anchors.top: parent.top
|
|
||||||
height: contentArea.height - mainFlickable.contentY
|
|
||||||
color: PlasmaCore.ColorScope.backgroundColor
|
|
||||||
width: drawerWidth
|
|
||||||
}
|
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
id: mainFlickable
|
id: mainFlickable
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
interactive: !window.expanded
|
|
||||||
Binding {
|
Binding {
|
||||||
target: mainFlickable
|
target: mainFlickable
|
||||||
property: "contentY"
|
property: "contentY"
|
||||||
value: -window.offset + contentArea.height - window.headerHeight
|
value: -window.offset + drawerHeight
|
||||||
when: !mainFlickable.moving && !mainFlickable.dragging && !mainFlickable.flicking
|
when: !mainFlickable.moving && !mainFlickable.dragging && !mainFlickable.flicking
|
||||||
}
|
}
|
||||||
//no loop as those 2 values compute to exactly the same
|
//no loop as those 2 values compute to exactly the same
|
||||||
onContentYChanged: {
|
onContentYChanged: {
|
||||||
window.offset = -contentY + contentArea.height - window.headerHeight
|
window.offset = -contentY + drawerHeight
|
||||||
if (contentY > contentArea.height - headerHeight) {
|
/* if (contentY > drawerHeight) {
|
||||||
contentY = contentArea.height - headerHeight;
|
contentY = d;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
contentWidth: window.width
|
contentWidth: window.width
|
||||||
contentHeight: window.height*2
|
contentHeight: window.height*2
|
||||||
|
|
@ -158,59 +134,17 @@ NanoShell.FullScreenOverlay {
|
||||||
window.updateState();
|
window.updateState();
|
||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
id: dismissArea
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: mainItem.height
|
height: mainFlickable.contentHeight
|
||||||
onClicked: window.close();
|
onClicked: window.close();
|
||||||
|
PlasmaComponents.Control {
|
||||||
Item {
|
|
||||||
id: mainItem
|
|
||||||
x: drawerX
|
|
||||||
width: drawerWidth
|
|
||||||
height: Math.max(contentArea.height, window.height*2)
|
|
||||||
Item {
|
|
||||||
id: contentArea
|
id: contentArea
|
||||||
anchors {
|
y: headerHeight
|
||||||
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
|
x: drawerX
|
||||||
width: drawerWidth
|
width: drawerWidth
|
||||||
height: childrenRect.height
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,12 +197,11 @@ PlasmaCore.ColorScope {
|
||||||
slidingPanel.drawerX = Math.min(Math.max(0, mouse.x - slidingPanel.drawerWidth/2), slidingPanel.width - slidingPanel.drawerWidth)
|
slidingPanel.drawerX = Math.min(Math.max(0, mouse.x - slidingPanel.drawerWidth/2), slidingPanel.width - slidingPanel.drawerWidth)
|
||||||
slidingPanel.userInteracting = true;
|
slidingPanel.userInteracting = true;
|
||||||
oldMouseY = mouse.y;
|
oldMouseY = mouse.y;
|
||||||
|
slidingPanel.offset = units.gridUnit * 2;
|
||||||
slidingPanel.showFullScreen();
|
slidingPanel.showFullScreen();
|
||||||
}
|
}
|
||||||
onPositionChanged: {
|
onPositionChanged: {
|
||||||
//var factor = (mouse.y - oldMouseY > 0) ? (1 - Math.max(0, (slidingArea.y + slidingPanel.overShoot) / slidingPanel.overShoot)) : 1
|
slidingPanel.offset = slidingPanel.offset + (mouse.y - oldMouseY);
|
||||||
var factor = 1;
|
|
||||||
slidingPanel.offset = slidingPanel.offset + (mouse.y - oldMouseY) * factor;
|
|
||||||
oldMouseY = mouse.y;
|
oldMouseY = mouse.y;
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
|
|
@ -215,53 +214,30 @@ PlasmaCore.ColorScope {
|
||||||
id: slidingPanel
|
id: slidingPanel
|
||||||
width: plasmoid.availableScreenRect.width
|
width: plasmoid.availableScreenRect.width
|
||||||
height: plasmoid.availableScreenRect.height
|
height: plasmoid.availableScreenRect.height
|
||||||
peekHeight: quickSettingsParent.height + notificationsParent.minimumHeight + root.height
|
openThreshold: units.gridUnit * 10
|
||||||
headerHeight: root.height
|
headerHeight: root.height
|
||||||
onExpandedChanged: {
|
|
||||||
modeSwitchAnim.running = false;
|
contentItem: ColumnLayout {
|
||||||
modeSwitchAnim.to = expanded ? width : 0
|
|
||||||
modeSwitchAnim.running = true;
|
|
||||||
}
|
|
||||||
contents: Item {
|
|
||||||
id: panelContents
|
id: panelContents
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
implicitHeight: slidingPanel.expanded ? (slidingPanel.height-slidingPanel.headerHeight)*0.8 : (quickSettingsParent.height + notificationsParent.height + root.height)
|
|
||||||
Rectangle {
|
DrawerBackground {
|
||||||
id: quickSettingsParent
|
Layout.fillWidth: true
|
||||||
parent: slidingPanel.fixedArea
|
contentItem: QuickSettings {
|
||||||
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
|
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 {
|
|
||||||
|
DrawerBackground {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
contentItem: Item {
|
||||||
id: notificationsParent
|
id: notificationsParent
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
bottom: parent.bottom
|
|
||||||
right: parent.right
|
|
||||||
bottomMargin: root.height
|
|
||||||
}
|
|
||||||
property var applet
|
property var applet
|
||||||
height: applet ? applet.fullRepresentationItem.Layout.maximumHeight : 0
|
implicitHeight: applet ? applet.fullRepresentationItem.Layout.maximumHeight : 0
|
||||||
property int minimumHeight: applet ? applet.fullRepresentationItem.Layout.minimumHeight : 0
|
property int minimumHeight: applet ? applet.fullRepresentationItem.Layout.minimumHeight : 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ RowLayout {
|
||||||
Layout.minimumHeight: width
|
Layout.minimumHeight: width
|
||||||
color: toggled ?
|
color: toggled ?
|
||||||
Qt.rgba(PlasmaCore.ColorScope.highlightColor.r, PlasmaCore.ColorScope.highlightColor.g, PlasmaCore.ColorScope.highlightColor.b, iconMouseArea.pressed ? 0.5 : 0.3) :
|
Qt.rgba(PlasmaCore.ColorScope.highlightColor.r, PlasmaCore.ColorScope.highlightColor.g, PlasmaCore.ColorScope.highlightColor.b, iconMouseArea.pressed ? 0.5 : 0.3) :
|
||||||
Qt.rgba(PlasmaCore.ColorScope.textColor.r, PlasmaCore.ColorScope.textColor.g, PlasmaCore.ColorScope.textColor.b, iconMouseArea.pressed ? 0.5 : 0.2)
|
Qt.rgba(PlasmaCore.ColorScope.textColor.r, PlasmaCore.ColorScope.textColor.g, PlasmaCore.ColorScope.textColor.b, iconMouseArea.pressed ? 0.5 : 0.1)
|
||||||
|
|
||||||
PlasmaCore.IconItem {
|
PlasmaCore.IconItem {
|
||||||
colorGroup: PlasmaCore.ColorScope.colorGroup
|
colorGroup: PlasmaCore.ColorScope.colorGroup
|
||||||
|
|
@ -61,7 +61,7 @@ RowLayout {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
color: Qt.rgba(PlasmaCore.ColorScope.textColor.r, PlasmaCore.ColorScope.textColor.g, PlasmaCore.ColorScope.textColor.b, labelMouseArea.pressed ? 0.5 : 0.2)
|
color: Qt.rgba(PlasmaCore.ColorScope.textColor.r, PlasmaCore.ColorScope.textColor.g, PlasmaCore.ColorScope.textColor.b, labelMouseArea.pressed ? 0.5 : 0.1)
|
||||||
PlasmaComponents.Label {
|
PlasmaComponents.Label {
|
||||||
anchors {
|
anchors {
|
||||||
fill: parent
|
fill: parent
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
implicitWidth: flow.implicitWidth + units.smallSpacing * 6
|
||||||
|
implicitHeight: flow.implicitHeight + units.smallSpacing * 6
|
||||||
|
|
||||||
function toggleAirplane() {
|
function toggleAirplane() {
|
||||||
print("toggle airplane mode")
|
print("toggle airplane mode")
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +183,7 @@ Item {
|
||||||
id: flow
|
id: flow
|
||||||
anchors {
|
anchors {
|
||||||
fill: parent
|
fill: parent
|
||||||
margins: units.largeSpacing
|
margins: units.smallSpacing*3
|
||||||
}
|
}
|
||||||
spacing: units.largeSpacing
|
spacing: units.largeSpacing
|
||||||
Repeater {
|
Repeater {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue