krunner: Load RunCommand.qml file from qrc rather than lookandfeel package

This way we do not load old or broken third party RunCommand.qml files in KRunner.
This also allows us to get rid of compatibility logic for old versions of this file.

BUG: 457174
wilder-5.26
Alexander Lohnau 4 years ago
parent d75ea4c06a
commit e31ba756dd
  1. 1
      krunner/CMakeLists.txt
  2. 2
      krunner/Messages.sh
  3. 28
      krunner/qml/RunCommand.qml
  4. 10
      krunner/qml/krunner.qrc
  5. 25
      krunner/view.cpp
  6. 17
      krunner/view.h

@ -1,6 +1,7 @@
set(krunner_SRCS set(krunner_SRCS
main.cpp main.cpp
view.cpp view.cpp
qml/krunner.qrc
) )
set(krunner_dbusAppXML dbus/org.kde.krunner.App.xml) set(krunner_dbusAppXML dbus/org.kde.krunner.App.xml)

@ -1,2 +1,2 @@
#! /usr/bin/env bash #! /usr/bin/env bash
$XGETTEXT *.cpp -o $podir/krunner.pot $XGETTEXT *.cpp qml/*.qml -o $podir/krunner.pot

@ -72,11 +72,11 @@ ColumnLayout {
runnerWindow.visible = false runnerWindow.visible = false
runnerWindow.displayConfiguration() runnerWindow.displayConfiguration()
} }
Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Configure") Accessible.name: i18n("Configure")
Accessible.description: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Configure KRunner Behavior") Accessible.description: i18n("Configure KRunner Behavior")
visible: KCMShell.authorize("kcm_krunnersettings.desktop").length > 0 visible: KCMShell.authorize("kcm_krunnersettings.desktop").length > 0
PlasmaComponents3.ToolTip { PlasmaComponents3.ToolTip {
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Configure KRunner…") text: i18n("Configure KRunner…")
} }
} }
PlasmaExtras.SearchField { PlasmaExtras.SearchField {
@ -87,11 +87,9 @@ ColumnLayout {
Layout.maximumWidth: PlasmaCore.Units.gridUnit * 25 Layout.maximumWidth: PlasmaCore.Units.gridUnit * 25
activeFocusOnPress: true activeFocusOnPress: true
placeholderText: results.runnerName ? i18ndc("plasma_lookandfeel_org.kde.lookandfeel", placeholderText: results.runnerName ? i18nc("Textfield placeholder text, query specific KRunner",
"Textfield placeholder text, query specific KRunner",
"Search '%1'…", results.runnerName) "Search '%1'…", results.runnerName)
: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", : i18nc("Textfield placeholder text", "Search…")
"Textfield placeholder text", "Search…")
PlasmaComponents3.BusyIndicator { PlasmaComponents3.BusyIndicator {
anchors { anchors {
@ -227,10 +225,10 @@ ColumnLayout {
// Reset if out quers starts with "?", otherwise set it to "?" // Reset if out quers starts with "?", otherwise set it to "?"
onClicked: root.query = root.query.startsWith("?") ? "" : "?" onClicked: root.query = root.query.startsWith("?") ? "" : "?"
icon.name: "question" icon.name: "question"
Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Show Usage Help") Accessible.name: i18n("Show Usage Help")
Accessible.description: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Show Usage Help") Accessible.description: i18n("Show Usage Help")
PlasmaComponents3.ToolTip { PlasmaComponents3.ToolTip {
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Show Usage Help") text: i18n("Show Usage Help")
} }
} }
PlasmaComponents3.ToolButton { PlasmaComponents3.ToolButton {
@ -238,10 +236,10 @@ ColumnLayout {
checked: runnerWindow.pinned checked: runnerWindow.pinned
onToggled: runnerWindow.pinned = checked onToggled: runnerWindow.pinned = checked
icon.name: "window-pin" icon.name: "window-pin"
Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Pin") Accessible.name: i18n("Pin")
Accessible.description: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Pin Search") Accessible.description: i18n("Pin Search")
PlasmaComponents3.ToolTip { PlasmaComponents3.ToolTip {
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Keep Open") text: i18n("Keep Open")
} }
} }
} }
@ -319,10 +317,10 @@ ColumnLayout {
delegate: Milou.ResultDelegate { delegate: Milou.ResultDelegate {
id: resultDelegate id: resultDelegate
width: listView.width width: listView.width
typeText: index === 0 ? i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Recent Queries") : "" typeText: index === 0 ? i18n("Recent Queries") : ""
additionalActions: [{ additionalActions: [{
icon: "list-remove", icon: "list-remove",
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Remove") text: i18n("Remove")
}] }]
Accessible.description: i18n("in category recent queries") Accessible.description: i18n("in category recent queries")
} }

@ -0,0 +1,10 @@
<!DOCTYPE RCC>
<!--
SPDX-FileCopyrightText: 2022 Alexander Lohnau <alexander.lohnau@gmx.de>
SPDX-License-Identifier: CC0-1.0
-->
<RCC version="1.0">
<qresource prefix="/krunner/">
<file>RunCommand.qml</file>
</qresource>
</RCC>

@ -26,9 +26,6 @@
#include <kdeclarative/qmlobject.h> #include <kdeclarative/qmlobject.h>
#include <KPackage/Package>
#include <KPackage/PackageLoader>
#include <KWayland/Client/connection_thread.h> #include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/registry.h> #include <KWayland/Client/registry.h>
#include <KWayland/Client/surface.h> #include <KWayland/Client/surface.h>
@ -72,15 +69,8 @@ View::View(QWindow *)
m_qmlObj->setInitializationDelayed(true); m_qmlObj->setInitializationDelayed(true);
connect(m_qmlObj, &KDeclarative::QmlObject::finished, this, &View::objectIncubated); connect(m_qmlObj, &KDeclarative::QmlObject::finished, this, &View::objectIncubated);
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel"));
KConfigGroup cg(KSharedConfig::openConfig(), "KDE");
const QString packageName = cg.readEntry("LookAndFeelPackage", QString());
if (!packageName.isEmpty()) {
package.setPath(packageName);
}
m_qmlObj->engine()->rootContext()->setContextProperty(QStringLiteral("runnerWindow"), this); m_qmlObj->engine()->rootContext()->setContextProperty(QStringLiteral("runnerWindow"), this);
m_qmlObj->setSource(package.fileUrl("runcommandmainscript")); m_qmlObj->setSource(QUrl(QStringLiteral("qrc:/krunner/RunCommand.qml")));
m_qmlObj->completeInitialization(); m_qmlObj->completeInitialization();
auto screenRemoved = [this](QScreen *screen) { auto screenRemoved = [this](QScreen *screen) {
@ -363,16 +353,3 @@ void View::setPinned(bool pinned)
Q_EMIT pinnedChanged(); Q_EMIT pinnedChanged();
} }
} }
void View::removeFromHistory(int index)
{
if (m_manager) {
m_manager->removeFromHistory(index);
Q_EMIT historyChanged();
}
}
QStringList View::history() const
{
return m_manager ? m_manager->history() : QStringList();
}

@ -40,9 +40,6 @@ class View : public PlasmaQuick::Dialog
Q_CLASSINFO("D-Bus Interface", "org.kde.krunner.App") Q_CLASSINFO("D-Bus Interface", "org.kde.krunner.App")
Q_PROPERTY(bool pinned READ pinned WRITE setPinned NOTIFY pinnedChanged) Q_PROPERTY(bool pinned READ pinned WRITE setPinned NOTIFY pinnedChanged)
Q_PROPERTY(QStringList history READ history NOTIFY historyChanged)
// TODO KF6 This is kept for compatibility with third party themes which override the RunCommand.qml file
Q_PROPERTY(Plasma::RunnerManager *runnerManager WRITE setRunnerManager)
Q_PROPERTY(bool helpEnabled READ helpEnabled NOTIFY helpEnabledChanged) Q_PROPERTY(bool helpEnabled READ helpEnabled NOTIFY helpEnabledChanged)
public: public:
@ -54,23 +51,9 @@ public:
bool freeFloating() const; bool freeFloating() const;
void setFreeFloating(bool floating); void setFreeFloating(bool floating);
QStringList history() const;
bool pinned() const; bool pinned() const;
void setPinned(bool pinned); void setPinned(bool pinned);
// TODO KF6 This is kept for compatibility with third party themes which override the RunCommand.qml file
Q_SIGNAL void historyChanged();
Q_INVOKABLE void addToHistory(const QString &)
{
// Kept for compatibility, since milou f442b33af3c292c49743083493423275a51c118a the KRunner framework logic is used for handling this
}
Q_INVOKABLE void removeFromHistory(int index);
void setRunnerManager(Plasma::RunnerManager *manager)
{
m_manager = manager;
}
bool helpEnabled() bool helpEnabled()
{ {
const static auto metaData = KPluginMetaData(QStringLiteral("kf5/krunner/helprunner")); const static auto metaData = KPluginMetaData(QStringLiteral("kf5/krunner/helprunner"));

Loading…
Cancel
Save