| 1 |
/* |
| 2 |
* Copyright 2012 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import Lomiri.Components 1.2 |
| 19 |
|
| 20 |
/*! |
| 21 |
\qmltype SheetBase |
| 22 |
\deprecated |
| 23 |
\inqmlmodule Lomiri.Components.Popups 1.0 |
| 24 |
\ingroup lomiri-popups |
| 25 |
\brief Parent class of different types of sheets. Not to be used directly. |
| 26 |
|
| 27 |
Examples: See subclasses. |
| 28 |
\b{Sheets are deprecated. Consider using \l Dialog, \l Popover or \l PageStack instead.} |
| 29 |
*/ |
| 30 |
PopupBase { |
| 31 |
id: sheet |
| 32 |
|
| 33 |
Component.onCompleted: { |
| 34 |
print("WARNING: Sheets are deprecated. " + |
| 35 |
"Consider using Dialog, Popover or PageStack instead.") |
| 36 |
} |
| 37 |
|
| 38 |
/*! |
| 39 |
\qmlproperty list<Object> container |
| 40 |
Content will be put inside the foreround of the sheet. |
| 41 |
*/ |
| 42 |
default property alias container: containerItem.data |
| 43 |
|
| 44 |
/*! |
| 45 |
Override the default width of the contents of the sheet. |
| 46 |
Total sheet width will be clamped between 50 grid units and the screen width. |
| 47 |
\qmlproperty real contentsWidth |
| 48 |
*/ |
| 49 |
property alias contentsWidth: foreground.contentsWidth |
| 50 |
|
| 51 |
/*! |
| 52 |
Override the default height of the contents of the sheet. |
| 53 |
Total sheet height will be clamped between 40 grid units and the screen height. |
| 54 |
\qmlproperty real contentsHeight |
| 55 |
*/ |
| 56 |
property alias contentsHeight: foreground.contentsHeight |
| 57 |
|
| 58 |
/*! |
| 59 |
The text shown in the header of the sheet. |
| 60 |
\qmlproperty string title |
| 61 |
*/ |
| 62 |
property alias title: foreground.title |
| 63 |
|
| 64 |
/*! |
| 65 |
The property controls whether the sheet is modal or not. Modal sheets block |
| 66 |
event propagation to items under dismissArea, when non-modal ones let these |
| 67 |
events passed to these items. |
| 68 |
|
| 69 |
The default value is true. |
| 70 |
*/ |
| 71 |
property bool modal: true |
| 72 |
|
| 73 |
/*! \internal */ |
| 74 |
property alias __leftButton: foreground.leftButton |
| 75 |
|
| 76 |
/*! \internal */ |
| 77 |
property alias __rightButton: foreground.rightButton |
| 78 |
|
| 79 |
fadingAnimation: LomiriNumberAnimation { duration: LomiriAnimation.SnapDuration } |
| 80 |
|
| 81 |
__foreground: foreground |
| 82 |
__eventGrabber.enabled: modal |
| 83 |
|
| 84 |
StyledItem { |
| 85 |
id: foreground |
| 86 |
activeFocusOnPress: true |
| 87 |
|
| 88 |
property string title |
| 89 |
property real contentsWidth: units.gu(64) |
| 90 |
property real contentsHeight: units.gu(40) |
| 91 |
property Button leftButton |
| 92 |
property Button rightButton |
| 93 |
|
| 94 |
y: Math.min(units.gu(15), (sheet.height - height)/2) |
| 95 |
anchors.horizontalCenter: parent.horizontalCenter |
| 96 |
|
| 97 |
property real minWidth: Math.min(units.gu(50), sheet.width) |
| 98 |
property real maxWidth: sheet.width |
| 99 |
property real minHeight: Math.min(units.gu(40), sheet.height) |
| 100 |
property real maxHeight: sheet.height |
| 101 |
|
| 102 |
Item { |
| 103 |
id: containerItem |
| 104 |
parent: foreground.__styleInstance.contentItem |
| 105 |
anchors { |
| 106 |
fill: parent |
| 107 |
margins: units.gu(1) |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
style: Theme.createStyleComponent("SheetForegroundStyle.qml", sheet) |
| 112 |
} |
| 113 |
} |