on xenial help sign in
3rd review changes set.
fa0ad60Nick Dedekind
Panel/Indicators/client/indicatorsclient.cpp+2−1
@@ -29,8 +29,9 @@
29void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
29void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
30{
30{
31 QStringList importPathList = engine->importPathList();
31 QStringList importPathList = engine->importPathList();
32− for (int i = paths.count()-1; i >= 0; i--)
32+ for (int i = paths.count()-1; i >= 0; i--) {
33 importPathList.prepend(paths[i]);
33 importPathList.prepend(paths[i]);
34+ }
34 engine->setImportPathList(importPathList);
35 engine->setImportPathList(importPathList);
35}
36}
36
37
main.cpp+3−2
@@ -28,16 +28,17 @@
28#include <libintl.h>
28#include <libintl.h>
29
29
30// local
30// local
31−#include "MouseTouchAdaptor.h"
32#include "paths.h"
31#include "paths.h"
32+#include "MouseTouchAdaptor.h"
33
33
34namespace {
34namespace {
35
35
36void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
36void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
37{
37{
38 QStringList importPathList = engine->importPathList();
38 QStringList importPathList = engine->importPathList();
39− for (int i = paths.count() -1; i >= 0; i--)
39+ for (int i = paths.count() -1; i >= 0; i--) {
40 importPathList.prepend(paths[i]);
40 importPathList.prepend(paths[i]);
41+ }
41 engine->setImportPathList(importPathList);
42 engine->setImportPathList(importPathList);
42}
43}
43
44
modules/Unity/Indicators/CMakeLists.txt+2−20
@@ -1,32 +1,16 @@
1project(IndicatorsQml)
1project(IndicatorsQml)
2
2
3pkg_check_modules(GLIB glib-2.0>=2.32)
3pkg_check_modules(GLIB glib-2.0>=2.32)
4−pkg_check_modules(LIBNM_GLIB libnm-glib>=0.9.6)
5−pkg_check_modules(LIBNM_UTIL libnm-util>=0.9.6)
6pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
4pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
7find_package(Qt5Core REQUIRED)
5find_package(Qt5Core REQUIRED)
8find_package(Qt5Quick REQUIRED)
6find_package(Qt5Quick REQUIRED)
9
7
10−if(LIBNM_GLIB_FOUND AND LIBNM_UTIL_FOUND AND GLIB_FOUND)
11− set(NETWORK_PLUGIN_ENABLED 1)
12−else()
13− set(NETWORK_PLUGIN_ENABLED 0)
14− message(WARNING "Missing glib or libnm dependency for the network plugin, not building")
15−endif()
16−
17add_subdirectory(qml)
8add_subdirectory(qml)
18−
19−if(NETWORK_PLUGIN_ENABLED)
20− set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNETWORK_PLUGIN_ENABLED" )
21−
22− add_subdirectory(Network)
9+add_subdirectory(Network)
23−endif()
24
10
25include_directories(
11include_directories(
26 ${CMAKE_CURRENT_SOURCE_DIR}
12 ${CMAKE_CURRENT_SOURCE_DIR}
27 ${CMAKE_CURRENT_BINARY_DIR}
13 ${CMAKE_CURRENT_BINARY_DIR}
28− ${Qt5Core_INCLUDE_DIRS}
29− ${Qt5Quick_INCLUDE_DIRS}
30 ${GLIB_INCLUDE_DIRS}
14 ${GLIB_INCLUDE_DIRS}
31 ${QMENUMODEL_INCLUDE_DIRS}
15 ${QMENUMODEL_INCLUDE_DIRS}
32)
16)
@@ -59,13 +43,11 @@ add_library(IndicatorsQml SHARED
59set_target_properties(IndicatorsQml PROPERTIES COMPILE_FLAGS -fvisibility=default)
43set_target_properties(IndicatorsQml PROPERTIES COMPILE_FLAGS -fvisibility=default)
60
44
61target_link_libraries(IndicatorsQml
45target_link_libraries(IndicatorsQml
62− ${Qt5Core_LIBRARIES}
63− ${Qt5Quick_LIBRARIES}
64 ${GOBJECT_LDFLAGS}
46 ${GOBJECT_LDFLAGS}
65 ${QMENUMODEL_LDFLAGS}
47 ${QMENUMODEL_LDFLAGS}
66)
48)
67
49
68−qt5_use_modules(IndicatorsQml Qml)
50+qt5_use_modules(IndicatorsQml Core Qml Quick)
69
51
70install(TARGETS IndicatorsQml
52install(TARGETS IndicatorsQml
71 DESTINATION ${SHELL_APP_DIR}/modules/Unity/Indicators
53 DESTINATION ${SHELL_APP_DIR}/modules/Unity/Indicators
modules/Unity/Indicators/Network/CMakeLists.txt+30−23
@@ -1,30 +1,37 @@
1project(IndicatorsNetworkQml)
1project(IndicatorsNetworkQml)
2
2
3−set(INDICATORS_NETWORK_SRC
3+pkg_check_modules(LIBNM_GLIB libnm-glib>=0.9.6)
4− networkagent.cpp
4+pkg_check_modules(LIBNM_UTIL libnm-util>=0.9.6)
5− plugin.cpp
6− secret-agent.c
7−)
8
5
9−add_library(IndicatorsNetworkQml MODULE
6+if(LIBNM_GLIB_FOUND AND LIBNM_UTIL_FOUND AND GLIB_FOUND)
10− ${INDICATORS_NETWORK_SRC}
7+ set(INDICATORS_NETWORK_SRC
8+ networkagent.cpp
9+ plugin.cpp
10+ secret-agent.c
11−)
11+ )
12
12
13−qt5_use_modules(IndicatorsNetworkQml Core Qml Widgets)
13+ add_library(IndicatorsNetworkQml MODULE
14+ ${INDICATORS_NETWORK_SRC}
15+ )
14
16
15−set_target_properties(IndicatorsNetworkQml PROPERTIES COMPILE_FLAGS -fPIC)
17+ qt5_use_modules(IndicatorsNetworkQml Core Qml Widgets)
16
18
17−include_directories(
19+ set_target_properties(IndicatorsNetworkQml PROPERTIES COMPILE_FLAGS -fPIC)
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
20
21+ include_directories(
22+ ${CMAKE_CURRENT_SOURCE_DIR}
23+ ${GLIB_INCLUDE_DIRS}
24+ ${QMENUMODEL_INCLUDE_DIRS}
25+ ${LIBNM_GLIB_INCLUDE_DIRS}
26+ ${LIBNM_UTIL_INCLUDE_DIRS}
27+ )
28+
25−target_link_libraries(IndicatorsNetworkQml
29+ target_link_libraries(IndicatorsNetworkQml
26− ${GLIB_LIBRARIES}
30+ ${GLIB_LIBRARIES}
27− ${QMENUMODEL_LDFLAGS}
31+ ${QMENUMODEL_LDFLAGS}
28− ${LIBNM_GLIB_LIBRARIES}
32+ ${LIBNM_GLIB_LIBRARIES}
29− ${LIBNM_UTIL_LIBRARIES}
33+ ${LIBNM_UTIL_LIBRARIES}
30−)
34+ )
35+else()
36+ message(WARNING "Missing glib or libnm dependency for the network plugin, not building")
37+endif()
modules/Unity/Indicators/indicator.cpp+1−13
@@ -19,19 +19,7 @@
19
19
20#include "indicator.h"
20#include "indicator.h"
21
21
22−#include <QUrl>
22+#include <QStringList>
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
23
36Indicator::Indicator(QObject *parent)
24Indicator::Indicator(QObject *parent)
37 : QObject(parent)
25 : QObject(parent)
modules/Unity/Indicators/indicator.h+1−5
@@ -25,10 +25,6 @@
25#include <QSettings>
25#include <QSettings>
26#include <memory>
26#include <memory>
27
27
28−class QDBusActionGroup;
29−class QDBusMenuModel;
30−class QStateAction;
31−
32class Indicator : public QObject
28class Indicator : public QObject
33{
29{
34 Q_OBJECT
30 Q_OBJECT
@@ -36,7 +32,7 @@ class Indicator : public QObject
36 Q_PROPERTY(QVariant indicatorProperties READ indicatorProperties NOTIFY indicatorPropertiesChanged)
32 Q_PROPERTY(QVariant indicatorProperties READ indicatorProperties NOTIFY indicatorPropertiesChanged)
37
33
38public:
34public:
39− typedef std::shared_ptr<Indicator> Ptr;
35+ typedef QSharedPointer<Indicator> Ptr;
40
36
41 Indicator(QObject *parent = 0);
37 Indicator(QObject *parent = 0);
42 virtual ~Indicator();
38 virtual ~Indicator();
modules/Unity/Indicators/indicatorsmanager.cpp+5−8
@@ -244,20 +244,17 @@ Indicator::Ptr IndicatorsManager::indicator(const QString& indicator)
244 if (!m_indicatorsData.contains(indicator))
244 if (!m_indicatorsData.contains(indicator))
245 {
245 {
246 qWarning() << Q_FUNC_INFO << "Invalid plugin name: " << indicator;
246 qWarning() << Q_FUNC_INFO << "Invalid plugin name: " << indicator;
247− return 0;
247+ return Indicator::Ptr();
248 }
248 }
249
249
250 IndicatorData *data = m_indicatorsData[indicator];
250 IndicatorData *data = m_indicatorsData[indicator];
251 if (data->m_indicator)
251 if (data->m_indicator)
252 return data->m_indicator;
252 return data->m_indicator;
253
253
254− Indicator::Ptr plugin = std::make_shared<Indicator>(this);
254+ Indicator::Ptr plugin(new Indicator(this));
255− if (plugin)
256− {
257− data->m_indicator = plugin;
255+ data->m_indicator = plugin;
258− QSettings settings(data->m_fileInfo.absoluteFilePath(), QSettings::IniFormat, this);
256+ QSettings settings(data->m_fileInfo.absoluteFilePath(), QSettings::IniFormat, this);
259− plugin->init(data->m_fileInfo.fileName(), settings);
257+ plugin->init(data->m_fileInfo.fileName(), settings);
260− }
261 return plugin;
258 return plugin;
262}
259}
263
260
modules/Unity/Indicators/indicatorsmodel.cpp+4−4
@@ -139,8 +139,8 @@ void IndicatorsModel::onIndicatorLoaded(const QString& indicator)
139 pos++;
139 pos++;
140 }
140 }
141
141
142− QObject::connect(plugin.get(), SIGNAL(identifierChanged(const QString&)), this, SLOT(onIdentifierChanged()));
142+ QObject::connect(plugin.data(), SIGNAL(identifierChanged(const QString&)), this, SLOT(onIdentifierChanged()));
143− QObject::connect(plugin.get(), SIGNAL(indicatorPropertiesChanged(const QVariant&)), this, SLOT(onIndicatorPropertiesChanged()));
143+ QObject::connect(plugin.data(), SIGNAL(indicatorPropertiesChanged(const QVariant&)), this, SLOT(onIndicatorPropertiesChanged()));
144
144
145 beginInsertRows(QModelIndex(), pos, pos);
145 beginInsertRows(QModelIndex(), pos, pos);
146
146
@@ -193,7 +193,7 @@ void IndicatorsModel::notifyDataChanged(QObject *sender, int role)
193 QMutableListIterator<Indicator::Ptr> iter(m_plugins);
193 QMutableListIterator<Indicator::Ptr> iter(m_plugins);
194 while(iter.hasNext())
194 while(iter.hasNext())
195 {
195 {
196− if (iter.next().get() == plugin)
196+ if (iter.next().data() == plugin)
197 {
197 {
198 QModelIndex changedIndex = this->index(index);
198 QModelIndex changedIndex = this->index(index);
199 dataChanged(changedIndex, changedIndex, QVector<int>() << role);
199 dataChanged(changedIndex, changedIndex, QVector<int>() << role);
@@ -269,7 +269,7 @@ QVariant IndicatorsModel::data(const QModelIndex &index, int role) const
269 }
269 }
270 break;
270 break;
271 case IsValid:
271 case IsValid:
272− return (plugin.get() ? true : false);
272+ return (plugin ? true : false);
273 case Priority:
273 case Priority:
274 case Title:
274 case Title:
275 case Description:
275 case Description:
tests/modules/Unity/Indicators/indicatorsmanagertest.cpp+9−10
@@ -69,7 +69,7 @@ private Q_SLOTS:
69 manager.load();
69 manager.load();
70
70
71 Indicator::Ptr indicator = manager.indicator("indicator-fake1");
71 Indicator::Ptr indicator = manager.indicator("indicator-fake1");
72− QVERIFY(indicator.get());
72+ QVERIFY(indicator ? true : false);
73
73
74 QCOMPARE(indicator->identifier(), QString("indicator-fake1"));
74 QCOMPARE(indicator->identifier(), QString("indicator-fake1"));
75
75
@@ -113,25 +113,24 @@ private Q_SLOTS:
113 IndicatorsManager manager;
113 IndicatorsManager manager;
114 manager.load();
114 manager.load();
115
115
116− QPointer<QObject> pi0;
116+ QWeakPointer<Indicator> wp0;
117− QPointer<QObject> pi1;
117+ QWeakPointer<Indicator> wp1;
118 {
118 {
119 Indicator::Ptr i0 = manager.indicator("indicator-fake1");
119 Indicator::Ptr i0 = manager.indicator("indicator-fake1");
120− pi0 = dynamic_cast<QObject*>(i0.get());
120+ wp0 = i0.toWeakRef();
121
121
122 Indicator::Ptr i1 = manager.indicator("indicator-fake1");
122 Indicator::Ptr i1 = manager.indicator("indicator-fake1");
123− pi1 = dynamic_cast<QObject*>(i1.get());
123+ wp1 = i1.toWeakRef();
124
124
125 manager.unload();
125 manager.unload();
126 // still alive while we have the shared pointers.
126 // still alive while we have the shared pointers.
127− QVERIFY(!pi0.isNull());
127+ QVERIFY(!wp0.isNull());
128− QVERIFY(!pi1.isNull());
128+ QVERIFY(!wp1.isNull());
129−
130 }
129 }
131
130
132 // no more smart pointers. should have been released.
131 // no more smart pointers. should have been released.
133− QVERIFY(pi0.isNull());
132+ QVERIFY(wp0.isNull());
134− QVERIFY(pi1.isNull());
133+ QVERIFY(wp1.isNull());
135 }
134 }
136};
135};
137
136