on xenial help sign in
[Indicators] Add support for ayatana indicators

This adds support for ayatana indicators but keeps the existing unity indicators to support legacy indicators, this also cleans up the indicator load logic.

commit9cc6008d99c53d455f2b534087f75926748e09d0 authorMarius Gripsgard <marius@ubports.com> dateTue 11 Aug 2020, 19:44 (6 years ago) parent524dc07
2 files changed+63−15
plugins/Unity/Indicators/indicatorsmanager.cpp+19−15 qml/Panel/Indicators/IndicatorMenuItemFactory.qml+44
plugins/Unity/Indicators/indicatorsmanager.cpp+19−15
@@ -55,20 +55,22 @@ void IndicatorsManager::load()
5555{
5656 unload();
5757
58− const QStringList xdgLocations = shellDataDirs();
59−
6058 m_fsWatcher.reset(new QFileSystemWatcher(this));
6159
62− Q_FOREACH(const QString& xdgLocation, xdgLocations)
63− {
64− const QString indicator_path = QDir::cleanPath(xdgLocation + "/unity/indicators");
65− QDir indicator_dir(indicator_path);
66− if (indicator_dir.exists())
67− {
60+ for (const auto xdgPath : shellDataDirs()) {
61+ // For legacy reasons we keep the old unity indicator path
62+ const auto unityPath = QDir::cleanPath(xdgPath + "/unity/indicators");
63+ if (QFile::exists(unityPath)) {
6864 // watch folder for changes.
69− m_fsWatcher->addPath(indicator_path);
65+ m_fsWatcher->addPath(unityPath);
66+ loadDir(unityPath);
67+ }
7068
71− loadDir(indicator_dir);
69+ const auto ayatanaPath = QDir::cleanPath(xdgPath + "/ayatana/indicators");
70+ if (QFile::exists(ayatanaPath)) {
71+ // watch folder for changes.
72+ m_fsWatcher->addPath(ayatanaPath);
73+ loadDir(ayatanaPath);
7274 }
7375 }
7476
@@ -131,13 +133,13 @@ void IndicatorsManager::loadFile(const QFileInfo& file_info)
131133 QStringList xdgLocations = shellDataDirs();
132134 for (int i = 0; i < xdgLocations.size(); i++)
133135 {
134− const QString indicatorDir = QDir::cleanPath(xdgLocations[i] + "/unity/indicators");
136+ const QString xdgLocation = QDir::cleanPath(xdgLocations[i]);
135137
136− if (newFileInfoDir == indicatorDir)
138+ if (newFileInfoDir.startsWith(xdgLocation))
137139 {
138140 file_info_location = i;
139141 }
140− if (currentDataDir == indicatorDir)
142+ if (currentDataDir.startsWith(xdgLocation))
141143 {
142144 current_data_location = i;
143145 }
@@ -284,8 +286,10 @@ Indicator::Ptr IndicatorsManager::indicator(const QString& indicator_name)
284286 // 2) enable keyboard indicator
285287 //
286288 // The rest of the indicators respect their default profile (which is "phone", even on desktop PCs)
287− if ((new_indicator->identifier() == QStringLiteral("indicator-session"))
288− || new_indicator->identifier() == QStringLiteral("indicator-keyboard")) {
289+ if (new_indicator->identifier() == QStringLiteral("indicator-session") ||
290+ new_indicator->identifier() == QStringLiteral("indicator-keyboard") ||
291+ new_indicator->identifier() == QStringLiteral("ayatana-indicator-session") ||
292+ new_indicator->identifier() == QStringLiteral("ayatana-indicator-keyboard")) {
289293 new_indicator->setProfile(QString(m_profile).replace(QStringLiteral("phone"), QStringLiteral("desktop")));
290294 } else {
291295 new_indicator->setProfile(m_profile);
qml/Panel/Indicators/IndicatorMenuItemFactory.qml+44
@@ -65,6 +65,32 @@ Object {
6565
6666 "com.canonical.indicator.calendar": calendarMenu,
6767 "com.canonical.indicator.location": timezoneMenu,
68+
69+ "org.ayatana.indicator.button" : buttonMenu,
70+ "org.ayatana.indicator.div" : separatorMenu,
71+ "org.ayatana.indicator.section" : sectionMenu,
72+ "org.ayatana.indicator.progress" : progressMenu,
73+ "org.ayatana.indicator.slider" : sliderMenu,
74+ "org.ayatana.indicator.switch" : switchMenu,
75+ "org.ayatana.indicator.alarm" : alarmMenu,
76+ "org.ayatana.indicator.appointment" : appointmentMenu,
77+ "org.ayatana.indicator.transfer" : transferMenu,
78+ "org.ayatana.indicator.button-section" : buttonSectionMenu,
79+ "org.ayatana.indicator.link" : linkMenu,
80+
81+ "org.ayatana.indicator.messages.messageitem" : messageItem,
82+ "org.ayatana.indicator.messages.sourceitem" : groupedMessage,
83+
84+ "org.ayatana.unity.slider" : sliderMenu,
85+ "org.ayatana.unity.switch" : switchMenu,
86+
87+ "org.ayatana.unity.media-player" : mediaPayerMenu,
88+ "org.ayatana.unity.playback-item" : playbackItemMenu,
89+
90+ "org.ayatana.indicator.network.modeminfoitem" : modeminfoitem,
91+
92+ "org.ayatana.indicator.calendar": calendarMenu,
93+ "org.ayatana.indicator.location": timezoneMenu,
6894 },
6995 "indicator-session": {
7096 "indicator.user-menu-item": Platform.isPC ? userMenuItem : null,
@@ -73,6 +99,14 @@ Object {
7399 },
74100 "indicator-messages": {
75101 "com.canonical.indicator.button": messagesButtonMenu
102+ },
103+ "ayatana-indicator-session": {
104+ "indicator.user-menu-item": Platform.isPC ? userMenuItem : null,
105+ "indicator.guest-menu-item": Platform.isPC ? userMenuItem : null,
106+ "org.ayatana.indicator.switch": Math.min(Screen.width, Screen.height) > units.gu(60) ? switchMenu : null // Desktop mode switch
107+ },
108+ "ayatana-indicator-messages": {
109+ "org.ayatana.indicator.button": messagesButtonMenu
76110 }
77111 }
78112
@@ -86,6 +120,16 @@ Object {
86120 "indicator-keyboard": {
87121 "indicator.map": null,
88122 "indicator.chart": null
123+ },
124+ "ayatana-indicator-session": {
125+ "indicator.logout": Platform.isPC ? undefined : null,
126+ "indicator.suspend": Platform.isPC ? undefined : null,
127+ "indicator.hibernate": Platform.isPC ? undefined : null,
128+ "indicator.reboot": Platform.isPC ? undefined : null
129+ },
130+ "ayatana-indicator-keyboard": {
131+ "indicator.map": null,
132+ "indicator.chart": null
89133 }
90134 }
91135