Changeset View
Changeset View
Standalone View
Standalone View
shell/shellcorona.cpp
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | |||||
81 | #include <xcb/xcb.h> | 81 | #include <xcb/xcb.h> | ||
82 | #endif | 82 | #endif | ||
83 | 83 | | |||
84 | 84 | | |||
85 | static const int s_configSyncDelay = 10000; // 10 seconds | 85 | static const int s_configSyncDelay = 10000; // 10 seconds | ||
86 | 86 | | |||
87 | ShellCorona::ShellCorona(QObject *parent) | 87 | ShellCorona::ShellCorona(QObject *parent) | ||
88 | : Plasma::Corona(parent), | 88 | : Plasma::Corona(parent), | ||
89 | m_config(KSharedConfig::openConfig(QStringLiteral("plasmarc"))), | ||||
89 | m_screenPool(new ScreenPool(KSharedConfig::openConfig(), this)), | 90 | m_screenPool(new ScreenPool(KSharedConfig::openConfig(), this)), | ||
90 | m_activityController(new KActivities::Controller(this)), | 91 | m_activityController(new KActivities::Controller(this)), | ||
91 | m_addPanelAction(nullptr), | 92 | m_addPanelAction(nullptr), | ||
92 | m_addPanelsMenu(nullptr), | 93 | m_addPanelsMenu(nullptr), | ||
93 | m_interactiveConsole(nullptr), | 94 | m_interactiveConsole(nullptr), | ||
94 | m_waylandPlasmaShell(nullptr) | 95 | m_waylandPlasmaShell(nullptr) | ||
95 | { | 96 | { | ||
96 | setupWaylandIntegration(); | 97 | setupWaylandIntegration(); | ||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | 208 | for (int i = 0; i < 10; ++i) { | |||
211 | QAction *action = taskbarActions->addAction(QStringLiteral("activate task manager entry %1").arg(QString::number(entryNumber))); | 212 | QAction *action = taskbarActions->addAction(QStringLiteral("activate task manager entry %1").arg(QString::number(entryNumber))); | ||
212 | action->setText(i18n("Activate Task Manager Entry %1", entryNumber)); | 213 | action->setText(i18n("Activate Task Manager Entry %1", entryNumber)); | ||
213 | KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::META + key)); | 214 | KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::META + key)); | ||
214 | connect(action, &QAction::triggered, this, [this, i] { | 215 | connect(action, &QAction::triggered, this, [this, i] { | ||
215 | activateTaskManagerEntry(i); | 216 | activateTaskManagerEntry(i); | ||
216 | }); | 217 | }); | ||
217 | } | 218 | } | ||
218 | 219 | | |||
219 | new Osd(this); | 220 | new Osd(m_config, this); | ||
221 | | ||||
222 | // catch when plasmarc changes, so we e.g. enable/disable the OSd | ||||
223 | m_configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + m_config->name(); | ||||
224 | KDirWatch::self()->addFile(m_configPath); | ||||
225 | connect(KDirWatch::self(), &KDirWatch::dirty, this, &ShellCorona::configurationChanged); | ||||
226 | connect(KDirWatch::self(), &KDirWatch::created, this, &ShellCorona::configurationChanged); | ||||
davidedmundson: KDirWatch::self() is a singleton
consider the case where two things use the singleton, you use… | |||||
220 | } | 227 | } | ||
graesslin: Is there no mechanism inside Plasma to notice when the config changes? | |||||
221 | 228 | | |||
222 | ShellCorona::~ShellCorona() | 229 | ShellCorona::~ShellCorona() | ||
223 | { | 230 | { | ||
224 | while (!containments().isEmpty()) { | 231 | while (!containments().isEmpty()) { | ||
225 | //deleting a containment will remove it from the list due to QObject::destroyed connect in Corona | 232 | //deleting a containment will remove it from the list due to QObject::destroyed connect in Corona | ||
226 | delete containments().first(); | 233 | delete containments().first(); | ||
227 | } | 234 | } | ||
228 | qDeleteAll(m_panelViews); | 235 | qDeleteAll(m_panelViews); | ||
Show All 20 Lines | 245 | { | |||
249 | m_lnfDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(m_lookAndFeelPackage.filePath("defaults")), "Desktop"); | 256 | m_lnfDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(m_lookAndFeelPackage.filePath("defaults")), "Desktop"); | ||
250 | m_lnfDefaultsConfig = KConfigGroup(&m_lnfDefaultsConfig, shell); | 257 | m_lnfDefaultsConfig = KConfigGroup(&m_lnfDefaultsConfig, shell); | ||
251 | 258 | | |||
252 | const QString themeGroupKey = QStringLiteral("Theme"); | 259 | const QString themeGroupKey = QStringLiteral("Theme"); | ||
253 | const QString themeNameKey = QStringLiteral("name"); | 260 | const QString themeNameKey = QStringLiteral("name"); | ||
254 | 261 | | |||
255 | QString themeName; | 262 | QString themeName; | ||
256 | 263 | | |||
257 | KConfigGroup plasmarc(KSharedConfig::openConfig(QStringLiteral("plasmarc")), themeGroupKey); | 264 | KConfigGroup plasmarc(m_config, themeGroupKey); | ||
258 | themeName = plasmarc.readEntry(themeNameKey, themeName); | 265 | themeName = plasmarc.readEntry(themeNameKey, themeName); | ||
259 | 266 | | |||
260 | if (themeName.isEmpty()) { | 267 | if (themeName.isEmpty()) { | ||
261 | KConfigGroup shellCfg = KConfigGroup(KSharedConfig::openConfig(package.filePath("defaults")), "Theme"); | 268 | KConfigGroup shellCfg = KConfigGroup(KSharedConfig::openConfig(package.filePath("defaults")), "Theme"); | ||
262 | 269 | | |||
263 | themeName = shellCfg.readEntry("name", "default"); | 270 | themeName = shellCfg.readEntry("name", "default"); | ||
264 | KConfigGroup lnfCfg = KConfigGroup(KSharedConfig::openConfig( | 271 | KConfigGroup lnfCfg = KConfigGroup(KSharedConfig::openConfig( | ||
265 | m_lookAndFeelPackage.filePath("defaults")), | 272 | m_lookAndFeelPackage.filePath("defaults")), | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | |||||
2008 | 2015 | | |||
2009 | void ShellCorona::updateStruts() | 2016 | void ShellCorona::updateStruts() | ||
2010 | { | 2017 | { | ||
2011 | foreach(PanelView* view, m_panelViews) { | 2018 | foreach(PanelView* view, m_panelViews) { | ||
2012 | view->updateStruts(); | 2019 | view->updateStruts(); | ||
2013 | } | 2020 | } | ||
2014 | } | 2021 | } | ||
2015 | 2022 | | |||
2023 | void ShellCorona::configurationChanged(const QString &path) | ||||
2024 | { | ||||
2025 | if (path == m_configPath) { | ||||
2026 | m_config->reparseConfiguration(); | ||||
2027 | } | ||||
2028 | } | ||||
2016 | 2029 | | |||
2017 | void ShellCorona::activateLauncherMenu() | 2030 | void ShellCorona::activateLauncherMenu() | ||
2018 | { | 2031 | { | ||
2019 | for (auto it = m_panelViews.constBegin(), end = m_panelViews.constEnd(); it != end; ++it) { | 2032 | for (auto it = m_panelViews.constBegin(), end = m_panelViews.constEnd(); it != end; ++it) { | ||
2020 | const auto applets = it.key()->applets(); | 2033 | const auto applets = it.key()->applets(); | ||
2021 | for (auto applet : applets) { | 2034 | for (auto applet : applets) { | ||
2022 | const auto provides = KPluginMetaData::readStringList(applet->pluginMetaData().rawData(), QStringLiteral("X-Plasma-Provides")); | 2035 | const auto provides = KPluginMetaData::readStringList(applet->pluginMetaData().rawData(), QStringLiteral("X-Plasma-Provides")); | ||
2023 | if (provides.contains(QLatin1String("org.kde.plasma.launchermenu"))) { | 2036 | if (provides.contains(QLatin1String("org.kde.plasma.launchermenu"))) { | ||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |
KDirWatch::self() is a singleton
consider the case where two things use the singleton, you use it to monitor ~/.plasmarc and another uses it to monitor /tmp/asdfadf this signal will be emitted in both cases. You should use the parameter in the signal to do some filtering.