void AudioPlayerControlRunner::reloadConfiguration()
{
+#warning TODO: untranslated keywords match
KConfigGroup grp = config();
m_player = grp.readEntry(CONFIG_PLAYER, "vlc");
m_comPlay = grp.readEntry(CONFIG_PLAY, i18n("play"));
if (ch.isNumber()) {
return true;
}
- if (QString(QLatin1String( ".,-+" )).contains( ch )) {
+ if (QString(QLatin1String(".,-+" )).contains(ch)) {
return true;
}
return false;
: Plasma::AbstractRunner(parent, args)
{
Q_UNUSED(args)
- setObjectName(QLatin1String( "Converter" ));
+ setObjectName(QLatin1String("Converter"));
- m_separators << QString( CONVERSION_CHAR );
+#warning TODO: untranslated keywords match
+ m_separators << QString(CONVERSION_CHAR);
m_separators << i18nc("list of words that can be used as amount of 'unit1' [in|to|as] 'unit2'",
- "in;to;as").split(QLatin1Char( ';' ));
+ "in;to;as").split(QLatin1Char(';'));
//can not ignore commands: we have things like m4
setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File |
#include <Plasma/Applet>
-static const QString dateWord = i18nc("Note this is a KRunner keyword", "date");
-static const QString timeWord = i18nc("Note this is a KRunner keyword", "time");
+static const char* dateWordChars = "date";
+static const QString dateWord = i18nc("Note this is a KRunner keyword", dateWordChars);
+static const char* timeWordChars = "time";
+static const QString timeWord = i18nc("Note this is a KRunner keyword", timeWordChars);
DateTimeRunner::DateTimeRunner(QObject *parent, const QVariantList &args)
: Plasma::AbstractRunner(parent, args)
void DateTimeRunner::match(Plasma::RunnerContext &context)
{
const QString term = context.query();
- if (term.compare(dateWord, Qt::CaseInsensitive) == 0) {
+ if (term.compare(dateWord, Qt::CaseInsensitive) == 0 ||
+ term.compare(QLatin1String(dateWordChars), Qt::CaseInsensitive) == 0) {
const QString date = KGlobal::locale()->formatDate(QDate::currentDate());
addMatch(i18n("Today's date is %1", date), date, context);
- } else if (term.startsWith(dateWord + QLatin1Char( ' ' ), Qt::CaseInsensitive)) {
+ } else if (term.startsWith(dateWord + QLatin1Char(' '), Qt::CaseInsensitive)) {
QString tzName;
- QDateTime dt = datetime(term, true, tzName);
+ const QString tz = term.right(term.length() - term.indexOf(QLatin1Char(' ')) - 1);
+ QDateTime dt = datetime(tz, tzName);
if (dt.isValid()) {
const QString date = KGlobal::locale()->formatDate(dt.date());
addMatch(i18n("The date in %1 is %2", tzName, date), date, context);
}
- } else if (term.compare(timeWord, Qt::CaseInsensitive) == 0) {
+ } else if (term.compare(timeWord, Qt::CaseInsensitive) == 0 ||
+ term.compare(QLatin1String(timeWordChars), Qt::CaseInsensitive) == 0) {
const QString time = KGlobal::locale()->formatTime(QTime::currentTime());
addMatch(i18n("The current time is %1", time), time, context);
- } else if (term.startsWith(timeWord + QLatin1Char( ' ' ), Qt::CaseInsensitive)) {
+ } else if (term.startsWith(timeWord + QLatin1Char(' '), Qt::CaseInsensitive) ||
+ term.startsWith(QLatin1String(timeWordChars) + QLatin1Char(' '), Qt::CaseInsensitive)) {
QString tzName;
- QDateTime dt = datetime(term, true, tzName);
+ const QString tz = term.right(term.length() - term.indexOf(QLatin1Char(' ')) - 1);
+ QDateTime dt = datetime(tz, tzName);
if (dt.isValid()) {
const QString time = KGlobal::locale()->formatTime(dt.time());
addMatch(i18n("The current time in %1 is %2", tzName, time), time, context);
}
}
-QDateTime DateTimeRunner::datetime(const QString &term, bool date, QString &tzName)
+QDateTime DateTimeRunner::datetime(const QString &tz, QString &tzName)
{
QDateTime dt;
- const QString tz = term.right(term.length() - (date ? dateWord.length() : timeWord.length()) - 1);
- if (tz.compare(QLatin1String( "UTC" ), Qt::CaseInsensitive) == 0) {
+ if (tz.compare(QLatin1String("UTC"), Qt::CaseInsensitive) == 0) {
tzName = QLatin1String( "UTC" );
dt = KDateTime::currentDateTime(KTimeZone::utc());
return dt;
dt = KDateTime::currentDateTime(zone);
} else {
foreach (const QByteArray &abbrev, zone.abbreviations()) {
- if (QString( abbrev ).contains(tz, Qt::CaseInsensitive)) {
+ if (QString(abbrev).contains(tz, Qt::CaseInsensitive)) {
tzName = abbrev;
dt = KDateTime::currentDateTime(zone);
}
match.setText(text);
match.setData(clipboardText);
match.setType(Plasma::QueryMatch::InformationalMatch);
- match.setIcon(KIcon(QLatin1String( "clock" )));
+ match.setIcon(KIcon(QLatin1String("clock")));
QList<Plasma::QueryMatch> matches;
matches << match;
void match(Plasma::RunnerContext &context);
private:
- QDateTime datetime(const QString &term, bool date, QString &tzName);
+ QDateTime datetime(const QString &term, QString &tzName);
void addMatch(const QString &text, const QString &clipboardText, Plasma::RunnerContext &context);
};
// Switch kate session: -u
// Should we add a match for this option or would that clutter the matches too much?
QStringList sessions = QStringList();
- const QStringList list = KGlobal::dirs()->findAllResources( "data", QLatin1String("kate/sessions/*.katesession"), KStandardDirs::NoDuplicates );
+ const QStringList list = KGlobal::dirs()->findAllResources(
+ "data", QLatin1String("kate/sessions/*.katesession"), KStandardDirs::NoDuplicates
+ );
KUrl url;
for (QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it)
{
if (!session.isEmpty()) {
QStringList args;
- args << QLatin1String("--start") << session << QLatin1String("-n");
+ args << QLatin1String("--start") << session << QLatin1String("-n");
KToolInvocation::kdeinitExec(QLatin1String("kate"), args);
}
}
loadSessions();
KDirWatch *historyWatch = new KDirWatch(this);
- const QStringList sessiondirs = KGlobal::dirs()->findDirs("data", QLatin1String( "konsole/" ));
+ const QStringList sessiondirs = KGlobal::dirs()->findDirs("data", QLatin1String("konsole/"));
foreach (const QString &dir, sessiondirs) {
historyWatch->addDir(dir);
}
connect(historyWatch, SIGNAL(dirty(QString)), this,SLOT(loadSessions()));
Plasma::RunnerSyntax s(QLatin1String( ":q:" ), i18n("Finds Konsole sessions matching :q:."));
- s.addExampleQuery(QLatin1String( "konsole :q:" ));
+ s.addExampleQuery(QLatin1String("konsole :q:"));
addSyntax(s);
- addSyntax(Plasma::RunnerSyntax(QLatin1String( "konsole" ), i18n("Lists all the Konsole sessions in your account.")));
+ addSyntax(Plasma::RunnerSyntax(QLatin1String("konsole"), i18n("Lists all the Konsole sessions in your account.")));
}
KonsoleSessions::~KonsoleSessions()
void KonsoleSessions::loadSessions()
{
- const QStringList list = KGlobal::dirs()->findAllResources("data", QLatin1String( "konsole/*.profile" ), KStandardDirs::NoDuplicates);
+ const QStringList list = KGlobal::dirs()->findAllResources(
+ "data", QLatin1String("konsole/*.profile"), KStandardDirs::NoDuplicates
+ );
QStringList::ConstIterator end = list.constEnd();
for (QStringList::ConstIterator it = list.constBegin(); it != end; ++it) {
QFileInfo info(*it);
return;
}
- if (term.compare(QLatin1String( "konsole" ), Qt::CaseInsensitive) == 0) {
+ if (term.compare(QLatin1String("konsole"), Qt::CaseInsensitive) == 0) {
QHashIterator<QString, QString> i(m_sessions);
while (i.hasNext()) {
i.next();
match.setRelevance(1.0);
match.setIcon(m_icon);
match.setData(i.key());
- match.setText(QLatin1String( "Konsole: " ) + i.value());
+ match.setText(QLatin1String("Konsole: ") + i.value());
context.addMatch(term, match);
}
} else {
match.setType(Plasma::QueryMatch::PossibleMatch);
match.setIcon(m_icon);
match.setData(i.key());
- match.setText(QLatin1String( "Konsole: " ) + i.value());
+ match.setText(QLatin1String("Konsole: ") + i.value());
if (i.value().compare(term, Qt::CaseInsensitive) == 0) {
match.setRelevance(1.0);
args << QLatin1String( "--profile" );
args << session;
kDebug() << "=== START: konsole" << args;
- KToolInvocation::kdeinitExec(QLatin1String( "konsole" ), args);
+ KToolInvocation::kdeinitExec(QLatin1String("konsole"), args);
}
}
: Plasma::AbstractRunner(parent, args)
{
Q_UNUSED(args)
- KGlobal::locale()->insertCatalog(QLatin1String( "krunner_spellcheckrunner" ));
- setObjectName(QLatin1String( "Spell Checker" ));
+ KGlobal::locale()->insertCatalog(QLatin1String("krunner_spellcheckrunner"));
+ setObjectName(QLatin1String("Spell Checker"));
setIgnoredTypes(Plasma::RunnerContext::FileSystem | Plasma::RunnerContext::NetworkLocation);
setSpeed(AbstractRunner::SlowSpeed);
}
void SpellCheckRunner::reloadConfiguration()
{
+#warning TODO: untranslated keyword match
m_triggerWord = config().readEntry("trigger", i18n("spell"));
//Processing will be triggered by "keyword "
m_triggerWord += QLatin1Char( ' ' );
// KGet is not running. Ask DBus to start it.
connection->startService(KGET_DBUS_SERVICE);
if(connection->lastError().type() != QDBusError::NoError) {
- KNotification::event(KNotification::Error,
- i18n("<p>KGet Runner could not communicate with KGet.</p><p style=\"font-size: small;\">Response from DBus:<br/>%1</p>", connection->lastError().message()),
- KIcon("dialog-warning").pixmap(KIconLoader::SizeSmall)/*, 0, KNotification::Persistent*/);
+ KNotification::event(
+ KNotification::Error,
+ i18n(
+ "<p>KGet Runner could not communicate with KGet.</p><p style=\"font-size: small;\">Response from DBus:<br/>%1</p>",
+ connection->lastError().message()
+ ),
+ KIcon("dialog-warning").pixmap(KIconLoader::SizeSmall)
+ );
return;
}