shell: Follow `ActivateWhenTypingOnDesktop` from KRunner

When the option is unchecked, typing on the desktop will not activate
KRunner.

FEATURE: 318538
FIXED-IN: 5.25
wilder-5.25
Fushan Wen 4 years ago
parent 078a1c9950
commit fa2241e24a
No known key found for this signature in database
GPG Key ID: 2E48D1487C91DCAA
  1. 1
      shell/CMakeLists.txt
  2. 16
      shell/desktopview.cpp
  3. 6
      shell/desktopview.h

@ -80,6 +80,7 @@ target_link_libraries(plasmashell
Qt::DBus
KF5::KIOCore
KF5::WindowSystem
KF5::ConfigCore # Activate KRunner on the desktop
KF5::Crash
KF5::Plasma
KF5::PlasmaQuick

@ -62,6 +62,18 @@ DesktopView::DesktopView(Plasma::Corona *corona, QScreen *targetScreen)
QObject::connect(m_activityController, &KActivities::Controller::activityAdded, this, &DesktopView::candidateContainmentsChanged);
QObject::connect(m_activityController, &KActivities::Controller::activityRemoved, this, &DesktopView::candidateContainmentsChanged);
// KRunner settings
KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("krunnerrc"));
KConfigGroup configGroup(config, "General");
m_activateKRunnerWhenTypingOnDesktop = configGroup.readEntry("ActivateWhenTypingOnDesktop", true);
m_configWatcher = KConfigWatcher::create(config);
connect(m_configWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &names) {
if (names.contains(QByteArray("ActivateWhenTypingOnDesktop"))) {
m_activateKRunnerWhenTypingOnDesktop = group.readEntry("ActivateWhenTypingOnDesktop", true);
}
});
}
DesktopView::~DesktopView()
@ -267,6 +279,10 @@ void DesktopView::keyPressEvent(QKeyEvent *e)
return;
}
if (!m_activateKRunnerWhenTypingOnDesktop) {
return;
}
// When a key is pressed on desktop when nothing else is active forward the key to krunner
if (handleKRunnerTextInput(e)) {
e->accept();

@ -10,6 +10,8 @@
#include <PlasmaQuick/ContainmentView>
#include <QPointer>
#include <KConfigWatcher>
namespace KWayland
{
namespace Client
@ -96,4 +98,8 @@ private:
WindowType m_windowType;
KWayland::Client::PlasmaShellSurface *m_shellSurface;
QString m_krunnerText;
// KRunner config
KConfigWatcher::Ptr m_configWatcher;
bool m_activateKRunnerWhenTypingOnDesktop;
};

Loading…
Cancel
Save