kDebug(kdbg_code) << "Creating BookmarksRunner";
setObjectName( QLatin1String("Bookmarks" ));
addSyntax(Plasma::RunnerSyntax(":q:", i18n("Finds web browser bookmarks matching :q:.")));
- setDefaultSyntax(Plasma::RunnerSyntax(i18nc("list of all web browser bookmarks", "bookmarks"),
- i18n("List all web browser bookmarks")));
+ setDefaultSyntax(
+ Plasma::RunnerSyntax(i18nc("list of all web browser bookmarks", "bookmarks"),
+ i18n("List all web browser bookmarks"))
+ );
connect(this, SIGNAL(prepare()), this, SLOT(prep()));
}
#include <QApplication>
#include <QClipboard>
-#include <KProtocolManager>
#include <KDebug>
#include <KLocale>
void KillRunner::reloadConfiguration()
{
+#warning TODO: untranslated keyword match, why is it even translated when it is configurable?
KConfigGroup grp = config();
m_triggerWord.clear();
if (grp.readEntry(CONFIG_USE_TRIGGERWORD, true)) {
}
QList<Plasma::QueryMatch> matches;
- const bool all = term.compare(i18n("places"), Qt::CaseInsensitive) == 0;
+ bool all = term.compare(i18n("places"), Qt::CaseInsensitive) == 0;
+ if (!all) {
+ all = term.compare(QLatin1String("places"), Qt::CaseInsensitive) == 0;
+ }
for (int i = 0; i <= m_places.rowCount(); i++) {
QModelIndex current_index = m_places.index(i, 0);
Plasma::QueryMatch::Type type = Plasma::QueryMatch::NoMatch;
#include <plasma/theme.h>
static const QString s_plasmaService = "org.kde.plasma-desktop";
+static const char* s_desktopConsole = "desktop console";
PlasmaDesktopRunner::PlasmaDesktopRunner(QObject *parent, const QVariantList &args)
: Plasma::AbstractRunner(parent, args),
- m_desktopConsoleKeyword(i18nc("Note this is a KRunner keyword", "desktop console")),
+ m_desktopConsoleKeyword(i18nc("Note this is a KRunner keyword", s_desktopConsole)),
m_enabled(false)
{
setObjectName( QLatin1String("Plasma-Desktop" ));
void PlasmaDesktopRunner::match(Plasma::RunnerContext &context)
{
- if (m_enabled && context.query().startsWith(m_desktopConsoleKeyword, Qt::CaseInsensitive)) {
+ const QString query = context.query();
+ bool matches = query.startsWith(m_desktopConsoleKeyword, Qt::CaseInsensitive);
+ if (!matches) {
+ matches = query.startsWith(QLatin1String(s_desktopConsole), Qt::CaseInsensitive);
+ }
+ if (m_enabled && matches) {
Plasma::QueryMatch match(this);
match.setId("plasma-desktop-console");
match.setType(Plasma::QueryMatch::ExactMatch);
QDBusMessage message;
QString query = context.query();
- if (query.compare(m_desktopConsoleKeyword, Qt::CaseInsensitive) == 0) {
+ if (query.compare(m_desktopConsoleKeyword, Qt::CaseInsensitive) == 0
+ || query.compare(QLatin1String(s_desktopConsole), Qt::CaseInsensitive) == 0) {
message = QDBusMessage::createMethodCall(s_plasmaService, "/MainApplication",
QString(), "showInteractiveConsole");
} else if (query.startsWith(m_desktopConsoleKeyword)) {
}
QList<Plasma::QueryMatch> matches;
- if (term.compare(i18nc("Note this is a KRunner keyword", "suspend"), Qt::CaseInsensitive) == 0) {
+ if (term.compare(i18nc("Note this is a KRunner keyword", "suspend"), Qt::CaseInsensitive) == 0 ||
+ term.compare(QLatin1String("suspend"), Qt::CaseInsensitive) == 0) {
QSet< Solid::PowerManagement::SleepState > states = Solid::PowerManagement::supportedSleepStates();
if (states.contains(Solid::PowerManagement::SuspendState)) {
if (states.contains(Solid::PowerManagement::HybridSuspendState)) {
addSuspendMatch(Solid::PowerManagement::HybridSuspendState, matches);
}
+#warning TODO: do not match these when not supported by the system
} else if (term.compare(i18nc("Note this is a KRunner keyword", "sleep"), Qt::CaseInsensitive) == 0 ||
- term.compare(i18nc("Note this is a KRunner keyword", "to ram"), Qt::CaseInsensitive) == 0) {
+ term.compare(QLatin1String("sleep"), Qt::CaseInsensitive) == 0 ||
+ term.compare(i18nc("Note this is a KRunner keyword", "to ram"), Qt::CaseInsensitive) == 0 ||
+ term.compare(QLatin1String("to ram"), Qt::CaseInsensitive) == 0) {
addSuspendMatch(Solid::PowerManagement::SuspendState, matches);
} else if (term.compare(i18nc("Note this is a KRunner keyword", "hibernate"), Qt::CaseInsensitive) == 0 ||
- term.compare(i18nc("Note this is a KRunner keyword", "to disk"), Qt::CaseInsensitive) == 0) {
+ term.compare(QLatin1String("hibernate"), Qt::CaseInsensitive) == 0 ||
+ term.compare(i18nc("Note this is a KRunner keyword", "to disk"), Qt::CaseInsensitive) == 0 ||
+ term.compare(QLatin1String("to disk"), Qt::CaseInsensitive) == 0) {
addSuspendMatch(Solid::PowerManagement::HibernateState, matches);
- } else if (term.compare(i18nc("Note this is a KRunner keyword", "hybrid"), Qt::CaseInsensitive) == 0) {
+ } else if (term.compare(i18nc("Note this is a KRunner keyword", "hybrid"), Qt::CaseInsensitive) == 0 ||
+ term.compare(QLatin1String("hybrid"), Qt::CaseInsensitive) == 0) {
addSuspendMatch(Solid::PowerManagement::HybridSuspendState, matches);
}
setupMatch(service, match);
qreal relevance = 0.6;
- if (service->categories().contains("X-KDE-More") ||
- !service->showInKDE()) {
+ if (service->categories().contains("X-KDE-More") || !service->showInKDE()) {
relevance = 0.5;
}
{
Q_UNUSED(args)
- setObjectName( QLatin1String("Sessions" ));
+ setObjectName(QLatin1String("Sessions"));
setPriority(LowPriority);
setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File |
Plasma::RunnerContext::NetworkLocation);
{
}
-void SessionRunner::matchCommands(QList<Plasma::QueryMatch> &matches, const QString& term)
+void SessionRunner::matchCommands(QList<Plasma::QueryMatch> &matches, const QString &term)
{
- if (term.compare(i18nc("log out command","logout"), Qt::CaseInsensitive) == 0 ||
- term.compare(i18n("log out"), Qt::CaseInsensitive) == 0) {
+ if (term.compare(i18nc("log out command", "logout"), Qt::CaseInsensitive) == 0 ||
+ term.compare(QLatin1String("logout"), Qt::CaseInsensitive) == 0 ||
+ term.compare(i18n("log out"), Qt::CaseInsensitive) == 0 ||
+ term.compare(QLatin1String("log out"), Qt::CaseInsensitive) == 0) {
Plasma::QueryMatch match(this);
match.setText(i18nc("log out command","Logout"));
match.setIcon(KIcon("system-log-out"));
match.setRelevance(0.9);
matches << match;
} else if (term.compare(i18nc("restart computer command", "restart"), Qt::CaseInsensitive) == 0 ||
- term.compare(i18nc("restart computer command", "reboot"), Qt::CaseInsensitive) == 0) {
+ term.compare(QLatin1String("restart"), Qt::CaseInsensitive) == 0 ||
+ term.compare(i18nc("restart computer command", "reboot"), Qt::CaseInsensitive) == 0 ||
+ term.compare(QLatin1String("reboot"), Qt::CaseInsensitive) == 0) {
Plasma::QueryMatch match(this);
match.setText(i18n("Restart the computer"));
match.setIcon(KIcon("system-reboot"));
match.setType(Plasma::QueryMatch::ExactMatch);
match.setRelevance(0.9);
matches << match;
- } else if (term.compare(i18nc("shutdown computer command","shutdown"), Qt::CaseInsensitive) == 0) {
+ } else if (term.compare(i18nc("shutdown computer command", "shutdown"), Qt::CaseInsensitive) == 0 ||
+ term.compare(QLatin1String("shutdown"), Qt::CaseInsensitive) == 0) {
Plasma::QueryMatch match(this);
match.setText(i18n("Shutdown the computer"));
match.setIcon(KIcon("system-shutdown"));
match.setType(Plasma::QueryMatch::ExactMatch);
match.setRelevance(0.9);
matches << match;
- } else if (term.compare(i18nc("lock screen command","lock"), Qt::CaseInsensitive) == 0) {
+ } else if (term.compare(i18nc("lock screen command", "lock"), Qt::CaseInsensitive) == 0 ||
+ term.compare(QLatin1String("lock"), Qt::CaseInsensitive) == 0) {
Plasma::QueryMatch match(this);
match.setText(i18n("Lock the screen"));
match.setIcon(KIcon("system-lock-screen"));
// first compare with SESSIONS. this must *NOT* be translated (i18n)
// as it is used as an internal command trigger (e.g. via d-bus),
// not as a user supplied query. and yes, "Ugh, magic strings"
- bool listAll = term.compare("SESSIONS", Qt::CaseInsensitive) == 0 ||
- term.compare(i18nc("User sessions", "sessions"), Qt::CaseInsensitive) == 0;
+ bool listAll = (
+ term.compare("SESSIONS", Qt::CaseInsensitive) == 0 ||
+ term.compare(i18nc("User sessions", "sessions"), Qt::CaseInsensitive) == 0
+ );
if (!listAll) {
//no luck, try the "switch" user command
bool onlyOptical = false;
bool forceEject = false;
bool showDevices = false;
- if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "device") , Qt::CaseInsensitive)) {
+ if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "device"), Qt::CaseInsensitive) ||
+ keywords[0].startsWith(QLatin1String("device"), Qt::CaseInsensitive)) {
showDevices = true;
keywords.removeFirst();
}
if (!keywords.isEmpty()) {
- if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "mount") , Qt::CaseInsensitive)) {
+ if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "mount"), Qt::CaseInsensitive) ||
+ keywords[0].startsWith(QLatin1String("mount"), Qt::CaseInsensitive)) {
showDevices = true;
onlyMountable = true;
keywords.removeFirst();
- } else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "unmount") , Qt::CaseInsensitive)) {
+ } else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "unmount"), Qt::CaseInsensitive) ||
+ keywords[0].startsWith(QLatin1String("unmount"), Qt::CaseInsensitive)) {
showDevices = true;
onlyMounted = true;
keywords.removeFirst();
- } else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "eject") , Qt::CaseInsensitive)) {
+ } else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "eject"), Qt::CaseInsensitive) ||
+ keywords[0].startsWith(QLatin1String("eject"), Qt::CaseInsensitive)) {
showDevices = true;
onlyOptical = true;
forceEject = true;
keywords.removeFirst();
- } else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "unlock") , Qt::CaseInsensitive)) {
+ } else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "unlock"), Qt::CaseInsensitive) ||
+ keywords[0].startsWith(QLatin1String("unlock"), Qt::CaseInsensitive)) {
showDevices = true;
onlyMountable = true;
onlyEncrypted = true;
keywords.removeFirst();
- } else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "lock") , Qt::CaseInsensitive)) {
+ } else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "lock"), Qt::CaseInsensitive) ||
+ keywords[0].startsWith(QLatin1String("lock"), Qt::CaseInsensitive)) {
showDevices = true;
onlyMounted = true;
onlyEncrypted = true;
// check if the search term ends with an action keyword
WindowAction action = ActivateAction;
- if (term.endsWith(i18nc("Note this is a KRunner keyword", "activate") , Qt::CaseInsensitive)) {
+ if (term.endsWith(i18nc("Note this is a KRunner keyword", "activate"), Qt::CaseInsensitive)) {
action = ActivateAction;
term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "activate")) - 1);
+ } else if (term.endsWith(QLatin1String("activate"), Qt::CaseInsensitive)) {
+ action = ActivateAction;
+ term = term.left(term.lastIndexOf(QLatin1String("activate")) - 1);
} else if (term.endsWith(i18nc("Note this is a KRunner keyword", "close") , Qt::CaseInsensitive)) {
action = CloseAction;
term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "close")) - 1);
+ } else if (term.endsWith(QLatin1String("close") , Qt::CaseInsensitive)) {
+ action = CloseAction;
+ term = term.left(term.lastIndexOf(QLatin1String("close")) - 1);
} else if (term.endsWith(i18nc("Note this is a KRunner keyword", "min") , Qt::CaseInsensitive)) {
action = MinimizeAction;
term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "min")) - 1);
+ } else if (term.endsWith(QLatin1String("min") , Qt::CaseInsensitive)) {
+ action = MinimizeAction;
+ term = term.left(term.lastIndexOf(QLatin1String("min")) - 1);
} else if (term.endsWith(i18nc("Note this is a KRunner keyword", "minimize") , Qt::CaseInsensitive)) {
action = MinimizeAction;
term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "minimize")) - 1);
+ } else if (term.endsWith(QLatin1String("minimize") , Qt::CaseInsensitive)) {
+ action = MinimizeAction;
+ term = term.left(term.lastIndexOf(QLatin1String("minimize")) - 1);
} else if (term.endsWith(i18nc("Note this is a KRunner keyword", "max") , Qt::CaseInsensitive)) {
action = MaximizeAction;
term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "max")) - 1);
+ } else if (term.endsWith(QLatin1String("max") , Qt::CaseInsensitive)) {
+ action = MaximizeAction;
+ term = term.left(term.lastIndexOf(QLatin1String("max")) - 1);
} else if (term.endsWith(i18nc("Note this is a KRunner keyword", "maximize") , Qt::CaseInsensitive)) {
action = MaximizeAction;
term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "maximize")) - 1);
+ } else if (term.endsWith(QLatin1String("maximize") , Qt::CaseInsensitive)) {
+ action = MaximizeAction;
+ term = term.left(term.lastIndexOf(QLatin1String("maximize")) - 1);
} else if (term.endsWith(i18nc("Note this is a KRunner keyword", "fullscreen") , Qt::CaseInsensitive)) {
action = FullscreenAction;
term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "fullscreen")) - 1);
+ } else if (term.endsWith(QLatin1String("fullscreen") , Qt::CaseInsensitive)) {
+ action = FullscreenAction;
+ term = term.left(term.lastIndexOf(QLatin1String("fullscreen")) - 1);
} else if (term.endsWith(i18nc("Note this is a KRunner keyword", "shade") , Qt::CaseInsensitive)) {
action = ShadeAction;
term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "shade")) - 1);
+ } else if (term.endsWith(QLatin1String("shade") , Qt::CaseInsensitive)) {
+ action = ShadeAction;
+ term = term.left(term.lastIndexOf(QLatin1String("shade")) - 1);
} else if (term.endsWith(i18nc("Note this is a KRunner keyword", "keep above") , Qt::CaseInsensitive)) {
action = KeepAboveAction;
term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "keep above")) - 1);
- } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "keep below") , Qt::CaseInsensitive)) {
+ } else if (term.endsWith(QLatin1String("keep above") , Qt::CaseInsensitive)) {
+ action = KeepAboveAction;
+ term = term.left(term.lastIndexOf(QLatin1String("keep above")) - 1);
+ } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "keep below"), Qt::CaseInsensitive)) {
action = KeepBelowAction;
term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "keep below")) - 1);
+ } else if (term.endsWith(QLatin1String("keep below") , Qt::CaseInsensitive)) {
+ action = KeepBelowAction;
+ term = term.left(term.lastIndexOf(QLatin1String("keep below")) - 1);
}
// keyword match: when term starts with "window" we list all windows
// the list can be restricted to windows matching a given name, class, role or desktop
- if (term.startsWith(i18nc("Note this is a KRunner keyword", "window") , Qt::CaseInsensitive)) {
+ if (term.startsWith(i18nc("Note this is a KRunner keyword", "window"), Qt::CaseInsensitive) ||
+ term.startsWith(QLatin1String("window"), Qt::CaseInsensitive)) {
const QStringList keywords = term.split(" ");
QString windowName;
QString windowClass;
if (keyword.endsWith('=')) {
continue;
}
- if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "name") + "=" , Qt::CaseInsensitive)) {
+ if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "name") + "=" , Qt::CaseInsensitive) ||
+ keyword.startsWith(QLatin1String("name="), Qt::CaseInsensitive)) {
windowName = keyword.split("=")[1];
- } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "class") + "=" , Qt::CaseInsensitive)) {
+ } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "class") + "=" , Qt::CaseInsensitive) ||
+ keyword.startsWith(QLatin1String("class="), Qt::CaseInsensitive)) {
windowClass = keyword.split("=")[1];
- } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "role") + "=" , Qt::CaseInsensitive)) {
+ } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "role") + "=" , Qt::CaseInsensitive) ||
+ keyword.startsWith(QLatin1String("role="), Qt::CaseInsensitive)) {
windowRole = keyword.split("=")[1];
- } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "desktop") + "=" , Qt::CaseInsensitive)) {
+ } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "desktop") + "=", Qt::CaseInsensitive) ||
+ keyword.startsWith(QLatin1String("desktop="), Qt::CaseInsensitive)) {
bool ok;
desktop = keyword.split("=")[1].toInt(&ok);
if (!ok || desktop > KWindowSystem::numberOfDesktops()) {
bool desktopAdded = false;
// check for desktop keyword
- if (term.startsWith(i18nc("Note this is a KRunner keyword", "desktop") , Qt::CaseInsensitive)) {
+ if (term.startsWith(i18nc("Note this is a KRunner keyword", "desktop") , Qt::CaseInsensitive) ||
+ term.startsWith(QLatin1String("desktop") , Qt::CaseInsensitive)) {
const QStringList parts = term.split(" ");
if (parts.size() == 1) {
// only keyword - list all desktops