Changeset View
Changeset View
Standalone View
Standalone View
shell/scripting/scriptengine_v1.cpp
Show First 20 Lines • Show All 154 Lines • ▼ Show 20 Line(s) | |||||
155 | { | 155 | { | ||
156 | //this needs to work also for string of numberls, like "20" | 156 | //this needs to work also for string of numberls, like "20" | ||
157 | if (param.isUndefined()) { | 157 | if (param.isUndefined()) { | ||
158 | return m_engine->newError(i18n("desktopById required an id")); | 158 | return m_engine->newError(i18n("desktopById required an id")); | ||
159 | } | 159 | } | ||
160 | 160 | | |||
161 | const quint32 id = param.toInt(); | 161 | const quint32 id = param.toInt(); | ||
162 | 162 | | |||
163 | foreach (Plasma::Containment *c, m_engine->m_corona->containments()) { | 163 | const auto containments = m_engine->m_corona->containments(); | ||
164 | for (Plasma::Containment *c : containments) { | ||||
164 | if (c->id() == id && !isPanel(c)) { | 165 | if (c->id() == id && !isPanel(c)) { | ||
165 | return m_engine->wrap(c); | 166 | return m_engine->wrap(c); | ||
166 | } | 167 | } | ||
167 | } | 168 | } | ||
168 | 169 | | |||
169 | return QJSValue(); | 170 | return QJSValue(); | ||
170 | } | 171 | } | ||
171 | 172 | | |||
▲ Show 20 Lines • Show All 253 Lines • ▼ Show 20 Line(s) | |||||
425 | { | 426 | { | ||
426 | //this needs to work also for string of numberls, like "20" | 427 | //this needs to work also for string of numberls, like "20" | ||
427 | if (idParam.isUndefined()) { | 428 | if (idParam.isUndefined()) { | ||
428 | return m_engine->newError(i18n("panelById requires an id")); | 429 | return m_engine->newError(i18n("panelById requires an id")); | ||
429 | } | 430 | } | ||
430 | 431 | | |||
431 | const quint32 id = idParam.toInt(); | 432 | const quint32 id = idParam.toInt(); | ||
432 | 433 | | |||
433 | foreach (Plasma::Containment *c, m_engine->m_corona->containments()) { | 434 | const auto containments = m_engine->m_corona->containments(); | ||
435 | for (Plasma::Containment *c : containments) { | ||||
434 | if (c->id() == id && isPanel(c)) { | 436 | if (c->id() == id && isPanel(c)) { | ||
435 | return m_engine->wrap(c); | 437 | return m_engine->wrap(c); | ||
436 | } | 438 | } | ||
437 | } | 439 | } | ||
438 | 440 | | |||
439 | return QJSValue(); | 441 | return QJSValue(); | ||
440 | } | 442 | } | ||
441 | 443 | | |||
▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Line(s) | 676 | } else if (KService::Ptr service = KMimeTypeTrader::self()->preferredService(application)) { | |||
675 | return storageId ? service->storageId() : onlyExec(service->exec()); | 677 | return storageId ? service->storageId() : onlyExec(service->exec()); | ||
676 | 678 | | |||
677 | } else { | 679 | } else { | ||
678 | // try the files in share/apps/kcm_componentchooser/ | 680 | // try the files in share/apps/kcm_componentchooser/ | ||
679 | const QStringList services = QStandardPaths::locateAll( | 681 | const QStringList services = QStandardPaths::locateAll( | ||
680 | QStandardPaths::GenericDataLocation, | 682 | QStandardPaths::GenericDataLocation, | ||
681 | QStringLiteral("kcm_componentchooser/")); | 683 | QStringLiteral("kcm_componentchooser/")); | ||
682 | qDebug() << "ok, trying in" << services; | 684 | qDebug() << "ok, trying in" << services; | ||
683 | foreach (const QString &service, services) { | 685 | for (const QString &service : services) { | ||
684 | if (!service.endsWith(QLatin1String(".desktop"))) { | 686 | if (!service.endsWith(QLatin1String(".desktop"))) { | ||
685 | continue; | 687 | continue; | ||
686 | } | 688 | } | ||
687 | KConfig config(service, KConfig::SimpleConfig); | 689 | KConfig config(service, KConfig::SimpleConfig); | ||
688 | KConfigGroup cg = config.group(QByteArray()); | 690 | KConfigGroup cg = config.group(QByteArray()); | ||
689 | const QString type = cg.readEntry("valueName", QString()); | 691 | const QString type = cg.readEntry("valueName", QString()); | ||
690 | // qDebug() << " checking" << service << type << application; | 692 | // qDebug() << " checking" << service << type << application; | ||
691 | if (matches(type, application)) { | 693 | if (matches(type, application)) { | ||
▲ Show 20 Lines • Show All 207 Lines • Show Last 20 Lines |