39 QString term = searchTerm;
40 WindowsRunnerAction action = ActivateAction;
41 if (QString keyword = i18nc(
"Note this is a KRunner keyword",
"activate"); term.endsWith(keyword, Qt::CaseInsensitive)) {
42 action = ActivateAction;
43 term = term.left(term.lastIndexOf(keyword) - 1);
44 }
else if (QString keyword = i18nc(
"Note this is a KRunner keyword",
"close"); term.endsWith(keyword, Qt::CaseInsensitive)) {
46 term = term.left(term.lastIndexOf(keyword) - 1);
47 }
else if (QString keyword = i18nc(
"Note this is a KRunner keyword",
"min"); term.endsWith(keyword, Qt::CaseInsensitive)) {
48 action = MinimizeAction;
49 term = term.left(term.lastIndexOf(keyword) - 1);
50 }
else if (QString keyword = i18nc(
"Note this is a KRunner keyword",
"minimize"); term.endsWith(keyword, Qt::CaseInsensitive)) {
51 action = MinimizeAction;
52 term = term.left(term.lastIndexOf(keyword) - 1);
53 }
else if (QString keyword = i18nc(
"Note this is a KRunner keyword",
"max"); term.endsWith(keyword, Qt::CaseInsensitive)) {
54 action = MaximizeAction;
55 term = term.left(term.lastIndexOf(keyword) - 1);
56 }
else if (term.endsWith(i18nc(
"Note this is a KRunner keyword",
"maximize"), Qt::CaseInsensitive)) {
57 action = MaximizeAction;
58 term = term.left(term.lastIndexOf(i18nc(
"Note this is a KRunner keyword",
"maximize")) - 1);
59 }
else if (QString keyword = i18nc(
"Note this is a KRunner keyword",
"fullscreen"); term.endsWith(keyword, Qt::CaseInsensitive)) {
60 action = FullscreenAction;
61 term = term.left(term.lastIndexOf(keyword) - 1);
62 }
else if (QString keyword = i18nc(
"Note this is a KRunner keyword",
"shade"); term.endsWith(keyword, Qt::CaseInsensitive)) {
64 term = term.left(term.lastIndexOf(keyword) - 1);
65 }
else if (QString keyword = i18nc(
"Note this is a KRunner keyword",
"keep above"); term.endsWith(keyword, Qt::CaseInsensitive)) {
66 action = KeepAboveAction;
67 term = term.left(term.lastIndexOf(keyword) - 1);
68 }
else if (QString keyword = i18nc(
"Note this is a KRunner keyword",
"keep below"); term.endsWith(keyword, Qt::CaseInsensitive)) {
69 action = KeepBelowAction;
70 term = term.left(term.lastIndexOf(keyword) - 1);
75 if (term.startsWith(i18nc(
"Note this is a KRunner keyword",
"window"), Qt::CaseInsensitive)) {
76 const QStringList keywords = term.split(QLatin1Char(
' '));
78 QString windowAppName;
81 for (
const QString &keyword : keywords) {
82 if (keyword.endsWith(QLatin1Char(
'='))) {
85 if (keyword.startsWith(i18nc(
"Note this is a KRunner keyword",
"name") + QLatin1Char(
'='), Qt::CaseInsensitive)) {
86 windowName = keyword.split(QLatin1Char(
'='))[1];
87 }
else if (keyword.startsWith(i18nc(
"Note this is a KRunner keyword",
"appname") + QLatin1Char(
'='), Qt::CaseInsensitive)) {
88 windowAppName = keyword.split(QLatin1Char(
'='))[1];
89 }
else if (keyword.startsWith(i18nc(
"Note this is a KRunner keyword",
"desktop") + QLatin1Char(
'='), Qt::CaseInsensitive)) {
90 desktopId = keyword.split(QLatin1Char(
'='))[1];
91 for (
const auto desktop : VirtualDesktopManager::self()->desktops()) {
92 if (desktop->name().contains(desktopId.toString(), Qt::CaseInsensitive) || desktop->x11DesktopNumber() == desktopId.toUInt()) {
93 targetDesktop = desktop;
98 if (windowName.isEmpty() && !keyword.contains(QLatin1Char(
'=')) && (!windowAppName.isEmpty() || targetDesktop)) {
105 if (window->isUnmanaged()) {
108 if (!window->isNormalWindow()) {
111 const QString appName = window->resourceClass();
112 const QString name = window->caption();
113 if (!windowName.isEmpty() && !name.startsWith(windowName, Qt::CaseInsensitive)) {
116 if (!windowAppName.isEmpty() && !appName.contains(windowAppName, Qt::CaseInsensitive)) {
120 if (targetDesktop && !window->desktops().contains(targetDesktop) && !window->isOnAllDesktops()) {
125 if (windowName.isEmpty() && windowAppName.isEmpty() && !targetDesktop) {
126 const QString &test = term.mid(keywords[0].length() + 1);
127 if (!name.contains(test, Qt::CaseInsensitive) && !appName.contains(test, Qt::CaseInsensitive)) {
132 if (actionSupported(window, action)) {
133 matches << windowsMatch(window, action);
137 if (!matches.isEmpty()) {
143 bool desktopAdded =
false;
145 if (term.startsWith(i18nc(
"Note this is a KRunner keyword",
"desktop"), Qt::CaseInsensitive)) {
146 const QStringList parts = term.split(QLatin1Char(
' '));
147 if (parts.size() == 1) {
149 for (
auto desktop : VirtualDesktopManager::self()->desktops()) {
150 matches << desktopMatch(desktop);
158 if (window->isUnmanaged()) {
161 if (!window->isNormalWindow()) {
164 const QString appName = window->resourceClass();
165 const QString name = window->caption();
166 if (name.startsWith(term, Qt::CaseInsensitive) || appName.startsWith(term, Qt::CaseInsensitive)) {
168 }
else if ((name.contains(term, Qt::CaseInsensitive) || appName.contains(term, Qt::CaseInsensitive)) && actionSupported(window, action)) {
173 for (
auto *desktop : VirtualDesktopManager::self()->desktops()) {
174 if (desktop->name().contains(term, Qt::CaseInsensitive)) {
175 if (!desktopAdded && desktop != VirtualDesktopManager::self()->currentDesktop()) {
176 matches << desktopMatch(desktop, ActivateDesktopAction, 0.8);
180 if (window->isUnmanaged()) {
183 if (!window->isNormalWindow()) {
186 if ((window->desktops().contains(desktop) || window->isOnAllDesktops()) && actionSupported(window, action)) {