mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
fix logic for open/close top panel
This commit is contained in:
parent
0998bcfa27
commit
5be8125c62
2 changed files with 28 additions and 5 deletions
|
|
@ -45,18 +45,33 @@ NanoShell.FullScreenOverlay {
|
|||
//width: Screen.width
|
||||
//height: Screen.height
|
||||
|
||||
enum MovementDirection {
|
||||
None = 0,
|
||||
Up,
|
||||
Down
|
||||
}
|
||||
property int direction: SlidingPanel.MovementDirection.None
|
||||
|
||||
function open() {
|
||||
window.showFullScreen();
|
||||
open.running = true;
|
||||
openAnim.restart();
|
||||
}
|
||||
function close() {
|
||||
closeAnim.running = true;
|
||||
closeAnim.restart();
|
||||
}
|
||||
function updateState() {
|
||||
if (offset < openThreshold) {
|
||||
if (window.direction === SlidingPanel.MovementDirection.None) {
|
||||
if (offset < openThreshold) {
|
||||
close();
|
||||
} else {
|
||||
openAnim.restart();
|
||||
}
|
||||
} else if (offset > openThreshold && window.direction === SlidingPanel.MovementDirection.Down) {
|
||||
openAnim.restart();
|
||||
} else if (mainFlickable.contentY > openThreshold) {
|
||||
close();
|
||||
} else {
|
||||
openAnim.running = true;
|
||||
openAnim.restart();
|
||||
}
|
||||
}
|
||||
Timer {
|
||||
|
|
@ -163,8 +178,15 @@ NanoShell.FullScreenOverlay {
|
|||
}
|
||||
//no loop as those 2 values compute to exactly the same
|
||||
onContentYChanged: {
|
||||
if (contentY === oldContentY) {
|
||||
window.direction = SlidingPanel.MovementDirection.None;
|
||||
} else {
|
||||
window.direction = contentY > oldContentY ? SlidingPanel.MovementDirection.Up : SlidingPanel.MovementDirection.Down;
|
||||
}
|
||||
window.offset = -contentY + contentArea.height
|
||||
oldContentY = contentY;
|
||||
}
|
||||
property real oldContentY
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
contentWidth: window.width
|
||||
contentHeight: window.height*2
|
||||
|
|
|
|||
|
|
@ -262,6 +262,7 @@ Item {
|
|||
}
|
||||
onPositionChanged: {
|
||||
slidingPanel.offset = Math.min(slidingPanel.contentItem.height, slidingPanel.offset + (mouse.y - oldMouseY));
|
||||
|
||||
oldMouseY = mouse.y;
|
||||
}
|
||||
onReleased: {
|
||||
|
|
@ -274,7 +275,7 @@ Item {
|
|||
id: slidingPanel
|
||||
width: plasmoid.availableScreenRect.width
|
||||
height: plasmoid.availableScreenRect.height
|
||||
openThreshold: units.gridUnit * 10
|
||||
openThreshold: units.gridUnit * 2
|
||||
headerHeight: root.height
|
||||
|
||||
onClosed: quickSettings.closed()
|
||||
|
|
|
|||
Loading…
Reference in a new issue