on xenial help sign in
add quirks for session and keyboard indicators
f698e80Lukáš Tinkl
plugins/Unity/Indicators/CMakeLists.txt+2−1
@@ -29,6 +29,7 @@ set(IndicatorsQML_SOURCES
29 sharedunitymenumodel.cpp
29 sharedunitymenumodel.cpp
30 unitymenumodelcache.cpp
30 unitymenumodelcache.cpp
31 unitymenumodelstack.cpp
31 unitymenumodelstack.cpp
32+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Platform/platform.cpp
32)
33)
33add_definitions(-DUNITYINDICATORS_LIBRARY)
34add_definitions(-DUNITYINDICATORS_LIBRARY)
34
35
@@ -42,6 +43,6 @@ target_link_libraries(IndicatorsQml
42 ${QMENUMODEL_LDFLAGS}
43 ${QMENUMODEL_LDFLAGS}
43)
44)
44
45
45−qt5_use_modules(IndicatorsQml Core Qml Quick)
46+qt5_use_modules(IndicatorsQml Core Qml Quick DBus)
46
47
47add_unity8_plugin(Unity.Indicators 0.1 Unity/Indicators TARGETS IndicatorsQml)
48add_unity8_plugin(Unity.Indicators 0.1 Unity/Indicators TARGETS IndicatorsQml)
plugins/Unity/Indicators/indicator.cpp+2−2
@@ -44,7 +44,7 @@ void Indicator::init(const QString& busName, const QSettings& settings)
44
44
45 setId(settings.value(QStringLiteral("Indicator Service/Name")).toString());
45 setId(settings.value(QStringLiteral("Indicator Service/Name")).toString());
46
46
47− QString actionObjectPath = settings.value(QStringLiteral("Indicator Service/ObjectPath")).toString();
47+ const QString actionObjectPath = settings.value(QStringLiteral("Indicator Service/ObjectPath")).toString();
48
48
49 QVariantMap properties;
49 QVariantMap properties;
50 properties.clear();
50 properties.clear();
@@ -87,7 +87,7 @@ void Indicator::setProfile(const QString& profile)
87 pos = m_settings.value(QStringLiteral("Indicator Service/Position"), QVariant::fromValue(0));
87 pos = m_settings.value(QStringLiteral("Indicator Service/Position"), QVariant::fromValue(0));
88 setPosition(pos.toInt());
88 setPosition(pos.toInt());
89
89
90− QString menuObjectPath = m_settings.value(profile + "/ObjectPath").toString();
90+ const QString menuObjectPath = m_settings.value(profile + "/ObjectPath").toString();
91 QVariantMap map = m_properties.toMap();
91 QVariantMap map = m_properties.toMap();
92 map.insert(QStringLiteral("menuObjectPath"), menuObjectPath);
92 map.insert(QStringLiteral("menuObjectPath"), menuObjectPath);
93 setIndicatorProperties(map);
93 setIndicatorProperties(map);
plugins/Unity/Indicators/indicatorsmanager.cpp+23−14
@@ -51,20 +51,19 @@ IndicatorsManager::IndicatorsManager(QObject* parent)
51IndicatorsManager::~IndicatorsManager()
51IndicatorsManager::~IndicatorsManager()
52{
52{
53 unload();
53 unload();
54−
55}
54}
56
55
57void IndicatorsManager::load()
56void IndicatorsManager::load()
58{
57{
59 unload();
58 unload();
60
59
61− QStringList xdgLocations = shellDataDirs();//QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
60+ const QStringList xdgLocations = shellDataDirs();
62
61
63 m_fsWatcher.reset(new QFileSystemWatcher(this));
62 m_fsWatcher.reset(new QFileSystemWatcher(this));
64
63
65 Q_FOREACH(const QString& xdgLocation, xdgLocations)
64 Q_FOREACH(const QString& xdgLocation, xdgLocations)
66 {
65 {
67− QString indicator_path = QDir::cleanPath(xdgLocation + "/unity/indicators");
66+ const QString indicator_path = QDir::cleanPath(xdgLocation + "/unity/indicators");
68 QDir indicator_dir(indicator_path);
67 QDir indicator_dir(indicator_path);
69 if (indicator_dir.exists())
68 if (indicator_dir.exists())
70 {
69 {
@@ -103,7 +102,7 @@ void IndicatorsManager::loadDir(const QDir& dir)
103{
102{
104 startVerify(dir.canonicalPath());
103 startVerify(dir.canonicalPath());
105
104
106− QFileInfoList indicator_files = dir.entryInfoList(QStringList(), QDir::Files|QDir::NoDotAndDotDot);
105+ const QFileInfoList indicator_files = dir.entryInfoList(QStringList(), QDir::Files|QDir::NoDotAndDotDot);
107 Q_FOREACH(const QFileInfo& indicator_file, indicator_files)
106 Q_FOREACH(const QFileInfo& indicator_file, indicator_files)
108 {
107 {
109 loadFile(indicator_file);
108 loadFile(indicator_file);
@@ -115,26 +114,32 @@ void IndicatorsManager::loadDir(const QDir& dir)
115void IndicatorsManager::loadFile(const QFileInfo& file_info)
114void IndicatorsManager::loadFile(const QFileInfo& file_info)
116{
115{
117 QSettings indicator_settings(file_info.absoluteFilePath(), QSettings::IniFormat, this);
116 QSettings indicator_settings(file_info.absoluteFilePath(), QSettings::IniFormat, this);
118− QString name = indicator_settings.value(QStringLiteral("Indicator Service/Name")).toString();
117+ const QString name = indicator_settings.value(QStringLiteral("Indicator Service/Name")).toString();
118+
119+ qDebug() << "!!! Loading indicator" << name << ", profile" << m_profile;
119
120
121+ if (m_platform.isPC() && name == "indicator-keyboard") {
122+ return; // convergence: skip this indicator until it works in Mir
123+ }
124+
120− auto iter = m_indicatorsData.find(name);
125+ auto iter = m_indicatorsData.constFind(name);
121− if (iter != m_indicatorsData.end())
126+ if (iter != m_indicatorsData.constEnd())
122 {
127 {
123− QString newFileInfoDir = QDir::cleanPath(file_info.canonicalPath());
128+ const QString newFileInfoDir = QDir::cleanPath(file_info.canonicalPath());
124 IndicatorData* currentData = (*iter);
129 IndicatorData* currentData = (*iter);
125 currentData->m_verified = true;
130 currentData->m_verified = true;
126
131
127 int file_info_location = -1;
132 int file_info_location = -1;
128 int current_data_location = -1;
133 int current_data_location = -1;
129
134
130− QString currentDataDir = QDir::cleanPath(currentData->m_fileInfo.canonicalPath());
135+ const QString currentDataDir = QDir::cleanPath(currentData->m_fileInfo.canonicalPath());
131
136
132 // if we've already got this indicator, we need to make sure we're not overwriting data which is
137 // if we've already got this indicator, we need to make sure we're not overwriting data which is
133 // from a lower priority standard path
138 // from a lower priority standard path
134 QStringList xdgLocations = shellDataDirs();
139 QStringList xdgLocations = shellDataDirs();
135 for (int i = 0; i < xdgLocations.size(); i++)
140 for (int i = 0; i < xdgLocations.size(); i++)
136 {
141 {
137− QString indicatorDir = QDir::cleanPath(xdgLocations[i] + "/unity/indicators");
142+ const QString indicatorDir = QDir::cleanPath(xdgLocations[i] + "/unity/indicators");
138
143
139 if (newFileInfoDir == indicatorDir)
144 if (newFileInfoDir == indicatorDir)
140 {
145 {
@@ -194,7 +199,7 @@ void IndicatorsManager::unloadFile(const QFileInfo& file)
194 {
199 {
195 if (!data->m_verified)
200 if (!data->m_verified)
196 {
201 {
197− QString name = data->m_name;
202+ const QString name = data->m_name;
198 Q_EMIT indicatorAboutToBeUnloaded(name);
203 Q_EMIT indicatorAboutToBeUnloaded(name);
199
204
200 delete data;
205 delete data;
@@ -253,7 +258,7 @@ void IndicatorsManager::endVerify(const QString& path)
253 {
258 {
254 if (!data->m_verified)
259 if (!data->m_verified)
255 {
260 {
256− QString name = data->m_name;
261+ const QString name = data->m_name;
257 Q_EMIT indicatorAboutToBeUnloaded(name);
262 Q_EMIT indicatorAboutToBeUnloaded(name);
258
263
259 delete data;
264 delete data;
@@ -271,7 +276,7 @@ Indicator::Ptr IndicatorsManager::indicator(const QString& indicator_name)
271 return Indicator::Ptr();
276 return Indicator::Ptr();
272 }
277 }
273
278
274− IndicatorData *data = m_indicatorsData[indicator_name];
279+ IndicatorData *data = m_indicatorsData.value(indicator_name);
275 if (data->m_indicator)
280 if (data->m_indicator)
276 {
281 {
277 return data->m_indicator;
282 return data->m_indicator;
@@ -281,7 +286,11 @@ Indicator::Ptr IndicatorsManager::indicator(const QString& indicator_name)
281 data->m_indicator = new_indicator;
286 data->m_indicator = new_indicator;
282 QSettings settings(data->m_fileInfo.absoluteFilePath(), QSettings::IniFormat, this);
287 QSettings settings(data->m_fileInfo.absoluteFilePath(), QSettings::IniFormat, this);
283 new_indicator->init(data->m_fileInfo.fileName(), settings);
288 new_indicator->init(data->m_fileInfo.fileName(), settings);
289+ if (new_indicator->identifier() == QStringLiteral("indicator-session") && m_platform.isMultiSession()) {
290+ new_indicator->setProfile("desktop"); // convergence: enable session indicator conditionally
291+ } else {
284− new_indicator->setProfile(m_profile);
292+ new_indicator->setProfile(m_profile);
293+ }
285 QObject::connect(this, &IndicatorsManager::profileChanged, new_indicator.data(), &Indicator::setProfile);
294 QObject::connect(this, &IndicatorsManager::profileChanged, new_indicator.data(), &Indicator::setProfile);
286 return new_indicator;
295 return new_indicator;
287}
296}
plugins/Unity/Indicators/indicatorsmanager.h+3
@@ -21,6 +21,7 @@
21
21
22#include "indicator.h"
22#include "indicator.h"
23#include "unityindicatorsglobal.h"
23#include "unityindicatorsglobal.h"
24+#include "../Platform/platform.h"
24
25
25#include <QObject>
26#include <QObject>
26#include <QFileSystemWatcher>
27#include <QFileSystemWatcher>
@@ -75,6 +76,8 @@ private:
75 QSharedPointer<QFileSystemWatcher> m_fsWatcher;
76 QSharedPointer<QFileSystemWatcher> m_fsWatcher;
76 bool m_loaded;
77 bool m_loaded;
77 QString m_profile;
78 QString m_profile;
79+
80+ Platform m_platform;
78};
81};
79
82
80#endif // INDICATORS_MANAGER_H
83#endif // INDICATORS_MANAGER_H
plugins/Unity/Indicators/indicatorsmodel.cpp+5−5
@@ -236,7 +236,7 @@ int IndicatorsModel::columnCount(const QModelIndex &) const
236 return 1;
236 return 1;
237}
237}
238
238
239−Q_INVOKABLE QVariant IndicatorsModel::data(int row, int role) const
239+QVariant IndicatorsModel::data(int row, int role) const
240{
240{
241 return data(index(row, 0), role);
241 return data(index(row, 0), role);
242}
242}
@@ -247,26 +247,26 @@ QVariant IndicatorsModel::data(const QModelIndex &index, int role) const
247 if (!index.isValid() || index.row() >= m_indicators.size())
247 if (!index.isValid() || index.row() >= m_indicators.size())
248 return QVariant();
248 return QVariant();
249
249
250− Indicator::Ptr indicator = m_indicators[index.row()];
250+ Indicator::Ptr indicator = m_indicators.at(index.row());
251
251
252 switch (role)
252 switch (role)
253 {
253 {
254 case IndicatorsModelRole::Identifier:
254 case IndicatorsModelRole::Identifier:
255 if (indicator)
255 if (indicator)
256 {
256 {
257− return QVariant(indicator->identifier());
257+ return indicator->identifier();
258 }
258 }
259 break;
259 break;
260 case IndicatorsModelRole::Position:
260 case IndicatorsModelRole::Position:
261 if (indicator)
261 if (indicator)
262 {
262 {
263− return QVariant(indicator->position());
263+ return indicator->position();
264 }
264 }
265 break;
265 break;
266 case IndicatorsModelRole::IndicatorProperties:
266 case IndicatorsModelRole::IndicatorProperties:
267 if (indicator)
267 if (indicator)
268 {
268 {
269− return QVariant(indicator->indicatorProperties());
269+ return indicator->indicatorProperties();
270 }
270 }
271 break;
271 break;
272 default:
272 default:
plugins/Unity/Indicators/menucontentactivator.h+1−1
@@ -34,7 +34,7 @@ public:
34 AbstractTimer(QObject *parent) : QObject(parent), m_isRunning(false) {}
34 AbstractTimer(QObject *parent) : QObject(parent), m_isRunning(false) {}
35 virtual int interval() const = 0;
35 virtual int interval() const = 0;
36 virtual void setInterval(int msecs) = 0;
36 virtual void setInterval(int msecs) = 0;
37− virtual void start() { m_isRunning = true; };
37+ virtual void start() { m_isRunning = true; }
38 virtual void stop() { m_isRunning = false; }
38 virtual void stop() { m_isRunning = false; }
39 bool isRunning() const { return m_isRunning; }
39 bool isRunning() const { return m_isRunning; }
40Q_SIGNALS:
40Q_SIGNALS:
plugins/Unity/Platform/CMakeLists.txt+2
@@ -1,3 +1,5 @@
1+find_package(Qt5DBus REQUIRED)
2+
1set(platformplugin_SRCS
3set(platformplugin_SRCS
2 platform.cpp
4 platform.cpp
3 plugin.cpp)
5 plugin.cpp)
plugins/Unity/Platform/platform.cpp+14−3
@@ -17,19 +17,25 @@
17#include "platform.h"
17#include "platform.h"
18
18
19#include <QDBusConnection>
19#include <QDBusConnection>
20+#include <QDebug>
20
21
21Platform::Platform(QObject *parent)
22Platform::Platform(QObject *parent)
22 : QObject(parent)
23 : QObject(parent)
23− , m_iface("org.freedesktop.hostname1", "/org/freedesktop/hostname1", "org.freedesktop.hostname1",
24− QDBusConnection::systemBus(), this)
25{
24{
26 QMetaObject::invokeMethod(this, "init");
25 QMetaObject::invokeMethod(this, "init");
27}
26}
28
27
29void Platform::init()
28void Platform::init()
30{
29{
30+ m_iface = new QDBusInterface("org.freedesktop.hostname1", "/org/freedesktop/hostname1", "org.freedesktop.hostname1",
31+ QDBusConnection::systemBus(), this);
32+ m_seatIface = new QDBusInterface("org.freedesktop.login1", "/org/freedesktop/login1/seat/self", "org.freedesktop.login1.Seat",
33+ QDBusConnection::systemBus(), this);
34+
31− m_chassis = m_iface.property("Chassis").toString();
35+ m_chassis = m_iface->property("Chassis").toString();
32 m_isPC = (m_chassis == "desktop" || m_chassis == "laptop" || m_chassis == "server");
36 m_isPC = (m_chassis == "desktop" || m_chassis == "laptop" || m_chassis == "server");
37+ m_isMultiSession = m_seatIface->property("CanMultiSession").toBool() && m_seatIface->property("CanGraphical").toBool();
38+ qDebug() << "Unity8 platform initialized, form factor" << m_chassis << ", multisession capable:" << m_isMultiSession;
33}
39}
34
40
35QString Platform::chassis() const
41QString Platform::chassis() const
@@ -41,3 +47,8 @@ bool Platform::isPC() const
41{
47{
42 return m_isPC;
48 return m_isPC;
43}
49}
50+
51+bool Platform::isMultiSession() const
52+{
53+ return m_isMultiSession;
54+}
plugins/Unity/Platform/platform.h+9−1
@@ -38,6 +38,10 @@ class Platform: public QObject
38 * Whether the machine is an ordinary PC (desktop, laptop or server)
38 * Whether the machine is an ordinary PC (desktop, laptop or server)
39 */
39 */
40 Q_PROPERTY(bool isPC READ isPC CONSTANT)
40 Q_PROPERTY(bool isPC READ isPC CONSTANT)
41+ /**
42+ * Whether the system is capable of running multiple (graphical) sessions
43+ */
44+ Q_PROPERTY(bool isMultiSession READ isMultiSession CONSTANT)
41
45
42public:
46public:
43 Platform(QObject *parent = nullptr);
47 Platform(QObject *parent = nullptr);
@@ -46,13 +50,17 @@ public:
46 QString chassis() const;
50 QString chassis() const;
47 bool isPC() const;
51 bool isPC() const;
48
52
53+ bool isMultiSession() const;
54+
49private Q_SLOTS:
55private Q_SLOTS:
50 void init();
56 void init();
51
57
52private:
58private:
53− QDBusInterface m_iface;
59+ QDBusInterface *m_iface = nullptr;
60+ QDBusInterface *m_seatIface = nullptr;
54 QString m_chassis;
61 QString m_chassis;
55 bool m_isPC;
62 bool m_isPC;
63+ bool m_isMultiSession;
56};
64};
57
65
58#endif // PLATFORM_H
66#endif // PLATFORM_H
qml/Shell.qml+2−2
@@ -516,7 +516,7 @@ Item {
516
516
517 indicatorsModel: Indicators.IndicatorsModel {
517 indicatorsModel: Indicators.IndicatorsModel {
518 // tablet and phone both use the same profile
518 // tablet and phone both use the same profile
519− profile: shell.usageScenario === "desktop" ? "desktop" : "phone"
519+ profile: "phone"
520 Component.onCompleted: load();
520 Component.onCompleted: load();
521 }
521 }
522 }
522 }
@@ -525,7 +525,7 @@ Item {
525 greeterShown: greeter.shown
525 greeterShown: greeter.shown
526 }
526 }
527
527
528− property bool topmostApplicationIsFullscreen:
528+ readonly property bool topmostApplicationIsFullscreen:
529 ApplicationManager.focusedApplicationId &&
529 ApplicationManager.focusedApplicationId &&
530 ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
530 ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
531
531
tests/plugins/Unity/Indicators/CMakeLists.txt+1−1
@@ -21,7 +21,7 @@ macro(indicator_test TEST)
21 ${TEST}Test.cpp
21 ${TEST}Test.cpp
22 ${test_ADDITIONAL_CPPS}
22 ${test_ADDITIONAL_CPPS}
23 )
23 )
24− qt5_use_modules(${TEST}Exec Test Core Qml)
24+ qt5_use_modules(${TEST}Exec Test Core Qml DBus)
25 target_link_libraries(${TEST}Exec
25 target_link_libraries(${TEST}Exec
26 ${test_ADDITIONAL_LIBS}
26 ${test_ADDITIONAL_LIBS}
27 ${GLIB_LIBRARIES}
27 ${GLIB_LIBRARIES}