on xenial help sign in
merge trunk again...
commitc1924f581aca58b93eb9f40d80fc72167c01b6b5 authorAlberto Aguirre <alberto.aguirre@canonical.com> dateTue 24 Jun 2014, 11:27 (12 years ago) parent48b7a14ad0a13f
31 files changed+848−85
debian/changelog+22 plugins/Dash/CardCreator.js+18−11 plugins/Unity/CMakeLists.txt+1 plugins/Unity/Session/CMakeLists.txt+17 plugins/Unity/Session/dbusunitysessionservice.cpp+46 plugins/Unity/Session/dbusunitysessionservice.h+82 plugins/Unity/Session/plugin.cpp+40 plugins/Unity/Session/plugin.h+34 plugins/Unity/Session/qmldir+3 po/sl.po+6−6 qml/Components/ResponsiveVerticalJournal.qml+74 qml/Dash/CardCarousel.qml−2 qml/Dash/CardFilterGrid.qml+1−4 qml/Dash/CardVerticalJournal.qml+89 qml/Dash/DashRenderer.qml−7 qml/Dash/GenericScopeView.qml+10−1 qml/Notifications/Notification.qml+13 qml/Shell.qml+25 src/main.cpp+1 tests/plugins/Dash/cardcreator/1.res+14−9 tests/plugins/Dash/cardcreator/2.res+2−1 tests/plugins/Dash/cardcreator/3.res+20−15 tests/plugins/Dash/cardcreator/4.res+2−1 tests/plugins/Dash/cardcreator/5.res+21−16 tests/plugins/Unity/CMakeLists.txt+1 tests/plugins/Unity/Session/CMakeLists.txt+20 tests/plugins/Unity/Session/sessionbackendtest.cpp+64 tests/qmltests/CMakeLists.txt+1 tests/qmltests/Components/tst_ResponsiveVerticalJournal.qml+183 tests/qmltests/Dash/tst_Card.qml+9 tests/qmltests/Notifications/tst_Notifications.qml+29−12
debian/changelog+22
@@ -1,3 +1,25 @@
1+unity8 (7.89+14.10.20140624-0ubuntu1) utopic; urgency=low
2+
3+ [ Ying-Chun Liu ]
4+ * Add logout support. Reviewed by: Daniel d'Andrada (LP: #1302213)
5+
6+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Tue, 24 Jun 2014 08:17:09 +0000
7+
8+unity8 (7.89+14.10.20140623.1-0ubuntu1) utopic; urgency=low
9+
10+ [ Michał Sawicz ]
11+ * Make so that fixedArtShapeSize actually fixes artShapeSize.
12+
13+ [ Albert Astals ]
14+ * Add VerticalJournal integration to Dash/scopes/QML (LP: #1326467)
15+ * Make so that fixedArtShapeSize actually fixes artShapeSize.
16+
17+ [ Mirco Müller ]
18+ * Added the frontend-part of sound-hint support for notifications with
19+ updated QML-tests.
20+
21+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 23 Jun 2014 11:17:12 +0000
22+
123unity8 (7.89+14.10.20140619.3-0ubuntu1) utopic; urgency=low
224
325 * New rebuild forced
plugins/Dash/CardCreator.js+18−11
@@ -55,8 +55,8 @@ var kBackgroundLoaderCode = 'Loader {\n\
5555// %3 is used as image height
5656var kArtShapeHolderCode = 'Item { \n\
5757 id: artShapeHolder; \n\
58− height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
59− width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
58+ height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
59+ width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; \n\
6060 anchors { %1 } \n\
6161 Loader { \n\
6262 id: artShapeLoader; \n\
@@ -68,13 +68,18 @@ var kArtShapeHolderCode = 'Item { \n\
6868 id: artShape; \n\
6969 objectName: "artShape"; \n\
7070 radius: "medium"; \n\
71− readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
71+ visible: image.status == Image.Ready; \n\
72+ readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
73+ readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
7274 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect; \n\
7375 Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; } \n\
7476 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings(); \n\
75− visible: image.status == Image.Ready; \n\
77+ Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } \n\
7678 function updateWidthHeightBindings() { \n\
77− if (aspectSmallerThanImageAspect) { \n\
79+ if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { \n\
80+ width = root.fixedArtShapeSize.width; \n\
81+ height = root.fixedArtShapeSize.height; \n\
82+ } else if (aspectSmallerThanImageAspect) { \n\
7883 width = Qt.binding(function() { return !visible ? 0 : image.width }); \n\
7984 height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect }); \n\
8085 } else { \n\
@@ -108,7 +113,7 @@ var kOverlayLoaderCode = 'Loader { \n\
108113 visible: showHeader && status == Loader.Ready; \n\
109114 sourceComponent: ShaderEffect { \n\
110115 id: overlay; \n\
111− height: fixedHeaderHeight != -1 ? fixedHeaderHeight : headerHeight; \n\
116+ height: fixedHeaderHeight > 0 ? fixedHeaderHeight + units.gu(1) * 2 : headerHeight; \n\
112117 opacity: 0.6; \n\
113118 property var source: ShaderEffectSource { \n\
114119 id: shaderSource; \n\
@@ -145,6 +150,7 @@ var kHeaderRow2Code = 'Row { \n\
145150 objectName: "outerRow"; \n\
146151 property real margins: units.gu(1); \n\
147152 spacing: margins; \n\
153+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
148154 anchors { %1 } \n\
149155 anchors.right: parent.right; \n\
150156 anchors.margins: margins;\n\
@@ -163,6 +169,7 @@ var kHeaderRow3Code = 'Row { \n\
163169 objectName: "outerRow"; \n\
164170 property real margins: units.gu(1); \n\
165171 spacing: margins; \n\
172+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
166173 anchors { %1 } \n\
167174 anchors.right: parent.right; \n\
168175 anchors.margins: margins;\n\
@@ -315,7 +322,7 @@ function cardString(template, components) {
315322 anchors = 'left: parent.left';
316323 if (hasMascot || hasTitle) {
317324 widthCode = 'height * artShape.aspect'
318− heightCode = 'headerHeight';
325+ heightCode = 'headerHeight + 2 * units.gu(1)';
319326 } else {
320327 // This side of the else is a bit silly, who wants an horizontal layout without mascot and title?
321328 // So we define a "random" height of the image height + 2 gu for the margins
@@ -366,13 +373,13 @@ function cardString(template, components) {
366373 }
367374
368375 if (hasHeaderRow) {
369− code += 'readonly property int headerHeight: row.height + row.margins * 2;\n'
376+ code += 'readonly property int headerHeight: row.height;\n'
370377 } else if (hasMascot) {
371− code += 'readonly property int headerHeight: mascotImage.height + units.gu(1) * 2;\n'
378+ code += 'readonly property int headerHeight: mascotImage.height;\n'
372379 } else if (hasSubtitle) {
373− code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2 + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
380+ code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
374381 } else if (hasTitle) {
375− code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2;\n'
382+ code += 'readonly property int headerHeight: titleLabel.height;\n'
376383 } else {
377384 code += 'readonly property int headerHeight: 0;\n'
378385 }
plugins/Unity/CMakeLists.txt+1
@@ -1,2 +1,3 @@
11add_subdirectory(Indicators)
22add_subdirectory(Launcher)
3+add_subdirectory(Session)
plugins/Unity/Session/CMakeLists.txtnew file+17
@@ -0,0 +1,17 @@
1+include_directories(
2+ ${CMAKE_CURRENT_SOURCE_DIR}
3+)
4+
5+set(QMLSESSIONPLUGIN_SRC
6+ plugin.cpp
7+ dbusunitysessionservice.cpp
8+ )
9+
10+add_library(UnitySession-qml MODULE
11+ ${QMLSESSIONPLUGIN_SRC}
12+ )
13+
14+qt5_use_modules(UnitySession-qml DBus Qml)
15+
16+# export the qmldir and qmltypes files
17+add_unity8_plugin(Unity.Session 0.1 Unity/Session TARGETS UnitySession-qml)
plugins/Unity/Session/dbusunitysessionservice.cppnew file+46
@@ -0,0 +1,46 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it under
5+ * the terms of the GNU Lesser General Public License version 3, as published by
6+ * the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but WITHOUT
9+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+ * 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+// local
18+#include "dbusunitysessionservice.h"
19+
20+// Qt
21+#include <QDBusConnection>
22+
23+DBusUnitySessionService::DBusUnitySessionService() : QObject()
24+{
25+ QDBusConnection connection = QDBusConnection::sessionBus();
26+
27+ connection.registerService("com.canonical.Unity");
28+ connection.registerObject("/com/canonical/Unity/Session", this,
29+ QDBusConnection::ExportScriptableSignals
30+ | QDBusConnection::ExportScriptableSlots
31+ | QDBusConnection::ExportScriptableInvokables);
32+}
33+
34+DBusUnitySessionService::~DBusUnitySessionService()
35+{
36+}
37+
38+void DBusUnitySessionService::Logout()
39+{
40+ Q_EMIT logoutReady();
41+}
42+
43+void DBusUnitySessionService::RequestLogout()
44+{
45+ Q_EMIT logoutRequested(false);
46+}
plugins/Unity/Session/dbusunitysessionservice.hnew file+82
@@ -0,0 +1,82 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it under
5+ * the terms of the GNU Lesser General Public License version 3, as published by
6+ * the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but WITHOUT
9+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+ * 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+#ifndef DBUSUNITYSESSIONSERVICE_H
18+#define DBUSUNITYSESSIONSERVICE_H
19+
20+#include <QObject>
21+
22+/**
23+ * DBusUnitySessionService provides com.canonical.Unity.Session dbus
24+ * interface.
25+ *
26+ * com.canonical.Unity.Session interface provides public methods
27+ * and signals to handle Logout/Reboot/Shutdown.
28+ */
29+class DBusUnitySessionService : public QObject
30+{
31+ Q_OBJECT
32+ Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Session")
33+
34+public:
35+ DBusUnitySessionService();
36+ ~DBusUnitySessionService();
37+
38+Q_SIGNALS:
39+ /**
40+ * logoutRequested signal
41+ *
42+ * This signal is emitted when some applications request the system to
43+ * logout.
44+ * @param have_inhibitors if there are any special running applications
45+ * which inhibit the logout.
46+ */
47+ void logoutRequested(bool have_inhibitors);
48+
49+ /**
50+ * logoutReady signal
51+ *
52+ * This signal is emitted when all the apps are closed. And the system
53+ * is safe to logout.
54+ */
55+ void logoutReady();
56+
57+public Q_SLOTS:
58+ /**
59+ * Logout the system.
60+ *
61+ * This method directly logout the system without user's confirmation.
62+ * Ordinary applications should avoid calling this method. Please call
63+ * RequestLogout() to ask the user to decide logout or not.
64+ * This method will stop all the running applications and then signal
65+ * logoutReady when all the apps stopped.
66+ */
67+ Q_SCRIPTABLE void Logout();
68+
69+ /**
70+ * Issue a logout request.
71+ *
72+ * This method emit the logoutRequested signal to the shell with a boolean
73+ * which indicates if there's any inhibitors. The shell should receive
74+ * this signal and display a dialog to ask the user to confirm the logout
75+ * action. If confirmed, shell can call Logout() method to kill the apps
76+ * and then logout
77+ */
78+ Q_SCRIPTABLE void RequestLogout();
79+
80+};
81+
82+#endif // DBUSUNITYSESSIONSERVICE_H
plugins/Unity/Session/plugin.cppnew file+40
@@ -0,0 +1,40 @@
1+/*
2+ * Copyright (C) 2014 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+ * Authors: Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
17+ */
18+
19+#include "plugin.h"
20+#include "dbusunitysessionservice.h"
21+
22+#include <QAbstractItemModel>
23+#include <QDBusConnection>
24+#include <QtQml/qqml.h>
25+
26+static QObject *dbusunitysessionservice_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
27+{
28+ Q_UNUSED(engine)
29+ Q_UNUSED(scriptEngine)
30+
31+ return new DBusUnitySessionService();
32+}
33+
34+void SessionPlugin::registerTypes(const char *uri)
35+{
36+ qmlRegisterType<QAbstractItemModel>();
37+
38+ Q_ASSERT(uri == QLatin1String("Unity.Session"));
39+ qmlRegisterSingletonType<DBusUnitySessionService>(uri, 0, 1, "DBusUnitySessionService", dbusunitysessionservice_provider);
40+}
plugins/Unity/Session/plugin.hnew file+34
@@ -0,0 +1,34 @@
1+/*
2+ * Copyright (C) 2014 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+ * Authors: Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
17+ */
18+
19+#ifndef SESSION_PLUGIN_H
20+#define SESSION_PLUGIN_H
21+
22+#include <QtQml/QQmlEngine>
23+#include <QtQml/QQmlExtensionPlugin>
24+
25+class SessionPlugin : public QQmlExtensionPlugin
26+{
27+ Q_OBJECT
28+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29+
30+public:
31+ void registerTypes(const char *uri);
32+};
33+
34+#endif
plugins/Unity/Session/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module Unity.Session
2+plugin UnitySession-qml
3+typeinfo UnitySession.qmltypes
po/sl.po+6−6
@@ -8,14 +8,14 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2014-06-13 09:55+0200\n"
11−"PO-Revision-Date: 2014-05-22 14:07+0000\n"
11+"PO-Revision-Date: 2014-06-23 09:29+0000\n"
1212"Last-Translator: Damir Jerovšek <Unknown>\n"
1313"Language-Team: Slovenian <sl@li.org>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
17−"X-Launchpad-Export-Date: 2014-06-17 06:51+0000\n"
18−"X-Generator: Launchpad (build 17045)\n"
17+"X-Launchpad-Export-Date: 2014-06-24 06:33+0000\n"
18+"X-Generator: Launchpad (build 17065)\n"
1919
2020#: plugins/Unity/Launcher/launcheritem.cpp:43
2121#: plugins/Unity/Launcher/launcheritem.cpp:73
@@ -82,7 +82,7 @@ msgstr "Klic v sili"
8282
8383#: qml/Components/Lockscreen.qml:231
8484msgid "OK"
85−msgstr ""
85+msgstr "V REDU"
8686
8787#: qml/Components/PageHeader.qml:365
8888msgid "Recent searches"
@@ -99,11 +99,11 @@ msgstr "Pozdravljeni"
9999
100100#: qml/Components/PinLockscreen.qml:198
101101msgid "CANCEL"
102−msgstr ""
102+msgstr "PREKLIČI"
103103
104104#: qml/Components/PinLockscreen.qml:216
105105msgid "DONE"
106−msgstr ""
106+msgstr "KONČANO"
107107
108108#: qml/Components/SeeMore.qml:35
109109msgid "See more"
qml/Components/ResponsiveVerticalJournal.qmlnew file+74
@@ -0,0 +1,74 @@
1+/*
2+ * Copyright (C) 2013-2014 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.0
18+import Ubuntu.Components 0.1
19+import "../Components"
20+import Dash 0.1
21+
22+/*!
23+ \brief A responsive wrapper around VerticalJournal.
24+
25+ Based on defined column width, delegates are laid out in columns following
26+ a top-left most position rule.
27+
28+ Example:
29+ +-----+ +-----+ +-----+
30+ | | | 2 | | |
31+ | | | | | |
32+ | 1 | +-----+ | 3 |
33+ | | +-----+ | |
34+ | | | | +-----+
35+ +-----+ | 4 | +-----+
36+ +-----+ | | | 5 |
37+ | 6 | +-----+ | |
38+ | | +-----+
39+ +-----+
40+*/
41+Item {
42+ property real minimumColumnSpacing: units.gu(1)
43+
44+ property alias columnWidth: verticalJournalView.columnWidth
45+ property alias rowSpacing: verticalJournalView.rowSpacing
46+ property alias model: verticalJournalView.model
47+ property alias delegate: verticalJournalView.delegate
48+ property alias displayMarginBeginning: verticalJournalView.displayMarginBeginning
49+ property alias displayMarginEnd: verticalJournalView.displayMarginEnd
50+ implicitHeight: verticalJournalView.implicitHeight
51+
52+ VerticalJournal {
53+ id: verticalJournalView
54+ objectName: "responsiveVerticalJournalView"
55+ anchors {
56+ fill: parent
57+ leftMargin: columnSpacing / 2
58+ rightMargin: columnSpacing / 2
59+ topMargin: rowSpacing / 2
60+ bottomMargin: rowSpacing / 2
61+ }
62+ clip: parent.height != implicitHeight
63+
64+ function px2gu(pixels) {
65+ return Math.floor(pixels / units.gu(1))
66+ }
67+
68+ columnSpacing: {
69+ // parent.width = columns * columnWidth + (columns-1) * spacing + spacing(margins)
70+ var expectedColumns = Math.max(1, Math.floor(parent.width / (columnWidth + minimumColumnSpacing)));
71+ Math.floor((parent.width - expectedColumns * columnWidth) / expectedColumns);
72+ }
73+ }
74+}
qml/Dash/CardCarousel.qml−2
@@ -27,9 +27,7 @@ DashRenderer {
2727 property alias selectedItemScaleFactor: carousel.selectedItemScaleFactor
2828 property alias tileAspectRatio: carousel.tileAspectRatio
2929
30− currentItem: carousel.currentItem
3130 height: carousel.implicitHeight + units.gu(6)
32− verticalSpacing: units.gu(3)
3331
3432 Carousel {
3533 id: carousel
qml/Dash/CardFilterGrid.qml+1−4
@@ -22,11 +22,8 @@ DashRenderer {
2222
2323 expandable: filterGrid.expandable
2424 collapsedHeight: filterGrid.collapsedHeight
25− margins: filterGrid.margins
2625 uncollapsedHeight: filterGrid.uncollapsedHeight
2726 originY: filterGrid.originY
28− verticalSpacing: units.gu(1)
29− currentItem: filterGrid.currentItem
3027 height: filterGrid.height
3128 filtered: filterGrid.filtered
3229
@@ -40,7 +37,7 @@ DashRenderer {
4037 minimumHorizontalSpacing: units.gu(1)
4138 delegateWidth: cardTool.cardWidth
4239 delegateHeight: cardTool.cardHeight
43− verticalSpacing: genericFilterGrid.verticalSpacing
40+ verticalSpacing: units.gu(1)
4441 model: genericFilterGrid.model
4542 collapsedRowCount: Math.min(2, cardTool && cardTool.template && cardTool.template["collapsed-rows"] || 2)
4643 displayMarginBeginning: genericFilterGrid.displayMarginBeginning
qml/Dash/CardVerticalJournal.qmlnew file+89
@@ -0,0 +1,89 @@
1+/*
2+ * Copyright (C) 2014 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.0
18+import Ubuntu.Components 0.1
19+import "../Components"
20+
21+DashRenderer {
22+ id: root
23+
24+ readonly property double collapseLimit: units.gu(35)
25+
26+ uncollapsedHeight: cardVerticalJournal.implicitHeight
27+ collapsedHeight: Math.min(collapseLimit, cardVerticalJournal.implicitHeight)
28+ expandable: uncollapsedHeight > collapseLimit
29+
30+ // This minHeight is used as bootstrapper for the height. Vertical Journal
31+ // is special by the fact that it doesn't know how to calculate its implicit height unless we give it
32+ // enough height that it can start creating its children so we make sure it has enough height for that
33+ // in case the model is non empty
34+ readonly property double minHeight: root.model.count > 1 ? cardVerticalJournal.rowSpacing + 1 : 0
35+ height: filtered ? Math.max(collapsedHeight, minHeight) : uncollapsedHeight
36+
37+ Behavior on height {
38+ id: heightBehaviour
39+ enabled: false
40+ animation: UbuntuNumberAnimation {
41+ onRunningChanged: {
42+ if (!running) {
43+ heightBehaviour.enabled = false
44+ }
45+ }
46+ }
47+ }
48+
49+ function setFilter(filter, animate) {
50+ heightBehaviour.enabled = animate;
51+ filtered = filter;
52+ }
53+
54+ ResponsiveVerticalJournal {
55+ id: cardVerticalJournal
56+
57+ model: root.model
58+
59+ anchors.fill: parent
60+ rowSpacing: minimumColumnSpacing
61+ columnWidth: cardTool.cardWidth
62+
63+ displayMarginBeginning: root.displayMarginBeginning
64+ displayMarginEnd: root.displayMarginEnd
65+
66+ delegate: Loader {
67+ id: loader
68+ sourceComponent: cardTool.cardComponent
69+ width: cardTool.cardWidth
70+ anchors.horizontalCenter: parent.horizontalCenter
71+ onLoaded: {
72+ item.objectName = "delegate" + index;
73+ item.width = Qt.binding(function() { return cardTool.cardWidth; });
74+ item.height = Qt.binding(function() { return cardTool.cardHeight; });
75+ item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
76+ item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
77+ item.cardData = Qt.binding(function() { return model; });
78+ item.template = Qt.binding(function() { return cardTool.template; });
79+ item.components = Qt.binding(function() { return cardTool.components; });
80+ item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });
81+ }
82+ Connections {
83+ target: loader.item
84+ onClicked: root.clicked(index, result)
85+ onPressAndHold: root.pressAndHold(index)
86+ }
87+ }
88+ }
89+}
qml/Dash/DashRenderer.qml−7
@@ -25,8 +25,6 @@ Item {
2525
2626 property int collapsedHeight: height
2727
28− property int margins: 0
29−
3028 property int uncollapsedHeight: height
3129
3230 property int displayMarginBeginning: 0
@@ -35,11 +33,6 @@ Item {
3533
3634 property real originY: 0
3735
38− property real verticalSpacing: 0
39−
40− // The current item of the renderer
41− property var currentItem
42−
4336 // The model to renderer
4437 property var model
4538
qml/Dash/GenericScopeView.qml+10−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013-2014 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -147,6 +147,7 @@ FocusScope {
147147 source: {
148148 switch (cardTool.categoryLayout) {
149149 case "carousel": return "CardCarousel.qml";
150+ case "vertical-journal": return "CardVerticalJournal.qml";
150151 case "running-apps": return "Apps/RunningApplicationsGrid.qml";
151152 case "grid":
152153 default: return "CardFilterGrid.qml";
@@ -202,6 +203,14 @@ FocusScope {
202203 previewListView.currentIndex = index;
203204 previewListView.open = true
204205 }
206+ onExpandableChanged: {
207+ // This can happen with the VJ that doesn't know how height it will be on creation
208+ // so doesn't set expandable until a bit too late for onLoaded
209+ if (rendererLoader.item.expandable) {
210+ var shouldFilter = baseItem.category != categoryView.expandedCategoryId;
211+ rendererLoader.item.setFilter(shouldFilter, false /*animate*/);
212+ }
213+ }
205214 }
206215 Connections {
207216 target: categoryView
qml/Notifications/Notification.qml+13
@@ -15,6 +15,7 @@
1515 */
1616
1717import QtQuick 2.0
18+import QtMultimedia 5.0
1819import Ubuntu.Components 0.1
1920import Unity.Notifications 1.0
2021import QMenuModel 0.1
@@ -66,6 +67,18 @@ Item {
6667 return result;
6768 }
6869
70+ Audio {
71+ id: sound
72+ objectName: "sound"
73+ source: hints["suppress-sound"] != "" ? hints["sound-file"] : undefined
74+ }
75+
76+ onOpacityChanged: {
77+ if (opacity == 1.0 && hints["suppress-sound"] != "true" && sound.source) {
78+ sound.play();
79+ }
80+ }
81+
6982 Behavior on height {
7083 id: normalHeightBehavior
7184
qml/Shell.qml+25
@@ -31,6 +31,7 @@ import "Panel"
3131import "Components"
3232import "Notifications"
3333import Unity.Notifications 1.0 as NotificationBackend
34+import Unity.Session 0.1
3435
3536FocusScope {
3637 id: shell
@@ -267,6 +268,30 @@ FocusScope {
267268 }
268269 }
269270
271+ Connections {
272+ target: DBusUnitySessionService
273+
274+ function closeAllApps() {
275+ while (true) {
276+ var app = ApplicationManager.get(0);
277+ if (app === null) {
278+ break;
279+ }
280+ ApplicationManager.stopApplication(app.appId);
281+ }
282+ }
283+
284+ onLogoutRequested: {
285+ // TODO: Display a dialog to ask the user to confirm.
286+ DBusUnitySessionService.Logout();
287+ }
288+
289+ onLogoutReady: {
290+ closeAllApps();
291+ Qt.quit();
292+ }
293+ }
294+
270295 Loader {
271296 id: applicationsDisplayLoader
272297 anchors.fill: parent
src/main.cpp+1
@@ -161,6 +161,7 @@ Load the testability driver");
161161
162162 view->setSource(source);
163163 view->setColor("transparent");
164+ QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit()));
164165
165166 if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || isUbuntuMirServer || parser.isSet(fullscreenOption)) {
166167 view->showFullScreen();
tests/plugins/Dash/cardcreator/1.res+14−9
@@ -16,8 +16,8 @@ onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artSh
1616readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1717Item {
1818 id: artShapeHolder;
19− height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height;
20− width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width;
19+ height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
20+ width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
2121 anchors { horizontalCenter: parent.horizontalCenter; }
2222 Loader {
2323 id: artShapeLoader;
@@ -28,14 +28,19 @@ Item {
2828 sourceComponent: UbuntuShape {
2929 id: artShape;
3030 objectName: "artShape";
31− radius: "medium";
32− readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
33− readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
34− Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
35− onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
31+ radius: "medium";
3632 visible: image.status == Image.Ready;
33+ readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
34+ readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
35+ readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
36+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
37+ onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
38+ Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
3739 function updateWidthHeightBindings() {
38− if (aspectSmallerThanImageAspect) {
40+ if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
41+ width = root.fixedArtShapeSize.width;
42+ height = root.fixedArtShapeSize.height;
43+ } else if (aspectSmallerThanImageAspect) {
3944 width = Qt.binding(function() { return !visible ? 0 : image.width });
4045 height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
4146 } else {
@@ -56,7 +61,7 @@ Item {
5661 }
5762 }
5863 }
59−readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2;
64+readonly property int headerHeight: titleLabel.height;
6065Label {
6166 id: titleLabel;
6267 objectName: "titleLabel";
tests/plugins/Dash/cardcreator/2.res+2−1
@@ -46,12 +46,13 @@ Loader {
4646 }
4747 }
4848readonly property size artShapeSize: Qt.size(-1, -1);
49−readonly property int headerHeight: row.height + row.margins * 2;
49+readonly property int headerHeight: row.height;
5050Row {
5151 id: row;
5252 objectName: "outerRow";
5353 property real margins: units.gu(1);
5454 spacing: margins;
55+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
5556 anchors { top: parent.top;
5657 topMargin: units.gu(1);
5758 left: parent.left;
tests/plugins/Dash/cardcreator/3.res+20−15
@@ -16,8 +16,8 @@ onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artSh
1616readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1717Item {
1818 id: artShapeHolder;
19− height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height;
20− width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width;
19+ height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
20+ width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
2121 anchors { horizontalCenter: parent.horizontalCenter; }
2222 Loader {
2323 id: artShapeLoader;
@@ -29,19 +29,24 @@ Item {
2929 id: artShape;
3030 objectName: "artShape";
3131 radius: "medium";
32− readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
33− readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
34− Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
35− onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
3632 visible: image.status == Image.Ready;
37− function updateWidthHeightBindings() {
38− if (aspectSmallerThanImageAspect) {
39− width = Qt.binding(function() { return !visible ? 0 : image.width });
40− height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
41− } else {
42− width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
43− height = Qt.binding(function() { return !visible ? 0 : image.height });
44− }
33+ readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
34+ readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
35+ readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
36+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
37+ onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
38+ Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
39+ function updateWidthHeightBindings() {
40+ if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
41+ width = root.fixedArtShapeSize.width;
42+ height = root.fixedArtShapeSize.height;
43+ } else if (aspectSmallerThanImageAspect) {
44+ width = Qt.binding(function() { return !visible ? 0 : image.width });
45+ height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
46+ } else {
47+ width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
48+ height = Qt.binding(function() { return !visible ? 0 : image.height });
49+ }
4550 }
4651 image: Image {
4752 objectName: "artImage";
@@ -56,7 +61,7 @@ Item {
5661 }
5762 }
5863 }
59−readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2 + subtitleLabel.height + subtitleLabel.anchors.topMargin;
64+readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
6065Label {
6166 id: titleLabel;
6267 objectName: "titleLabel";
tests/plugins/Dash/cardcreator/4.res+2−1
@@ -13,12 +13,13 @@ AbstractButton {
1313 property bool showHeader: true;
1414 implicitWidth: childrenRect.width;
1515readonly property size artShapeSize: Qt.size(-1, -1);
16−readonly property int headerHeight: row.height + row.margins * 2;
16+readonly property int headerHeight: row.height;
1717Row {
1818 id: row;
1919 objectName: "outerRow";
2020 property real margins: units.gu(1);
2121 spacing: margins;
22+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
2223 anchors { top: parent.top;
2324 topMargin: units.gu(1);
2425 left: parent.left;
tests/plugins/Dash/cardcreator/5.res+21−16
@@ -16,8 +16,8 @@ onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artSh
1616readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1717Item {
1818 id: artShapeHolder;
19− height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height;
20− width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width;
19+ height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
20+ width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
2121 anchors { horizontalCenter: parent.horizontalCenter; }
2222 Loader {
2323 id: artShapeLoader;
@@ -29,19 +29,24 @@ Item {
2929 id: artShape;
3030 objectName: "artShape";
3131 radius: "medium";
32− readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
33− readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
34− Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
35− onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
3632 visible: image.status == Image.Ready;
37− function updateWidthHeightBindings() {
38− if (aspectSmallerThanImageAspect) {
39− width = Qt.binding(function() { return !visible ? 0 : image.width });
40− height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
41− } else {
42− width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
43− height = Qt.binding(function() { return !visible ? 0 : image.height });
44− }
33+ readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
34+ readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
35+ readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
36+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
37+ onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
38+ Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
39+ function updateWidthHeightBindings() {
40+ if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
41+ width = root.fixedArtShapeSize.width;
42+ height = root.fixedArtShapeSize.height;
43+ } else if (aspectSmallerThanImageAspect) {
44+ width = Qt.binding(function() { return !visible ? 0 : image.width });
45+ height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
46+ } else {
47+ width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
48+ height = Qt.binding(function() { return !visible ? 0 : image.height });
49+ }
4550 }
4651 image: Image {
4752 objectName: "artImage";
@@ -68,7 +73,7 @@ Loader {
6873 visible: showHeader && status == Loader.Ready;
6974 sourceComponent: ShaderEffect {
7075 id: overlay;
71− height: fixedHeaderHeight != -1 ? fixedHeaderHeight : headerHeight;
76+ height: fixedHeaderHeight > 0 ? fixedHeaderHeight + units.gu(1) * 2 : headerHeight;
7277 opacity: 0.6;
7378 property var source: ShaderEffectSource {
7479 id: shaderSource;
@@ -96,7 +101,7 @@ Loader {
96101 }";
97102 }
98103 }
99−readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2 + subtitleLabel.height + subtitleLabel.anchors.topMargin;
104+readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
100105Label {
101106 id: titleLabel;
102107 objectName: "titleLabel";
tests/plugins/Unity/CMakeLists.txt+1
@@ -1,2 +1,3 @@
11add_subdirectory(Indicators)
22add_subdirectory(Launcher)
3+add_subdirectory(Session)
tests/plugins/Unity/Session/CMakeLists.txtnew file+20
@@ -0,0 +1,20 @@
1+include_directories(
2+ ${CMAKE_CURRENT_BINARY_DIR}
3+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Session
4+)
5+
6+add_definitions(-DSM_BUSNAME=sessionBus)
7+add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
8+add_definitions(-DSESSION_TESTING)
9+
10+### SessionBackendTest
11+set(testBackendCommand dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/sessionbackendtestExec
12+ --parameter -o --parameter ${CMAKE_BINARY_DIR}/sessionbackendtest.xml,xunitxml
13+ --parameter -o --parameter -,txt)
14+add_test(NAME sessionbackendtest COMMAND ${testBackendCommand})
15+add_custom_target(sessionbackendtest ${testBackendCommand})
16+add_executable(sessionbackendtestExec
17+ sessionbackendtest.cpp
18+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Session/dbusunitysessionservice.cpp
19+)
20+qt5_use_modules(sessionbackendtestExec Test Core Qml DBus)
tests/plugins/Unity/Session/sessionbackendtest.cppnew file+64
@@ -0,0 +1,64 @@
1+/*
2+ * Copyright 2013 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+ * Authors:
17+ * Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
18+ */
19+
20+#include <QtTest>
21+#include <QDBusConnection>
22+#include <QDBusMessage>
23+#include <QDBusInterface>
24+#include <QDBusReply>
25+#include <QDBusVariant>
26+
27+#include "dbusunitysessionservice.h"
28+
29+class SessionBackendTest : public QObject
30+{
31+ Q_OBJECT
32+
33+private Q_SLOTS:
34+
35+ void initTestCase() {
36+ }
37+
38+ void testDbusIfaceMethods_data() {
39+ QTest::addColumn<QString>("method");
40+
41+ QTest::newRow("Logout") << "RequestLogout";
42+ }
43+
44+ void testDbusIfaceMethods() {
45+ QFETCH(QString, method);
46+
47+ DBusUnitySessionService dbusUnitySessionService;
48+
49+ QDBusConnection con = QDBusConnection::sessionBus();
50+ QDBusInterface interface ("com.canonical.Unity",
51+ "/com/canonical/Unity/Session",
52+ "com.canonical.Unity.Session",
53+ con);
54+ QDBusReply<void> reply;
55+
56+ QCOMPARE(interface.isValid(), true);
57+ reply = interface.call(method);
58+ QCOMPARE(reply.isValid(), true);
59+
60+ }
61+};
62+
63+QTEST_GUILESS_MAIN(SessionBackendTest)
64+#include "sessionbackendtest.moc"
tests/qmltests/CMakeLists.txt+1
@@ -29,6 +29,7 @@ add_qml_test(Components LazyImage)
2929add_qml_test(Components Rating)
3030add_qml_test(Components ResponsiveFlowView)
3131add_qml_test(Components ResponsiveGridView)
32+add_qml_test(Components ResponsiveVerticalJournal IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
3233add_qml_test(Components SeeMore)
3334add_qml_test(Components Showable)
3435add_qml_test(Components PageHeaderLabel)
tests/qmltests/Components/tst_ResponsiveVerticalJournal.qmlnew file+183
@@ -0,0 +1,183 @@
1+/*
2+ * Copyright 2013-2014 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.0
18+import QtTest 1.0
19+import ".."
20+import "../../../qml/Components"
21+import Ubuntu.Components.ListItems 0.1 as ListItem
22+import Ubuntu.Components 0.1
23+import Utils 0.1
24+import Unity.Test 0.1 as UT
25+
26+Item {
27+ width: units.gu(80) + controls.width
28+ height: units.gu(80)
29+
30+ Column {
31+ id: controls
32+ width: units.gu(40)
33+ height: parent.height
34+ anchors.top: parent.top
35+ anchors.right: parent.right
36+ ListItem.ValueSelector {
37+ id: cardSizeSelector
38+ text: "card-size"
39+ // small, medium, large card sizes
40+ values: [units.gu(12), units.gu(18.5), units.gu(38)]
41+ selectedIndex: 0
42+ }
43+ ListItem.ValueSelector {
44+ id: minColumnSpacingSelector
45+ text: "minColumnSpacing"
46+ values: [0, units.gu(2), units.gu(8), units.gu(25)]
47+ selectedIndex: 0
48+ }
49+ ListItem.ValueSelector {
50+ id: rowSpacingSelector
51+ text: "rowSpacing"
52+ values: [units.gu(1), units.gu(2), units.gu(4), units.gu(8)]
53+ selectedIndex: 1
54+ }
55+ }
56+
57+ ListModel {
58+ id: fakeModel
59+ ListElement { name: "A" }
60+ ListElement { name: "B" }
61+ ListElement { name: "C" }
62+ ListElement { name: "D" }
63+ ListElement { name: "E" }
64+ ListElement { name: "F" }
65+ ListElement { name: "G" }
66+ ListElement { name: "H" }
67+ ListElement { name: "I" }
68+ ListElement { name: "J" }
69+ ListElement { name: "K" }
70+ ListElement { name: "L" }
71+ ListElement { name: "M" }
72+ ListElement { name: "N" }
73+ ListElement { name: "O" }
74+ ListElement { name: "P" }
75+ ListElement { name: "Q" }
76+ ListElement { name: "R" }
77+ ListElement { name: "S" }
78+ ListElement { name: "T" }
79+ ListElement { name: "U" }
80+ }
81+
82+ SortFilterProxyModel {
83+ id: wrappedFakeModel
84+ model: fakeModel
85+ }
86+
87+ Rectangle {
88+ id: journalRect
89+ height: parent.height
90+ color: "grey"
91+ anchors.top: parent.top
92+ anchors.left: parent.left
93+ anchors.right: controls.left
94+
95+ ResponsiveVerticalJournal {
96+ id: journal
97+ anchors.fill: parent
98+ model: wrappedFakeModel
99+ minimumColumnSpacing: minColumnSpacingSelector.values[minColumnSpacingSelector.selectedIndex]
100+ rowSpacing: rowSpacingSelector.values[rowSpacingSelector.selectedIndex]
101+ columnWidth: cardSizeSelector.values[cardSizeSelector.selectedIndex]
102+
103+ delegate: Rectangle {
104+ id: delegateItem
105+ // So that it can be identified by test code
106+ property bool isJournalDelegate: true
107+ objectName: "delegate" + index
108+ color: "grey"
109+ border.color: "red"
110+ border.width: 1
111+
112+ // width derived from Card's template['card-size']
113+ width: cardSizeSelector.values[cardSizeSelector.selectedIndex]
114+ height: Math.max(units.gu(8), Math.floor(Math.random() * 300))
115+
116+ Rectangle {
117+ color: "green"
118+ anchors.centerIn: parent
119+ width: units.gu(6)
120+ height: units.gu(6)
121+ Text {
122+ anchors.centerIn: parent
123+ text: name
124+ }
125+ }
126+
127+ Text { x:0; y:0; text:"(" + parent.x + ", " + parent.y + ")"}
128+ }
129+ }
130+ }
131+
132+ UT.UnityTestCase {
133+ name: "ResponsiveVerticalJournal"
134+ when: windowShown
135+
136+ function test_minimumColumnSpacing_data() {
137+ return [{minColumnSpacingIndex: 0, expectedColumns: 2},
138+ {minColumnSpacingIndex: 1, expectedColumns: 2},
139+ {minColumnSpacingIndex: 2, expectedColumns: 1}]
140+ }
141+
142+ // Test how minimumColumnSpacing affects column count.
143+ function test_minimumColumnSpacing(data) {
144+ cardSizeSelector.selectedIndex = 2 // large card
145+
146+ minColumnSpacingSelector.selectedIndex = data.minColumnSpacingIndex
147+
148+ tryCompareFunction(countJournalDelegatesOnFirstRow, data.expectedColumns)
149+ }
150+
151+ function test_maximumNumberOfColumns_data() {
152+ return [{cardSizeIndex: 0, expectedColumns: 6},
153+ {cardSizeIndex: 1, expectedColumns: 4},
154+ {cardSizeIndex: 2, expectedColumns: 2}]
155+ }
156+
157+ // Test how maximumNumberOfColumns and columnWidth affect column count.
158+ function test_maximumNumberOfColumns(data) {
159+ minColumnSpacingSelector.selectedIndex = 0 // no spacing
160+
161+ cardSizeSelector.selectedIndex = data.cardSizeIndex // columnWidth
162+
163+ tryCompareFunction(countJournalDelegatesOnFirstRow, data.expectedColumns)
164+ }
165+
166+ function countJournalDelegatesOnFirstRow() {
167+ return __countJournalDelegatesOnFirstRow(journal.visibleChildren, 0)
168+ }
169+
170+ function __countJournalDelegatesOnFirstRow(objList, total) {
171+ for (var i = 0; i < objList.length; ++i) {
172+ var child = objList[i];
173+ if (child.isJournalDelegate !== undefined && child.y === 0) {
174+ ++total;
175+ } else {
176+ total = __countJournalDelegatesOnFirstRow(
177+ child.visibleChildren, total)
178+ }
179+ }
180+ return total
181+ }
182+ }
183+}
tests/qmltests/Dash/tst_Card.qml+9
@@ -305,6 +305,15 @@ Rectangle {
305305 }
306306 }
307307
308+ function test_art_shape_fixed_size() {
309+ selector.selectedIndex = 6;
310+ card.fixedArtShapeSize = Qt.size( units.gu(8), units.gu(4) );
311+ waitForRendering(card);
312+ tryCompare(art, "width", units.gu(8));
313+ tryCompare(art, "height", units.gu(4));
314+ tryCompare(art, "fixedArtShapeSizeAspect", 2);
315+ }
316+
308317 function test_art_layout_data() {
309318 return [
310319 { tag: "Vertical", left: function() { return units.gu(1); }, index: 0},
tests/qmltests/Notifications/tst_Notifications.qml+29−12
@@ -21,6 +21,7 @@ import "../../../qml/Notifications"
2121import Ubuntu.Components 0.1
2222import Unity.Test 0.1
2323import Unity.Notifications 1.0
24+import QtMultimedia 5.0
2425
2526Row {
2627 id: rootRow
@@ -245,7 +246,8 @@ Row {
245246 nonShapedIcon: false,
246247 secondaryIconVisible: true,
247248 buttonRowVisible: true,
248− buttonTinted: true
249+ buttonTinted: true,
250+ hasSound: false
249251 },
250252 {
251253 tag: "Ephemeral notification - icon-summary layout",
@@ -263,12 +265,15 @@ Row {
263265 nonShapedIcon: false,
264266 secondaryIconVisible: true,
265267 buttonRowVisible: false,
266− buttonTinted: false
268+ buttonTinted: false,
269+ hasSound: false
267270 },
268271 {
269272 tag: "Ephemeral notification - check suppression of secondary icon for icon-summary layout",
270273 type: Notification.Ephemeral,
271− hints: {"x-canonical-private-button-tint": "false"},
274+ hints: {"x-canonical-private-button-tint": "false",
275+ "sound-file": "dummy.ogg",
276+ "suppress-sound": "true"},
272277 summary: "New comment successfully published",
273278 body: "",
274279 icon: "",
@@ -282,12 +287,14 @@ Row {
282287 nonShapedIcon: false,
283288 secondaryIconVisible: true,
284289 buttonRowVisible: false,
285− buttonTinted: false
290+ buttonTinted: false,
291+ hasSound: false
286292 },
287293 {
288294 tag: "Interactive notification",
289295 type: Notification.Interactive,
290− hints: {"x-canonical-private-button-tint": "false"},
296+ hints: {"x-canonical-private-button-tint": "false",
297+ "sound-file": "dummy.ogg"},
291298 summary: "Interactive notification",
292299 body: "This is a notification that can be clicked",
293300 icon: "../graphics/avatars/amanda.png",
@@ -300,12 +307,14 @@ Row {
300307 nonShapedIcon: false,
301308 secondaryIconVisible: false,
302309 buttonRowVisible: false,
303− buttonTinted: false
310+ buttonTinted: false,
311+ hasSound: true
304312 },
305313 {
306314 tag: "Snap Decision without secondary icon and no button-tint",
307315 type: Notification.SnapDecision,
308− hints: {"x-canonical-private-button-tint": "false"},
316+ hints: {"x-canonical-private-button-tint": "false",
317+ "sound-file": "dummy.ogg"},
309318 summary: "Bro Coly",
310319 body: "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.",
311320 icon: "../graphics/avatars/anna_olsson.png",
@@ -319,12 +328,14 @@ Row {
319328 nonShapedIcon: false,
320329 secondaryIconVisible: false,
321330 buttonRowVisible: true,
322− buttonTinted: false
331+ buttonTinted: false,
332+ hasSound: true
323333 },
324334 {
325335 tag: "Ephemeral notification",
326336 type: Notification.Ephemeral,
327− hints: {"x-canonical-private-button-tint": "false"},
337+ hints: {"x-canonical-private-button-tint": "false",
338+ "sound-file": "dummy.ogg"},
328339 summary: "Cole Raby",
329340 body: "I did not expect it to be that late.",
330341 icon: "../graphics/avatars/funky.png",
@@ -337,13 +348,15 @@ Row {
337348 nonShapedIcon: false,
338349 secondaryIconVisible: true,
339350 buttonRowVisible: false,
340− buttonTinted: false
351+ buttonTinted: false,
352+ hasSound: true
341353 },
342354 {
343355 tag: "Ephemeral notification with non-shaped icon",
344356 type: Notification.Ephemeral,
345357 hints: {"x-canonical-private-button-tint": "false",
346− "x-canonical-non-shaped-icon": "true"},
358+ "x-canonical-non-shaped-icon": "true",
359+ "sound-file": "dummy.ogg"},
347360 summary: "Contacts",
348361 body: "Synchronised contacts-database with cloud-storage.",
349362 icon: "../graphics/applicationIcons/contacts-app.png",
@@ -356,7 +369,8 @@ Row {
356369 nonShapedIcon: true,
357370 secondaryIconVisible: false,
358371 buttonRowVisible: false,
359− buttonTinted: false
372+ buttonTinted: false,
373+ hasSound: true
360374 }
361375 ]
362376 }
@@ -419,6 +433,9 @@ Row {
419433 compare(bodyLabel.visible, data.bodyVisible, "body-text visibility is incorrect")
420434 compare(buttonRow.visible, data.buttonRowVisible, "button visibility is incorrect")
421435
436+ var audioItem = findInvisibleChild(notification, "sound")
437+ tryCompare(audioItem, "playbackState", data.hasSound ? Audio.PlayingState : Audio.StoppedState)
438+
422439 if(data.buttonRowVisible) {
423440 var buttonCancel = findChild(buttonRow, "button1")
424441 var buttonAccept = findChild(buttonRow, "button0")