mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +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
|
||||
height: units.iconSizes.small
|
||||
color: "black"
|
||||
color: Qt.rgba(0, 0, 0, 0.7)
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: timeSource
|
||||
|
|
@ -217,8 +217,8 @@ Item {
|
|||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onPressed: slidingPanel.visible = true;
|
||||
onPositionChanged: slidingPanel.offset = mouse.y
|
||||
onReleased: slidingPanel.updateState();
|
||||
onPositionChanged: slidingPanel.offset = mouse.y;
|
||||
onReleased: slidingPanel.updateState(mouse.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Window 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
|
||||
Window {
|
||||
id: window
|
||||
|
|
@ -28,9 +29,18 @@ Window {
|
|||
|
||||
color: "transparent"
|
||||
|
||||
function updateState() {
|
||||
mouseArea.state = offset > slidingArea.height / 2 ? "open" : "closed";
|
||||
mouseArea.startOffset = units.iconSizes.large;
|
||||
function updateState(y) {
|
||||
var delta = offset - mouseArea.startOffset;
|
||||
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: {
|
||||
|
|
@ -49,7 +59,9 @@ Window {
|
|||
|
||||
property int startY: 0
|
||||
property int startOffset: units.iconSizes.large;
|
||||
property string startState: "closed"
|
||||
onPressed: {
|
||||
startState = state;
|
||||
startY = mouse.y;
|
||||
startOffset = window.offset;
|
||||
state = "dragging";
|
||||
|
|
@ -57,15 +69,25 @@ Window {
|
|||
onPositionChanged: {
|
||||
window.offset = Math.min(slidingArea.height, startOffset + (mouse.y - startY));
|
||||
}
|
||||
onReleased: window.updateState()
|
||||
onReleased: window.updateState(mouse.y)
|
||||
|
||||
Rectangle {
|
||||
id: slidingArea
|
||||
width: window.width
|
||||
height: window.height
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
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: [
|
||||
|
|
|
|||
Loading…
Reference in a new issue