on xenial help sign in
more shuffling around. fixed tests
faa9e8dNick Dedekind
CMakeLists.txt+1
@@ -132,6 +132,7 @@ install(FILES ${QML_JS_FILES}
132
132
133# add subdirectories to build
133# add subdirectories to build
134add_subdirectory(plugins)
134add_subdirectory(plugins)
135+add_subdirectory(Panel)
135
136
136# install subdirectories
137# install subdirectories
137set(QML_DIRS
138set(QML_DIRS
Panel/CMakeLists.txtnew file+1
@@ -0,0 +1 @@
1+add_subdirectory(indicatorsclient)
Panel/IndicatorItem.qml+5−4
@@ -21,10 +21,10 @@ import IndicatorsClient 0.1 as IndicatorsClient
21Item {
21Item {
22 id: indicatorItem
22 id: indicatorItem
23
23
24− property alias iconUrl: loader.source
24+ property alias iconQml: loader.source
25 property bool highlighted: false
25 property bool highlighted: false
26 property bool dimmed: false
26 property bool dimmed: false
27− property var initialProperties: undefined
27+ property var indicatorProperties: undefined
28
28
29 opacity: dimmed ? 0.4 : 1
29 opacity: dimmed ? 0.4 : 1
30
30
@@ -39,9 +39,9 @@ Item {
39 if (status == Loader.Ready) {
39 if (status == Loader.Ready) {
40 item.height = Qt.binding(function() { return indicatorItem.height; })
40 item.height = Qt.binding(function() { return indicatorItem.height; })
41
41
42− for(var pName in initialProperties) {
42+ for(var pName in indicatorProperties) {
43 if (item.hasOwnProperty(pName)) {
43 if (item.hasOwnProperty(pName)) {
44− item[pName] = initialProperties[pName]
44+ item[pName] = indicatorProperties[pName]
45 }
45 }
46 }
46 }
47 }
47 }
@@ -55,6 +55,7 @@ Item {
55
55
56 Rectangle {
56 Rectangle {
57 color: "#dd4814"
57 color: "#dd4814"
58+ objectName: "highlight"
58 height: units.dp(2)
59 height: units.dp(2)
59 width: parent.width
60 width: parent.width
60 anchors.top: parent.bottom
61 anchors.top: parent.bottom
Panel/IndicatorRow.qml+3−2
@@ -60,8 +60,9 @@ Item {
60
60
61 property int ownIndex: index
61 property int ownIndex: index
62
62
63− iconUrl: model.iconUrl
63+ iconQml: model.iconQml
64− initialProperties : model.initialProperties
64+
65+ indicatorProperties : model.indicatorProperties
65 highlighted: indicatorRow.state == "reveal" || indicatorRow.state == "locked" || indicatorRow.state == "commit" ? ownIndex == indicatorRow.currentItemIndex : false
66 highlighted: indicatorRow.state == "reveal" || indicatorRow.state == "locked" || indicatorRow.state == "commit" ? ownIndex == indicatorRow.currentItemIndex : false
66 dimmed: { //See FIXME in Indicators regarding the "states" change
67 dimmed: { //See FIXME in Indicators regarding the "states" change
67 if (indicatorRow.state == "initial" || indicatorRow.state == "") {
68 if (indicatorRow.state == "initial" || indicatorRow.state == "") {
Panel/Indicators.qml+1−3
@@ -16,7 +16,6 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19−import IndicatorsClient 0.1 as IndicatorsClient
20
19
21import "../Components"
20import "../Components"
22import "../Components/Math.js" as MathLocal
21import "../Components/Math.js" as MathLocal
@@ -222,9 +221,8 @@ Showable {
222
221
223 }
222 }
224
223
225− IndicatorsClient.IndicatorsModel {
224+ IndicatorsDataModel {
226 id: indicatorsModel
225 id: indicatorsModel
227− Component.onCompleted: load()
228 }
226 }
229
227
230 Connections {
228 Connections {
plugins/IndicatorsClient/resources/qml/DatetimeIndicatorIcon.qml → Panel/Indicators/DatetimeIndicatorIcon.qmlrenamed+1−1
@@ -14,7 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 *
16 * Authors:
16 * Authors:
17− * Renato Araujo Oliveira Filho <renato@canonical.com>
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18 */
18 */
19
19
20import QtQuick 2.0
20import QtQuick 2.0
plugins/IndicatorsClient/resources/qml/DatetimeIndicatorPage.qml → Panel/Indicators/DatetimeIndicatorPage.qmlrenamed+1−1
@@ -32,7 +32,7 @@ Flickable {
32 left: parent.left
32 left: parent.left
33 right: parent.right
33 right: parent.right
34 }
34 }
35− source: "qrc:/indicatorsclient/artwork/datetime/time_and_date@18.png"
35+ source: "../graphics/time_and_date@18.png"
36 fillMode: Image.PreserveAspectFit
36 fillMode: Image.PreserveAspectFit
37 }
37 }
38
38
plugins/IndicatorsClient/resources/qml/DefaultIndicatorIcon.qml → Panel/Indicators/DefaultIndicatorIcon.qmlrenamed+3−3
@@ -14,7 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 *
16 * Authors:
16 * Authors:
17− * Renato Araujo Oliveira Filho <renato@canonical.com>
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18 */
18 */
19
19
20import QtQuick 2.0
20import QtQuick 2.0
@@ -43,8 +43,8 @@ IndicatorsClient.IndicatorIcon {
43 id: itemImage
43 id: itemImage
44 objectName: "itemImage"
44 objectName: "itemImage"
45 visible: source != ""
45 visible: source != ""
46− height: units.gu(2.5)
46+ height: indicatorIcon.iconSize
47− width: units.gu(2.5)
47+ width: indicatorIcon.iconSize
48 anchors.verticalCenter: parent.verticalCenter
48 anchors.verticalCenter: parent.verticalCenter
49 }
49 }
50
50
plugins/IndicatorsClient/resources/qml/DefaultIndicatorPage.qml → Panel/Indicators/DefaultIndicatorPage.qmlrenamed+1−1
@@ -14,7 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 *
16 * Authors:
16 * Authors:
17− * Renato Araujo Oliveira Filho <renato@canonical.com>
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18 */
18 */
19
19
20import QtQuick 2.0
20import QtQuick 2.0
plugins/IndicatorsClient/indicators/sound/indicatorclient_sound.h → Panel/Indicators/MessagingIndicatorIcon.qmlrenamed+6−15
@@ -14,21 +14,12 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 *
16 * Authors:
16 * Authors:
17− * Renato Araujo Oliveira Filho <renato@canonical.com>
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18 */
18 */
19
19
20−#ifndef INDICATORCLIENT_SOUND_H
20+import QtQuick 2.0
21−#define INDICATORCLIENT_SOUND_H
22
21
23−#include "indicatorclient_common.h"
22+DefaultIndicatorIcon {
24−
23+ // default the icon so we have something to show when we don't have the bus.
25−class IndicatorClientSound : public IndicatorClientCommon
24+ iconSource: "image://gicon/messages"
26−{
27− Q_OBJECT
28−public:
29− IndicatorClientSound(QObject *parent=0);
30−
31− void init(const QSettings& settings);
32−};
25+}
33−
34−#endif
plugins/IndicatorsClient/resources/qml/MessagingIndicatorPage.qml → Panel/Indicators/MessagingIndicatorPage.qmlrenamed+1−1
@@ -14,7 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 *
16 * Authors:
16 * Authors:
17− * Renato Araujo Oliveira Filho <renato.filho@canonical.com>
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18 */
18 */
19
19
20import QtQuick 2.0
20import QtQuick 2.0
plugins/IndicatorsClient/resources/qml/NetworkIndicatorIcon.qml → Panel/Indicators/NetworkIndicatorIcon.qmlrenamed+3−3
@@ -14,7 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 *
16 * Authors:
16 * Authors:
17− * Renato Araujo Oliveira Filho <renato@canonical.com>
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18 */
18 */
19
19
20import QtQuick 2.0
20import QtQuick 2.0
@@ -34,8 +34,8 @@ IndicatorsClient.IndicatorIcon {
34 objectName: "itemImage"
34 objectName: "itemImage"
35 source: get_icon_for_signal(connectionState, signalStrength)
35 source: get_icon_for_signal(connectionState, signalStrength)
36 visible: source != ""
36 visible: source != ""
37− height: units.gu(2.5)
37+ height: indicatorIcon.iconSize
38− width: units.gu(2.5)
38+ width: indicatorIcon.iconSize
39 anchors {
39 anchors {
40 verticalCenter: parent.verticalCenter
40 verticalCenter: parent.verticalCenter
41 horizontalCenter: parent.horizontalCenter
41 horizontalCenter: parent.horizontalCenter
plugins/IndicatorsClient/resources/qml/NetworkIndicatorPage.qml → Panel/Indicators/NetworkIndicatorPage.qmlrenamed+12−4
@@ -19,8 +19,8 @@
19
19
20import QtQuick 2.0
20import QtQuick 2.0
21import IndicatorsClient 0.1 as IndicatorsClient
21import IndicatorsClient 0.1 as IndicatorsClient
22+import IndicatorsClient.Network 0.1 as ICNetwork
22import Ubuntu.Components 0.1
23import Ubuntu.Components 0.1
23−import NetworkSettings 0.1
24
24
25PageStack {
25PageStack {
26 id: _network
26 id: _network
@@ -43,12 +43,20 @@ PageStack {
43 }
43 }
44 }
44 }
45
45
46+ Component {
47+ id: passwordPageComponent
48+
49+ ICNetwork.PasswordPage {
50+ agent: networkAgent
51+ token: token
52+ }
53+ }
54+
46− NetworkAgent {
55+ ICNetwork.NetworkAgent {
47 id: networkAgent
56 id: networkAgent
48
57
49 onSecretRequested: {
58 onSecretRequested: {
50− _network.push(Qt.createComponent("PasswordPage.qml"),
59+ _network.push(passwordPageComponent)
51− {"agent" : networkAgent, "token" : token})
52 }
60 }
53 }
61 }
54
62
plugins/IndicatorsClient/indicators/sound/indicatorclient_sound.cpp → Panel/Indicators/SoundIndicatorIcon.qmlrenamed+5−13
@@ -14,20 +14,12 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 *
16 * Authors:
16 * Authors:
17− * Renato Araujo Oliveira Filho <renato@canonical.com>
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18 */
18 */
19
19
20−#include "indicatorclient_sound.h"
20+import QtQuick 2.0
21
21
22−IndicatorClientSound::IndicatorClientSound(QObject *parent)
22+DefaultIndicatorIcon {
23− : IndicatorClientCommon(parent)
23+ // default the icon so we have something to show when we don't have the bus.
24−{
24+ iconSource: "image://gicon/audio-volume-high"
25− setTitle("Sound");
26− setPriority(IndicatorPriority::SOUND);
27−}
28−
29−
30−void IndicatorClientSound::init(const QSettings& settings)
31−{
32− IndicatorClientCommon::init(settings);
33}
25}
Panel/IndicatorsDataModel.qmlnew file+68
@@ -0,0 +1,68 @@
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+ * Renato Araujo Oliveira Filho <renato@canonical.com>
18+ */
19+
20+import QtQuick 2.0
21+import IndicatorsClient 0.1
22+import Utils 0.1
23+
24+IndicatorsModel {
25+ id: ic_model
26+
27+ Component.onCompleted: load()
28+
29+ property var applicationPaths: ApplicationPaths {}
30+
31+ indicatorData : {
32+ 'indicator-messaging' : {
33+ 'title': 'Messaging',
34+ 'description' : '',
35+ 'priority': 10,
36+ 'iconQml' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorIcon.qml',
37+ 'pageQml' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/MessagingIndicatorPage.qml'
38+ },
39+ 'indicator-sound' : {
40+ 'title': 'Sound',
41+ 'description' : '',
42+ 'priority': 20,
43+ 'iconQml' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/SoundIndicatorIcon.qml',
44+ 'pageQml' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
45+ },
46+ 'indicator-network' : {
47+ 'title': 'Networks',
48+ 'description' : '',
49+ 'priority': 30,
50+ 'iconQml' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorIcon.qml',
51+ 'pageQml' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/NetworkIndicatorPage.qml'
52+ },
53+ 'indicator-power' : {
54+ 'title': 'Battery',
55+ 'description' : '',
56+ 'priority': 40,
57+ 'iconQml' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorIcon.qml',
58+ 'pageQml' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DefaultIndicatorPage.qml'
59+ },
60+ 'indicator-datetime' : {
61+ 'title': 'Date and Time',
62+ 'description' : '',
63+ 'priority': 100,
64+ 'iconQml' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorIcon.qml',
65+ 'pageQml' : applicationPaths.shellAppDirectory()+'/Panel/Indicators/DatetimeIndicatorPage.qml'
66+ }
67+ }
68+}
Panel/MenuContent.qml+3−3
@@ -94,7 +94,7 @@ Rectangle {
94
94
95 width: menus.width
95 width: menus.width
96 height: menus.height
96 height: menus.height
97− source: pageUrl
97+ source: pageQml
98 visible: content.__shown
98 visible: content.__shown
99 onVisibleChanged: {
99 onVisibleChanged: {
100 // Reset the indicator states
100 // Reset the indicator states
@@ -106,9 +106,9 @@ Rectangle {
106
106
107 onStatusChanged: {
107 onStatusChanged: {
108 if (status == Loader.Ready) {
108 if (status == Loader.Ready) {
109− for(var pName in initialProperties) {
109+ for(var pName in indicatorProperties) {
110 if (item.hasOwnProperty(pName)) {
110 if (item.hasOwnProperty(pName)) {
111− item[pName] = initialProperties[pName]
111+ item[pName] = indicatorProperties[pName]
112 }
112 }
113 }
113 }
114 if (contentActive && menus.visible) {
114 if (contentActive && menus.visible) {
Panel/Menus/Overview/OverviewGrid.qml+19−24
@@ -56,34 +56,29 @@ Item {
56 interactive: false
56 interactive: false
57 delegate:
57 delegate:
58 AbstractButton {
58 AbstractButton {
59+ id: indicatorButton
59 objectName: "overviewGridButton" + index
60 objectName: "overviewGridButton" + index
60 width: grid.cellWidth
61 width: grid.cellWidth
61 height: grid.cellHeight
62 height: grid.cellHeight
62− Image {
63− id: imageIcon
64− objectName: "overviewGridButtonImage"
65− source: iconSource
66− width: units.gu(4)
67− height: units.gu(4)
68− anchors {
69− centerIn: parent
70− verticalCenterOffset: -units.gu(1)
71− }
72− sourceSize.width: width
73− sourceSize.height: height
74− visible: labelIcon.text === ""
75− }
76
63
77− Label {
64+ Loader {
78− id: labelIcon
65+ id: loader
79− text: label
66+ source: iconQml
80− color: "#f3f3e7"
67+
81− opacity: 0.8
68+ onStatusChanged: {
82− font.family: "Ubuntu"
69+ item.width = units.gu(5)
83− fontSize: "large"
70+ item.height = units.gu(5)
84− anchors {
71+
85− centerIn: parent
72+ item.x = Qt.binding(function() { return indicatorButton.width/2 - item.width/2; })
86− verticalCenterOffset: -units.gu(1)
73+ item.y = Qt.binding(function() { return indicatorButton.height/2 - item.height/2 - units.gu(1); })
74+
75+ if (status == Loader.Ready) {
76+ for(var pName in indicatorProperties) {
77+ if (item.hasOwnProperty(pName)) {
78+ item[pName] = indicatorProperties[pName]
79+ }
80+ }
81+ }
87 }
82 }
88 }
83 }
89
84
Panel/graphics/time_and_date@18.pngnew file

Binary file not shown.

plugins/IndicatorsClient/client/CMakeLists.txt → Panel/indicatorsclient/CMakeLists.txtrenamed−5
@@ -9,13 +9,8 @@ set(INDICATORS_CLIENT_SRC
9set(INDICATORS_CLIENT_HEADERS
9set(INDICATORS_CLIENT_HEADERS
10 indicatorsclient.h
10 indicatorsclient.h
11)
11)
12−
13−qt5_add_resources(INDICATORS_CLIENT_RESOURCES_RCC
14− indicatorsclient.qrc)
15−
16add_executable(${INDICATORS_CLIENT_APP}
12add_executable(${INDICATORS_CLIENT_APP}
17 ${INDICATORS_CLIENT_SRC}
13 ${INDICATORS_CLIENT_SRC}
18− ${INDICATORS_CLIENT_RESOURCES_RCC}
19 ${INDICATORS_CLIENT_HEADERS}
14 ${INDICATORS_CLIENT_HEADERS}
20)
15)
21
16
plugins/IndicatorsClient/indicators/messaging/indicatorclient_messaging.h → Panel/indicatorsclient/IndicatorsClient.qmlrenamed+19−15
@@ -15,24 +15,28 @@
15 *
15 *
16 * Authors:
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18− * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
18 */
20
19
21−#ifndef INDICATORCLIENT_MESSAGING_H
20+import QtQuick 2.0
22−#define INDICATORCLIENT_MESSAGING_H
21+import Ubuntu.Components 0.1
22+import Ubuntu.Components.ListItems 0.1 as ListItem
23
23
24−#include "indicatorclient_common.h"
24+Rectangle {
25+ color: "black"
26+ id: root
25
27
26−class IndicatorClientMessaging : public IndicatorClientCommon
28+ PageStack {
27−{
29+ id: pages
28− Q_OBJECT
29−public:
30− IndicatorClientMessaging(QObject *parent=0);
31− ~IndicatorClientMessaging();
32
30
33− void init(const QSettings& settings);
31+ anchors.fill: parent
32+ Component.onCompleted: root.reset()
33+ }
34
34
35− QUrl pageComponentSource() const;
35+ function reset() {
36−};
36+ pages.clear();
37−
37+ var component = Qt.createComponent("IndicatorsList.qml")
38−#endif
38+ var page = component.createObject(pages)
39+ console.log(component.errorString())
40+ pages.push(page);
41+ }
42+}
Panel/indicatorsclient/IndicatorsList.qmlnew 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+ * Renato Araujo Oliveira Filho <renato@canonical.com>
18+ */
19+
20+import QtQuick 2.0
21+import Ubuntu.Components 0.1
22+import Ubuntu.Components.ListItems 0.1 as ListItem
23+import IndicatorsClient 0.1 as IndicatorsClient
24+import ".."
25+
26+Page {
27+ id: page
28+ anchors.fill: parent
29+ title: "Plugin list"
30+
31+ IndicatorsDataModel {
32+ id: indicatorsModel
33+ }
34+
35+ ListView {
36+ id: mainMenu
37+ objectName: "mainMenu"
38+ anchors.fill: parent
39+ model: indicatorsModel
40+
41+ delegate: IndicatorsClient.Menu {
42+ anchors.left: parent.left
43+ anchors.right: parent.right
44+ height: implicitHeight
45+ progression: isValid
46+ objectName: identifier
47+
48+ Label {
49+ anchors.left: parent.left
50+ anchors.leftMargin: units.gu(0.5)
51+ anchors.verticalCenter: parent.verticalCenter
52+ text: title
53+ }
54+
55+ onClicked: {
56+ if (progression) {
57+ var page = Qt.createComponent("IndicatorsPage.qml")
58+ pages.push(page.createObject(pages), {"indicatorProperties" : model.indicatorProperties, "pageQml" : model.pageQml})
59+ }
60+ }
61+ }
62+ }
63+}
64+
plugins/IndicatorsClient/indicators/messaging/indicatorclient_messaging.cpp → Panel/indicatorsclient/IndicatorsPage.qmlrenamed+24−20
@@ -15,31 +15,35 @@
15 *
15 *
16 * Authors:
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18− * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
18 */
20
19
21−#include "indicatorclient_messaging.h"
20+import QtQuick 2.0
21+import Ubuntu.Components 0.1
22
22
23−#include <QUrl>
23+Page {
24−#include <QtPlugin>
24+ id: _page
25
25
26−IndicatorClientMessaging::IndicatorClientMessaging(QObject *parent)
26+ title: indicatorProperties && indicatorProperties.title ? indicatorProperties.title : ""
27− : IndicatorClientCommon(parent)
27+ property variant indicatorProperties
28−{
28+ property alias pageQml : page_loader.source
29− setTitle("Messages");
30− setPriority(IndicatorPriority::MESSAGING);
31−}
32
29
33−IndicatorClientMessaging::~IndicatorClientMessaging()
30+ anchors.fill: parent
34−{
35−}
36
31
37−void IndicatorClientMessaging::init(const QSettings& settings)
32+ Loader {
38−{
33+ id: page_loader
39− IndicatorClientCommon::init(settings);
34+ objectName: "page_loader"
40−}
35+
36+ anchors.fill: parent
41
37
42−QUrl IndicatorClientMessaging::pageComponentSource() const
38+ onStatusChanged: {
43−{
39+ if (status == Loader.Ready) {
44− return QUrl("qrc:/indicatorsclient/qml/MessagingIndicatorPage.qml");
40+ for(var pName in indicatorProperties) {
41+ if (item.hasOwnProperty(pName)) {
42+ item[pName] = indicatorProperties[pName]
43+ }
44+ }
45+ item.start()
46+ }
47+ }
48+ }
45}
49}
plugins/IndicatorsClient/client/indicatorsclient.cpp → Panel/indicatorsclient/indicatorsclient.cpprenamed+4−1
@@ -19,6 +19,7 @@
19 */
19 */
20
20
21#include "indicatorsclient.h"
21#include "indicatorsclient.h"
22+#include "paths.h"
22
23
23#include <QQuickView>
24#include <QQuickView>
24#include <QQmlContext>
25#include <QQmlContext>
@@ -44,8 +45,10 @@ IndicatorsClient::~IndicatorsClient()
44void IndicatorsClient::setupUI()
45void IndicatorsClient::setupUI()
45{
46{
46 m_view = new QQuickView;
47 m_view = new QQuickView;
48+ m_view->engine()->setBaseUrl(QUrl::fromLocalFile(::shellAppDirectory()+"Panel/indicatorsclient/"));
49+ m_view->engine()->addImportPath(::shellImportPath());
47
50
48− m_view->setSource(QUrl("qrc:qml/IndicatorsClient.qml"));
51+ m_view->setSource(QUrl("IndicatorsClient.qml"));
49 m_view->setResizeMode(QQuickView::SizeRootObjectToView);
52 m_view->setResizeMode(QQuickView::SizeRootObjectToView);
50
53
51 //Usable size on desktop
54 //Usable size on desktop
plugins/IndicatorsClient/client/indicatorsclient.h → Panel/indicatorsclient/indicatorsclient.hrenamed

The content is the same.

plugins/IndicatorsClient/client/indicatorsclient.qrc → Panel/indicatorsclient/indicatorsclient.qrcrenamed

The content is the same.

plugins/IndicatorsClient/client/main.cpp → Panel/indicatorsclient/main.cpprenamed

The content is the same.

plugins/IndicatorsClient/client/qml/IndicatorsClient.qml → Panel/indicatorsclient/qml/IndicatorsClient.qmlrenamed

The content is the same.

plugins/IndicatorsClient/client/qml/IndicatorsList.qml → Panel/indicatorsclient/qml/IndicatorsList.qmlrenamed

The content is the same.

plugins/IndicatorsClient/client/qml/IndicatorsPage.qml → Panel/indicatorsclient/qml/IndicatorsPage.qmlrenamed

The content is the same.

main.cpp+6−7
@@ -22,13 +22,14 @@
22#include <QtGui/QIcon>
22#include <QtGui/QIcon>
23#include <QtGui/QGuiApplication>
23#include <QtGui/QGuiApplication>
24#include <QtQml/QQmlEngine>
24#include <QtQml/QQmlEngine>
25+#include <QtQml/QQmlContext>
25#include <qpa/qplatformnativeinterface.h>
26#include <qpa/qplatformnativeinterface.h>
26#include <QLibrary>
27#include <QLibrary>
27#include <libintl.h>
28#include <libintl.h>
28
29
29// local
30// local
30−#include "paths.h"
31#include "MouseTouchAdaptor.h"
31#include "MouseTouchAdaptor.h"
32+#include "paths.h"
32
33
33namespace {
34namespace {
34/* When you append and import path to the list of import paths it will be the *last*
35/* When you append and import path to the list of import paths it will be the *last*
@@ -88,7 +89,7 @@ int main(int argc, char** argv)
88 QQuickView* view = new QQuickView();
89 QQuickView* view = new QQuickView();
89 view->setResizeMode(QQuickView::SizeRootObjectToView);
90 view->setResizeMode(QQuickView::SizeRootObjectToView);
90 view->setTitle("Qml Phone Shell");
91 view->setTitle("Qml Phone Shell");
91− view->engine()->setBaseUrl(QUrl::fromLocalFile(shellAppDirectory()));
92+ view->engine()->setBaseUrl(QUrl::fromLocalFile(::shellAppDirectory()));
92 if (args.contains(QLatin1String("-frameless"))) {
93 if (args.contains(QLatin1String("-frameless"))) {
93 view->setFlags(Qt::FramelessWindowHint);
94 view->setFlags(Qt::FramelessWindowHint);
94 }
95 }
@@ -111,12 +112,10 @@ int main(int argc, char** argv)
111 nativeInterface->setProperty("ubuntuSessionType", 1);
112 nativeInterface->setProperty("ubuntuSessionType", 1);
112 view->setProperty("role", 2); // INDICATOR_ACTOR_ROLE
113 view->setProperty("role", 2); // INDICATOR_ACTOR_ROLE
113
114
114− QObject::connect(view->engine(), SIGNAL(quit()), qApp, SLOT(quit()));
115−
116 QUrl source("Shell.qml");
115 QUrl source("Shell.qml");
117− view->engine()->addImportPath(shellAppDirectory());
116+ view->engine()->addImportPath(::shellAppDirectory());
118− view->engine()->addImportPath(shellImportPath());
117+ view->engine()->addImportPath(::shellImportPath());
119− appendImportPath(view->engine(), fakePluginsImportPath());
118+ appendImportPath(view->engine(), ::fakePluginsImportPath());
120 view->setSource(source);
119 view->setSource(source);
121 view->setColor("transparent");
120 view->setColor("transparent");
122
121
paths.h.in+6−1
@@ -17,6 +17,9 @@
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
18 */
19
19
20+#ifndef PATHS_H
21+#define PATHS_H
22+
20// Qt
23// Qt
21#include <QtCore/QCoreApplication>
24#include <QtCore/QCoreApplication>
22#include <QtCore/QDir>
25#include <QtCore/QDir>
@@ -62,7 +65,7 @@ inline QString fakePluginsImportPath() {
62
65
63inline QStringList shellDataDirs() {
66inline QStringList shellDataDirs() {
64 QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
67 QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
65− if (!isRunningInstalled()) {
68+ if (!isRunningInstalled() && getenv("UNITY_TEST_ENV")==NULL) {
66 dirs.prepend("@CMAKE_BINARY_DIR@/share");
69 dirs.prepend("@CMAKE_BINARY_DIR@/share");
67 }
70 }
68 return dirs;
71 return dirs;
@@ -71,3 +74,5 @@ inline QStringList shellDataDirs() {
71inline QString sourceDirectory() {
74inline QString sourceDirectory() {
72 return QString("@CMAKE_SOURCE_DIR@/");
75 return QString("@CMAKE_SOURCE_DIR@/");
73}
76}
77+
78+#endif
plugins/IndicatorsClient/CMakeLists.txt+3−9
@@ -14,13 +14,13 @@ else()
14 message(WARNING "Missing glib or libnm dependency for the network plugin, not building")
14 message(WARNING "Missing glib or libnm dependency for the network plugin, not building")
15endif()
15endif()
16
16
17−
18add_subdirectory(indicators)
17add_subdirectory(indicators)
19−add_subdirectory(client)
20add_subdirectory(qml)
18add_subdirectory(qml)
21
19
22if(NETWORK_PLUGIN_ENABLED)
20if(NETWORK_PLUGIN_ENABLED)
23 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNETWORK_PLUGIN_ENABLED" )
21 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNETWORK_PLUGIN_ENABLED" )
22+
23+ add_subdirectory(Network)
24endif()
24endif()
25
25
26include_directories(
26include_directories(
@@ -30,12 +30,11 @@ include_directories(
30 ${Qt5Quick_INCLUDE_DIRS}
30 ${Qt5Quick_INCLUDE_DIRS}
31 ${GLIB_INCLUDE_DIRS}
31 ${GLIB_INCLUDE_DIRS}
32 ${QMENUMODEL_INCLUDE_DIRS}
32 ${QMENUMODEL_INCLUDE_DIRS}
33− ${indicatorclient_common_SOURCE_DIR}
34)
33)
35
34
36set(IndicatorsClientQML_SOURCES
35set(IndicatorsClientQML_SOURCES
37 flatmenuproxymodel.cpp
36 flatmenuproxymodel.cpp
38− indicatorsfactory.cpp
37+ indicator.cpp
39 indicatorsmanager.cpp
38 indicatorsmanager.cpp
40 indicatorsmodel.cpp
39 indicatorsmodel.cpp
41 plugin.cpp
40 plugin.cpp
@@ -64,11 +63,6 @@ target_link_libraries(IndicatorsClientQml
64 ${Qt5Quick_LIBRARIES}
63 ${Qt5Quick_LIBRARIES}
65 ${GOBJECT_LDFLAGS}
64 ${GOBJECT_LDFLAGS}
66 ${QMENUMODEL_LDFLAGS}
65 ${QMENUMODEL_LDFLAGS}
67− indicatorclient_datetime
68− indicatorclient_messaging
69− indicatorclient_power
70− indicatorclient_sound
71− indicatorclient_network
72)
66)
73
67
74qt5_use_modules(IndicatorsClientQml Qml)
68qt5_use_modules(IndicatorsClientQml Qml)
plugins/IndicatorsClient/Network/CMakeLists.txtnew file+30
@@ -0,0 +1,30 @@
1+project(IndicatorsClientNetworkQml)
2+
3+set(INDICATORCLIENT_NETWORK_SRC
4+ networkagent.cpp
5+ plugin.cpp
6+ secret-agent.c
7+)
8+
9+add_library(IndicatorsClientNetworkQml MODULE
10+ ${INDICATORCLIENT_NETWORK_SRC}
11+)
12+
13+qt5_use_modules(IndicatorsClientNetworkQml Core Qml Widgets)
14+
15+set_target_properties(IndicatorsClientNetworkQml PROPERTIES COMPILE_FLAGS -fPIC)
16+
17+include_directories(
18+ ${CMAKE_CURRENT_SOURCE_DIR}
19+ ${GLIB_INCLUDE_DIRS}
20+ ${QMENUMODEL_INCLUDE_DIRS}
21+ ${LIBNM_GLIB_INCLUDE_DIRS}
22+ ${LIBNM_UTIL_INCLUDE_DIRS}
23+)
24+
25+target_link_libraries(IndicatorsClientNetworkQml
26+ ${GLIB_LIBRARIES}
27+ ${QMENUMODEL_LDFLAGS}
28+ ${LIBNM_GLIB_LIBRARIES}
29+ ${LIBNM_UTIL_LIBRARIES}
30+)
plugins/IndicatorsClient/indicators/network/networkagent.cpp → plugins/IndicatorsClient/Network/networkagent.cpprenamed

The content is the same.

plugins/IndicatorsClient/indicators/network/networkagent.h → plugins/IndicatorsClient/Network/networkagent.hrenamed

The content is the same.

plugins/IndicatorsClient/Network/plugin.cppnew file+31
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (C) 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 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+ * Author: Michał Sawicz <michal.sawicz@canonical.com>
17+ */
18+
19+// Qt
20+#include <QtQml>
21+
22+// self
23+#include "plugin.h"
24+
25+// local
26+#include "networkagent.h"
27+
28+void IndicatorsClientNetworkPlugin::registerTypes(const char *uri)
29+{
30+ qmlRegisterType<NetworkAgent>(uri, 0, 1, "NetworkAgent");
31+}
plugins/IndicatorsClient/Network/plugin.hnew file+32
@@ -0,0 +1,32 @@
1+/*
2+ * Copyright (C) 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 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+ * Author: Nick Dedekind <nick.dedekind@canonical.com>
17+ */
18+
19+#ifndef INDICATORSCLIENT_NETWORK_PLUGIN_H
20+#define INDICATORSCLIENT_NETWORK_PLUGIN_H
21+
22+#include <QtQml/QQmlExtensionPlugin>
23+
24+class IndicatorsClientNetworkPlugin : public QQmlExtensionPlugin
25+{
26+ Q_OBJECT
27+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
28+public:
29+ void registerTypes(const char *uri);
30+};
31+
32+#endif // INDICATORSCLIENT_NETWORK_PLUGIN_H
plugins/IndicatorsClient/indicators/network/secret-agent.c → plugins/IndicatorsClient/Network/secret-agent.crenamed

The content is the same.

plugins/IndicatorsClient/indicators/network/secret-agent.h → plugins/IndicatorsClient/Network/secret-agent.hrenamed

The content is the same.

plugins/IndicatorsClient/indicator.cppnew file+85
@@ -0,0 +1,85 @@
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+ * Renato Araujo Oliveira Filho <renato@canonical.com>
18+ */
19+
20+#include "indicator.h"
21+
22+#include <QUrl>
23+#include <QtPlugin>
24+#include <QResource>
25+#include <QDebug>
26+#include <QFileInfo>
27+#include <QDir>
28+#include <QQmlEngine>
29+#include <QQmlContext>
30+#include <QJsonObject>
31+
32+#include <qdbusmenumodel.h>
33+#include <qdbusactiongroup.h>
34+#include <qstateaction.h>
35+
36+Indicator::Indicator(QObject *parent)
37+ : QObject(parent)
38+{
39+}
40+
41+Indicator::~Indicator()
42+{
43+}
44+
45+void Indicator::init(const QSettings& settings)
46+{
47+ setId(settings.value("Indicator Service/Name").toString());
48+ QString dbusService = settings.value("Indicator Service/DBusName").toString();
49+ QString objectPath = settings.value("Indicator Service/ObjectPath").toString();
50+
51+ QVariantMap properties;
52+ properties.clear();
53+ properties.insert("busType", 1);
54+ properties.insert("busName", dbusService);
55+ properties.insert("objectPath", objectPath);
56+ setIndicatorProperties(properties);
57+}
58+
59+QString Indicator::identifier() const
60+{
61+ return m_identifier;
62+}
63+
64+void Indicator::setId(const QString &identifier)
65+{
66+ if (identifier != m_identifier) {
67+ m_identifier = identifier;
68+ Q_EMIT identifierChanged(m_identifier);
69+ }
70+}
71+
72+
73+QVariant Indicator::indicatorProperties() const
74+{
75+ return m_properties;
76+}
77+
78+void Indicator::setIndicatorProperties(const QVariant &properties)
79+{
80+ if (m_properties != properties)
81+ {
82+ m_properties = properties;
83+ Q_EMIT indicatorPropertiesChanged(m_properties);
84+ }
85+}
plugins/IndicatorsClient/indicator.hnew file+62
@@ -0,0 +1,62 @@
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+ * Renato Araujo Oliveira Filho <renato@canonical.com>
18+ * Nick Dedekind <nick.dedekind@canonical.com>
19+ */
20+
21+#ifndef INDICATOR_H
22+#define INDICATOR_H
23+
24+#include <QObject>
25+#include <QSettings>
26+#include <memory>
27+
28+class QDBusActionGroup;
29+class QDBusMenuModel;
30+class QStateAction;
31+
32+class Indicator : public QObject
33+{
34+ Q_OBJECT
35+ Q_PROPERTY(QString identifier READ identifier NOTIFY identifierChanged)
36+ Q_PROPERTY(QVariant indicatorProperties READ indicatorProperties NOTIFY indicatorPropertiesChanged)
37+
38+public:
39+ typedef std::shared_ptr<Indicator> Ptr;
40+
41+ Indicator(QObject *parent = 0);
42+ virtual ~Indicator();
43+
44+ void init(const QSettings& settings);
45+
46+ QString identifier() const;
47+ QVariant indicatorProperties() const;
48+
49+Q_SIGNALS:
50+ void identifierChanged(const QString &identifier);
51+ void indicatorPropertiesChanged(const QVariant &properties);
52+
53+protected:
54+ void setId(const QString &id);
55+ void setIndicatorProperties(const QVariant &properties);
56+
57+private:
58+ QString m_identifier;
59+ QVariant m_properties;
60+};
61+
62+#endif // INDICATOR_H
plugins/IndicatorsClient/indicatorclientinterface.hdeleted−124
@@ -1,124 +0,0 @@
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− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− */
19−
20−#ifndef INDICATORCLIENTININTERFACE_H
21−#define INDICATORCLIENTININTERFACE_H
22−
23−#include <QMap>
24−#include <QString>
25−#include <QUrl>
26−#include <QObject>
27−#include <QQmlComponent>
28−#include <QQmlEngine>
29−#include <QSettings>
30−
31−#include <memory>
32−
33−class IndicatorClientInterface
34−{
35−public:
36− typedef QMap<QString, QVariant> PropertiesMap;
37−
38− typedef std::shared_ptr<IndicatorClientInterface> Ptr;
39−
40− enum IndicatorPriority {
41− MESSAGING = 0,
42− SOUND = 10,
43− NETWORK = 20,
44− POWER = 30,
45− DATETIME = 100
46− };
47− /**
48− * @brief This fuction will be called by PluginManager after create the plugin object
49− * @param config The dbus configuration used by this plugin
50− */
51− virtual void init(const QSettings& settings) = 0;
52−
53− /**
54− * @brief This function will be called by PluginManager before destroy the plugin
55− */
56− virtual void shutdown() = 0;
57−
58− /**
59− * @brief Used to retrieve the current plugin identifier
60− * @return The identifier
61− *
62− * This function can be used to retrieve the indicator identifier
63− */
64− virtual QString identifier() const = 0;
65−
66− /**
67− * @brief Used to retrieve the current plugin title
68− * @return The title
69− *
70− * This function can be used to retrieve the indicator title which can be used as plugin name on the menu
71− */
72− virtual QString title() const = 0;
73−
74− /**
75− * @brief Used to retrieve the current plugin label
76− * @return The label
77− *
78− * This function can be used to retrieve the indicator label which can appear in the panel
79− */
80− virtual QString label() const = 0;
81−
82− /**
83− * @brief Used to retrieve the current plugin label
84− * @return The label
85− *
86− * This function can be used to retrieve the indicator description which can appear in the panel
87− */
88− virtual QString description() const = 0;
89−
90− /**
91− * @brief Used to retrieve the current plugin visibility
92− * @return The visibility
93− *
94− * This function can be used to retrieve the indicator is visible on the panel or not
95− */
96− virtual bool visible() const = 0;
97−
98− /**
99− * @brief Used to retrieve the current plugin priority
100− * @return The priorty value for the plugin, this will be used to arrange the plugin on the indicator panel
101− */
102− virtual int priority() const = 0;
103−
104− /**
105− * @brief Used to retrieve the icon component source file
106− * @return The icon component url
107− */
108− virtual QUrl iconComponentSource() const = 0;
109−
110− /**
111− * @brief Used to retrieve the plugin page component source file
112− * @return A url pointing to the component source file
113− */
114− virtual QUrl pageComponentSource() const = 0;
115−
116− /**
117− * @brief Used during the plugin Component instanciation to set the initial properties
118− * @return The map with the initial property and value: {'property-name' : property-value}
119− */
120−
121− virtual PropertiesMap initialProperties() = 0;
122−};
123−
124−#endif
plugins/IndicatorsClient/indicators/CMakeLists.txt+17−6
@@ -1,6 +1,17 @@
1−add_subdirectory(common)
1+set(INDICATOR_FILES
2−add_subdirectory(messaging)
2+ ${CMAKE_CURRENT_SOURCE_DIR}/indicator-datetime.indicator
3−add_subdirectory(sound)
3+ ${CMAKE_CURRENT_SOURCE_DIR}/indicator-messaging.indicator
4−add_subdirectory(power)
4+ ${CMAKE_CURRENT_SOURCE_DIR}/indicator-network.indicator
5−add_subdirectory(datetime)
5+ ${CMAKE_CURRENT_SOURCE_DIR}/indicator-power.indicator
6−add_subdirectory(network)
6+ ${CMAKE_CURRENT_SOURCE_DIR}/indicator-sound.indicator
7+)
8+
9+# copy indicators file into build directory for shadow builds
10+file(COPY ${INDICATOR_FILES}
11+ DESTINATION ${CMAKE_BINARY_DIR}/share/unity/indicators
12+)
13+
14+# install indicator file
15+install(FILES ${INDICATOR_FILES}
16+ DESTINATION ${CMAKE_INSTALL_DATADIR}/unity/indicators
17+)
plugins/IndicatorsClient/indicators/common/CMakeLists.txtdeleted−24
@@ -1,24 +0,0 @@
1−project(indicatorclient_common)
2−
3−set(INDICATORCLIENT_COMMON_SRC
4− indicatorclient_common.cpp
5−)
6−
7−add_library(indicatorclient_common STATIC
8− ${INDICATORCLIENT_COMMON_RESOURCES_RCC}
9− ${INDICATORCLIENT_COMMON_SRC}
10−)
11−
12−qt5_use_modules(indicatorclient_common Core Qml)
13−
14−set_target_properties(indicatorclient_common PROPERTIES COMPILE_FLAGS -fPIC)
15−
16−include_directories(
17− ${CMAKE_CURRENT_SOURCE_DIR}
18− ${QMENUMODEL_INCLUDE_DIRS}
19− ${IndicatorsClientQml_SOURCE_DIR}
20−)
21−
22−target_link_libraries(indicatorclient_common
23− ${QMENUMODEL_LDFLAGS}
24−)
plugins/IndicatorsClient/indicators/common/indicatorclient_common.cppdeleted−159
@@ -1,159 +0,0 @@
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− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− */
19−
20−#include "indicatorclient_common.h"
21−
22−#include <QUrl>
23−#include <QtPlugin>
24−#include <QResource>
25−#include <QDebug>
26−#include <QFileInfo>
27−#include <QDir>
28−#include <QQmlEngine>
29−#include <QQmlContext>
30−#include <QJsonObject>
31−
32−#include <qdbusmenumodel.h>
33−#include <qdbusactiongroup.h>
34−#include <qstateaction.h>
35−
36−//TODO: load this property dynamically
37−#define TARGET_DEVICE "phone"
38−
39−IndicatorClientCommon::IndicatorClientCommon(QObject *parent)
40− : QObject(parent),
41− m_visible(false),
42− m_priority(0)
43−{
44−}
45−
46−IndicatorClientCommon::~IndicatorClientCommon()
47−{
48− shutdown();
49−}
50−
51−void IndicatorClientCommon::init(const QSettings& settings)
52−{
53− setId(settings.value("Indicator Service/Name").toString());
54− QString dbusService = settings.value("Indicator Service/DBusName").toString();
55− QString objectPath = settings.value("Indicator Service/ObjectPath").toString();
56−
57− m_initialProperties.clear();
58− m_initialProperties.insert("title", m_title);
59− m_initialProperties.insert("busType", 1);
60− m_initialProperties.insert("busName", dbusService);
61− m_initialProperties.insert("objectPath", objectPath);
62−}
63−
64−void IndicatorClientCommon::shutdown()
65−{
66−}
67−
68−QString IndicatorClientCommon::identifier() const
69−{
70− return m_identifier;
71−}
72−
73−void IndicatorClientCommon::setId(const QString &identifier)
74−{
75− if (identifier != m_identifier) {
76− m_identifier = identifier;
77− Q_EMIT identifierChanged(m_identifier);
78− }
79−}
80−
81−QString IndicatorClientCommon::title() const
82−{
83− return m_title;
84−}
85−
86−void IndicatorClientCommon::setTitle(const QString &title)
87−{
88− if (title != m_title) {
89− m_title = title;
90− Q_EMIT titleChanged(m_title);
91− }
92−}
93−
94−QString IndicatorClientCommon::description() const
95−{
96− return m_description;
97−}
98−
99−void IndicatorClientCommon::setDescription(const QString &description)
100−{
101− if (description != m_description) {
102− m_description = description;
103− Q_EMIT titleChanged(m_description);
104− }
105−}
106−
107−int IndicatorClientCommon::priority() const
108−{
109− return m_priority;
110−}
111−
112−void IndicatorClientCommon::setPriority(int priority)
113−{
114− if (priority != m_priority) {
115− m_priority = priority;
116− Q_EMIT priorityChanged(m_priority);
117− }
118−}
119−
120−bool IndicatorClientCommon::visible() const
121−{
122− return m_visible;
123−}
124−
125−void IndicatorClientCommon::setVisible(bool visible)
126−{
127− if (visible != m_visible) {
128− m_visible = visible;
129− Q_EMIT visibleChanged(m_visible);
130− }
131−}
132−
133−QString IndicatorClientCommon::label() const
134−{
135− return m_label;
136−}
137−
138−void IndicatorClientCommon::setLabel(const QString &label)
139−{
140− if (label != m_label) {
141− m_label = label;
142− Q_EMIT labelChanged(m_label);
143− }
144−}
145−
146−QUrl IndicatorClientCommon::iconComponentSource() const
147−{
148− return QUrl("qrc:/indicatorsclient/qml/DefaultIndicatorIcon.qml");
149−}
150−
151−QUrl IndicatorClientCommon::pageComponentSource() const
152−{
153− return QUrl("qrc:/indicatorsclient/qml/DefaultIndicatorPage.qml");
154−}
155−
156−IndicatorClientInterface::PropertiesMap IndicatorClientCommon::initialProperties()
157−{
158− return m_initialProperties;
159−}
plugins/IndicatorsClient/indicators/common/indicatorclient_common.hdeleted−86
@@ -1,86 +0,0 @@
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− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− * Nick Dedekind <nick.dedekind@canonical.com>
19− */
20−
21−#ifndef INDICATORCLIENT_COMMON_H
22−#define INDICATORCLIENT_COMMON_H
23−
24−#include <indicatorclientinterface.h>
25−#include <QObject>
26−
27−class QDBusActionGroup;
28−class QDBusMenuModel;
29−class QStateAction;
30−
31−class IndicatorClientCommon : public QObject, public IndicatorClientInterface
32−{
33− Q_OBJECT
34− Q_PROPERTY(QString identifier READ identifier NOTIFY identifierChanged)
35− Q_PROPERTY(QString title READ title NOTIFY titleChanged)
36− Q_PROPERTY(QString label READ label NOTIFY labelChanged)
37− Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
38− Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
39− Q_PROPERTY(int priority READ priority NOTIFY priorityChanged)
40−
41−public:
42− IndicatorClientCommon(QObject *parent = 0);
43− ~IndicatorClientCommon();
44−
45− void init(const QSettings& settings);
46− void shutdown();
47−
48− QString identifier() const;
49− QString title() const;
50− bool visible() const;
51− QString description() const;
52− QString label() const;
53− int priority() const;
54−
55− QUrl iconComponentSource() const;
56− QUrl pageComponentSource() const;
57− PropertiesMap initialProperties();
58−
59−Q_SIGNALS:
60− void identifierChanged(const QString &identifier);
61− void titleChanged(const QString &title);
62− void visibleChanged(bool visible);
63− void descriptionChanged(const QString &description);
64− void labelChanged(const QString &label);
65− void priorityChanged(int priority);
66−
67−protected:
68− PropertiesMap m_initialProperties;
69−
70− void setId(const QString &id);
71− void setTitle(const QString &title);
72− void setDescription(const QString &description);
73− void setVisible(bool visible);
74− void setLabel(const QString &title);
75− void setPriority(int priority);
76−
77−private:
78− QString m_identifier;
79− QString m_title;
80− QString m_description;
81− QString m_label;
82− bool m_visible;
83− int m_priority;
84−};
85−
86−#endif // INDICATORCLIENT_COMMON_H
plugins/IndicatorsClient/indicators/datetime/CMakeLists.txtdeleted−37
@@ -1,37 +0,0 @@
1−set(INDICATORCLIENT_DATETIME_SRC
2− indicatorclient_datetime.cpp
3−)
4−
5−add_library(indicatorclient_datetime STATIC
6− ${INDICATORCLIENT_DATETIME_SRC}
7−)
8−
9−qt5_use_modules(indicatorclient_datetime Core Qml)
10−
11−set_target_properties(indicatorclient_datetime PROPERTIES COMPILE_FLAGS -fPIC)
12−
13−include_directories(
14− ${CMAKE_CURRENT_SOURCE_DIR}
15− ${QMENUMODEL_INCLUDE_DIRS}
16− ${indicatorclient_common_SOURCE_DIR}
17− ${IndicatorsClientQml_SOURCE_DIR}
18−)
19−
20−target_link_libraries(indicatorclient_datetime
21− indicatorclient_common
22− ${QMENUMODEL_LDFLAGS}
23−)
24−
25−set(INDICATOR_FILES
26− ${CMAKE_CURRENT_SOURCE_DIR}/indicator-datetime.indicator
27−)
28−
29−# copy indicators file into build directory for shadow builds
30−file(COPY ${INDICATOR_FILES}
31− DESTINATION ${CMAKE_BINARY_DIR}/share/unity/indicators
32−)
33−
34−# install indicator file
35−install(FILES ${INDICATOR_FILES}
36− DESTINATION ${CMAKE_INSTALL_DATADIR}/unity/indicators
37−)
plugins/IndicatorsClient/indicators/datetime/indicatorclient_datetime.cppdeleted−58
@@ -1,58 +0,0 @@
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− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− * Ubo Riboni <ugo.riboni@canonical.com>
19− */
20−
21−#include "indicatorclient_datetime.h"
22−
23−#include <qdbusmenumodel.h>
24−#include <qdbusactiongroup.h>
25−#include <qstateaction.h>
26−#include <QDateTime>
27−#include <QDebug>
28−
29−IndicatorClientDateTime::IndicatorClientDateTime(QObject *parent)
30− : IndicatorClientCommon(parent),
31− m_action(0)
32−{
33− setTitle("Date and Time");
34− setPriority(IndicatorPriority::DATETIME);
35−}
36−
37−IndicatorClientDateTime::~IndicatorClientDateTime()
38−{
39−}
40−
41−void IndicatorClientDateTime::init(const QSettings& settings)
42−{
43− IndicatorClientCommon::init(settings);
44−}
45−
46−void IndicatorClientDateTime::shutdown()
47−{
48−}
49−
50−QUrl IndicatorClientDateTime::iconComponentSource() const
51−{
52− return QUrl("qrc:/indicatorsclient/qml/DatetimeIndicatorIcon.qml");
53−}
54−
55−QUrl IndicatorClientDateTime::pageComponentSource() const
56−{
57− return QUrl("qrc:/indicatorsclient/qml/DatetimeIndicatorPage.qml");
58−}
plugins/IndicatorsClient/indicators/datetime/indicatorclient_datetime.hdeleted−49
@@ -1,49 +0,0 @@
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− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− * Ubo Riboni <ugo.riboni@canonical.com>
19− */
20−
21−#ifndef INDICATORCLIENT_DATETIME_H
22−#define INDICATORCLIENT_DATETIME_H
23−
24−#include "indicatorclient_common.h"
25−#include <QTimer>
26−#include <QDateTime>
27−
28−class QStateAction;
29−
30−class IndicatorClientDateTime : public IndicatorClientCommon
31−{
32− Q_OBJECT
33−public:
34− IndicatorClientDateTime(QObject *parent=0);
35− ~IndicatorClientDateTime();
36−
37− void init(const QSettings& settings);
38− void shutdown();
39−
40− QUrl iconComponentSource() const;
41− QUrl pageComponentSource() const;
42−
43−private:
44− QTimer m_timer;
45− QString m_format;
46− QStateAction *m_action;
47−};
48−
49−#endif
plugins/IndicatorsClient/indicators/datetime/indicator-datetime.indicator → plugins/IndicatorsClient/indicators/indicator-datetime.indicatorrenamed

The content is the same.

plugins/IndicatorsClient/indicators/messaging/indicator-messaging.indicator → plugins/IndicatorsClient/indicators/indicator-messaging.indicatorrenamed

The content is the same.

plugins/IndicatorsClient/indicators/network/indicator-network.indicator → plugins/IndicatorsClient/indicators/indicator-network.indicatorrenamed

The content is the same.

plugins/IndicatorsClient/indicators/power/indicator-power.indicator → plugins/IndicatorsClient/indicators/indicator-power.indicatorrenamed

The content is the same.

plugins/IndicatorsClient/indicators/sound/indicator-sound.indicator → plugins/IndicatorsClient/indicators/indicator-sound.indicatorrenamed

The content is the same.

plugins/IndicatorsClient/indicators/messaging/CMakeLists.txtdeleted−36
@@ -1,36 +0,0 @@
1−set(INDICATORCLIENT_MESSAGING_SRC
2− indicatorclient_messaging.cpp
3−)
4−
5−add_library(indicatorclient_messaging STATIC
6− ${INDICATORCLIENT_MESSAGING_SRC}
7−)
8−
9−qt5_use_modules(indicatorclient_messaging Core Qml)
10−
11−set_target_properties(indicatorclient_messaging PROPERTIES COMPILE_FLAGS -fPIC)
12−
13−include_directories(
14− ${CMAKE_CURRENT_SOURCE_DIR}
15− ${indicatorclient_common_SOURCE_DIR}
16− ${IndicatorsClientQml_SOURCE_DIR}
17−)
18−
19−target_link_libraries(indicatorclient_messaging
20− indicatorclient_common
21− ${QMENUMODEL_LDFLAGS}
22−)
23−
24−set(INDICATOR_FILES
25− ${CMAKE_CURRENT_SOURCE_DIR}/indicator-messaging.indicator
26−)
27−
28−# copy indicators file into build directory for shadow builds
29−file(COPY ${INDICATOR_FILES}
30− DESTINATION ${CMAKE_BINARY_DIR}/share/unity/indicators
31−)
32−
33−# install indicator file
34−install(FILES ${INDICATOR_FILES}
35− DESTINATION ${CMAKE_INSTALL_DATADIR}/unity/indicators
36−)
plugins/IndicatorsClient/indicators/network/CMakeLists.txtdeleted−45
@@ -1,45 +0,0 @@
1−set(INDICATORCLIENT_NETWORK_SRC
2− indicatorclient_network.cpp
3− networkagent.cpp
4− secret-agent.c
5−)
6−
7−add_library(indicatorclient_network
8− ${INDICATORCLIENT_NETWORK_SRC}
9−)
10−
11−qt5_use_modules(indicatorclient_network Core Qml Widgets)
12−
13−set_target_properties(indicatorclient_network PROPERTIES COMPILE_FLAGS -fPIC)
14−
15−include_directories(
16− ${CMAKE_CURRENT_SOURCE_DIR}
17− ${GLIB_INCLUDE_DIRS}
18− ${LIBNM_GLIB_INCLUDE_DIRS}
19− ${LIBNM_UTIL_INCLUDE_DIRS}
20− ${QMENUMODEL_INCLUDE_DIRS}
21− ${indicatorclient_common_SOURCE_DIR}
22− ${IndicatorsClientQml_SOURCE_DIR}
23−)
24−
25−target_link_libraries(indicatorclient_network
26− indicatorclient_common
27− ${GLIB_LIBRARIES}
28− ${LIBNM_GLIB_LIBRARIES}
29− ${LIBNM_UTIL_LIBRARIES}
30− ${QMENUMODEL_LDFLAGS}
31−)
32−
33−set(INDICATOR_FILES
34− ${CMAKE_CURRENT_SOURCE_DIR}/indicator-network.indicator
35−)
36−
37−# copy indicators file into build directory for shadow builds
38−file(COPY ${INDICATOR_FILES}
39− DESTINATION ${CMAKE_BINARY_DIR}/share/unity/indicators
40−)
41−
42−# install indicator file
43−install(FILES ${INDICATOR_FILES}
44− DESTINATION ${CMAKE_INSTALL_DATADIR}/unity/indicators
45−)
plugins/IndicatorsClient/indicators/network/indicatorclient_network.cppdeleted−57
@@ -1,57 +0,0 @@
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− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− */
19−
20−#include "indicatorclient_network.h"
21−#include "networkagent.h"
22−
23−#include <QUrl>
24−#include <QtQml>
25−#include <QtPlugin>
26−
27−#include <qdbusmenumodel.h>
28−#include <qdbusactiongroup.h>
29−#include <qstateaction.h>
30−
31−IndicatorClientNetwork::IndicatorClientNetwork(QObject *parent)
32− : IndicatorClientCommon(parent)
33−{
34− setTitle("Networks");
35− setPriority(IndicatorPriority::NETWORK);
36−}
37−
38−IndicatorClientNetwork::~IndicatorClientNetwork()
39−{
40−}
41−
42−void IndicatorClientNetwork::init(const QSettings& settings)
43−{
44− IndicatorClientCommon::init(settings);
45−
46− qmlRegisterType<NetworkAgent>("NetworkSettings", 0, 1, "NetworkAgent");
47−}
48−
49−QUrl IndicatorClientNetwork::iconComponentSource() const
50−{
51− return QUrl("qrc:/indicatorsclient/qml/NetworkIndicatorIcon.qml");
52−}
53−
54−QUrl IndicatorClientNetwork::pageComponentSource() const
55−{
56− return QUrl("qrc:/indicatorsclient/qml/NetworkIndicatorPage.qml");
57−}
plugins/IndicatorsClient/indicators/network/indicatorclient_network.hdeleted−40
@@ -1,40 +0,0 @@
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− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− */
19−
20−#ifndef INDICATORCLIENT_NETWORK_H
21−#define INDICATORCLIENT_NETWORK_H
22−
23−#include "indicatorclient_common.h"
24−#include <QTimer>
25−
26−class QStateAction;
27−
28−class IndicatorClientNetwork : public IndicatorClientCommon
29−{
30− Q_OBJECT
31−public:
32− IndicatorClientNetwork(QObject *parent=0);
33− ~IndicatorClientNetwork();
34−
35− void init(const QSettings& settings);
36− QUrl iconComponentSource() const;
37− QUrl pageComponentSource() const;
38−};
39−
40−#endif
plugins/IndicatorsClient/indicators/power/CMakeLists.txtdeleted−36
@@ -1,36 +0,0 @@
1−set(INDICATORCLIENT_POWER_SRC
2− indicatorclient_power.cpp
3−)
4−
5−add_library(indicatorclient_power STATIC
6− ${INDICATORCLIENT_POWER_SRC}
7−)
8−
9−qt5_use_modules(indicatorclient_power Core Qml)
10−
11−set_target_properties(indicatorclient_power PROPERTIES COMPILE_FLAGS -fPIC)
12−
13−include_directories(
14− ${CMAKE_CURRENT_SOURCE_DIR}
15− ${indicatorclient_common_SOURCE_DIR}
16− ${IndicatorsClientQml_SOURCE_DIR}
17−)
18−
19−target_link_libraries(indicatorclient_power
20− indicatorclient_common
21− ${QMENUMODEL_LDFLAGS}
22−)
23−
24−set(INDICATOR_FILES
25− ${CMAKE_CURRENT_SOURCE_DIR}/indicator-power.indicator
26−)
27−
28−# copy indicators file into build directory for shadow builds
29−file(COPY ${INDICATOR_FILES}
30− DESTINATION ${CMAKE_BINARY_DIR}/share/unity/indicators
31−)
32−
33−# install indicator file
34−install(FILES ${INDICATOR_FILES}
35− DESTINATION ${CMAKE_INSTALL_DATADIR}/unity/indicators
36−)
plugins/IndicatorsClient/indicators/power/indicatorclient_power.cppdeleted−33
@@ -1,33 +0,0 @@
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− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− * Ubo Riboni <ugo.riboni@canonical.com>
19− */
20−
21−#include "indicatorclient_power.h"
22−
23−IndicatorClientPower::IndicatorClientPower(QObject *parent)
24− : IndicatorClientCommon(parent)
25−{
26− setTitle("Battery");
27− setPriority(IndicatorPriority::POWER);
28−}
29−
30−void IndicatorClientPower::init(const QSettings& settings)
31−{
32− IndicatorClientCommon::init(settings);
33−}
plugins/IndicatorsClient/indicators/power/indicatorclient_power.hdeleted−35
@@ -1,35 +0,0 @@
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− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− * Ubo Riboni <ugo.riboni@canonical.com>
19− */
20−
21−#ifndef INDICATORCLIENT_POWER_H
22−#define INDICATORCLIENT_POWER_H
23−
24−#include "indicatorclient_common.h"
25−
26−class IndicatorClientPower : public IndicatorClientCommon
27−{
28− Q_OBJECT
29−public:
30− IndicatorClientPower(QObject *parent=0);
31−
32− void init(const QSettings& settings);
33−};
34−
35−#endif
plugins/IndicatorsClient/indicators/sound/CMakeLists.txtdeleted−36
@@ -1,36 +0,0 @@
1−set(INDICATORCLIENT_SOUND_SRC
2− indicatorclient_sound.cpp
3−)
4−
5−add_library(indicatorclient_sound STATIC
6− ${INDICATORCLIENT_SOUND_SRC}
7−)
8−
9−qt5_use_modules(indicatorclient_sound Core Qml)
10−
11−set_target_properties(indicatorclient_sound PROPERTIES COMPILE_FLAGS -fPIC)
12−
13−include_directories(
14− ${CMAKE_CURRENT_SOURCE_DIR}
15− ${indicatorclient_common_SOURCE_DIR}
16− ${IndicatorsClientQml_SOURCE_DIR}
17−)
18−
19−target_link_libraries(indicatorclient_sound
20− indicatorclient_common
21− ${QMENUMODEL_LDFLAGS}
22−)
23−
24−set(INDICATOR_FILES
25− ${CMAKE_CURRENT_SOURCE_DIR}/indicator-sound.indicator
26−)
27−
28−# copy indicators file into build directory for shadow builds
29−file(COPY ${INDICATOR_FILES}
30− DESTINATION ${CMAKE_BINARY_DIR}/share/unity/indicators
31−)
32−
33−# install indicator file
34−install(FILES ${INDICATOR_FILES}
35− DESTINATION ${CMAKE_INSTALL_DATADIR}/unity/indicators
36−)
plugins/IndicatorsClient/indicatorsfactory.cppdeleted−61
@@ -1,61 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Michał Sawicz <michal.sawicz@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// local
21−#include "indicatorsfactory.h"
22−
23−// indicators
24−#include "indicators/datetime/indicatorclient_datetime.h"
25−#include "indicators/messaging/indicatorclient_messaging.h"
26−#include "indicators/network/indicatorclient_network.h"
27−#include "indicators/power/indicatorclient_power.h"
28−#include "indicators/sound/indicatorclient_sound.h"
29−
30−IndicatorsFactory::IndicatorsFactory()
31−{
32− registerIndicator<IndicatorClientDateTime>("indicator-datetime");
33− registerIndicator<IndicatorClientMessaging>("indicator-messaging");
34− registerIndicator<IndicatorClientNetwork>("indicator-network");
35− registerIndicator<IndicatorClientPower>("indicator-power");
36− registerIndicator<IndicatorClientSound>("indicator-sound");
37−}
38−
39−IndicatorsFactory::~IndicatorsFactory()
40−{
41− qDeleteAll(m_factoryItems);
42−}
43−
44−IndicatorsFactory& IndicatorsFactory::instance()
45−{
46− static IndicatorsFactory factory;
47− return factory;
48−}
49−
50−IndicatorClientInterface::Ptr IndicatorsFactory::create(const QString& indicator, QObject* parent)
51−{
52− if (!m_factoryItems.contains(indicator))
53− return IndicatorClientInterface::Ptr();
54− return m_factoryItems[indicator]->create(parent);
55−}
56−
57−
58−bool IndicatorsFactory::isRegistered(const QString& indicator)
59−{
60− return m_factoryItems.contains(indicator);
61−}
plugins/IndicatorsClient/indicatorsfactory.hdeleted−74
@@ -1,74 +0,0 @@
1−/*
2− * Copyright (C) 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 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− * Author: Nick Dedekind <nick.dedekind@canonical.com>
17− */
18−
19−#ifndef INDICATORS_FACTORY_H
20−#define INDICATORS_FACTORY_H
21−
22−#include <QString>
23−#include <QObject>
24−#include <QHash>
25−
26−#include "indicatorclientinterface.h"
27−
28−class IndicatorFactoryItem
29−{
30−public:
31− virtual ~IndicatorFactoryItem() {}
32− virtual IndicatorClientInterface::Ptr create(QObject* parent = 0) = 0;
33−};
34−
35−template<class TYPE>
36−class IndicatorFactoryItemTyped : public IndicatorFactoryItem
37−{
38−public:
39− IndicatorFactoryItemTyped() {}
40−
41− IndicatorClientInterface::Ptr create(QObject* parent = 0) { return std::make_shared<TYPE>(parent); }
42−};
43−
44−class IndicatorsFactory : public QObject
45−{
46− Q_OBJECT
47−public:
48− virtual ~IndicatorsFactory();
49−
50− IndicatorClientInterface::Ptr create(const QString& indicator, QObject* parent = 0);
51−
52− template<class TYPE>
53− void registerIndicator(const QString& indicator)
54− {
55− if (m_factoryItems.contains(indicator))
56− return;
57− m_factoryItems[indicator] = new IndicatorFactoryItemTyped<TYPE>();
58− Q_EMIT registered(indicator);
59− }
60−
61− bool isRegistered(const QString& indicator);
62−
63− static IndicatorsFactory& instance();
64−
65−Q_SIGNALS:
66− void registered(const QString& indicator);
67−
68−private:
69− IndicatorsFactory();
70−
71− QHash<QString, IndicatorFactoryItem*> m_factoryItems;
72−};
73−
74−#endif // INDICATORSCLIENT_PLUGIN_H
plugins/IndicatorsClient/indicatorsmanager.cpp+11−23
@@ -18,7 +18,6 @@
18 */
18 */
19
19
20#include "indicatorsmanager.h"
20#include "indicatorsmanager.h"
21−#include "indicatorsfactory.h"
22
21
23#include <QSettings>
22#include <QSettings>
24#include <QDebug>
23#include <QDebug>
@@ -39,7 +38,7 @@ public:
39 QFileInfo m_fileInfo;
38 QFileInfo m_fileInfo;
40
39
41 bool m_verified;
40 bool m_verified;
42− IndicatorClientInterface::Ptr m_obj;
41+ Indicator::Ptr m_indicator;
43};
42};
44
43
45IndicatorsManager::IndicatorsManager(QObject* parent)
44IndicatorsManager::IndicatorsManager(QObject* parent)
@@ -116,13 +115,6 @@ void IndicatorsManager::load(const QFileInfo& file_info)
116 indicator_settings.beginGroup("Indicator Service");
115 indicator_settings.beginGroup("Indicator Service");
117 QString name = indicator_settings.value("Name").toString();
116 QString name = indicator_settings.value("Name").toString();
118
117
119− // don't bother loading if it's not registered.
120− if (!IndicatorsFactory::instance().isRegistered(name))
121− {
122− qWarning() << Q_FUNC_INFO << "Invalid plugin name: " << name << " - not registered in factory.";
123− return;
124− }
125−
126 auto iter = m_indicatorsData.find(name);
118 auto iter = m_indicatorsData.find(name);
127 if (iter != m_indicatorsData.end())
119 if (iter != m_indicatorsData.end())
128 {
120 {
@@ -174,11 +166,6 @@ void IndicatorsManager::unload()
174 while(iter.hasNext())
166 while(iter.hasNext())
175 {
167 {
176 iter.next();
168 iter.next();
177− IndicatorData* data = iter.value();
178− if (data->m_obj)
179− {
180− data->m_obj->shutdown();
181− }
182 Q_EMIT indicatorAboutToBeUnloaded(iter.key());
169 Q_EMIT indicatorAboutToBeUnloaded(iter.key());
183 }
170 }
184
171
@@ -253,32 +240,33 @@ void IndicatorsManager::endVerify(const QString& path)
253 }
240 }
254}
241}
255
242
256−IndicatorClientInterface::Ptr IndicatorsManager::indicator(const QString& indicator)
243+Indicator::Ptr IndicatorsManager::indicator(const QString& indicator)
257{
244{
258− if (!m_indicatorsData.contains(indicator)) {
245+ if (!m_indicatorsData.contains(indicator))
246+ {
259 qWarning() << Q_FUNC_INFO << "Invalid plugin name: " << indicator;
247 qWarning() << Q_FUNC_INFO << "Invalid plugin name: " << indicator;
260 return 0;
248 return 0;
261 }
249 }
262
250
263 IndicatorData *data = m_indicatorsData[indicator];
251 IndicatorData *data = m_indicatorsData[indicator];
264− if (data->m_obj)
252+ if (data->m_indicator)
265− return data->m_obj;
253+ return data->m_indicator;
266
254
267− IndicatorClientInterface::Ptr plugin = IndicatorsFactory::instance().create(indicator, this);
255+ Indicator::Ptr plugin = std::make_shared<Indicator>(this);
268 if (plugin)
256 if (plugin)
269 {
257 {
270− data->m_obj = plugin;
258+ data->m_indicator = plugin;
271 plugin->init(QSettings(data->m_fileInfo.absoluteFilePath(), QSettings::IniFormat, this));
259 plugin->init(QSettings(data->m_fileInfo.absoluteFilePath(), QSettings::IniFormat, this));
272 }
260 }
273 return plugin;
261 return plugin;
274}
262}
275
263
276−QList<IndicatorClientInterface::Ptr> IndicatorsManager::indicators()
264+QList<Indicator::Ptr> IndicatorsManager::indicators()
277{
265{
278− QList<IndicatorClientInterface::Ptr> list;
266+ QList<Indicator::Ptr> list;
279 Q_FOREACH(IndicatorData* data, m_indicatorsData)
267 Q_FOREACH(IndicatorData* data, m_indicatorsData)
280 {
268 {
281− IndicatorClientInterface::Ptr plugin = indicator(data->m_name);
269+ Indicator::Ptr plugin = indicator(data->m_name);
282 list.append(plugin);
270 list.append(plugin);
283 }
271 }
284 return list;
272 return list;
plugins/IndicatorsClient/indicatorsmanager.h+3−3
@@ -27,7 +27,7 @@
27#include <QHash>
27#include <QHash>
28#include <QSharedPointer>
28#include <QSharedPointer>
29
29
30−#include "indicatorclientinterface.h"
30+#include "indicator.h"
31
31
32class IndicatorsManager : public QObject
32class IndicatorsManager : public QObject
33{
33{
@@ -40,9 +40,9 @@ public:
40 Q_INVOKABLE void load();
40 Q_INVOKABLE void load();
41 Q_INVOKABLE void unload();
41 Q_INVOKABLE void unload();
42
42
43− IndicatorClientInterface::Ptr indicator(const QString& indicator);
43+ Indicator::Ptr indicator(const QString& indicator);
44
44
45− QList<IndicatorClientInterface::Ptr> indicators();
45+ QList<Indicator::Ptr> indicators();
46
46
47 bool isLoaded() const;
47 bool isLoaded() const;
48
48
plugins/IndicatorsClient/indicatorsmodel.cpp+103−83
@@ -19,18 +19,13 @@
19
19
20#include "indicatorsmodel.h"
20#include "indicatorsmodel.h"
21#include "indicatorsmanager.h"
21#include "indicatorsmanager.h"
22−#include "indicatorclientinterface.h"
22+#include "indicator.h"
23+#include "paths.h"
23
24
24#include <QQmlContext>
25#include <QQmlContext>
25#include <QQmlEngine>
26#include <QQmlEngine>
26#include <QDebug>
27#include <QDebug>
27
28
28−
29−static bool comparePlugins(const IndicatorClientInterface::Ptr obj1, const IndicatorClientInterface::Ptr obj2)
30−{
31− return obj1->priority() < obj2->priority();
32−}
33−
34/*!
29/*!
35 \qmltype IndicatorsModel
30 \qmltype IndicatorsModel
36 \inherits QAbstractListModel
31 \inherits QAbstractListModel
@@ -128,37 +123,40 @@ void IndicatorsModel::unload()
128/*! \internal */
123/*! \internal */
129void IndicatorsModel::onIndicatorLoaded(const QString& indicator)
124void IndicatorsModel::onIndicatorLoaded(const QString& indicator)
130{
125{
131− IndicatorClientInterface::Ptr plugin = m_manager->indicator(indicator);
126+ Indicator::Ptr plugin = m_manager->indicator(indicator);
132 if (!plugin)
127 if (!plugin)
133 return;
128 return;
134
129
135− QList<IndicatorClientInterface::Ptr>::iterator i = qLowerBound(m_plugins.begin(), m_plugins.end(), plugin, comparePlugins);
130+ if (m_plugins.indexOf(plugin) >= 0)
136− int insert_pos = qMin(i - m_plugins.begin(), m_plugins.count());
131+ return;
137−
138− beginInsertRows(QModelIndex(), insert_pos, insert_pos);
139
132
140− QObject* obj = dynamic_cast<QObject*>(plugin.get());
133+ // find the insert position
141− if (obj)
134+ int pos = 0;
142− {
135+ while (pos < count()) {
143− QObject::connect(obj, SIGNAL(identifierChanged(const QString&)), this, SLOT(onIdentifierChanged()));
136+ // keep going while the existing priority is less.
144− QObject::connect(obj, SIGNAL(titleChanged(const QString&)), this, SLOT(onTitleChanged()));
137+ if (indicatorData(plugin, Priority).toInt() < data(index(pos), Priority).toInt())
145− QObject::connect(obj, SIGNAL(labelChanged(const QString&)), this, SLOT(onLabelChanged()));
138+ break;
139+ pos++;
146 }
140 }
147
141
148− m_plugins.insert(i, plugin);
142+ QObject::connect(plugin.get(), SIGNAL(identifierChanged(const QString&)), this, SLOT(onIdentifierChanged()));
143+ QObject::connect(plugin.get(), SIGNAL(indicatorPropertiesChanged(const QVariant&)), this, SLOT(onIndicatorPropertiesChanged()));
144+
145+ beginInsertRows(QModelIndex(), pos, pos);
149
146
147+ m_plugins.insert(pos, plugin);
150 endInsertRows();
148 endInsertRows();
151}
149}
152
150
153/*! \internal */
151/*! \internal */
154void IndicatorsModel::onIndicatorAboutToBeUnloaded(const QString& indicator)
152void IndicatorsModel::onIndicatorAboutToBeUnloaded(const QString& indicator)
155{
153{
156− IndicatorClientInterface::Ptr plugin = m_manager->indicator(indicator);
154+ Indicator::Ptr plugin = m_manager->indicator(indicator);
157 if (!plugin)
155 if (!plugin)
158 return;
156 return;
159
157
160 int i = 0;
158 int i = 0;
161− QMutableListIterator<IndicatorClientInterface::Ptr> iter(m_plugins);
159+ QMutableListIterator<Indicator::Ptr> iter(m_plugins);
162 while(iter.hasNext())
160 while(iter.hasNext())
163 {
161 {
164 if (plugin == iter.next())
162 if (plugin == iter.next())
@@ -179,26 +177,20 @@ void IndicatorsModel::onIdentifierChanged()
179}
177}
180
178
181/*! \internal */
179/*! \internal */
182−void IndicatorsModel::onTitleChanged()
180+void IndicatorsModel::onIndicatorPropertiesChanged()
183{
181{
184− notifyDataChanged(QObject::sender(), Title);
182+ notifyDataChanged(QObject::sender(), IndicatorProperties);
185−}
186−
187−/*! \internal */
188−void IndicatorsModel::onLabelChanged()
189−{
190− notifyDataChanged(QObject::sender(), Label);
191}
183}
192
184
193/*! \internal */
185/*! \internal */
194void IndicatorsModel::notifyDataChanged(QObject *sender, int role)
186void IndicatorsModel::notifyDataChanged(QObject *sender, int role)
195{
187{
196− IndicatorClientInterface* plugin = dynamic_cast<IndicatorClientInterface*>(sender);
188+ Indicator* plugin = qobject_cast<Indicator*>(sender);
197 if (!plugin)
189 if (!plugin)
198 return;
190 return;
199
191
200 int index = 0;
192 int index = 0;
201− QMutableListIterator<IndicatorClientInterface::Ptr> iter(m_plugins);
193+ QMutableListIterator<Indicator::Ptr> iter(m_plugins);
202 while(iter.hasNext())
194 while(iter.hasNext())
203 {
195 {
204 if (iter.next().get() == plugin)
196 if (iter.next().get() == plugin)
@@ -215,14 +207,15 @@ void IndicatorsModel::notifyDataChanged(QObject *sender, int role)
215QHash<int, QByteArray> IndicatorsModel::roleNames() const
207QHash<int, QByteArray> IndicatorsModel::roleNames() const
216{
208{
217 static QHash<int, QByteArray> roles;
209 static QHash<int, QByteArray> roles;
218− if (roles.isEmpty()) {
210+ if (roles.isEmpty())
211+ {
219 roles[Identifier] = "identifier";
212 roles[Identifier] = "identifier";
213+ roles[Priority] = "priority";
220 roles[Title] = "title";
214 roles[Title] = "title";
221− roles[Label] = "label";
222 roles[Description] = "description";
215 roles[Description] = "description";
223− roles[IconUrl] = "iconUrl";
216+ roles[IconQml] = "iconQml";
224− roles[PageUrl] = "pageUrl";
217+ roles[PageQml] = "pageQml";
225− roles[InitialProperties] = "initialProperties";
218+ roles[IndicatorProperties] = "indicatorProperties";
226 roles[IsValid] = "isValid";
219 roles[IsValid] = "isValid";
227 }
220 }
228 return roles;
221 return roles;
@@ -234,63 +227,69 @@ int IndicatorsModel::columnCount(const QModelIndex &) const
234 return 1;
227 return 1;
235}
228}
236
229
230+/*! \internal */
231+QVariant IndicatorsModel::defaultData(Indicator::Ptr plugin, int role)
232+{
233+ switch (role)
234+ {
235+ case Priority:
236+ return 0;
237+ case Title:
238+ return plugin ? plugin->identifier() : "Unknown";
239+ case Description:
240+ return "";
241+ case IconQml:
242+ return shellAppDirectory()+"/Panel/Indicators/DefaultIndicatorIcon.qml";
243+ case PageQml:
244+ return shellAppDirectory()+"/Panel/Indicators/DefaultIndicatorPage.qml";
245+ }
246+ return QVariant();
247+}
248+
237/*! \internal */
249/*! \internal */
238QVariant IndicatorsModel::data(const QModelIndex &index, int role) const
250QVariant IndicatorsModel::data(const QModelIndex &index, int role) const
239{
251{
240 if (!index.isValid() || index.row() >= m_plugins.size())
252 if (!index.isValid() || index.row() >= m_plugins.size())
241 return QVariant();
253 return QVariant();
242
254
243− QVariant attribute;
244−
245− IndicatorClientInterface::Ptr plugin = m_plugins[index.row()];
255+ Indicator::Ptr plugin = m_plugins[index.row()];
246
256
247− switch (role) {
257+ switch (role)
248− case Identifier:
249− if (plugin) {
250− attribute = QVariant(plugin->identifier());
251− }
252− break;
253− case Title:
254− if (plugin) {
255− attribute = QVariant(plugin->title());
256− }
257− break;
258− case Label:
259− if (plugin) {
260− attribute = QVariant(plugin->label());
261− }
262− break;
263− case Description:
264 {
258 {
259+ case Identifier:
265− if (plugin) {
260+ if (plugin)
266− attribute = QVariant(plugin->description());
261+ {
262+ return QVariant(plugin->identifier());
263+ }
264+ break;
265+ case IndicatorProperties:
266+ if (plugin)
267+ {
268+ return QVariant(plugin->indicatorProperties());
267− }
269+ }
270+ break;
271+ case IsValid:
272+ return (plugin.get() ? true : false);
273+ case Priority:
274+ case Title:
275+ case Description:
276+ case IconQml:
277+ case PageQml:
278+ return indicatorData(plugin, role);
279+ default:
268− break;
280+ break;
269 }
281 }
270− case IconUrl:
282+ return QVariant();
271− if (plugin) {
283+}
272− return plugin->iconComponentSource().toString();
284+
273− } else {
285+QVariant IndicatorsModel::indicatorData(const Indicator::Ptr& plugin, int role) const
274− attribute = QVariant("No plugin");
286+{
275− }
287+ if (plugin && m_parsed_indicator_data.contains(plugin->identifier()))
276− break;
288+ {
277− case PageUrl:
289+ QVariantMap data = m_parsed_indicator_data[plugin->identifier()];
278− if (plugin) {
290+ return data.value(roleNames()[role], QVariant());
279− return plugin->pageComponentSource();
280− }
281− break;
282− case InitialProperties:
283− if (plugin) {
284− attribute = plugin->initialProperties();
285− }
286− break;
287− case IsValid:
288− attribute = QVariant(plugin != 0);
289− break;
290− default:
291− break;
292 }
291 }
293− return attribute;
292+ return defaultData(plugin, role);
294}
293}
295
294
296/*! \internal */
295/*! \internal */
@@ -304,3 +303,24 @@ int IndicatorsModel::rowCount(const QModelIndex&) const
304{
303{
305 return m_plugins.count();
304 return m_plugins.count();
306}
305}
306+
307+void IndicatorsModel::setIndicatorData(const QVariant& data)
308+{
309+ m_indicator_data = data;
310+
311+ m_parsed_indicator_data.clear();
312+ QMap<QString, QVariant> map = data.toMap();
313+ QMapIterator<QString, QVariant> iter(map);
314+ while(iter.hasNext())
315+ {
316+ iter.next();
317+ m_parsed_indicator_data[iter.key()] = iter.value().toMap();
318+ }
319+
320+ Q_EMIT indicatorDataChanged(m_indicator_data);
321+}
322+
323+QVariant IndicatorsModel::indicatorData() const
324+{
325+ return m_indicator_data;
326+}
plugins/IndicatorsClient/indicatorsmodel.h+19−9
@@ -21,7 +21,7 @@
21#ifndef INDICATORSMODEL_H
21#ifndef INDICATORSMODEL_H
22#define INDICATORSMODEL_H
22#define INDICATORSMODEL_H
23
23
24−#include "indicatorclientinterface.h"
24+#include "indicator.h"
25
25
26#include <QAbstractListModel>
26#include <QAbstractListModel>
27#include <QQmlEngine>
27#include <QQmlEngine>
@@ -31,17 +31,19 @@ class IndicatorsManager;
31class IndicatorsModel : public QAbstractListModel
31class IndicatorsModel : public QAbstractListModel
32{
32{
33 Q_OBJECT
33 Q_OBJECT
34+ Q_ENUMS(Roles)
34 Q_PROPERTY(int count READ count NOTIFY countChanged)
35 Q_PROPERTY(int count READ count NOTIFY countChanged)
36+ Q_PROPERTY(QVariant indicatorData READ indicatorData WRITE setIndicatorData NOTIFY indicatorDataChanged)
35
37
36public:
38public:
37− enum ModelRoles {
39+ enum Roles {
38 Identifier = 0,
40 Identifier = 0,
41+ Priority,
39 Title,
42 Title,
40− Label,
41 Description,
43 Description,
42− IconUrl,
44+ IconQml,
43− PageUrl,
45+ PageQml,
44− InitialProperties,
46+ IndicatorProperties,
45 IsValid
47 IsValid
46 };
48 };
47
49
@@ -60,22 +62,30 @@ public:
60 QModelIndex parent (const QModelIndex &index) const;
62 QModelIndex parent (const QModelIndex &index) const;
61 int rowCount(const QModelIndex &parent = QModelIndex()) const;
63 int rowCount(const QModelIndex &parent = QModelIndex()) const;
62
64
65+ void setIndicatorData(const QVariant& data);
66+ QVariant indicatorData() const;
67+
63Q_SIGNALS:
68Q_SIGNALS:
64 void countChanged();
69 void countChanged();
70+ void indicatorDataChanged(const QVariant& data);
65
71
66private Q_SLOTS:
72private Q_SLOTS:
67 void onIdentifierChanged();
73 void onIdentifierChanged();
68− void onTitleChanged();
74+ void onIndicatorPropertiesChanged();
69− void onLabelChanged();
70 void onIndicatorLoaded(const QString& indicator);
75 void onIndicatorLoaded(const QString& indicator);
71 void onIndicatorAboutToBeUnloaded(const QString& indicator);
76 void onIndicatorAboutToBeUnloaded(const QString& indicator);
72
77
73private:
78private:
74 IndicatorsManager *m_manager;
79 IndicatorsManager *m_manager;
80+
75− QList<IndicatorClientInterface::Ptr> m_plugins;
81+ QList<Indicator::Ptr> m_plugins;
82+ QVariant m_indicator_data;
83+ QMap<QString, QVariantMap> m_parsed_indicator_data;
76
84
77 void notifyDataChanged(QObject *sender, int role);
85 void notifyDataChanged(QObject *sender, int role);
78 int count() const;
86 int count() const;
87+ QVariant indicatorData(const Indicator::Ptr& plugin, int role) const;
88+ static QVariant defaultData(Indicator::Ptr plugin, int role);
79};
89};
80
90
81#endif // INDICATORSMODEL_H
91#endif // INDICATORSMODEL_H
plugins/IndicatorsClient/qml/ButtonMenu.qml+1−1
@@ -21,7 +21,7 @@ import QtQuick 2.0
21import Ubuntu.Components 0.1
21import Ubuntu.Components 0.1
22
22
23BasicMenu {
23BasicMenu {
24− property variant action: menu && actionGroup ? actionGroup.action(menu.action) : undefined
24+ property variant action: menu && menu.action!="" && actionGroup ? actionGroup.action(menu.action) : null
25
25
26 color: "#221e1b"
26 color: "#221e1b"
27 height: undefined // If we're using implicitHieght, we need to make sure height is not set.
27 height: undefined // If we're using implicitHieght, we need to make sure height is not set.
plugins/IndicatorsClient/qml/DBusActionState.qml+2−2
@@ -46,7 +46,7 @@ Item {
46 \preliminary
46 \preliminary
47 The dbus action name
47 The dbus action name
48 */
48 */
49− property string action : undefined
49+ property string action : ""
50
50
51 /*!
51 /*!
52 \preliminary
52 \preliminary
@@ -78,7 +78,7 @@ Item {
78
78
79 Item {
79 Item {
80 id: priv
80 id: priv
81− property variant actionObject : action && actionGroup ? actionGroup.action(action) : null
81+ property variant actionObject : action!="" && actionGroup ? actionGroup.action(action) : null
82 property variant actionState: actionObject ? actionObject.state : undefined
82 property variant actionState: actionObject ? actionObject.state : undefined
83
83
84 Binding {
84 Binding {
plugins/IndicatorsClient/qml/IndicatorIcon.qml+2
@@ -26,6 +26,7 @@ IndicatorBase {
26 id: indicatorIcon
26 id: indicatorIcon
27 property var action: undefined
27 property var action: undefined
28 property bool started: (busType != 0) && (busName != "") && (objectPath != "")
28 property bool started: (busType != 0) && (busName != "") && (objectPath != "")
29+ property int iconSize: height - units.gu(0.5)
29
30
30 signal actionStateChanged()
31 signal actionStateChanged()
31
32
@@ -43,6 +44,7 @@ IndicatorBase {
43 onActionGroupUpdated: update_state()
44 onActionGroupUpdated: update_state()
44 onModelUpdated: update_state()
45 onModelUpdated: update_state()
45
46
47+
46 function update_state() {
48 function update_state() {
47 var data = proxyModel.get(0)
49 var data = proxyModel.get(0)
48 if (data == undefined || data.extra == undefined) {
50 if (data == undefined || data.extra == undefined) {
plugins/IndicatorsClient/qml/ProgressMenu.qml+1−1
@@ -55,7 +55,7 @@ Menu {
55 }
55 }
56
56
57 DBusActionState {
57 DBusActionState {
58− action: menu ? menu.action : undefined
58+ action: menu ? menu.action : ""
59 target: progressBar
59 target: progressBar
60 property: "value"
60 property: "value"
61 }
61 }
plugins/IndicatorsClient/qml/SliderMenu.qml+2−2
@@ -31,7 +31,7 @@ Menu {
31 id: slider
31 id: slider
32 width: _sliderMenu.text ? units.gu(20) : _sliderMenu.width - units.gu(4)
32 width: _sliderMenu.text ? units.gu(20) : _sliderMenu.width - units.gu(4)
33 anchors.verticalCenter: parent.verticalCenter
33 anchors.verticalCenter: parent.verticalCenter
34− live: false
34+ live: false
35 // FIXME: The interval should be [0.0 - 1.0]. Unfortunately, when
35 // FIXME: The interval should be [0.0 - 1.0]. Unfortunately, when
36 // reaching the boundaries (0.0 or 1.0), the value is converted
36 // reaching the boundaries (0.0 or 1.0), the value is converted
37 // to an integer when automatically wrapped in a variant when
37 // to an integer when automatically wrapped in a variant when
@@ -59,7 +59,7 @@ Menu {
59 }
59 }
60
60
61 DBusActionState {
61 DBusActionState {
62− action: menu ? menu.action : undefined
62+ action: menu ? menu.action : ""
63 target: slider
63 target: slider
64 property: "value"
64 property: "value"
65 }
65 }
plugins/IndicatorsClient/qml/SwitchMenu.qml+1−1
@@ -33,7 +33,7 @@ Menu {
33 }
33 }
34
34
35 DBusActionState {
35 DBusActionState {
36− action: menu ? menu.action : undefined
36+ action: menu ? menu.action : ""
37 target: switcher
37 target: switcher
38 property: "checked"
38 property: "checked"
39 }
39 }
plugins/IndicatorsClient/qml/TextMenu.qml+1−1
@@ -74,7 +74,7 @@ Menu {
74 }
74 }
75
75
76 DBusActionState {
76 DBusActionState {
77− action: menu ? menu.action : undefined
77+ action: menu ? menu.action : ""
78 target: _textField
78 target: _textField
79 property: "text"
79 property: "text"
80 }
80 }
plugins/IndicatorsClient/qml/messaging/GroupedMessage.qml+1−1
@@ -23,7 +23,7 @@ import Ubuntu.Components 0.1
23import IndicatorsClient 0.1 as IndicatorsClient
23import IndicatorsClient 0.1 as IndicatorsClient
24
24
25IndicatorsClient.BasicMenu {
25IndicatorsClient.BasicMenu {
26− property variant action: menu && actionGroup ? actionGroup.action(menu.action) : undefined
26+ property variant action: menu && menu.action!="" && actionGroup ? actionGroup.action(menu.action) : null
27 property alias count: label.text
27 property alias count: label.text
28
28
29 color: "#221e1b"
29 color: "#221e1b"
plugins/IndicatorsClient/qml/messaging/HeroMessage.qml+1−1
@@ -26,7 +26,7 @@ IndicatorsClient.BasicMenu {
26 id: __heroMessage
26 id: __heroMessage
27
27
28 property variant actionsDescription: null
28 property variant actionsDescription: null
29− property variant action: menu && actionGroup ? actionGroup.action(menu.action) : undefined
29+ property variant action: menu && menu.action!="" && actionGroup ? actionGroup.action(menu.action) : null
30 property alias heroMessageHeader: __heroMessageHeader
30 property alias heroMessageHeader: __heroMessageHeader
31 property real collapsedHeight: heroMessageHeader.y + heroMessageHeader.bodyBottom + units.gu(2)
31 property real collapsedHeight: heroMessageHeader.y + heroMessageHeader.bodyBottom + units.gu(2)
32 property real expandedHeight: collapsedHeight
32 property real expandedHeight: collapsedHeight
plugins/IndicatorsClient/qml/network/AccessPoint.qml+2−2
@@ -51,7 +51,7 @@ IndicatorsClient.Menu {
51 return "image://gicon/" + imageName;
51 return "image://gicon/" + imageName;
52 }
52 }
53
53
54− icon: menu && wifiApStrength ? getNetworkIcon(menu) : "image://gicon/nm-no-connection"
54+ icon: menu && wifiApStrength ? getNetworkIcon(menu) : "image://gicon/wifi-none"
55 iconFrame: false
55 iconFrame: false
56 control: CheckBox {
56 control: CheckBox {
57 id: checkBoxActive
57 id: checkBoxActive
@@ -62,7 +62,7 @@ IndicatorsClient.Menu {
62 }
62 }
63
63
64 IndicatorsClient.DBusActionState {
64 IndicatorsClient.DBusActionState {
65− action: menu ? menu.action : undefined
65+ action: menu ? menu.action : ""
66 target: checkBoxActive
66 target: checkBoxActive
67 property: "checked"
67 property: "checked"
68 }
68 }
plugins/IndicatorsClient/qml/network/qmldir+1
@@ -1,4 +1,5 @@
1module IndicatorsClient.Network
1module IndicatorsClient.Network
2+plugin IndicatorsClientNetworkQml
2
3
3NetworkPage 0.1 NetworkPage.qml
4NetworkPage 0.1 NetworkPage.qml
4AccessPoint 0.1 AccessPoint.qml
5AccessPoint 0.1 AccessPoint.qml
plugins/IndicatorsClient/resources/indicatorclient.qrc−9
@@ -1,16 +1,7 @@
1<RCC>
1<RCC>
2 <qresource prefix="/indicatorsclient">
2 <qresource prefix="/indicatorsclient">
3− <file>artwork/datetime/time_and_date@18.png</file>
4 <file>artwork/messaging/default_contact.png</file>
3 <file>artwork/messaging/default_contact.png</file>
5 <file>artwork/messaging/default_app.svg</file>
4 <file>artwork/messaging/default_app.svg</file>
6 <file>artwork/messaging/message_sms01_54px.png</file>
5 <file>artwork/messaging/message_sms01_54px.png</file>
7−
8− <file>qml/DefaultIndicatorIcon.qml</file>
9− <file>qml/DefaultIndicatorPage.qml</file>
10− <file>qml/DatetimeIndicatorIcon.qml</file>
11− <file>qml/DatetimeIndicatorPage.qml</file>
12− <file>qml/MessagingIndicatorPage.qml</file>
13− <file>qml/NetworkIndicatorIcon.qml</file>
14− <file>qml/NetworkIndicatorPage.qml</file>
15 </qresource>
6 </qresource>
16</RCC>
7</RCC>
plugins/Utils/CMakeLists.txt+1
@@ -5,6 +5,7 @@ include_directories(
5)
5)
6
6
7set(QMLPLUGIN_SRC
7set(QMLPLUGIN_SRC
8+ applicationpaths.h
8 qlimitproxymodelqml.cpp
9 qlimitproxymodelqml.cpp
9 qsortfilterproxymodelqml.cpp
10 qsortfilterproxymodelqml.cpp
10 ubuntuwindow.cpp
11 ubuntuwindow.cpp
plugins/Utils/applicationpaths.hnew file+40
@@ -0,0 +1,40 @@
1+/*
2+ * Copyright (C) 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 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+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
17+ */
18+
19+
20+#ifndef APPLICATION_PATHS_H
21+#define APPLICATION_PATHS_H
22+
23+#include <QObject>
24+#include "paths.h"
25+
26+class ApplicationPaths : public QObject
27+{
28+ Q_OBJECT
29+public:
30+ ApplicationPaths(QObject*parent=0):QObject(parent) {}
31+
32+ Q_INVOKABLE bool isRunningInstalled() const { return ::isRunningInstalled(); }
33+ Q_INVOKABLE QString shellAppDirectory() const { return ::shellAppDirectory(); }
34+ Q_INVOKABLE QString shellImportPath() const { return ::shellImportPath(); }
35+ Q_INVOKABLE QString fakePluginsImportPath() const { return ::fakePluginsImportPath(); }
36+ Q_INVOKABLE QStringList shellDataDirs() const { return ::shellDataDirs(); }
37+ Q_INVOKABLE QString sourceDirectory() const { return ::sourceDirectory(); }
38+};
39+
40+#endif // APPLICATION_PATHS_H
plugins/Utils/plugin.cpp+2
@@ -24,6 +24,7 @@
24#include "plugin.h"
24#include "plugin.h"
25
25
26// local
26// local
27+#include "applicationpaths.h"
27#include "qlimitproxymodelqml.h"
28#include "qlimitproxymodelqml.h"
28#include "qsortfilterproxymodelqml.h"
29#include "qsortfilterproxymodelqml.h"
29#include "ubuntuwindow.h"
30#include "ubuntuwindow.h"
@@ -35,4 +36,5 @@ void UtilsPlugin::registerTypes(const char *uri)
35 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
36 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
36 qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");
37 qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");
37 qmlRegisterExtendedType<QQuickWindow, UbuntuWindow>(uri, 0, 1, "Window");
38 qmlRegisterExtendedType<QQuickWindow, UbuntuWindow>(uri, 0, 1, "Window");
39+ qmlRegisterType<ApplicationPaths>(uri, 0, 1, "ApplicationPaths");
38}
40}
tests/autopilot/indicators_client/emulators/__init__.py+2−7
@@ -5,7 +5,7 @@
5# under the terms of the GNU General Public License version 3, as published
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
6# by the Free Software Foundation.
7
7
8−from autopilot.introspection.dbus import CustomEmulatorBase
8+from autopilot.introspection.dbus import DBusIntrospectionObject
9from autopilot.input import Mouse, Touch, Pointer
9from autopilot.input import Mouse, Touch, Pointer
10from autopilot.platform import model
10from autopilot.platform import model
11
11
@@ -13,7 +13,7 @@ from time import sleep
13
13
14from autopilot.introspection.dbus import IntrospectableObjectMetaclass
14from autopilot.introspection.dbus import IntrospectableObjectMetaclass
15
15
16−class IndicatorsEmulatorBase(CustomEmulatorBase):
16+class IndicatorsIntrospectionObject(DBusIntrospectionObject):
17
17
18 """A common class that provides introspection and other helpers to indictors."""
18 """A common class that provides introspection and other helpers to indictors."""
19
19
@@ -29,8 +29,3 @@ class IndicatorsEmulatorBase(CustomEmulatorBase):
29 def setUp(self):
29 def setUp(self):
30 self.pointing_device = Pointer(self.input_device_class.create())
30 self.pointing_device = Pointer(self.input_device_class.create())
31 super(IndicatorsTestCase, self).setUp()
31 super(IndicatorsTestCase, self).setUp()
32−
33−
34− def plop(self):
35− print type(CustomEmulatorBase)
36− print "PLOP"
tests/autopilot/indicators_client/emulators/common.py+4−37
@@ -5,43 +5,10 @@
5# under the terms of the GNU General Public License version 3, as published
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
6# by the Free Software Foundation.
7
7
8−from indicators_client.emulators import IndicatorsEmulatorBase
8+from indicators_client.emulators import IndicatorsIntrospectionObject
9
9
10−class SwitchMenu(IndicatorsEmulatorBase):
10+class SwitchMenu(IndicatorsIntrospectionObject):
11 """A switch menu control."""
11 """A switch menu control."""
12
12
13− def setUp(self):
13+class Switch(IndicatorsIntrospectionObject):
14− print "PLOP"
15− super(IndicatorsEmulatorBase, self).setUp()
16−
17− def switch(self):
18− self.plop()
19− ab_switch = self.select_single("CheckBox");
20− self.assertThat(ab_switch, NotEquals(None))
21−
22− self.pointing_device.move_to_object(ab_switch)
23− self.pointing_device.click()
24−
25−class SliderMenu(IndicatorsEmulatorBase):
26− """A slider menu control."""
14+ """A switch control."""
27−
28− def set_value(self, new_value):
29− brightness_slider = self.select_single("Slider");
30− self.assertThat(brightness_slider, NotEquals(None))
31−
32− self.pointing_device.move_to_object(brightness_slider)
33−
34− old_ab_value = brightness_slider.value
35− pixel_ratio = brightness_slider.width / (brightness_slider.maximumValue - brightness_slider.minimumValue)
36− print pixel_ratio
37−
38− while True:
39−
40− pixels_to_move = int(pixel_ratio * (new_value - old_ab_value) / 15)
41− if pixels_to_move == 0:
42− break;
43− print pixels_to_move
44−
45− self.pointing_device.drag(self.pointing_device.x, self.pointing_device.y, self.pointing_device.x + pixels_to_move, self.pointing_device.y)
46−
47− old_ab_value = brightness_slider.value
tests/autopilot/indicators_client/emulators/main_window.py+2
@@ -5,6 +5,8 @@
5# under the terms of the GNU General Public License version 3, as published
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
6# by the Free Software Foundation.
7
7
8+from indicators_client.emulators import IndicatorsIntrospectionObject
9+
8class MainWindow(object):
10class MainWindow(object):
9 """An emulator class that makes it easy to interact with the shell"""
11 """An emulator class that makes it easy to interact with the shell"""
10
12
tests/autopilot/indicators_client/tests/__init__.py+1−3
@@ -15,7 +15,6 @@ from autopilot.matchers import Eventually
15from autopilot.platform import model
15from autopilot.platform import model
16from testtools.matchers import Equals
16from testtools.matchers import Equals
17
17
18−from indicators_client.emulators import IndicatorsEmulatorBase
19from indicators_client.emulators.main_window import MainWindow
18from indicators_client.emulators.main_window import MainWindow
20from logging import getLogger
19from logging import getLogger
21import sys
20import sys
@@ -47,8 +46,7 @@ class IndicatorsTestCase(AutopilotTestCase):
47 def launch_test_local(self):
46 def launch_test_local(self):
48 os.environ['LD_LIBRARY_PATH'] = "../../../unity_build/build/lib"
47 os.environ['LD_LIBRARY_PATH'] = "../../../unity_build/build/lib"
49 os.environ['QML2_IMPORT_PATH'] = "../../builddir/plugins:../../builddir/tests/mocks"
48 os.environ['QML2_IMPORT_PATH'] = "../../builddir/plugins:../../builddir/tests/mocks"
50− self.app = self.launch_test_application("../../builddir/plugins/IndicatorsClient/client/indicators-client",
49+ self.app = self.launch_test_application("../../builddir/Panel/indicatorsclient/indicators-client")
51− emulator_base=IndicatorsEmulatorBase)
52
50
53 def skipWrapper(*args, **kwargs):
51 def skipWrapper(*args, **kwargs):
54 pass
52 pass
tests/autopilot/indicators_client/tests/test_power.py+34−4
@@ -11,7 +11,6 @@ from testtools.matchers import Equals, NotEquals
11from autopilot.matchers import Eventually
11from autopilot.matchers import Eventually
12
12
13from indicators_client.tests import IndicatorsTestCase
13from indicators_client.tests import IndicatorsTestCase
14−from indicators_client.emulators.common import SwitchMenu, SliderMenu
15from time import sleep
14from time import sleep
16import random
15import random
17import math
16import math
@@ -34,15 +33,46 @@ class TestDisplayMenus(IndicatorsTestCase):
34 # self.main_window.get_indicators_client().reset()
33 # self.main_window.get_indicators_client().reset()
35 super(TestDisplayMenus, self).tearDown()
34 super(TestDisplayMenus, self).tearDown()
36
35
36+
37+ # START SECTION
38+ # We need to move these to emulators once autopilot supports emulators for
39+ # applications started with AutopilotTestCase.launch_test_application
40+
41+ def switch_auto_brightness(self, auto_brightness):
42+ ab_switch = auto_brightness.select_single("CheckBox");
43+ self.assertThat(ab_switch, NotEquals(None))
44+
45+ self.pointing_device.move_to_object(ab_switch)
46+ self.pointing_device.click()
47+
48+ def set_brightness_to_value(self, brightness_menu, new_value):
49+ brightness_slider = brightness_menu.select_single("Slider");
50+ self.assertThat(brightness_slider, NotEquals(None))
51+
52+ self.pointing_device.move_to_object(brightness_slider)
53+
54+ old_ab_value = brightness_slider.value
55+ pixel_ratio = brightness_slider.width / (brightness_slider.maximumValue - brightness_slider.minimumValue)
56+
57+ while True:
58+
59+ pixels_to_move = int(pixel_ratio * (new_value - old_ab_value) / 15)
60+ if pixels_to_move == 0:
61+ break;
62+
63+ self.pointing_device.drag(self.pointing_device.x, self.pointing_device.y, self.pointing_device.x + pixels_to_move, self.pointing_device.y)
64+
65+ old_ab_value = brightness_slider.value
66+
37 def test_auto_bright_switch(self):
67 def test_auto_bright_switch(self):
38 """Test the auto-bright switch"""
68 """Test the auto-bright switch"""
39
69
40 auto_brightness = self.app.select_single("SwitchMenu", objectName="auto-brightness")
70 auto_brightness = self.app.select_single("SwitchMenu", objectName="auto-brightness")
41 self.assertThat(auto_brightness, NotEquals(None))
71 self.assertThat(auto_brightness, NotEquals(None))
42
72
43− # old_ab_value = auto_brightness.checked
73+ old_ab_value = auto_brightness.checked
44
74
45− auto_brightness.switch()
75+ self.switch_auto_brightness(auto_brightness)
46
76
47 # TODO - should check backend when it's introspectable.
77 # TODO - should check backend when it's introspectable.
48 self.assertThat(auto_brightness.checked, Eventually(NotEquals(old_ab_value)))
78 self.assertThat(auto_brightness.checked, Eventually(NotEquals(old_ab_value)))
@@ -60,7 +90,7 @@ class TestDisplayMenus(IndicatorsTestCase):
60 if (abs(desired_value - old_ab_value) >= (brightness_menu.maximumValue - brightness_menu.minimumValue)/4):
90 if (abs(desired_value - old_ab_value) >= (brightness_menu.maximumValue - brightness_menu.minimumValue)/4):
61 break;
91 break;
62
92
63− brightness_menu.set_value(desired_value)
93+ self.set_brightness_to_value(brightness_menu, desired_value)
64
94
65 # TODO - should check backend when it's introspectable.
95 # TODO - should check backend when it's introspectable.
66 self.assertThat(brightness_menu.value, Eventually(NotEquals(old_ab_value)))
96 self.assertThat(brightness_menu.value, Eventually(NotEquals(old_ab_value)))
tests/data/unity/indicators/indicator-fake4.indicatornew file+4
@@ -0,0 +1,4 @@
1+[Indicator Service]
2+Name=indicator-fake4
3+DBusName=com.canonical.indicator.fake4
4+ObjectPath=/com/canonical/indicator/fake4
tests/plugins/IndicatorsClient/CMakeLists.txt+1−1
@@ -12,7 +12,7 @@ macro(run_tests)
12 -o -,txt)
12 -o -,txt)
13 add_test(NAME ${_test} COMMAND ${testCommand})
13 add_test(NAME ${_test} COMMAND ${testCommand})
14 add_custom_target(${_test} ${testCommand})
14 add_custom_target(${_test} ${testCommand})
15− add_executable(${_test}Exec ${_test}.cpp fakeindicator.h
15+ add_executable(${_test}Exec ${_test}.cpp
16 )
16 )
17 qt5_use_modules(${_test}Exec Test Core Qml)
17 qt5_use_modules(${_test}Exec Test Core Qml)
18 target_link_libraries(${_test}Exec
18 target_link_libraries(${_test}Exec
tests/plugins/IndicatorsClient/fakeindicator.hdeleted−62
@@ -1,62 +0,0 @@
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− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− * Nick Dedekind <nick.dedekind@canonical.com>
19− */
20−
21−#ifndef FAKE_INDICATORCLIENT_H
22−#define FAKE_INDICATORCLIENT_H
23−
24−#include "indicatorclient_common.h"
25−
26−class FakeIndicatorClient : public IndicatorClientCommon
27−{
28− Q_OBJECT
29− Q_PROPERTY(int initializedCount READ initializedCount)
30−public:
31− FakeIndicatorClient(QObject *parent=0)
32− : IndicatorClientCommon(parent)
33− , m_initializedCount(0)
34− {
35− }
36− void init(const QSettings& settings)
37− {
38− IndicatorClientCommon::init(settings);
39− m_initializedCount++;
40− }
41− int initializedCount() const { return m_initializedCount; }
42− void shutdown() { m_initializedCount--; }
43−
44− private:
45− int m_initializedCount;
46−};
47−
48−
49−#define FAKE_INDICATOR(number, title) \
50− class FakeIndicatorClient##number : public FakeIndicatorClient \
51− { \
52− public: \
53− FakeIndicatorClient##number(QObject *parent=0) \
54− : FakeIndicatorClient(parent) \
55− { \
56− setTitle(title); \
57− setPriority(number); \
58− } \
59− };
60−
61−
62−#endif
tests/plugins/IndicatorsClient/indicatorsmanagertest.cpp+16−26
@@ -17,27 +17,26 @@
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
18 */
19
19
20−#include "fakeindicator.h"
21#include "indicatorsmanager.h"
20#include "indicatorsmanager.h"
22−#include "indicatorsfactory.h"
23#include "paths.h"
21#include "paths.h"
24
22
25#include <QtTest>
23#include <QtTest>
26#include <QDebug>
24#include <QDebug>
27
25
28−FAKE_INDICATOR(1, "Fake Title 1")
29−FAKE_INDICATOR(2, "Fake Title 2")
30−
31class IndicatorsManagerTest : public QObject
26class IndicatorsManagerTest : public QObject
32{
27{
33 Q_OBJECT
28 Q_OBJECT
34private Q_SLOTS:
29private Q_SLOTS:
35
30
36− void initTestCase() {
31+ void initTestCase()
32+ {
33+ setenv("UNITY_TEST_ENV", "1", 1);
37 setenv("XDG_DATA_DIRS", (sourceDirectory() + "/tests/data").toLatin1().data(), 1);
34 setenv("XDG_DATA_DIRS", (sourceDirectory() + "/tests/data").toLatin1().data(), 1);
35+ }
38
36
39− IndicatorsFactory::instance().registerIndicator<FakeIndicatorClient1>("indicator-fake1");
37+ void cleanupTestCase()
40− IndicatorsFactory::instance().registerIndicator<FakeIndicatorClient2>("indicator-fake2");
38+ {
39+ unsetenv("UNITY_TEST_ENV");
41 }
40 }
42
41
43 /*
42 /*
@@ -45,7 +44,6 @@ private Q_SLOTS:
45 */
44 */
46 void testLoad()
45 void testLoad()
47 {
46 {
48−
49 IndicatorsManager manager;
47 IndicatorsManager manager;
50
48
51 QVERIFY(!manager.isLoaded());
49 QVERIFY(!manager.isLoaded());
@@ -54,7 +52,7 @@ private Q_SLOTS:
54 manager.load();
52 manager.load();
55
53
56 QVERIFY(manager.isLoaded());
54 QVERIFY(manager.isLoaded());
57− QCOMPARE(manager.indicators().count(), 2);
55+ QCOMPARE(manager.indicators().count(), 4);
58
56
59 manager.unload();
57 manager.unload();
60
58
@@ -70,19 +68,14 @@ private Q_SLOTS:
70 IndicatorsManager manager;
68 IndicatorsManager manager;
71 manager.load();
69 manager.load();
72
70
73− IndicatorClientInterface::Ptr indicator = manager.indicator("indicator-fake1");
71+ Indicator::Ptr indicator = manager.indicator("indicator-fake1");
74 QVERIFY(indicator.get());
72 QVERIFY(indicator.get());
75
73
76 QCOMPARE(indicator->identifier(), QString("indicator-fake1"));
74 QCOMPARE(indicator->identifier(), QString("indicator-fake1"));
77− QCOMPARE(indicator->title(), QString("Fake Title 1"));
78− QCOMPARE(indicator->label(), QString());
79− QCOMPARE(indicator->description(), QString());
80− QCOMPARE(indicator->priority(), 1);
81
75
82 // Check that the initial properties have been set.
76 // Check that the initial properties have been set.
83− IndicatorClientInterface::PropertiesMap props = indicator->initialProperties();
77+ QVariantMap props = indicator->indicatorProperties().toMap();
84− QCOMPARE(props.count(), 4);
78+ QCOMPARE(props.count(), 3);
85− QCOMPARE(props["title"].toString(), QString("Fake Title 1"));
86 QCOMPARE(props["busType"].toInt(), 1);
79 QCOMPARE(props["busType"].toInt(), 1);
87 QCOMPARE(props["busName"].toString(), QString("com.canonical.indicator.fake1"));
80 QCOMPARE(props["busName"].toString(), QString("com.canonical.indicator.fake1"));
88 QCOMPARE(props["objectPath"].toString(), QString("/com/canonical/indicator/fake1"));
81 QCOMPARE(props["objectPath"].toString(), QString("/com/canonical/indicator/fake1"));
@@ -96,13 +89,13 @@ private Q_SLOTS:
96 IndicatorsManager manager;
89 IndicatorsManager manager;
97 manager.load();
90 manager.load();
98
91
99− IndicatorClientInterface::Ptr i0 = manager.indicator("indicator-fake1");
92+ Indicator::Ptr i0 = manager.indicator("indicator-fake1");
100− IndicatorClientInterface::Ptr i1 = manager.indicator("indicator-fake1");
93+ Indicator::Ptr i1 = manager.indicator("indicator-fake1");
101 QVERIFY(i0?true:false);
94 QVERIFY(i0?true:false);
102 QVERIFY(i1?true:false);
95 QVERIFY(i1?true:false);
103 QCOMPARE(i0, i1);
96 QCOMPARE(i0, i1);
104
97
105− IndicatorClientInterface::Ptr i2 = manager.indicator("indicator-fake2");
98+ Indicator::Ptr i2 = manager.indicator("indicator-fake2");
106 QVERIFY(i2?true:false);
99 QVERIFY(i2?true:false);
107 QVERIFY(i2 != i1);
100 QVERIFY(i2 != i1);
108 QVERIFY(i2 != i1);
101 QVERIFY(i2 != i1);
@@ -119,14 +112,11 @@ private Q_SLOTS:
119 QPointer<QObject> pi0;
112 QPointer<QObject> pi0;
120 QPointer<QObject> pi1;
113 QPointer<QObject> pi1;
121 {
114 {
122− IndicatorClientInterface::Ptr i0 = manager.indicator("indicator-fake1");
115+ Indicator::Ptr i0 = manager.indicator("indicator-fake1");
123 pi0 = dynamic_cast<QObject*>(i0.get());
116 pi0 = dynamic_cast<QObject*>(i0.get());
124− QCOMPARE(pi0->property("initializedCount").toInt(), 1);
125
117
126− IndicatorClientInterface::Ptr i1 = manager.indicator("indicator-fake1");
118+ Indicator::Ptr i1 = manager.indicator("indicator-fake1");
127 pi1 = dynamic_cast<QObject*>(i1.get());
119 pi1 = dynamic_cast<QObject*>(i1.get());
128− QCOMPARE(pi0->property("initializedCount").toInt(), 1);
129− QCOMPARE(pi1->property("initializedCount").toInt(), 1);
130
120
131 manager.unload();
121 manager.unload();
132 // still alive while we have the shared pointers.
122 // still alive while we have the shared pointers.
tests/plugins/IndicatorsClient/indicatorsmodeltest.cpp+38−30
@@ -17,31 +17,30 @@
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
18 */
19
19
20−#include "fakeindicator.h"
21#include "indicatorsmodel.h"
20#include "indicatorsmodel.h"
22−#include "indicatorsfactory.h"
23#include "paths.h"
21#include "paths.h"
24
22
25#include <QtTest>
23#include <QtTest>
26#include <QDebug>
24#include <QDebug>
27
25
28−FAKE_INDICATOR(1, "Fake Title 1")
29−FAKE_INDICATOR(2, "Fake Title 2")
30−
31class IndicatorsModelTest : public QObject
26class IndicatorsModelTest : public QObject
32{
27{
33 Q_OBJECT
28 Q_OBJECT
34private Q_SLOTS:
29private Q_SLOTS:
35
30
36− void initTestCase() {
31+ void initTestCase()
32+ {
33+ setenv("UNITY_TEST_ENV", "1", 1);
37 setenv("XDG_DATA_DIRS", (sourceDirectory() + "/tests/data").toLatin1().data(), 1);
34 setenv("XDG_DATA_DIRS", (sourceDirectory() + "/tests/data").toLatin1().data(), 1);
35+ }
38
36
39− IndicatorsFactory::instance().registerIndicator<FakeIndicatorClient1>("indicator-fake1");
37+ void cleanupTestCase()
40− IndicatorsFactory::instance().registerIndicator<FakeIndicatorClient2>("indicator-fake2");
38+ {
39+ unsetenv("UNITY_TEST_ENV");
41 }
40 }
42
41
43 /*
42 /*
44− * Test if all plugins is loaded correct
43+ * Testa that all the plugins are loaded / unloaded correctly
45 */
44 */
46 void testLoad()
45 void testLoad()
47 {
46 {
@@ -51,7 +50,7 @@ private Q_SLOTS:
51
50
52 model.load();
51 model.load();
53
52
54− QCOMPARE(model.property("count").toInt(), 2);
53+ QCOMPARE(model.property("count").toInt(), 4);
55
54
56 model.unload();
55 model.unload();
57
56
@@ -60,31 +59,40 @@ private Q_SLOTS:
60 }
59 }
61
60
62 /*
61 /*
63− * Test if the plugin data was loaded correct
62+ * Testa that the plugin data was loaded correctly
64 */
63 */
65− void testDataOrder()
64+ void testDataAndOrder()
66 {
65 {
66+ // Priority order. (2, 1, 4, 3)
67+ QVariantMap map;
68+ QVariantMap map1; map1["priority"] = 1; map1["title"] = "fake1";
69+ QVariantMap map2; map2["priority"] = 0; map2["title"] = "fake2";
70+ QVariantMap map3; map3["priority"] = 3; map3["title"] = "fake3";
71+ QVariantMap map4; map4["priority"] = 2; map4["title"] = "fake4";
72+ map["indicator-fake1"] = map1;
73+ map["indicator-fake2"] = map2;
74+ map["indicator-fake3"] = map3;
75+ map["indicator-fake4"] = map4;
76+
67 IndicatorsModel model;
77 IndicatorsModel model;
78+ model.setIndicatorData(map);
68 model.load();
79 model.load();
69
80
70− QVariantMap data = model.get(0);
81+ QCOMPARE(model.get(0)["identifier"].toString(), QString("indicator-fake2"));
71− QCOMPARE(data["title"].toString(), QString("Fake Title 1"));
72− QCOMPARE(data["label"].toString(), QString());
82+ QCOMPARE(model.get(0)["title"].toString(), QString("fake2"));
73− QCOMPARE(data["description"].toString(), QString());
83+ QCOMPARE(model.get(0)["indicatorProperties"].toMap()["busName"].toString(), QString("com.canonical.indicator.fake2"));
74− // There is no QML context
84+
75− QVERIFY(!data["component"].value<QObject*>());
85+ QCOMPARE(model.get(1)["identifier"].toString(), QString("indicator-fake1"));
76− QCOMPARE(data["isValid"].toBool(), true);
86+ QCOMPARE(model.get(1)["title"].toString(), QString("fake1"));
77−
87+ QCOMPARE(model.get(1)["indicatorProperties"].toMap()["busName"].toString(), QString("com.canonical.indicator.fake1"));
78− data = model.get(1);
88+
79− QCOMPARE(data["title"].toString(), QString("Fake Title 2"));
89+ QCOMPARE(model.get(2)["identifier"].toString(), QString("indicator-fake4"));
80− QCOMPARE(data["label"].toString(), QString());
90+ QCOMPARE(model.get(2)["title"].toString(), QString("fake4"));
81− QCOMPARE(data["description"].toString(), QString());
91+ QCOMPARE(model.get(2)["indicatorProperties"].toMap()["busName"].toString(), QString("com.canonical.indicator.fake4"));
82− // There is no QML context
92+
83− QVERIFY(!data["component"].value<QObject*>());
93+ QCOMPARE(model.get(3)["identifier"].toString(), QString("indicator-fake3"));
84− QCOMPARE(data["isValid"].toBool(), true);
94+ QCOMPARE(model.get(3)["title"].toString(), QString("fake3"));
85−
95+ QCOMPARE(model.get(3)["indicatorProperties"].toMap()["busName"].toString(), QString("com.canonical.indicator.fake3"));
86− data = model.get(3);
87− QVERIFY(data.isEmpty());
88 }
96 }
89};
97};
90
98
tests/qmltests/CMakeLists.txt+5−5
@@ -57,11 +57,11 @@ add_qml_test(Hud Hud)
57add_qml_test(Hud Result)
57add_qml_test(Hud Result)
58add_qml_test(Launcher Launcher IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
58add_qml_test(Launcher Launcher IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
59add_qml_test(Notifications Notifications)
59add_qml_test(Notifications Notifications)
60−add_qml_test(Panel IndicatorRow)
60+add_qml_test(Panel IndicatorRow IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
61−add_qml_test(Panel Indicators)
61+add_qml_test(Panel Indicators IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
62−add_qml_test(Panel MenuContent)
62+add_qml_test(Panel MenuContent IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
63−add_qml_test(Panel Overview)
63+add_qml_test(Panel Overview IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
64−add_qml_test(Panel Panel)
64+add_qml_test(Panel Panel IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
65add_qml_test(Panel SearchIndicator)
65add_qml_test(Panel SearchIndicator)
66add_qml_test(Panel/Menus IndicatorMenuWindow IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS})
66add_qml_test(Panel/Menus IndicatorMenuWindow IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS})
67add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
67add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
tests/qmltests/Panel/tst_IndicatorItem.qml+13−28
@@ -29,54 +29,39 @@ Rectangle {
29 IndicatorItem {
29 IndicatorItem {
30 id: indicatorItem
30 id: indicatorItem
31 anchors.fill: parent
31 anchors.fill: parent
32− iconSource: "../../../Panel/graphics/Clock.png"
33− label: "Clock"
34 }
32 }
35
33
36 UT.UnityTestCase {
34 UT.UnityTestCase {
37 name: "IndicatorItem"
35 name: "IndicatorItem"
38
36
39 function init_test() {
37 function init_test() {
40− indicatorItem.iconSource = "../../../Panel/graphics/Clock.png"
41− indicatorItem.label = "Clock"
42 }
38 }
43
39
44 function test_dimmed() {
40 function test_dimmed() {
45 init_test()
41 init_test()
46
42
47− var itemRow = findChild(indicatorItem, "itemRow")
48 indicatorItem.dimmed = true
43 indicatorItem.dimmed = true
49− compare(itemRow.opacity > 0, true, "IndicatorItem opacity should not be 0")
44+ compare(indicatorItem.opacity > 0, true, "IndicatorItem opacity should not be 0")
50− compare(itemRow.opacity < 1, true, "IndicatorItem opacity should not be 1")
45+ compare(indicatorItem.opacity < 1, true, "IndicatorItem opacity should not be 1")
51 }
46 }
52
47
53− function test_empty() {
48+ function test_highlight() {
54− init_test()
55−
56− indicatorItem.iconSource = ""
57− indicatorItem.label = ""
49+ var itemHighlight = findChild(indicatorItem, "highlight")
58− compare(indicatorItem.visible, false, "IndicatorItem should not be visible")
50+ verify(itemHighlight != undefined)
59− }
60
51
61− function test_noLabel() {
52+ indicatorItem.highlighted = true;
62− init_test()
53+ compare(itemHighlight.visible, true, "Indicator should be highlighted")
63
54
64− var itemImage = findChild(indicatorItem, "itemImage")
55+ indicatorItem.highlighted = false;
65− var itemLabel = findChild(indicatorItem, "itemLabel")
56+ compare(itemHighlight.visible, false, "Indicator should not be highlighted")
66− indicatorItem.label = ""
67− compare(itemImage.visible, true, "The image should be visible")
68− compare(itemImage.width > 0, true, "The image should have a positive width")
69− compare(itemLabel.width > 0, false, "The label should not have a positive width")
70 }
57 }
71
58
72− function test_noImage() {
59+ function test_empty() {
73 init_test()
60 init_test()
74
61
75− var itemImage = findChild(indicatorItem, "itemImage")
76− var itemLabel = findChild(indicatorItem, "itemLabel")
77− indicatorItem.iconSource = ""
78− compare(itemImage.visible, false, "The image should not be visible")
62+ compare(indicatorItem.visible, false, "IndicatorItem should not be visible.")
79− compare(itemLabel.width > 0, true, "The label should have a positive width")
63+ indicatorItem.iconQml = "qrc:/tests/indciatorsclient/qml/fake_menu_icon1.qml";
64+ tryCompare(indicatorItem, "visible", true)
80 }
65 }
81 }
66 }
82}
67}
tests/qmltests/Panel/tst_IndicatorRow.qml+3−1
@@ -53,6 +53,7 @@ Item {
53
53
54 IndicatorsClient.IndicatorsModel {
54 IndicatorsClient.IndicatorsModel {
55 id: indicatorModel
55 id: indicatorModel
56+ Component.onCompleted: load()
56 }
57 }
57
58
58 UT.UnityTestCase {
59 UT.UnityTestCase {
@@ -177,6 +178,7 @@ Item {
177 }
178 }
178
179
179 function test_intial_state() {
180 function test_intial_state() {
181+ wait(1000)
180 init_test();
182 init_test();
181
183
182 indicatorRow.state = "initial";
184 indicatorRow.state = "initial";
@@ -241,7 +243,7 @@ Item {
241 compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in locked state");
243 compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in locked state");
242 }
244 }
243
245
244− function test_active_overview_() {
246+ function test_active_overview() {
245 init_test();
247 init_test();
246
248
247 indicatorRow.overviewActive = true;
249 indicatorRow.overviewActive = true;
tests/qmltests/Panel/tst_MenuContent.qml+9−8
@@ -27,11 +27,11 @@ Item {
27 height: units.gu(70)
27 height: units.gu(70)
28
28
29 property var indicator_status: {
29 property var indicator_status: {
30− 'menu_plugin1': { 'started': false, 'reset': 0 },
30+ 'menu_page1': { 'started': false, 'reset': 0 },
31− 'menu_plugin2': { 'started': false, 'reset': 0 },
31+ 'menu_page2': { 'started': false, 'reset': 0 },
32− 'menu_plugin3': { 'started': false, 'reset': 0 },
32+ 'menu_page3': { 'started': false, 'reset': 0 },
33− 'menu_plugin4': { 'started': false, 'reset': 0 },
33+ 'menu_page4': { 'started': false, 'reset': 0 },
34− 'menu_plugin5': { 'started': false, 'reset': 0 }
34+ 'menu_page5': { 'started': false, 'reset': 0 }
35 }
35 }
36
36
37 // Dummy objects
37 // Dummy objects
@@ -41,6 +41,7 @@ Item {
41
41
42 IndicatorsClient.IndicatorsModel {
42 IndicatorsClient.IndicatorsModel {
43 id: indicatorsModel
43 id: indicatorsModel
44+ Component.onCompleted: load()
44 }
45 }
45
46
46 MenuContent {
47 MenuContent {
@@ -123,20 +124,20 @@ Item {
123 }
124 }
124
125
125 function get_test_menu_objecName(index) {
126 function get_test_menu_objecName(index) {
126− return "menu_plugin"+(index+1);
127+ return "menu_page"+(index+1);
127 }
128 }
128
129
129 property string test_menu_objectName : ""
130 property string test_menu_objectName : ""
130 function current_menu_equals_test_menu() {
131 function current_menu_equals_test_menu() {
131 var current_loader = menu_content_test.findChild(menuContent, "menus").currentItem
132 var current_loader = menu_content_test.findChild(menuContent, "menus").currentItem
132 if (current_loader == undefined) {
133 if (current_loader == undefined) {
133− console.log("current_loader undefined");
134+ console.log("current_loader 'menus' undefined");
134 return false;
135 return false;
135 }
136 }
136
137
137 var menu = menu_content_test.findChild(menuContent, test_menu_objectName);
138 var menu = menu_content_test.findChild(menuContent, test_menu_objectName);
138 if (menu == undefined) {
139 if (menu == undefined) {
139− console.log("test_menu undefined");
140+ console.log("test_menu " + test_menu_objectName + " undefined");
140 return false;
141 return false;
141 }
142 }
142
143
tests/qmltests/Panel/tst_Overview.qml+5−17
@@ -20,6 +20,7 @@ import ".."
20import "../../../Panel/Menus"
20import "../../../Panel/Menus"
21import "../../../Components"
21import "../../../Components"
22import Unity.Test 0.1 as UT
22import Unity.Test 0.1 as UT
23+import IndicatorsClient 0.1
23
24
24Rectangle {
25Rectangle {
25 id: shell
26 id: shell
@@ -47,9 +48,9 @@ Rectangle {
47
48
48 ListModel {
49 ListModel {
49 id: mockModel
50 id: mockModel
50− ListElement {title: "foo"; label: "foo"; iconSource: "graphics/sound_on_icon.png"}
51+ ListElement {title: "fake1"; iconQml: "qrc:/tests/indciatorsclient/qml/fake_menu_icon1.qml"; indicatorProperties: ""}
51− ListElement {title: "bar"; label: ""; iconSource: "graphics/sound_on_icon.png"}
52+ ListElement {title: "fake2"; iconQml: "qrc:/tests/indciatorsclient/qml/fake_menu_icon2.qml"; indicatorProperties: ""}
52− ListElement {title: "baz"; label: "baz"; iconSource: "graphics/sound_on_icon.png"}
53+ ListElement {title: "fake3"; iconQml: "qrc:/tests/indciatorsclient/qml/fake_menu_icon3.qml"; indicatorProperties: ""}
53 }
54 }
54
55
55 ListModel {
56 ListModel {
@@ -98,7 +99,7 @@ Rectangle {
98 button = findChild(overview, "overviewGridButton3");
99 button = findChild(overview, "overviewGridButton3");
99 compare(button, undefined, "There should only be 3 buttons... found at least 4...");
100 compare(button, undefined, "There should only be 3 buttons... found at least 4...");
100
101
101− mockModel2.append({title: "humppa", label: "", iconSource: "graphics/sound_on_icon.png"})
102+ mockModel2.append({title: "humppa", iconQml: "qrc:/tests/indciatorsclient/qml/fake_menu_icon4.qml", indicatorProperties: ""})
102 overviewGrid.forceLayout();
103 overviewGrid.forceLayout();
103 waitForRendering(overviewGrid);
104 waitForRendering(overviewGrid);
104
105
@@ -106,19 +107,6 @@ Rectangle {
106 verify(button !== undefined, "button3 wasn't found");
107 verify(button !== undefined, "button3 wasn't found");
107 }
108 }
108
109
109− function test_text_or_icon_data() {
110− return [
111− {tag: "text", index: 0, imageVisible: false},
112− {tag: "image", index: 1, imageVisible: true}
113− ]
114− }
115−
116− function test_text_or_icon(data) {
117− var button = findChild(overview, "overviewGridButton" + data.index);
118− var image = findChild(button, "overviewGridButtonImage");
119− compare(image.visible, data.imageVisible)
120− }
121−
122 function test_volume_slider_data() {
110 function test_volume_slider_data() {
123 return [
111 return [
124 {tag: "0%", sliderPos:0},
112 {tag: "0%", sliderPos:0},
tests/qmltests/plugins/CMakeLists.txt+1
@@ -1,3 +1,4 @@
1add_subdirectory(HudClient)
1add_subdirectory(HudClient)
2+add_subdirectory(IndicatorsClient)
2add_subdirectory(Ubuntu)
3add_subdirectory(Ubuntu)
3add_subdirectory(Unity)
4add_subdirectory(Unity)
tests/qmltests/plugins/IndicatorsClient/CMakeLists.txtnew file+59
@@ -0,0 +1,59 @@
1+project(IndicatorsClientFakeQml)
2+
3+find_package(Qt5Core REQUIRED)
4+find_package(Qt5Quick REQUIRED)
5+
6+include_directories(
7+ ${CMAKE_CURRENT_SOURCE_DIR}
8+ ${CMAKE_CURRENT_BINARY_DIR}
9+ ${Qt5Core_INCLUDE_DIRS}
10+ ${Qt5Quick_INCLUDE_DIRS}
11+)
12+
13+set(IndicatorsClientFakeQml_SOURCES
14+ plugin.cpp
15+)
16+
17+set(IndicatorsClientFakeQml_RESOURCES
18+ indicatorsclient_fake.qrc
19+)
20+
21+qt5_add_resources(IndicatorsClientFakeQml_RESOURCES_RCC
22+ ${IndicatorsClientFakeQml_RESOURCES}
23+)
24+
25+add_library(IndicatorsClientFakeQml SHARED
26+ ${IndicatorsClientFakeQml_RESOURCES_RCC}
27+ ${IndicatorsClientFakeQml_SOURCES}
28+)
29+# Because this is an internal support library, we want
30+# to expose all symbols in it. Consider changing this
31+# either to a static library or just using the
32+# files directly in targets.
33+set_target_properties(IndicatorsClientFakeQml PROPERTIES COMPILE_FLAGS -fvisibility=default)
34+
35+target_link_libraries(IndicatorsClientFakeQml
36+ ${Qt5Core_LIBRARIES}
37+ ${Qt5Quick_LIBRARIES}
38+ ${GOBJECT_LDFLAGS}
39+ ${QMENUMODEL_LDFLAGS}
40+)
41+
42+qt5_use_modules(IndicatorsClientFakeQml Qml)
43+
44+
45+
46+file(GLOB IndicatorsClientFake_QMLFILES
47+ *.qml
48+ qml/FakeMenuPage.qml
49+)
50+
51+# copy qmldir file into build directory for shadow builds
52+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
53+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
54+)
55+
56+# copy qmldir file into build directory for shadow builds
57+file(COPY ${IndicatorsClientFake_QMLFILES}
58+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
59+)
tests/qmltests/plugins/IndicatorsClient/IndicatorsModel.qmlnew file+76
@@ -0,0 +1,76 @@
1+/*
2+ * Copyright (C) 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 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+
19+ListModel {
20+
21+ property var indicatorData : undefined
22+
23+ function load() {}
24+
25+ ListElement {
26+ identifier: "indicator-fake1";
27+ priority: 0
28+ title: "Menu1";
29+ description: "";
30+ iconQml: "qrc:/tests/indciatorsclient/qml/fake_menu_icon1.qml";
31+ pageQml: "qrc:/tests/indciatorsclient/qml/fake_menu_page1.qml";
32+ indicatorProperties: "";
33+ isValid: "";
34+ }
35+ ListElement {
36+ identifier: "indicator-fake2";
37+ priority: 1
38+ title: "Menu2";
39+ description: "";
40+ iconQml: "qrc:/tests/indciatorsclient/qml/fake_menu_icon2.qml";
41+ pageQml: "qrc:/tests/indciatorsclient/qml/fake_menu_page2.qml";
42+ indicatorProperties: "";
43+ isValid: "";
44+ }
45+ ListElement {
46+ identifier: "indicator-fake3";
47+ priority: 2
48+ title: "Menu3";
49+ description: "";
50+ iconQml: "qrc:/tests/indciatorsclient/qml/fake_menu_icon3.qml";
51+ pageQml: "qrc:/tests/indciatorsclient/qml/fake_menu_page3.qml";
52+ indicatorProperties: "";
53+ isValid: "";
54+ }
55+ ListElement {
56+ identifier: "indicator-fake4";
57+ priority: 3
58+ title: "Menu4";
59+ description: "";
60+ iconQml: "qrc:/tests/indciatorsclient/qml/fake_menu_icon4.qml";
61+ pageQml: "qrc:/tests/indciatorsclient/qml/fake_menu_page4.qml";
62+ indicatorProperties: "";
63+ isValid: "";
64+ }
65+ ListElement {
66+ identifier: "indicator-fake4";
67+ priority: 4
68+ title: "Menu5";
69+ description: "";
70+ iconQml: "qrc:/tests/indciatorsclient/qml/fake_menu_icon5.qml";
71+ pageQml: "qrc:/tests/indciatorsclient/qml/fake_menu_page5.qml";
72+ indicatorProperties: "";
73+ isValid: "";
74+ }
75+
76+}
tests/qmltests/plugins/IndicatorsClient/indicatorsclient_fake.qrcnew file+14
@@ -0,0 +1,14 @@
1+<RCC>
2+ <qresource prefix="/tests/indciatorsclient">
3+ <file>qml/fake_menu_icon1.qml</file>
4+ <file>qml/fake_menu_icon2.qml</file>
5+ <file>qml/fake_menu_icon3.qml</file>
6+ <file>qml/fake_menu_icon4.qml</file>
7+ <file>qml/fake_menu_icon5.qml</file>
8+ <file>qml/fake_menu_page1.qml</file>
9+ <file>qml/fake_menu_page2.qml</file>
10+ <file>qml/fake_menu_page3.qml</file>
11+ <file>qml/fake_menu_page4.qml</file>
12+ <file>qml/fake_menu_page5.qml</file>
13+ </qresource>
14+</RCC>
tests/qmltests/plugins/IndicatorsClient/plugin.cppnew file+30
@@ -0,0 +1,30 @@
1+/*
2+ * Copyright (C) 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 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+ * Author: Michał Sawicz <michal.sawicz@canonical.com>
17+ */
18+
19+// Qt
20+#include <QtQml>
21+
22+// self
23+#include "plugin.h"
24+
25+// local
26+
27+void IndicatorsClientPlugin::registerTypes(const char *)
28+{
29+ Q_INIT_RESOURCE(indicatorsclient_fake);
30+}
tests/qmltests/plugins/IndicatorsClient/plugin.hnew file+32
@@ -0,0 +1,32 @@
1+/*
2+ * Copyright (C) 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 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+ * Author: Nick Dedekind <nick.dedekind@canonical.com>
17+ */
18+
19+#ifndef INDICATORSCLIENT_PLUGIN_H
20+#define INDICATORSCLIENT_PLUGIN_H
21+
22+#include <QtQml/QQmlExtensionPlugin>
23+
24+class IndicatorsClientPlugin : public QQmlExtensionPlugin
25+{
26+ Q_OBJECT
27+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
28+public:
29+ void registerTypes(const char *uri);
30+};
31+
32+#endif // INDICATORSCLIENT_PLUGIN_H
tests/qmltests/Panel/qml/FakeMenuPlugin.qml → tests/qmltests/plugins/IndicatorsClient/qml/FakeMenuPage.qmlrenamed

The content is the same.

tests/qmltests/plugins/IndicatorsClient/qml/fake_menu_icon1.qmlnew file+7
@@ -0,0 +1,7 @@
1+import QtQuick 2.0
2+
3+Rectangle {
4+ width: 40
5+ height: 40
6+ color : "red"
7+}
tests/qmltests/plugins/IndicatorsClient/qml/fake_menu_icon2.qmlnew file+7
@@ -0,0 +1,7 @@
1+import QtQuick 2.0
2+
3+Rectangle {
4+ width: 40
5+ height: 40
6+ color : "yellow"
7+}
tests/qmltests/plugins/IndicatorsClient/qml/fake_menu_icon3.qmlnew file+7
@@ -0,0 +1,7 @@
1+import QtQuick 2.0
2+
3+Rectangle {
4+ width: 40
5+ height: 40
6+ color : "blue"
7+}
tests/qmltests/plugins/IndicatorsClient/qml/fake_menu_icon4.qmlnew file+7
@@ -0,0 +1,7 @@
1+import QtQuick 2.0
2+
3+Rectangle {
4+ width: 40
5+ height: 40
6+ color : "green"
7+}
tests/qmltests/plugins/IndicatorsClient/qml/fake_menu_icon5.qmlnew file+7
@@ -0,0 +1,7 @@
1+import QtQuick 2.0
2+
3+Rectangle {
4+ width: 40
5+ height: 40
6+ color : "orange"
7+}
tests/qmltests/Panel/qml/fake_menu_plugin1.qml → tests/qmltests/plugins/IndicatorsClient/qml/fake_menu_page1.qmlrenamed+3−2
@@ -15,10 +15,11 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import IndicatorsClient 0.1 as IndicatorsClient
18
19
19−FakeMenuPlugin {
20+IndicatorsClient.FakeMenuPage {
20 id: menu_plugin1
21 id: menu_plugin1
21− objectName: "menu_plugin1"
22+ objectName: "menu_page1"
22
23
23 Rectangle {
24 Rectangle {
24 id: contents
25 id: contents
tests/qmltests/Panel/qml/fake_menu_plugin2.qml → tests/qmltests/plugins/IndicatorsClient/qml/fake_menu_page2.qmlrenamed+3−2
@@ -15,10 +15,11 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import IndicatorsClient 0.1 as IndicatorsClient
18
19
19−FakeMenuPlugin {
20+IndicatorsClient.FakeMenuPage {
20 id: menu_plugin2
21 id: menu_plugin2
21− objectName: "menu_plugin2"
22+ objectName: "menu_page2"
22
23
23 Rectangle {
24 Rectangle {
24 id: contents
25 id: contents
tests/qmltests/Panel/qml/fake_menu_plugin3.qml → tests/qmltests/plugins/IndicatorsClient/qml/fake_menu_page3.qmlrenamed+3−2
@@ -15,10 +15,11 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import IndicatorsClient 0.1 as IndicatorsClient
18
19
19−FakeMenuPlugin {
20+IndicatorsClient.FakeMenuPage {
20 id: menu_plugin3
21 id: menu_plugin3
21− objectName: "menu_plugin3"
22+ objectName: "menu_page3"
22
23
23 Rectangle {
24 Rectangle {
24 id: contents
25 id: contents
tests/qmltests/Panel/qml/fake_menu_plugin4.qml → tests/qmltests/plugins/IndicatorsClient/qml/fake_menu_page4.qmlrenamed+3−2
@@ -15,10 +15,11 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import IndicatorsClient 0.1 as IndicatorsClient
18
19
19−FakeMenuPlugin {
20+IndicatorsClient.FakeMenuPage {
20 id: menu_plugin4
21 id: menu_plugin4
21− objectName: "menu_plugin4"
22+ objectName: "menu_page4"
22
23
23 Rectangle {
24 Rectangle {
24 id: contents
25 id: contents
tests/qmltests/Panel/qml/fake_menu_plugin5.qml → tests/qmltests/plugins/IndicatorsClient/qml/fake_menu_page5.qmlrenamed+3−2
@@ -15,10 +15,11 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import IndicatorsClient 0.1 as IndicatorsClient
18
19
19−FakeMenuPlugin {
20+IndicatorsClient.FakeMenuPage {
20 id: menu_plugin5
21 id: menu_plugin5
21− objectName: "menu_plugin5"
22+ objectName: "menu_page5"
22
23
23 Rectangle {
24 Rectangle {
24 id: contents
25 id: contents
tests/qmltests/plugins/IndicatorsClient/qmldirnew file+5
@@ -0,0 +1,5 @@
1+module IndicatorsClient
2+plugin IndicatorsClientFakeQml
3+
4+IndicatorsModel 0.1 IndicatorsModel.qml
5+FakeMenuPage 0.1 FakeMenuPage.qml