PowerDevilRunner::PowerDevilRunner(QObject *parent, const QVariantList &args) : Plasma::AbstractRunner(parent), m_shortestCommand(1000) { Q_UNUSED(args) qDBusRegisterMetaType< StringStringMap >(); setObjectName( QLatin1String("PowerDevil" )); setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::NetworkLocation | Plasma::RunnerContext::Help); updateStatus(); initUpdateTriggers(); /* Let's define all the words here. m_words contains all the words that * will eventually trigger a match in the runner. */ QStringList commands; commands << i18nc("Note this is a KRunner keyword", "power profile") << i18nc("Note this is a KRunner keyword", "suspend") << i18nc("Note this is a KRunner keyword", "sleep") << i18nc("Note this is a KRunner keyword", "hibernate") << i18nc("Note this is a KRunner keyword", "to disk") << i18nc("Note this is a KRunner keyword", "to ram") << i18nc("Note this is a KRunner keyword", "screen brightness") << i18nc("Note this is a KRunner keyword", "dim screen"); foreach (const QString &command, commands) { if (command.length() < m_shortestCommand) { m_shortestCommand = command.length(); } } }
CharacterRunner::CharacterRunner( QObject* parent, const QVariantList &args ) : Plasma::AbstractRunner(parent, args) { Q_UNUSED(args) setObjectName(QLatin1String( "CharacterRunner" )); setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::NetworkLocation | Plasma::RunnerContext::Executable | Plasma::RunnerContext::ShellCommand); reloadConfiguration(); }
LocationsRunner::LocationsRunner(QObject *parent, const QVariantList& args) : Plasma::AbstractRunner(parent, args) { Q_UNUSED(args); // set the name shown after the result in krunner window setObjectName(QStringLiteral("Locations")); setIgnoredTypes(Plasma::RunnerContext::Executable | Plasma::RunnerContext::ShellCommand); addSyntax(Plasma::RunnerSyntax(QStringLiteral(":q:"), i18n("Finds local directories and files, network locations and Internet sites with paths matching :q:."))); }
KonquerorSessions::KonquerorSessions(QObject *parent, const QVariantList& args) : Plasma::AbstractRunner(parent, args) { Q_UNUSED(args); setObjectName(QLatin1String( "Konqueror Sessions" )); setIgnoredTypes(Plasma::RunnerContext::FileSystem | Plasma::RunnerContext::NetworkLocation); m_icon = KIcon(QLatin1String( "konqueror" )); loadSessions(); KDirWatch *historyWatch = new KDirWatch(this); const QStringList sessiondirs = KGlobal::dirs()->findDirs("data", QLatin1String( "konqueror/profiles/" )); foreach (const QString &dir, sessiondirs) { historyWatch->addDir(dir); }
ShellRunner::ShellRunner(QObject *parent, const QVariantList &args) : Plasma::AbstractRunner(parent, args), m_inTerminal(false), m_asOtherUser(false) { setObjectName( QLatin1String("Command" )); setPriority(AbstractRunner::HighestPriority); setHasRunOptions(true); m_enabled = KAuthorized::authorizeKAction("run_command") && KAuthorized::authorizeKAction("shell_access"); setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::NetworkLocation | Plasma::RunnerContext::UnknownType | Plasma::RunnerContext::Help); addSyntax(Plasma::RunnerSyntax(":q:", i18n("Finds commands that match :q:, using common shell syntax"))); }
ActivityRunner::ActivityRunner(QObject *parent, const QVariantList &args) : Plasma::AbstractRunner(parent, args), m_activities(0), m_keywordi18n(i18nc("KRunner keyword", "activity")), m_keyword("activity"), m_enabled(false) { setObjectName(QLatin1String("Activities")); setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::NetworkLocation | Plasma::RunnerContext::Help); connect(this, SIGNAL(prepare()), this, SLOT(prep())); connect(this, SIGNAL(teardown()), this, SLOT(down())); serviceStatusChanged(KActivities::Consumer::FullFunctionality); }
Translator::Translator(QObject *parent, const QVariantList &args) : Plasma::AbstractRunner(parent, args) { Q_UNUSED(args); setObjectName(QLatin1String("Translator")); reloadConfiguration(); setHasRunOptions(true); setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::NetworkLocation); setSpeed(AbstractRunner::SlowSpeed); setPriority(HighestPriority); setDefaultSyntax(Plasma::RunnerSyntax(QString::fromLatin1("%1:q:").arg(i18n("<language code>")),i18n("Translates the word(s) :q: into target language"))); setDefaultSyntax(Plasma::RunnerSyntax(QString::fromLatin1("%1:q:").arg(i18n("<source languagce>-<target languagce>")), i18n("Translates the word(s) :q: from the source into target language"))); }
KDevelopSessions::KDevelopSessions(QObject *parent, const QVariantList& args) : Plasma::AbstractRunner(parent, args) { kWarning() << "INIT KDEV"; setObjectName(QLatin1String("KDevelop Sessions")); setIgnoredTypes(Plasma::RunnerContext::File | Plasma::RunnerContext::Directory | Plasma::RunnerContext::NetworkLocation); m_icon = KIcon(QLatin1String("kdevelop")); loadSessions(); // listen for changes to the list of kdevelop sessions KDirWatch *historyWatch = new KDirWatch(this); const QStringList sessiondirs = KGlobal::dirs()->findDirs("data", QLatin1String("kdevelop/sessions/")); foreach (const QString &dir, sessiondirs) { historyWatch->addDir(dir); }
WebshortcutRunner::WebshortcutRunner(QObject *parent, const QVariantList& args) : Plasma::AbstractRunner(parent, args), m_match(this), m_filterBeforeRun(false) { Q_UNUSED(args); setObjectName( QLatin1String("Web Shortcut" )); setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::Executable); m_match.setType(Plasma::QueryMatch::ExactMatch); m_match.setRelevance(0.9); // Listen for KUriFilter plugin config changes and update state... QDBusConnection sessionDbus = QDBusConnection::sessionBus(); sessionDbus.connect(QString(), QStringLiteral("/"), QStringLiteral("org.kde.KUriFilterPlugin"), QStringLiteral("configure"), this, SLOT(readFiltersConfig())); connect(this, &WebshortcutRunner::teardown, this, &WebshortcutRunner::resetState); readFiltersConfig(); }
Translator::Translator(QObject* parent, const QVariantList& args) : Plasma::AbstractRunner(parent, args) { Q_UNUSED(args) setObjectName(QLatin1String("Translator")); setHasRunOptions(false); setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::NetworkLocation); setSpeed(AbstractRunner::SlowSpeed); QList<Plasma::RunnerSyntax> syntaxes; Plasma::RunnerSyntax autoSyntax(QString::fromLatin1("%1:q:").arg(i18n("<language code>")), i18n("Translates the word(s) :q: into target language")); syntaxes.append(autoSyntax); Plasma::RunnerSyntax syntax(QString::fromLatin1("%1:q:").arg(i18n("<source language>-<target language>")), i18n("Translates the word(s) :q: from the source into target language")); syntaxes.append(syntax); setSyntaxes(syntaxes); }
SessionRunner::SessionRunner(QObject *parent, const QVariantList &args) : Plasma::AbstractRunner(parent, args) { setObjectName( QLatin1String("Sessions" )); setPriority(LowPriority); setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::NetworkLocation); m_canLogout = KAuthorized::authorizeAction(QStringLiteral("logout")) && KAuthorized::authorize(QStringLiteral("logout")); if (m_canLogout) { addSyntax(Plasma::RunnerSyntax(i18nc("log out command", "logout"), i18n("Logs out, exiting the current desktop session"))); addSyntax(Plasma::RunnerSyntax(i18nc("shutdown computer command", "shutdown"), i18n("Turns off the computer"))); } if (KAuthorized::authorizeAction(QStringLiteral("lock_screen")) && m_canLogout) { addSyntax(Plasma::RunnerSyntax(i18nc("lock screen command", "lock"), i18n("Locks the current sessions and starts the screen saver"))); } Plasma::RunnerSyntax rebootSyntax(i18nc("restart computer command", "restart"), i18n("Reboots the computer")); rebootSyntax.addExampleQuery(i18nc("restart computer command", "reboot")); addSyntax(rebootSyntax); m_triggerWord = i18nc("switch user command", "switch"); addSyntax(Plasma::RunnerSyntax(i18nc("switch user command", "switch :q:"), i18n("Switches to the active session for the user :q:, " "or lists all active sessions if :q: is not provided"))); Plasma::RunnerSyntax fastUserSwitchSyntax(i18n("switch user"), i18n("Starts a new session as a different user")); fastUserSwitchSyntax.addExampleQuery(i18n("new session")); addSyntax(fastUserSwitchSyntax); //"SESSIONS" should not be translated; it's used programmaticaly setDefaultSyntax(Plasma::RunnerSyntax(QStringLiteral("SESSIONS"), i18n("Lists all sessions"))); }