Commit 003e30a6 authored by Piotr Henryk Dabrowski's avatar Piotr Henryk Dabrowski Committed by Nate Graham
Browse files

aggregate text for KRunner in DesktopView

Aggregate text for KRunner in DesktopView to prevent eating fast-typed characters.

CCBUG: 416145
partial solution: resolved for DesktopView, not resolved for running KRunner from shortcut

Test Plan:
When DesktopView is focused, typed characters show KRunner query.
All fast-typed characters should now appear correctly in KRunner window,
instead of only first typed character.
parent 8801aae8
......@@ -236,11 +236,43 @@ bool DesktopView::event(QEvent *e)
m_shellSurface = nullptr;
break;
}
} else if (e->type() == QEvent::FocusOut) {
m_krunnerText.clear();
}
return PlasmaQuick::ContainmentView::event(e);
}
bool DesktopView::handleKRunnerTextInput(QKeyEvent *e)
{
// allow only Shift and GroupSwitch modifiers
if (e->modifiers() & ~Qt::ShiftModifier & ~Qt::GroupSwitchModifier) {
return false;
}
bool krunnerTextChanged = false;
const QString eventText = e->text();
for (const QChar ch : eventText) {
if (!ch.isPrint()) {
continue;
}
if (ch.isSpace() && m_krunnerText.isEmpty()) {
continue;
}
m_krunnerText += ch;
krunnerTextChanged = true;
}
if (krunnerTextChanged) {
const QString interface(QStringLiteral("org.kde.krunner"));
if (!KAuthorized::authorize(QStringLiteral("run_command"))) {
return false;
}
org::kde::krunner::App krunner(interface, QStringLiteral("/App"), QDBusConnection::sessionBus());
krunner.query(m_krunnerText);
return true;
}
return false;
}
void DesktopView::keyPressEvent(QKeyEvent *e)
{
ContainmentView::keyPressEvent(e);
......@@ -256,18 +288,9 @@ void DesktopView::keyPressEvent(QKeyEvent *e)
}
// When a key is pressed on desktop when nothing else is active forward the key to krunner
if (!e->modifiers() || e->modifiers() == Qt::ShiftModifier) {
const QString text = e->text().trimmed();
if (!text.isEmpty() && text[0].isPrint()) {
const QString interface(QStringLiteral("org.kde.krunner"));
if (!KAuthorized::authorize(QStringLiteral("run_command"))) {
return;
}
org::kde::krunner::App krunner(interface, QStringLiteral("/App"), QDBusConnection::sessionBus());
krunner.query(text);
e->accept();
return;
}
if (handleKRunnerTextInput(e)) {
e->accept();
return;
}
}
......
......@@ -102,12 +102,14 @@ private:
void coronaPackageChanged(const KPackage::Package &package);
void ensureWindowType();
void setupWaylandIntegration();
bool handleKRunnerTextInput(QKeyEvent *e);
QPointer<PlasmaQuick::ConfigView> m_configView;
QPointer<QScreen> m_oldScreen;
QPointer<QScreen> m_screenToFollow;
WindowType m_windowType;
KWayland::Client::PlasmaShellSurface *m_shellSurface;
QString m_krunnerText;
};
#endif // DESKTOPVIEW_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment