本文整理汇总了C++中plasma::RunnerContext::type方法的典型用法代码示例。如果您正苦于以下问题:C++ RunnerContext::type方法的具体用法?C++ RunnerContext::type怎么用?C++ RunnerContext::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plasma::RunnerContext
的用法示例。
在下文中一共展示了RunnerContext::type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: match
void ShellRunner::match(Plasma::RunnerContext &context)
{
if (!m_enabled) {
return;
}
if (context.type() == Plasma::RunnerContext::Executable ||
context.type() == Plasma::RunnerContext::ShellCommand) {
const QString term = context.query();
Plasma::QueryMatch match(this);
match.setId(term);
match.setType(Plasma::QueryMatch::ExactMatch);
match.setIcon(QIcon::fromTheme("system-run"));
match.setText(i18n("Run %1", term));
match.setRelevance(0.7);
context.addMatch(match);
}
}
示例2: match
void LocationsRunner::match(Plasma::RunnerContext &context)
{
QString term = context.query();
Plasma::RunnerContext::Type type = context.type();
if (type == Plasma::RunnerContext::Directory || type == Plasma::RunnerContext::File) {
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::ExactMatch);
match.setText(i18n("Open %1", term));
if (type == Plasma::RunnerContext::File) {
match.setIcon(QIcon::fromTheme(KIO::iconNameForUrl(QUrl(term))));
} else {
match.setIcon(QIcon::fromTheme(QStringLiteral("system-file-manager")));
}
match.setRelevance(1);
match.setData(term);
match.setType(Plasma::QueryMatch::ExactMatch);
if (type == Plasma::RunnerContext::Directory) {
match.setId(QStringLiteral("opendir"));
} else {
match.setId(QStringLiteral("openfile"));
}
context.addMatch(match);
} else if (type == Plasma::RunnerContext::Help) {
//qDebug() << "Locations matching because of" << type;
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::ExactMatch);
match.setText(i18n("Open %1", term));
match.setIcon(QIcon::fromTheme(QStringLiteral("system-help")));
match.setRelevance(1);
match.setType(Plasma::QueryMatch::ExactMatch);
match.setId(QStringLiteral("help"));
context.addMatch(match);
} else if (type == Plasma::RunnerContext::NetworkLocation || type == Plasma::RunnerContext::UnknownType) {
const bool filtered = KUriFilter::self()->filterUri(term, QStringList() << QStringLiteral("kshorturifilter"));
if (!filtered) {
return;
}
QUrl url(term);
if (!KProtocolInfo::isKnownProtocol(url.scheme())) {
return;
}
Plasma::QueryMatch match(this);
match.setText(i18n("Go to %1", url.toDisplayString()));
match.setIcon(QIcon::fromTheme(KProtocolInfo::icon(url.scheme())));
match.setData(url.url());
if (KProtocolInfo::isHelperProtocol(url.scheme())) {
//qDebug() << "helper protocol" << url.protocol() <<"call external application" ;
if (url.scheme() == QLatin1String("mailto")) {
match.setText(i18n("Send email to %1",url.path()));
} else {
match.setText(i18n("Launch with %1", KProtocolInfo::exec(url.scheme())));
}
} else {
//qDebug() << "protocol managed by browser" << url.protocol();
match.setText(i18n("Go to %1", url.toDisplayString()));
}
if (type == Plasma::RunnerContext::UnknownType) {
match.setId(QStringLiteral("openunknown"));
match.setRelevance(0.5);
match.setType(Plasma::QueryMatch::PossibleMatch);
} else {
match.setId(QStringLiteral("opennetwork"));
match.setRelevance(0.7);
match.setType(Plasma::QueryMatch::ExactMatch);
}
context.addMatch(match);
}
}