/usr/share/unity8/Components/Showable.qml is in unity8-common 8.12+16.04.20160401-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
Item {
id: showable
property bool available: true
property bool shown: true
/* If your showable supports on demand content creation/destruction,
set this to false when destroyed and true when ready to be shown.
NOTE: You should load your content when "required" is true and
destroy when "required" is false
*/
property bool created: true
property bool required
property bool __shouldShow: false
property bool __skipShowAnimation: false
property bool __skipHideAnimation: false
property list<QtObject> hides
property var showAnimation
property var hideAnimation
// automatically set the target on showAnimation and hideAnimation to be the
// showable itself
onShowAnimationChanged: if (showAnimation) showAnimation["target"] = showable
onHideAnimationChanged: if (hideAnimation) hideAnimation["target"] = showable
Component.onCompleted: required = shown;
function __hideOthers() {
var i
for (i=0; i<hides.length; i++) {
hides[i].hide()
}
}
function show() {
required = true;
if (created) {
__reallyShow();
} else {
__shouldShow = true;
}
}
function showNow() {
__skipShowAnimation = true;
show();
}
onCreatedChanged: {
if (created && __shouldShow) {
__reallyShow();
__shouldShow = false;
}
}
function __reallyShow() {
if (!available) {
__skipShowAnimation = false;
return false;
}
__hideOthers();
if (hideAnimation != undefined && hideAnimation.running) {
hideAnimation.stop();
}
if (showAnimation != undefined) {
if (!showAnimation.running) {
showAnimation.restart()
}
if (__skipShowAnimation) {
showAnimation.complete();
}
} else {
visible = true;
}
shown = true;
__skipShowAnimation = false;
return true;
}
/*
Will be called right before starting the hideAnimation.
*/
property var prepareToHide: function(){}
function hide() {
if (showAnimation != undefined && showAnimation.running) {
showAnimation.stop()
}
if (typeof prepareToHide === "function") {
prepareToHide();
} else {
console.warn("Showable.prepareToHide should be a function, but it's a " +
(typeof prepareToHide) + " instead");
}
if (hideAnimation != undefined) {
if (!hideAnimation.running) {
hideAnimation.restart()
}
if (__skipHideAnimation) {
hideAnimation.complete();
}
} else {
visible = false
required = false
}
shown = false
__skipHideAnimation = false;
}
function hideNow() {
__skipHideAnimation = true;
hide();
}
Connections {
target: hideAnimation ? hideAnimation: null
onRunningChanged: {
if (!hideAnimation.running) {
required = false;
}
}
}
}
|