mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-02 17:54:45 +00:00
slightly better behavior
This commit is contained in:
parent
f957eff823
commit
9ba5bf8db8
2 changed files with 32 additions and 10 deletions
|
|
@ -196,7 +196,7 @@ Item {
|
||||||
}
|
}
|
||||||
z: 1
|
z: 1
|
||||||
height: units.iconSizes.small
|
height: units.iconSizes.small
|
||||||
color: "black"
|
color: Qt.rgba(0, 0, 0, 0.7)
|
||||||
|
|
||||||
PlasmaCore.DataSource {
|
PlasmaCore.DataSource {
|
||||||
id: timeSource
|
id: timeSource
|
||||||
|
|
@ -217,8 +217,8 @@ Item {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onPressed: slidingPanel.visible = true;
|
onPressed: slidingPanel.visible = true;
|
||||||
onPositionChanged: slidingPanel.offset = mouse.y
|
onPositionChanged: slidingPanel.offset = mouse.y;
|
||||||
onReleased: slidingPanel.updateState();
|
onReleased: slidingPanel.updateState(mouse.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Window 2.0
|
import QtQuick.Window 2.0
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
|
||||||
Window {
|
Window {
|
||||||
id: window
|
id: window
|
||||||
|
|
@ -28,9 +29,18 @@ Window {
|
||||||
|
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
function updateState() {
|
function updateState(y) {
|
||||||
mouseArea.state = offset > slidingArea.height / 2 ? "open" : "closed";
|
var delta = offset - mouseArea.startOffset;
|
||||||
mouseArea.startOffset = units.iconSizes.large;
|
if (delta > units.gridUnit * 8) {
|
||||||
|
mouseArea.state = "open";
|
||||||
|
mouseArea.startOffset = units.iconSizes.large;
|
||||||
|
} else if (delta < -units.gridUnit * 8) {
|
||||||
|
mouseArea.state = "closed";
|
||||||
|
mouseArea.startOffset = units.iconSizes.large;
|
||||||
|
} else {
|
||||||
|
mouseArea.state = mouseArea.startState;
|
||||||
|
}
|
||||||
|
mouseArea.startState = mouseArea.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
|
|
@ -49,7 +59,9 @@ Window {
|
||||||
|
|
||||||
property int startY: 0
|
property int startY: 0
|
||||||
property int startOffset: units.iconSizes.large;
|
property int startOffset: units.iconSizes.large;
|
||||||
|
property string startState: "closed"
|
||||||
onPressed: {
|
onPressed: {
|
||||||
|
startState = state;
|
||||||
startY = mouse.y;
|
startY = mouse.y;
|
||||||
startOffset = window.offset;
|
startOffset = window.offset;
|
||||||
state = "dragging";
|
state = "dragging";
|
||||||
|
|
@ -57,15 +69,25 @@ Window {
|
||||||
onPositionChanged: {
|
onPositionChanged: {
|
||||||
window.offset = Math.min(slidingArea.height, startOffset + (mouse.y - startY));
|
window.offset = Math.min(slidingArea.height, startOffset + (mouse.y - startY));
|
||||||
}
|
}
|
||||||
onReleased: window.updateState()
|
onReleased: window.updateState(mouse.y)
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: slidingArea
|
id: slidingArea
|
||||||
width: window.width
|
width: parent.width
|
||||||
height: window.height
|
height: parent.height
|
||||||
y: -height + window.offset
|
y: -height + window.offset
|
||||||
|
|
||||||
color: Qt.rgba(0, 0, 0, 0.8)
|
color: Qt.rgba(0, 0, 0, 0.7)
|
||||||
|
Rectangle {
|
||||||
|
width: parent.width / 4
|
||||||
|
height: units.gridUnit/2
|
||||||
|
color: "yellow"
|
||||||
|
anchors {
|
||||||
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
bottom: parent.bottom
|
||||||
|
bottomMargin: units.gridUnit/2
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
states: [
|
states: [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue