mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22:52 +00:00
kdeplasma-addons: match the untranslated terms as fallback in runners
see the following commit in kde-workspace repo: 9c2fb0b928746ec94fb56022a473de2cf81f9945 Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
f4ba650074
commit
6ccb85540b
8 changed files with 51 additions and 33 deletions
|
@ -201,6 +201,7 @@ void AudioPlayerControlRunner::run(const Plasma::RunnerContext &context, const P
|
|||
|
||||
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"));
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
if (ch.isNumber()) {
|
||||
return true;
|
||||
}
|
||||
if (QString(QLatin1String( ".,-+" )).contains( ch )) {
|
||||
if (QString(QLatin1String(".,-+" )).contains(ch)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -121,11 +121,12 @@ ConverterRunner::ConverterRunner(QObject* parent, const QVariantList &args)
|
|||
: 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 |
|
||||
|
|
|
@ -30,8 +30,10 @@
|
|||
|
||||
#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)
|
||||
|
@ -51,22 +53,27 @@ DateTimeRunner::~DateTimeRunner()
|
|||
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);
|
||||
|
@ -74,12 +81,11 @@ void DateTimeRunner::match(Plasma::RunnerContext &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;
|
||||
|
@ -97,7 +103,7 @@ QDateTime DateTimeRunner::datetime(const QString &term, bool date, QString &tzNa
|
|||
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);
|
||||
}
|
||||
|
@ -115,7 +121,7 @@ void DateTimeRunner::addMatch(const QString &text, const QString &clipboardText,
|
|||
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;
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
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);
|
||||
};
|
||||
|
||||
|
|
|
@ -83,7 +83,9 @@ void KateSessions::loadSessions()
|
|||
// 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)
|
||||
{
|
||||
|
@ -168,7 +170,7 @@ void KateSessions::run(const Plasma::RunnerContext &context, const Plasma::Query
|
|||
|
||||
if (!session.isEmpty()) {
|
||||
QStringList args;
|
||||
args << QLatin1String("--start") << session << QLatin1String("-n");
|
||||
args << QLatin1String("--start") << session << QLatin1String("-n");
|
||||
KToolInvocation::kdeinitExec(QLatin1String("kate"), args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ KonsoleSessions::KonsoleSessions(QObject *parent, const QVariantList& 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);
|
||||
}
|
||||
|
@ -49,10 +49,10 @@ KonsoleSessions::KonsoleSessions(QObject *parent, const QVariantList& args)
|
|||
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()
|
||||
|
@ -61,7 +61,9 @@ 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);
|
||||
|
@ -94,7 +96,7 @@ void KonsoleSessions::match(Plasma::RunnerContext &context)
|
|||
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();
|
||||
|
@ -103,7 +105,7 @@ void KonsoleSessions::match(Plasma::RunnerContext &context)
|
|||
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 {
|
||||
|
@ -123,7 +125,7 @@ void KonsoleSessions::match(Plasma::RunnerContext &context)
|
|||
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);
|
||||
|
@ -148,7 +150,7 @@ void KonsoleSessions::run(const Plasma::RunnerContext &context, const Plasma::Qu
|
|||
args << QLatin1String( "--profile" );
|
||||
args << session;
|
||||
kDebug() << "=== START: konsole" << args;
|
||||
KToolInvocation::kdeinitExec(QLatin1String( "konsole" ), args);
|
||||
KToolInvocation::kdeinitExec(QLatin1String("konsole"), args);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ SpellCheckRunner::SpellCheckRunner(QObject* parent, const QVariantList &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);
|
||||
}
|
||||
|
@ -106,6 +106,7 @@ void SpellCheckRunner::destroydata()
|
|||
|
||||
void SpellCheckRunner::reloadConfiguration()
|
||||
{
|
||||
#warning TODO: untranslated keyword match
|
||||
m_triggerWord = config().readEntry("trigger", i18n("spell"));
|
||||
//Processing will be triggered by "keyword "
|
||||
m_triggerWord += QLatin1Char( ' ' );
|
||||
|
|
|
@ -76,9 +76,14 @@ void KGetRunner::run(const Plasma::RunnerContext& /*context*/, const Plasma::Que
|
|||
// 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue