mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +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"));
|
||||
|
|
|
@ -123,6 +123,7 @@ ConverterRunner::ConverterRunner(QObject* parent, const QVariantList &args)
|
|||
Q_UNUSED(args)
|
||||
setObjectName(QLatin1String("Converter"));
|
||||
|
||||
#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(';'));
|
||||
|
|
|
@ -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)) {
|
||||
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,10 +81,9 @@ 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) {
|
||||
tzName = QLatin1String( "UTC" );
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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