2 * Copyright 2014 Canonical Ltd.
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.
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.
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/>.
20 //! \brief This component loads the widgets based on widgetData["type"].
25 //! Identifier of the widget.
26 property string widgetId: ""
28 //! Type of the widget to display.
29 property string widgetType: ""
31 //! Widget data, forwarded to the widget as is.
32 property var widgetData: null
34 //! The ScopeStyle component.
35 property var scopeStyle: null
37 //! Should the widget show in expanded mode (For those that support it)
38 property bool expanded: widgetType !== "expandable" || widgetData["expanded"] === true
40 //! Should the orientation be locked
41 readonly property bool orientationLock: status === Loader.Ready ? item.orientationLock : false
43 //! Should it have margins when on a single columns?
44 readonly property bool singleColumnMarginless: status === Loader.Ready ? item.singleColumnMarginless : false
46 /// The parent (vertical) flickable this widget is in (if any)
47 property var parentFlickable: null
49 //! Triggered signal forwarded from the widgets.
50 signal triggered(string widgetId, string actionId, var data)
52 //! MakesureVisible signal forwarded from the widgets.
53 signal makeSureVisible(var item)
58 property url widgetSource: {
60 case "actions": return "PreviewActions.qml";
61 case "audio": return "PreviewAudioPlayback.qml";
62 case "comment": return "PreviewComment.qml";
63 case "comment-input": return "PreviewCommentInput.qml";
64 case "expandable": return "PreviewExpandable.qml";
65 case "gallery": return "PreviewImageGallery.qml";
66 case "header": return "PreviewHeader.qml";
67 case "icon-actions": return "PreviewIconActions.qml";
68 case "image": return "PreviewZoomableImage.qml";
69 case "progress": return "PreviewProgress.qml";
70 case "payments": return "PreviewPayments.qml";
71 case "rating-input": return "PreviewRatingInput.qml";
72 case "rating-edit": return "PreviewRatingEdit.qml";
73 case "reviews": return "PreviewRatingDisplay.qml";
74 case "table": return "PreviewTable.qml";
75 case "text": return "PreviewTextSummary.qml";
77 if (!widgetData) return "";
78 var source = widgetData.hasOwnProperty("source") ? widgetData["source"].toString() : "";
79 if (source.match("^https{0,1}\:") !== null) {
80 return "PreviewVideoPlayback.qml";
82 return "PreviewInlineVideo.qml";
90 item.widgetId = Qt.binding(function() { return root.widgetId } )
91 item.widgetData = Qt.binding(function() { return root.widgetData } )
92 item.expanded = Qt.binding(function() { return root.expanded } )
93 item.scopeStyle = Qt.binding(function() { return root.scopeStyle } )
94 item.parentFlickable = Qt.binding(function() { return root.parentFlickable } )
99 onTriggered: root.triggered(widgetId, actionId, data)
100 onMakeSureVisible: root.makeSureVisible(item)