243
244
.arg(config.layoutName())
244
245
.arg(desktopMode ? QStringLiteral("desktopswitcher/DesktopSwitcher.qml") : QStringLiteral("windowswitcher/WindowSwitcher.qml")));
245
246
if (file.isNull()) {
246
auto findSwitcher = [this, desktopMode] {
247
QString constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(config.layoutName());
247
const QString folderName = QStringLiteral(KWIN_NAME) + (desktopMode ? QStringLiteral("/desktoptabbox/") : QStringLiteral("/tabbox/"));
248
auto findSwitcher = [this, desktopMode, folderName] {
248
249
const QString type = desktopMode ? QStringLiteral("KWin/DesktopSwitcher") : QStringLiteral("KWin/WindowSwitcher");
249
KService::List offers = KServiceTypeTrader::self()->query(type, constraint);
250
auto offers = KPackage::PackageLoader::self()->findPackages(type, folderName,
251
[this] (const KPluginMetaData &data) {
252
return data.pluginId().compare(config.layoutName(), Qt::CaseInsensitive) == 0;
250
255
if (offers.isEmpty()) {
252
constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(QStringLiteral("informative"));
253
offers = KServiceTypeTrader::self()->query(type, constraint);
257
offers = KPackage::PackageLoader::self()->findPackages(type, folderName,
258
[this] (const KPluginMetaData &data) {
259
return data.pluginId().compare(QStringLiteral("informative"), Qt::CaseInsensitive) == 0;
254
262
if (offers.isEmpty()) {
255
qDebug() << "could not find default window switcher layout";
256
return KService::Ptr();
263
qCDebug(KWIN_TABBOX) << "could not find default window switcher layout";
264
return KPluginMetaData();
259
267
return offers.first();
261
KService::Ptr service = findSwitcher();
265
if (service->property(QStringLiteral("X-Plasma-API")).toString() != QStringLiteral("declarativeappletscript")) {
266
qDebug() << "Window Switcher Layout is no declarativeappletscript";
269
auto findScriptFile = [desktopMode, service] {
270
const QString pluginName = service->property(QStringLiteral("X-KDE-PluginInfo-Name")).toString();
271
const QString scriptName = service->property(QStringLiteral("X-Plasma-MainScript")).toString();
272
const QString type = desktopMode ? QStringLiteral("/desktoptabbox/") : QStringLiteral("/tabbox/");
273
return QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(KWIN_NAME) + type + pluginName + QStringLiteral("/contents/") + scriptName);
269
auto service = findSwitcher();
270
if (!service.isValid()) {
273
if (service.value(QStringLiteral("X-Plasma-API")) != QStringLiteral("declarativeappletscript")) {
274
qCDebug(KWIN_TABBOX) << "Window Switcher Layout is no declarativeappletscript";
277
auto findScriptFile = [desktopMode, service, folderName] {
278
const QString pluginName = service.pluginId();
279
const QString scriptName = service.value(QStringLiteral("X-Plasma-MainScript"));
280
return QStandardPaths::locate(QStandardPaths::GenericDataLocation, folderName + pluginName + QStringLiteral("/contents/") + scriptName);
275
282
file = findScriptFile();
277
284
if (file.isNull()) {
278
qDebug() << "Could not find QML file for window switcher";
285
qCDebug(KWIN_TABBOX) << "Could not find QML file for window switcher";
281
288
m_qmlComponent->loadUrl(QUrl::fromLocalFile(file));
282
289
if (m_qmlComponent->isError()) {
283
qDebug() << "Component failed to load: " << m_qmlComponent->errors();
290
qCDebug(KWIN_TABBOX) << "Component failed to load: " << m_qmlComponent->errors();
284
291
QStringList args;
285
292
args << QStringLiteral("--passivepopup") << i18n("The Window Switcher installation is broken, resources are missing.\n"
286
293
"Contact your distribution about this.") << QStringLiteral("20");