on xenial help sign in
Added preview Sharing
commit035510f88877409938ea5ef35dd5da7b28a0518b authorAndrea Cimitan <andrea.cimitan@gmail.com> dateFri 2 Oct 2015, 11:41 (11 years ago) parent18e9de0
3 files changed+147
qml/Dash/Previews/PreviewSharing.qml+101 qml/Dash/Previews/PreviewVideoPlayback.qml+23 qml/Dash/Previews/PreviewZoomableImage.qml+23
qml/Dash/Previews/PreviewSharing.qmlnew file+101
@@ -0,0 +1,101 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU 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 General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU 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 Ubuntu.Components 1.3
19+import Ubuntu.Content 1.1
20+
21+Item {
22+ id: root
23+ implicitHeight: button.height
24+ implicitWidth: button.width
25+
26+ property var shareUris
27+ readonly property bool isUrlExternal: url && url.indexOf("file:///") != 0 && url.indexOf("/") != 0
28+ readonly property string contentType: shareUris ? shareUris["contentType"] : ""
29+ readonly property string url: shareUris ? shareUris["uri"] : ""
30+ readonly property Item rootItem: QuickUtils.rootItem(root)
31+
32+ visible: url != ""
33+
34+ AbstractButton {
35+ id: button
36+ height: units.gu(4)
37+ width: units.gu(4)
38+ onClicked: peerPicker.visible = true
39+
40+ Icon {
41+ anchors.centerIn: parent
42+ height: units.gu(3)
43+ width: units.gu(3)
44+ source: "image://theme/share"
45+ }
46+ }
47+
48+ Component {
49+ id: exportItemComponent
50+ ContentItem {
51+ name: i18n.tr("Preview Share Item")
52+ }
53+ }
54+
55+ Component {
56+ id: contentPeerComponent
57+ ContentPeerPicker {
58+ handler: ContentHandler.Share
59+ contentType: {
60+ // for now, treat all external urls as Links, or it will break contenthub
61+ if (root.isUrlExternal) return ContentType.Links;
62+
63+ switch(root.contentType) {
64+ case "all": return ContentType.All;
65+ case "contacts": return ContentType.Contacts;
66+ case "documents": return ContentType.Documents;
67+ case "links": return ContentType.Links;
68+ case "music": return ContentType.Music;
69+ case "pictures": return ContentType.Pictures;
70+ case "text": return ContentType.Text;
71+ default:
72+ case "unknown": return ContentType.Unknown;
73+ case "videos": return ContentType.Videos;
74+ }
75+ }
76+
77+ onPeerSelected: {
78+ var transfer = peer.request();
79+ if (transfer.state === ContentTransfer.InProgress) {
80+ var items = new Array();
81+ var exportItem = exportItemComponent.createObject();
82+ exportItem.url = url;
83+ items.push(exportItem);
84+ transfer.items = items;
85+ transfer.state = ContentTransfer.Charged;
86+ }
87+ peerPicker.visible = false;
88+ }
89+ onCancelPressed: peerPicker.visible = false;
90+ }
91+ }
92+
93+ Loader {
94+ id: peerPicker
95+ parent: rootItem
96+ anchors.fill: parent
97+ visible: false
98+
99+ sourceComponent: root.visible ? contentPeerComponent : undefined
100+ }
101+}
qml/Dash/Previews/PreviewVideoPlayback.qml+23
@@ -72,5 +72,28 @@ PreviewWidget {
7272 anchors.fill: parent
7373 onClicked: Qt.openUrlExternally(widgetData["source"])
7474 }
75+
76+ Rectangle {
77+ id: toolbar
78+ anchors {
79+ left: parent.left
80+ right: parent.right
81+ bottom: parent.bottom
82+ }
83+ height: units.gu(6)
84+ color: Qt.rgba(0, 0, 0, 0.8)
85+
86+ visible: sharingWidget.url != ""
87+
88+ PreviewSharing {
89+ id: sharingWidget
90+ anchors {
91+ left: parent.left
92+ verticalCenter: parent.verticalCenter
93+ leftMargin: units.gu(1)
94+ }
95+ shareUris: widgetData["shareUris"]
96+ }
97+ }
7598 }
7699}
qml/Dash/Previews/PreviewZoomableImage.qml+23
@@ -63,6 +63,29 @@ PreviewWidget {
6363 // But at the moment the model never changes
6464 onStatusChanged: if (lazyImage.sourceImage.status === Image.Error) lazyImage.sourceImage.source = widgetData["fallback"];
6565 }
66+
67+ Rectangle {
68+ id: toolbar
69+ anchors {
70+ left: parent.left
71+ right: parent.right
72+ bottom: parent.bottom
73+ }
74+ height: units.gu(6)
75+ color: Qt.rgba(0, 0, 0, 0.8)
76+
77+ visible: sharingWidget.url != ""
78+
79+ PreviewSharing {
80+ id: sharingWidget
81+ anchors {
82+ left: parent.left
83+ verticalCenter: parent.verticalCenter
84+ leftMargin: units.gu(1)
85+ }
86+ shareUris: widgetData["shareUris"]
87+ }
88+ }
6689 }
6790
6891 PreviewOverlay {