on xenial help sign in
add quirks for session and keyboard indicators
commitf698e8038dc08b401ed1ca7c7d4b133f58ffd9df authorLukáš Tinkl <lukas.tinkl@canonical.com> dateMon 16 Nov 2015, 15:02 (11 years ago) parent78bdee5
11 files changed+64−30
plugins/Unity/Indicators/CMakeLists.txt+2−1 plugins/Unity/Indicators/indicator.cpp+2−2 plugins/Unity/Indicators/indicatorsmanager.cpp+23−14 plugins/Unity/Indicators/indicatorsmanager.h+3 plugins/Unity/Indicators/indicatorsmodel.cpp+5−5 plugins/Unity/Indicators/menucontentactivator.h+1−1 plugins/Unity/Platform/CMakeLists.txt+2 plugins/Unity/Platform/platform.cpp+14−3 plugins/Unity/Platform/platform.h+9−1 qml/Shell.qml+2−2 tests/plugins/Unity/Indicators/CMakeLists.txt+1−1
plugins/Unity/Indicators/CMakeLists.txt+2−1
@@ -29,6 +29,7 @@ set(IndicatorsQML_SOURCES
2929 sharedunitymenumodel.cpp
3030 unitymenumodelcache.cpp
3131 unitymenumodelstack.cpp
32+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Platform/platform.cpp
3233)
3334add_definitions(-DUNITYINDICATORS_LIBRARY)
3435
@@ -42,6 +43,6 @@ target_link_libraries(IndicatorsQml
4243 ${QMENUMODEL_LDFLAGS}
4344)
4445
45−qt5_use_modules(IndicatorsQml Core Qml Quick)
46+qt5_use_modules(IndicatorsQml Core Qml Quick DBus)
4647
4748add_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)
4444
4545 setId(settings.value(QStringLiteral("Indicator Service/Name")).toString());
4646
47− QString actionObjectPath = settings.value(QStringLiteral("Indicator Service/ObjectPath")).toString();
47+ const QString actionObjectPath = settings.value(QStringLiteral("Indicator Service/ObjectPath")).toString();
4848
4949 QVariantMap properties;
5050 properties.clear();
@@ -87,7 +87,7 @@ void Indicator::setProfile(const QString& profile)
8787 pos = m_settings.value(QStringLiteral("Indicator Service/Position"), QVariant::fromValue(0));
8888 setPosition(pos.toInt());
8989
90− QString menuObjectPath = m_settings.value(profile + "/ObjectPath").toString();
90+ const QString menuObjectPath = m_settings.value(profile + "/ObjectPath").toString();
9191 QVariantMap map = m_properties.toMap();
9292 map.insert(QStringLiteral("menuObjectPath"), menuObjectPath);
9393 setIndicatorProperties(map);
plugins/Unity/Indicators/indicatorsmanager.cpp+23−14
@@ -51,20 +51,19 @@ IndicatorsManager::IndicatorsManager(QObject* parent)
5151IndicatorsManager::~IndicatorsManager()
5252{
5353 unload();
54−
5554}
5655
5756void IndicatorsManager::load()
5857{
5958 unload();
6059
61− QStringList xdgLocations = shellDataDirs();//QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
60+ const QStringList xdgLocations = shellDataDirs();
6261
6362 m_fsWatcher.reset(new QFileSystemWatcher(this));
6463
6564 Q_FOREACH(const QString& xdgLocation, xdgLocations)
6665 {
67− QString indicator_path = QDir::cleanPath(xdgLocation + "/unity/indicators");
66+ const QString indicator_path = QDir::cleanPath(xdgLocation + "/unity/indicators");
6867 QDir indicator_dir(indicator_path);
6968 if (indicator_dir.exists())
7069 {
@@ -103,7 +102,7 @@ void IndicatorsManager::loadDir(const QDir& dir)
103102{
104103 startVerify(dir.canonicalPath());
105104
106− QFileInfoList indicator_files = dir.entryInfoList(QStringList(), QDir::Files|QDir::NoDotAndDotDot);
105+ const QFileInfoList indicator_files = dir.entryInfoList(QStringList(), QDir::Files|QDir::NoDotAndDotDot);
107106 Q_FOREACH(const QFileInfo& indicator_file, indicator_files)
108107 {
109108 loadFile(indicator_file);
@@ -115,26 +114,32 @@ void IndicatorsManager::loadDir(const QDir& dir)
115114void IndicatorsManager::loadFile(const QFileInfo& file_info)
116115{
117116 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;
119120
120− auto iter = m_indicatorsData.find(name);
121− if (iter != m_indicatorsData.end())
121+ if (m_platform.isPC() && name == "indicator-keyboard") {
122+ return; // convergence: skip this indicator until it works in Mir
123+ }
124+
125+ auto iter = m_indicatorsData.constFind(name);
126+ if (iter != m_indicatorsData.constEnd())
122127 {
123− QString newFileInfoDir = QDir::cleanPath(file_info.canonicalPath());
128+ const QString newFileInfoDir = QDir::cleanPath(file_info.canonicalPath());
124129 IndicatorData* currentData = (*iter);
125130 currentData->m_verified = true;
126131
127132 int file_info_location = -1;
128133 int current_data_location = -1;
129134
130− QString currentDataDir = QDir::cleanPath(currentData->m_fileInfo.canonicalPath());
135+ const QString currentDataDir = QDir::cleanPath(currentData->m_fileInfo.canonicalPath());
131136
132137 // if we've already got this indicator, we need to make sure we're not overwriting data which is
133138 // from a lower priority standard path
134139 QStringList xdgLocations = shellDataDirs();
135140 for (int i = 0; i < xdgLocations.size(); i++)
136141 {
137− QString indicatorDir = QDir::cleanPath(xdgLocations[i] + "/unity/indicators");
142+ const QString indicatorDir = QDir::cleanPath(xdgLocations[i] + "/unity/indicators");
138143
139144 if (newFileInfoDir == indicatorDir)
140145 {
@@ -194,7 +199,7 @@ void IndicatorsManager::unloadFile(const QFileInfo& file)
194199 {
195200 if (!data->m_verified)
196201 {
197− QString name = data->m_name;
202+ const QString name = data->m_name;
198203 Q_EMIT indicatorAboutToBeUnloaded(name);
199204
200205 delete data;
@@ -253,7 +258,7 @@ void IndicatorsManager::endVerify(const QString& path)
253258 {
254259 if (!data->m_verified)
255260 {
256− QString name = data->m_name;
261+ const QString name = data->m_name;
257262 Q_EMIT indicatorAboutToBeUnloaded(name);
258263
259264 delete data;
@@ -271,7 +276,7 @@ Indicator::Ptr IndicatorsManager::indicator(const QString& indicator_name)
271276 return Indicator::Ptr();
272277 }
273278
274− IndicatorData *data = m_indicatorsData[indicator_name];
279+ IndicatorData *data = m_indicatorsData.value(indicator_name);
275280 if (data->m_indicator)
276281 {
277282 return data->m_indicator;
@@ -281,7 +286,11 @@ Indicator::Ptr IndicatorsManager::indicator(const QString& indicator_name)
281286 data->m_indicator = new_indicator;
282287 QSettings settings(data->m_fileInfo.absoluteFilePath(), QSettings::IniFormat, this);
283288 new_indicator->init(data->m_fileInfo.fileName(), settings);
284− new_indicator->setProfile(m_profile);
289+ if (new_indicator->identifier() == QStringLiteral("indicator-session") && m_platform.isMultiSession()) {
290+ new_indicator->setProfile("desktop"); // convergence: enable session indicator conditionally
291+ } else {
292+ new_indicator->setProfile(m_profile);
293+ }
285294 QObject::connect(this, &IndicatorsManager::profileChanged, new_indicator.data(), &Indicator::setProfile);
286295 return new_indicator;
287296}
plugins/Unity/Indicators/indicatorsmanager.h+3
@@ -21,6 +21,7 @@
2121
2222#include "indicator.h"
2323#include "unityindicatorsglobal.h"
24+#include "../Platform/platform.h"
2425
2526#include <QObject>
2627#include <QFileSystemWatcher>
@@ -75,6 +76,8 @@ private:
7576 QSharedPointer<QFileSystemWatcher> m_fsWatcher;
7677 bool m_loaded;
7778 QString m_profile;
79+
80+ Platform m_platform;
7881};
7982
8083#endif // INDICATORS_MANAGER_H
plugins/Unity/Indicators/indicatorsmodel.cpp+5−5
@@ -236,7 +236,7 @@ int IndicatorsModel::columnCount(const QModelIndex &) const
236236 return 1;
237237}
238238
239−Q_INVOKABLE QVariant IndicatorsModel::data(int row, int role) const
239+QVariant IndicatorsModel::data(int row, int role) const
240240{
241241 return data(index(row, 0), role);
242242}
@@ -247,26 +247,26 @@ QVariant IndicatorsModel::data(const QModelIndex &index, int role) const
247247 if (!index.isValid() || index.row() >= m_indicators.size())
248248 return QVariant();
249249
250− Indicator::Ptr indicator = m_indicators[index.row()];
250+ Indicator::Ptr indicator = m_indicators.at(index.row());
251251
252252 switch (role)
253253 {
254254 case IndicatorsModelRole::Identifier:
255255 if (indicator)
256256 {
257− return QVariant(indicator->identifier());
257+ return indicator->identifier();
258258 }
259259 break;
260260 case IndicatorsModelRole::Position:
261261 if (indicator)
262262 {
263− return QVariant(indicator->position());
263+ return indicator->position();
264264 }
265265 break;
266266 case IndicatorsModelRole::IndicatorProperties:
267267 if (indicator)
268268 {
269− return QVariant(indicator->indicatorProperties());
269+ return indicator->indicatorProperties();
270270 }
271271 break;
272272 default:
plugins/Unity/Indicators/menucontentactivator.h+1−1
@@ -34,7 +34,7 @@ public:
3434 AbstractTimer(QObject *parent) : QObject(parent), m_isRunning(false) {}
3535 virtual int interval() const = 0;
3636 virtual void setInterval(int msecs) = 0;
37− virtual void start() { m_isRunning = true; };
37+ virtual void start() { m_isRunning = true; }
3838 virtual void stop() { m_isRunning = false; }
3939 bool isRunning() const { return m_isRunning; }
4040Q_SIGNALS:
plugins/Unity/Platform/CMakeLists.txt+2
@@ -1,3 +1,5 @@
1+find_package(Qt5DBus REQUIRED)
2+
13set(platformplugin_SRCS
24 platform.cpp
35 plugin.cpp)
plugins/Unity/Platform/platform.cpp+14−3
@@ -17,19 +17,25 @@
1717#include "platform.h"
1818
1919#include <QDBusConnection>
20+#include <QDebug>
2021
2122Platform::Platform(QObject *parent)
2223 : QObject(parent)
23− , m_iface("org.freedesktop.hostname1", "/org/freedesktop/hostname1", "org.freedesktop.hostname1",
24− QDBusConnection::systemBus(), this)
2524{
2625 QMetaObject::invokeMethod(this, "init");
2726}
2827
2928void Platform::init()
3029{
31− m_chassis = m_iface.property("Chassis").toString();
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+
35+ m_chassis = m_iface->property("Chassis").toString();
3236 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;
3339}
3440
3541QString Platform::chassis() const
@@ -41,3 +47,8 @@ bool Platform::isPC() const
4147{
4248 return m_isPC;
4349}
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
3838 * Whether the machine is an ordinary PC (desktop, laptop or server)
3939 */
4040 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)
4145
4246public:
4347 Platform(QObject *parent = nullptr);
@@ -46,13 +50,17 @@ public:
4650 QString chassis() const;
4751 bool isPC() const;
4852
53+ bool isMultiSession() const;
54+
4955private Q_SLOTS:
5056 void init();
5157
5258private:
53− QDBusInterface m_iface;
59+ QDBusInterface *m_iface = nullptr;
60+ QDBusInterface *m_seatIface = nullptr;
5461 QString m_chassis;
5562 bool m_isPC;
63+ bool m_isMultiSession;
5664};
5765
5866#endif // PLATFORM_H
qml/Shell.qml+2−2
@@ -516,7 +516,7 @@ Item {
516516
517517 indicatorsModel: Indicators.IndicatorsModel {
518518 // tablet and phone both use the same profile
519− profile: shell.usageScenario === "desktop" ? "desktop" : "phone"
519+ profile: "phone"
520520 Component.onCompleted: load();
521521 }
522522 }
@@ -525,7 +525,7 @@ Item {
525525 greeterShown: greeter.shown
526526 }
527527
528− property bool topmostApplicationIsFullscreen:
528+ readonly property bool topmostApplicationIsFullscreen:
529529 ApplicationManager.focusedApplicationId &&
530530 ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
531531
tests/plugins/Unity/Indicators/CMakeLists.txt+1−1
@@ -21,7 +21,7 @@ macro(indicator_test TEST)
2121 ${TEST}Test.cpp
2222 ${test_ADDITIONAL_CPPS}
2323 )
24− qt5_use_modules(${TEST}Exec Test Core Qml)
24+ qt5_use_modules(${TEST}Exec Test Core Qml DBus)
2525 target_link_libraries(${TEST}Exec
2626 ${test_ADDITIONAL_LIBS}
2727 ${GLIB_LIBRARIES}