2014-10-23 13:41:23 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright 2014 Marco Martin <notmart@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* 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
|
2015-06-12 04:26:00 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
2015-03-18 12:49:28 +00:00
|
|
|
import QtQuick.Window 2.2
|
2014-10-23 14:29:27 +00:00
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
2015-12-14 15:19:43 +00:00
|
|
|
import org.kde.plasma.private.mobileshell 2.0
|
2014-10-23 13:41:23 +00:00
|
|
|
|
2015-06-19 23:51:08 +00:00
|
|
|
FullScreenPanel {
|
2014-10-23 13:41:23 +00:00
|
|
|
id: window
|
|
|
|
|
|
|
|
|
|
property int offset: 0
|
2017-09-01 16:35:41 +00:00
|
|
|
property int peekHeight
|
2017-09-05 11:59:20 +00:00
|
|
|
property bool userInteracting: false
|
2017-09-14 19:03:56 +00:00
|
|
|
property bool expanded: false
|
2014-10-23 13:41:23 +00:00
|
|
|
|
|
|
|
|
color: "transparent"
|
2015-03-13 16:17:24 +00:00
|
|
|
property alias contents: contentArea.data
|
2017-09-05 11:14:15 +00:00
|
|
|
property int headerHeight
|
2014-10-23 13:41:23 +00:00
|
|
|
|
2015-12-18 12:49:33 +00:00
|
|
|
width: Screen.width
|
|
|
|
|
height: Screen.height
|
|
|
|
|
|
2017-09-01 16:35:41 +00:00
|
|
|
property alias fixedArea: fixedArea
|
2016-10-05 16:03:41 +00:00
|
|
|
function open() {
|
2018-02-12 15:37:35 +00:00
|
|
|
window.showFullScreen();
|
2017-09-01 16:49:07 +00:00
|
|
|
peekAnim.running = true;
|
2016-10-05 16:03:41 +00:00
|
|
|
}
|
|
|
|
|
function close() {
|
2017-09-01 16:35:41 +00:00
|
|
|
closeAnim.running = true;
|
2016-10-05 16:03:41 +00:00
|
|
|
}
|
2014-10-23 15:00:24 +00:00
|
|
|
function updateState() {
|
2017-09-14 19:03:56 +00:00
|
|
|
if (expanded) {
|
|
|
|
|
openAnim.running = true;
|
|
|
|
|
} else if (offset < peekHeight / 2) {
|
2017-09-01 16:35:41 +00:00
|
|
|
close();
|
|
|
|
|
} else if (offset < peekHeight) {
|
|
|
|
|
open();
|
2017-09-01 16:49:07 +00:00
|
|
|
} else if (mainFlickable.contentY < 0) {
|
|
|
|
|
openAnim.running = true;
|
2014-10-23 14:29:27 +00:00
|
|
|
}
|
2014-10-23 14:13:19 +00:00
|
|
|
}
|
2017-09-05 11:14:15 +00:00
|
|
|
Timer {
|
|
|
|
|
id: updateStateTimer
|
|
|
|
|
interval: 0
|
|
|
|
|
onTriggered: updateState()
|
|
|
|
|
}
|
2017-09-04 16:15:49 +00:00
|
|
|
onActiveChanged: {
|
|
|
|
|
if (!active) {
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-23 14:13:19 +00:00
|
|
|
onVisibleChanged: {
|
|
|
|
|
if (visible) {
|
2015-12-18 12:49:33 +00:00
|
|
|
window.width = Screen.width;
|
|
|
|
|
window.height = Screen.height;
|
2017-09-04 16:15:49 +00:00
|
|
|
window.requestActivate();
|
2017-09-14 19:03:56 +00:00
|
|
|
} else {
|
|
|
|
|
window.expanded = false;
|
2014-10-23 14:13:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
2017-09-01 16:35:41 +00:00
|
|
|
SequentialAnimation {
|
|
|
|
|
id: closeAnim
|
|
|
|
|
PropertyAnimation {
|
|
|
|
|
target: window
|
|
|
|
|
duration: units.longDuration
|
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
|
properties: "offset"
|
|
|
|
|
from: window.offset
|
|
|
|
|
to: 0
|
2014-10-23 13:41:23 +00:00
|
|
|
}
|
2017-09-01 16:35:41 +00:00
|
|
|
ScriptAction {
|
|
|
|
|
script: {
|
|
|
|
|
window.visible = false;
|
2015-03-13 16:17:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2017-09-01 16:35:41 +00:00
|
|
|
}
|
|
|
|
|
PropertyAnimation {
|
2017-09-01 16:49:07 +00:00
|
|
|
id: peekAnim
|
2017-09-01 16:35:41 +00:00
|
|
|
target: window
|
|
|
|
|
duration: units.longDuration
|
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
|
properties: "offset"
|
|
|
|
|
from: window.offset
|
2017-09-05 11:14:15 +00:00
|
|
|
to: window.peekHeight - headerHeight
|
2017-09-01 16:35:41 +00:00
|
|
|
}
|
2017-09-01 16:49:07 +00:00
|
|
|
PropertyAnimation {
|
|
|
|
|
id: openAnim
|
|
|
|
|
target: window
|
|
|
|
|
duration: units.longDuration
|
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
|
properties: "offset"
|
|
|
|
|
from: window.offset
|
|
|
|
|
to: contentArea.height
|
|
|
|
|
}
|
2017-09-01 16:35:41 +00:00
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
color: Qt.rgba(0, 0, 0, 0.6 * Math.min(1, offset/contentArea.height))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PlasmaCore.ColorScope {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
y: Math.min(0, -height + window.offset)
|
|
|
|
|
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
2014-10-23 13:41:23 +00:00
|
|
|
|
|
|
|
|
Rectangle {
|
2017-09-01 16:35:41 +00:00
|
|
|
anchors {
|
|
|
|
|
top: parent.top
|
|
|
|
|
left: parent.left
|
|
|
|
|
right: parent.right
|
|
|
|
|
}
|
|
|
|
|
height: contentArea.height - mainFlickable.contentY
|
|
|
|
|
color: PlasmaCore.ColorScope.backgroundColor
|
2015-03-13 16:17:24 +00:00
|
|
|
}
|
|
|
|
|
|
2017-09-01 16:35:41 +00:00
|
|
|
Flickable {
|
|
|
|
|
id: mainFlickable
|
|
|
|
|
anchors.fill: parent
|
2017-09-14 19:03:56 +00:00
|
|
|
interactive: !window.expanded
|
2017-09-01 16:35:41 +00:00
|
|
|
Binding {
|
|
|
|
|
target: mainFlickable
|
|
|
|
|
property: "contentY"
|
2017-09-05 11:14:15 +00:00
|
|
|
value: -window.offset + contentArea.height - window.headerHeight
|
2017-09-01 16:35:41 +00:00
|
|
|
when: !mainFlickable.moving && !mainFlickable.dragging && !mainFlickable.flicking
|
|
|
|
|
}
|
|
|
|
|
//no loop as those 2 values compute to exactly the same
|
2017-09-05 13:53:42 +00:00
|
|
|
onContentYChanged: {
|
|
|
|
|
window.offset = -contentY + contentArea.height - window.headerHeight
|
|
|
|
|
if (contentY > contentArea.height - headerHeight) {
|
|
|
|
|
contentY = contentArea.height - headerHeight;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-01 16:35:41 +00:00
|
|
|
contentWidth: window.width
|
|
|
|
|
contentHeight: window.height*2
|
|
|
|
|
bottomMargin: window.height
|
2017-09-05 11:59:20 +00:00
|
|
|
onMovementStarted: window.userInteracting = true;
|
|
|
|
|
onFlickStarted: window.userInteracting = true;
|
|
|
|
|
onMovementEnded: {
|
|
|
|
|
window.userInteracting = false;
|
|
|
|
|
window.updateState();
|
|
|
|
|
}
|
|
|
|
|
onFlickEnded: {
|
|
|
|
|
window.userInteracting = true;
|
|
|
|
|
window.updateState();
|
|
|
|
|
}
|
2017-09-01 16:35:41 +00:00
|
|
|
Item {
|
|
|
|
|
width: window.width
|
2017-09-05 11:14:15 +00:00
|
|
|
height: Math.max(contentArea.height, window.height*2)
|
2015-03-13 16:17:24 +00:00
|
|
|
Item {
|
|
|
|
|
id: contentArea
|
|
|
|
|
anchors {
|
2017-09-01 16:35:41 +00:00
|
|
|
left: parent.left
|
|
|
|
|
right: parent.right
|
2015-03-13 16:17:24 +00:00
|
|
|
}
|
2017-09-01 16:35:41 +00:00
|
|
|
height: children[0].implicitHeight
|
2017-09-05 11:14:15 +00:00
|
|
|
onHeightChanged: {
|
2017-09-05 11:59:20 +00:00
|
|
|
if (!window.userInteracting) {
|
|
|
|
|
updateStateTimer.restart()
|
|
|
|
|
}
|
2017-09-05 11:14:15 +00:00
|
|
|
}
|
2015-03-13 16:17:24 +00:00
|
|
|
}
|
|
|
|
|
Rectangle {
|
2017-09-05 13:53:42 +00:00
|
|
|
height: units.smallSpacing
|
2015-03-13 16:17:24 +00:00
|
|
|
anchors {
|
|
|
|
|
left: parent.left
|
|
|
|
|
right: parent.right
|
2017-09-01 16:35:41 +00:00
|
|
|
top: contentArea.bottom
|
2015-03-13 16:17:24 +00:00
|
|
|
}
|
|
|
|
|
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"
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-23 14:29:27 +00:00
|
|
|
}
|
2017-09-01 16:35:41 +00:00
|
|
|
MouseArea {
|
|
|
|
|
anchors {
|
|
|
|
|
left: parent.left
|
|
|
|
|
right: parent.right
|
|
|
|
|
top: contentArea.bottom
|
|
|
|
|
}
|
|
|
|
|
height: window.height
|
|
|
|
|
onClicked: window.close();
|
2015-07-13 13:50:22 +00:00
|
|
|
}
|
2015-06-11 05:43:14 +00:00
|
|
|
}
|
2015-06-08 19:28:42 +00:00
|
|
|
}
|
2017-09-01 16:35:41 +00:00
|
|
|
Item {
|
|
|
|
|
id: fixedArea
|
|
|
|
|
anchors {
|
|
|
|
|
left: parent.left
|
|
|
|
|
right: parent.right
|
|
|
|
|
top: parent.top
|
2014-10-23 14:13:19 +00:00
|
|
|
}
|
2017-09-01 16:35:41 +00:00
|
|
|
height: childrenRect.height
|
|
|
|
|
}
|
2014-10-23 14:13:19 +00:00
|
|
|
}
|
2014-10-23 13:41:23 +00:00
|
|
|
}
|