| 1 |
/* |
| 2 |
* Copyright (C) 2013 Canonical, Ltd. |
| 3 |
* |
| 4 |
* Authors: |
| 5 |
* Renato Araujo Oliveira Filho <[email protected]> |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; version 3. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
*/ |
| 19 |
|
| 20 |
import QtQuick 2.4 |
| 21 |
import Lomiri.Components 1.3 |
| 22 |
|
| 23 |
|
| 24 |
MouseArea { |
| 25 |
id: root |
| 26 |
|
| 27 |
property bool active: false |
| 28 |
readonly property alias aboutToDismiss: dismissControls.running |
| 29 |
default property alias controls: contents.children |
| 30 |
readonly property bool fullVisible: (spacer.height === 0) |
| 31 |
|
| 32 |
function dismiss() |
| 33 |
{ |
| 34 |
dismissControls.restart() |
| 35 |
} |
| 36 |
|
| 37 |
function abortDismiss() |
| 38 |
{ |
| 39 |
dismissControls.stop() |
| 40 |
active = true |
| 41 |
} |
| 42 |
|
| 43 |
onActiveChanged: dismissControls.stop() |
| 44 |
|
| 45 |
hoverEnabled: true |
| 46 |
onExited: dismiss() |
| 47 |
onEntered: { |
| 48 |
abortDismiss() |
| 49 |
active = true |
| 50 |
} |
| 51 |
|
| 52 |
Timer { |
| 53 |
id: dismissControls |
| 54 |
|
| 55 |
running: false |
| 56 |
interval: 3000 |
| 57 |
repeat: false |
| 58 |
onTriggered: root.active = false |
| 59 |
} |
| 60 |
|
| 61 |
Column { |
| 62 |
anchors.fill: parent |
| 63 |
Item { |
| 64 |
id: spacer |
| 65 |
anchors { |
| 66 |
left: parent.left |
| 67 |
right: parent.right |
| 68 |
} |
| 69 |
height: root.active ? 0 : contents.height |
| 70 |
} |
| 71 |
Item { |
| 72 |
id: contents |
| 73 |
anchors { |
| 74 |
left: parent.left |
| 75 |
right: parent.right |
| 76 |
} |
| 77 |
height: childrenRect.height |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
states: [ |
| 82 |
State { |
| 83 |
name: "active" |
| 84 |
when: root.active |
| 85 |
PropertyChanges { |
| 86 |
target: spacer |
| 87 |
height: 0 |
| 88 |
enabled: false |
| 89 |
} |
| 90 |
}, |
| 91 |
State { |
| 92 |
name: "deActive" |
| 93 |
when: !root.active |
| 94 |
PropertyChanges { |
| 95 |
target: spacer |
| 96 |
height: contents.height |
| 97 |
enabled: true |
| 98 |
} |
| 99 |
} |
| 100 |
] |
| 101 |
|
| 102 |
transitions: [ |
| 103 |
Transition { |
| 104 |
from: "deActive" |
| 105 |
to: "active" |
| 106 |
LomiriNumberAnimation { |
| 107 |
target: spacer |
| 108 |
property: "height" |
| 109 |
duration: LomiriAnimation.FastDuration |
| 110 |
} |
| 111 |
}, |
| 112 |
Transition { |
| 113 |
from: "active" |
| 114 |
to: "deActive" |
| 115 |
LomiriNumberAnimation { |
| 116 |
target: spacer |
| 117 |
property: "height" |
| 118 |
duration: LomiriAnimation.SlowDuration |
| 119 |
} |
| 120 |
} |
| 121 |
] |
| 122 |
} |