mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
plasma: prepare for Plasma::QueryMatch changes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
6437341e9d
commit
dbfe038aa4
15 changed files with 16 additions and 55 deletions
|
@ -538,7 +538,7 @@ void LauncherSearch::slotUpdateLayout(const QList<Plasma::QueryMatch> &matches)
|
|||
iconsize, match.icon(), match.text(), match.subtext()
|
||||
);
|
||||
launcherwidget->setData(match.id());
|
||||
if (!match.isEnabled() || match.type() == Plasma::QueryMatch::InformationalMatch) {
|
||||
if (!match.isEnabled()) {
|
||||
launcherwidget->disableHover();
|
||||
}
|
||||
int counter = 0;
|
||||
|
|
|
@ -32,25 +32,19 @@ BookmarkMatch::BookmarkMatch(Favicon *favicon, const QString& searchTerm, const
|
|||
|
||||
Plasma::QueryMatch BookmarkMatch::asQueryMatch( Plasma::AbstractRunner* runner )
|
||||
{
|
||||
Plasma::QueryMatch::Type type = Plasma::QueryMatch::NoMatch;
|
||||
qreal relevance = 0;
|
||||
|
||||
if (m_bookmarkTitle.compare(m_searchTerm, Qt::CaseInsensitive) == 0 ||
|
||||
(!m_description.isEmpty() && m_description.compare(m_searchTerm, Qt::CaseInsensitive) == 0)
|
||||
) {
|
||||
type = Plasma::QueryMatch::ExactMatch;
|
||||
relevance = 1.0;
|
||||
} else if (m_bookmarkTitle.contains(m_searchTerm, Qt::CaseInsensitive)) {
|
||||
type = Plasma::QueryMatch::PossibleMatch;
|
||||
relevance = 0.45;
|
||||
} else if (!m_description.isEmpty() && m_description.contains(m_searchTerm, Qt::CaseInsensitive)) {
|
||||
type = Plasma::QueryMatch::PossibleMatch;
|
||||
relevance = 0.3;
|
||||
} else if (m_bookmarkURL.contains(m_searchTerm, Qt::CaseInsensitive)) {
|
||||
type = Plasma::QueryMatch::PossibleMatch;
|
||||
relevance = 0.2;
|
||||
} else {
|
||||
type = Plasma::QueryMatch::PossibleMatch;
|
||||
relevance = 0.18;
|
||||
}
|
||||
|
||||
|
@ -58,7 +52,6 @@ Plasma::QueryMatch BookmarkMatch::asQueryMatch( Plasma::AbstractRunner* runner )
|
|||
bool isDescriptionEmpty = m_description.isEmpty();
|
||||
|
||||
Plasma::QueryMatch match(runner);
|
||||
match.setType(type);
|
||||
match.setRelevance(relevance);
|
||||
match.setIcon(m_favicon->iconFor(m_bookmarkURL));
|
||||
match.setSubtext(m_bookmarkURL);
|
||||
|
|
|
@ -220,11 +220,11 @@ void CalculatorRunner::match(Plasma::RunnerContext &context)
|
|||
}
|
||||
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(Plasma::QueryMatch::InformationalMatch);
|
||||
match.setIcon(KIcon("accessories-calculator"));
|
||||
match.setText(result);
|
||||
match.setData(result);
|
||||
match.setId(term);
|
||||
match.setEnabled(false);
|
||||
context.addMatch(term, match);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ void LocationsRunner::match(Plasma::RunnerContext &context)
|
|||
|
||||
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) {
|
||||
|
@ -66,7 +65,6 @@ void LocationsRunner::match(Plasma::RunnerContext &context)
|
|||
|
||||
match.setRelevance(1);
|
||||
match.setData(term);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
|
||||
if (type == Plasma::RunnerContext::Directory) {
|
||||
match.setId("opendir");
|
||||
|
@ -77,11 +75,9 @@ void LocationsRunner::match(Plasma::RunnerContext &context)
|
|||
} else if (type == Plasma::RunnerContext::Help) {
|
||||
//kDebug() << "Locations matching because of" << type;
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
match.setText(i18n("Open %1", term));
|
||||
match.setIcon(KIcon("system-help"));
|
||||
match.setRelevance(1);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
match.setId("help");
|
||||
context.addMatch(term, match);
|
||||
} else if (type == Plasma::RunnerContext::NetworkLocation || type == Plasma::RunnerContext::UnknownType) {
|
||||
|
@ -117,11 +113,9 @@ void LocationsRunner::match(Plasma::RunnerContext &context)
|
|||
if (type == Plasma::RunnerContext::UnknownType) {
|
||||
match.setId("openunknown");
|
||||
match.setRelevance(0.5);
|
||||
match.setType(Plasma::QueryMatch::PossibleMatch);
|
||||
} else {
|
||||
match.setId("opennetwork");
|
||||
match.setRelevance(0.7);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
}
|
||||
|
||||
context.addMatch(term, match);
|
||||
|
|
|
@ -90,21 +90,17 @@ void PlacesRunnerHelper::match(Plasma::RunnerContext *c)
|
|||
}
|
||||
for (int i = 0; i <= m_places.rowCount(); i++) {
|
||||
QModelIndex current_index = m_places.index(i, 0);
|
||||
Plasma::QueryMatch::Type type = Plasma::QueryMatch::NoMatch;
|
||||
qreal relevance = 0;
|
||||
qreal relevance = 0.0;
|
||||
|
||||
const QString text = m_places.text(current_index);
|
||||
if ((all && !text.isEmpty()) || text.compare(term, Qt::CaseInsensitive) == 0) {
|
||||
type = Plasma::QueryMatch::ExactMatch;
|
||||
relevance = all ? 0.9 : 1.0;
|
||||
} else if (text.contains(term, Qt::CaseInsensitive)) {
|
||||
type = Plasma::QueryMatch::PossibleMatch;
|
||||
relevance = 0.7;
|
||||
}
|
||||
|
||||
if (type != Plasma::QueryMatch::NoMatch) {
|
||||
if (relevance != 0.0) {
|
||||
Plasma::QueryMatch match(static_cast<PlacesRunner *>(parent()));
|
||||
match.setType(type);
|
||||
match.setRelevance(relevance);
|
||||
match.setIcon(KIcon(m_places.icon(current_index)));
|
||||
match.setText(text);
|
||||
|
|
|
@ -160,7 +160,6 @@ void PowerDevilRunner::match(Plasma::RunnerContext &context)
|
|||
void PowerDevilRunner::addSuspendMatch(const Solid::PowerManagement::SleepState value, QList<Plasma::QueryMatch> &matches)
|
||||
{
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
|
||||
switch (value) {
|
||||
case Solid::PowerManagement::SuspendState: {
|
||||
|
|
|
@ -81,7 +81,6 @@ void RecentDocuments::match(Plasma::RunnerContext &context)
|
|||
KConfig _config( document, KConfig::SimpleConfig);
|
||||
KConfigGroup config(&_config, "Desktop Entry" );
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(Plasma::QueryMatch::PossibleMatch);
|
||||
match.setRelevance(1.0);
|
||||
match.setIcon(KIcon(config.readEntry("Icon")));
|
||||
match.setData(document); // TODO: Read URL[$e], or can we just pass the path to the .desktop file?
|
||||
|
|
|
@ -61,7 +61,6 @@ void ServiceRunner::match(Plasma::RunnerContext &context)
|
|||
foreach (const KService::Ptr &service, services) {
|
||||
if (!service->noDisplay() && service->property("NotShowIn", QVariant::String) != "KDE") {
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
setupMatch(service, match);
|
||||
match.setRelevance(1);
|
||||
matches << match;
|
||||
|
@ -116,7 +115,6 @@ void ServiceRunner::match(Plasma::RunnerContext &context)
|
|||
seen.insert(exec);
|
||||
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(Plasma::QueryMatch::PossibleMatch);
|
||||
setupMatch(service, match);
|
||||
qreal relevance(0.6);
|
||||
|
||||
|
@ -172,7 +170,6 @@ void ServiceRunner::match(Plasma::RunnerContext &context)
|
|||
continue;
|
||||
}
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(Plasma::QueryMatch::PossibleMatch);
|
||||
setupMatch(service, match);
|
||||
|
||||
qreal relevance = 0.6;
|
||||
|
|
|
@ -75,7 +75,6 @@ void SessionRunner::matchCommands(QList<Plasma::QueryMatch> &matches, const QStr
|
|||
match.setText(i18nc("log out command","Logout"));
|
||||
match.setIcon(KIcon("system-log-out"));
|
||||
match.setData(LogoutAction);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
match.setRelevance(0.9);
|
||||
matches << match;
|
||||
} else if (term.compare(i18nc("restart computer command", "restart"), Qt::CaseInsensitive) == 0 ||
|
||||
|
@ -86,7 +85,6 @@ void SessionRunner::matchCommands(QList<Plasma::QueryMatch> &matches, const QStr
|
|||
match.setText(i18n("Restart the computer"));
|
||||
match.setIcon(KIcon("system-reboot"));
|
||||
match.setData(RestartAction);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
match.setRelevance(0.9);
|
||||
matches << match;
|
||||
} else if (term.compare(i18nc("shutdown computer command", "shutdown"), Qt::CaseInsensitive) == 0 ||
|
||||
|
@ -95,7 +93,6 @@ void SessionRunner::matchCommands(QList<Plasma::QueryMatch> &matches, const QStr
|
|||
match.setText(i18n("Shutdown the computer"));
|
||||
match.setIcon(KIcon("system-shutdown"));
|
||||
match.setData(ShutdownAction);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
match.setRelevance(0.9);
|
||||
matches << match;
|
||||
} else if (term.compare(i18nc("lock screen command", "lock"), Qt::CaseInsensitive) == 0 ||
|
||||
|
@ -104,7 +101,6 @@ void SessionRunner::matchCommands(QList<Plasma::QueryMatch> &matches, const QStr
|
|||
match.setText(i18n("Lock the screen"));
|
||||
match.setIcon(KIcon("system-lock-screen"));
|
||||
match.setData(LockAction);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
match.setRelevance(0.9);
|
||||
matches << match;
|
||||
}
|
||||
|
@ -148,7 +144,6 @@ void SessionRunner::match(Plasma::RunnerContext &context)
|
|||
|
||||
if (switchUser && dm.isSwitchable()) {
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
match.setIcon(KIcon("system-switch-user"));
|
||||
match.setText(i18n("New Session"));
|
||||
matches << match;
|
||||
|
@ -165,26 +160,22 @@ void SessionRunner::match(Plasma::RunnerContext &context)
|
|||
}
|
||||
|
||||
QString name = KDisplayManager::sess2Str(session);
|
||||
Plasma::QueryMatch::Type type = Plasma::QueryMatch::NoMatch;
|
||||
qreal relevance = 0.7;
|
||||
|
||||
if (listAll) {
|
||||
type = Plasma::QueryMatch::ExactMatch;
|
||||
relevance = 1;
|
||||
relevance = 1.0;
|
||||
} else if (matchUser) {
|
||||
if (name.compare(user, Qt::CaseInsensitive) == 0) {
|
||||
// we need an elif branch here because we don't
|
||||
// want the last conditional to be checked if !listAll
|
||||
type = Plasma::QueryMatch::ExactMatch;
|
||||
relevance = 1;
|
||||
relevance = 1.0;
|
||||
} else if (name.contains(user, Qt::CaseInsensitive)) {
|
||||
type = Plasma::QueryMatch::PossibleMatch;
|
||||
relevance = 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
if (type != Plasma::QueryMatch::NoMatch) {
|
||||
if (relevance != 0.0) {
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(type);
|
||||
match.setRelevance(relevance);
|
||||
match.setIcon(KIcon("user-identity"));
|
||||
match.setText(name);
|
||||
|
|
|
@ -47,7 +47,6 @@ void ShellRunner::match(Plasma::RunnerContext &context)
|
|||
const QString term = context.query();
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setId(term);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
match.setIcon(KIcon("system-run"));
|
||||
match.setText(i18n("Run %1", term));
|
||||
match.setRelevance(0.7);
|
||||
|
|
|
@ -340,7 +340,6 @@ void SolidRunner::addDeviceMatch(const QString &term, Plasma::RunnerContext &con
|
|||
const Solid::Device &soliddevice, const SolidMatchType solidmatchtype)
|
||||
{
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(Plasma::QueryMatch::PossibleMatch);
|
||||
match.setId(soliddevice.udi());
|
||||
match.setData(static_cast<int>(solidmatchtype));
|
||||
match.setIcon(KIcon(soliddevice.icon()));
|
||||
|
|
|
@ -40,7 +40,6 @@ WebshortcutRunner::WebshortcutRunner(QObject *parent, const QVariantList& args)
|
|||
|
||||
m_icon = KIcon("internet-web-browser");
|
||||
|
||||
m_match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
m_match.setRelevance(0.9);
|
||||
|
||||
// Listen for KUriFilter plugin config changes and update state...
|
||||
|
|
|
@ -68,10 +68,8 @@ void WindowedWidgetsRunner::match(Plasma::RunnerContext &context)
|
|||
Plasma::QueryMatch match(this);
|
||||
setupMatch(service, match);
|
||||
if (service->name().compare(term, Qt::CaseInsensitive) == 0) {
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
match.setRelevance(1);
|
||||
} else {
|
||||
match.setType(Plasma::QueryMatch::PossibleMatch);
|
||||
match.setRelevance(0.7);
|
||||
}
|
||||
matches << match;
|
||||
|
|
|
@ -87,7 +87,7 @@ void WindowsRunner::gatherInfo()
|
|||
}
|
||||
}
|
||||
|
||||
for (int i=1; i<=KWindowSystem::numberOfDesktops(); i++) {
|
||||
for (int i = 1; i<=KWindowSystem::numberOfDesktops(); i++) {
|
||||
m_desktopNames << KWindowSystem::desktopName(i);
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ void WindowsRunner::match(Plasma::RunnerContext& context)
|
|||
}
|
||||
// blacklisted everything else: we have a match
|
||||
if (actionSupported(info, action)){
|
||||
matches << windowMatch(info, action, 1.0, Plasma::QueryMatch::ExactMatch);
|
||||
matches << windowMatch(info, action, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,11 +307,11 @@ void WindowsRunner::match(Plasma::RunnerContext& context)
|
|||
QString className = QString::fromUtf8(info.windowClassName());
|
||||
if (info.name().startsWith(term, Qt::CaseInsensitive) ||
|
||||
className.startsWith(term, Qt::CaseInsensitive)) {
|
||||
matches << windowMatch(info, action, 0.8, Plasma::QueryMatch::ExactMatch);
|
||||
matches << windowMatch(info, action, 0.8);
|
||||
} else if ((info.name().contains(term, Qt::CaseInsensitive) ||
|
||||
className.contains(term, Qt::CaseInsensitive)) &&
|
||||
actionSupported(info, action)) {
|
||||
matches << windowMatch(info, action, 0.7, Plasma::QueryMatch::PossibleMatch);
|
||||
matches << windowMatch(info, action, 0.7);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ void WindowsRunner::match(Plasma::RunnerContext& context)
|
|||
it.next();
|
||||
KWindowInfo info = it.value();
|
||||
if (info.isOnDesktop(desktop) && actionSupported(info, action)) {
|
||||
matches << windowMatch(info, action, 0.5, Plasma::QueryMatch::PossibleMatch);
|
||||
matches << windowMatch(info, action, 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ void WindowsRunner::match(Plasma::RunnerContext& context)
|
|||
}
|
||||
}
|
||||
|
||||
void WindowsRunner::run(const Plasma::RunnerContext& context, const Plasma::QueryMatch &match)
|
||||
void WindowsRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
|
||||
{
|
||||
Q_UNUSED(context)
|
||||
// check if it's a desktop
|
||||
|
@ -419,7 +419,6 @@ void WindowsRunner::run(const Plasma::RunnerContext& context, const Plasma::Quer
|
|||
Plasma::QueryMatch WindowsRunner::desktopMatch(int desktop, qreal relevance)
|
||||
{
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||
match.setData(desktop);
|
||||
match.setId("desktop-" + QString::number(desktop));
|
||||
match.setIcon(KIcon("user-desktop"));
|
||||
|
@ -435,10 +434,9 @@ Plasma::QueryMatch WindowsRunner::desktopMatch(int desktop, qreal relevance)
|
|||
return match;
|
||||
}
|
||||
|
||||
Plasma::QueryMatch WindowsRunner::windowMatch(const KWindowInfo& info, WindowAction action, qreal relevance, Plasma::QueryMatch::Type type)
|
||||
Plasma::QueryMatch WindowsRunner::windowMatch(const KWindowInfo& info, WindowAction action, qreal relevance)
|
||||
{
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setType(type);
|
||||
match.setData(QString::number((int)action) + QLatin1String("_") + QString::number(info.win()));
|
||||
match.setIcon(m_icons[info.win()]);
|
||||
match.setText(info.name());
|
||||
|
|
|
@ -49,8 +49,7 @@ private:
|
|||
KeepBelowAction
|
||||
};
|
||||
Plasma::QueryMatch desktopMatch(int desktop, qreal relevance = 1.0);
|
||||
Plasma::QueryMatch windowMatch(const KWindowInfo &info, WindowAction action, qreal relevance,
|
||||
Plasma::QueryMatch::Type type);
|
||||
Plasma::QueryMatch windowMatch(const KWindowInfo &info, WindowAction action, qreal relevance);
|
||||
bool actionSupported(const KWindowInfo& info, WindowAction action);
|
||||
|
||||
QHash<WId, KWindowInfo> m_windows;
|
||||
|
|
Loading…
Add table
Reference in a new issue