Update lookandfeel/runcommand/RunCommand.qml
I noticed this discussion on Reddit. While I don't use the Breath theme, I figured I'd let you know.
https://www.reddit.com/r/kde/comments/me6l4o/this_week_in_kde_all_the_things/gse71wy/
KRunner’s history drop-down menu now always works even if you’re using a crusty old Plasma theme that’s a fork of an old version of Breeze and hasn’t been updated in ages and ages (Alexander Lohnau, Plasma 5.22)
It seems the breath
Global Theme (lookandfeel) is using an older version of runcommand/RunCommand.qml
. As is breath2
.
- If you remove the
runcommand
folder, it should fallback to Breeze's defaultRunCommand.qml
which will remain up to date. - If you want to keep
RunCommand.qml
, here's the latest released version (Plasma 5.21):
diff --git a/./RunCommand-breath.qml b/./RunCommand-5.21.qml
index 88b0eefe4..27170d9d8 100644
--- a/./RunCommand-breath.qml
+++ b/./RunCommand-5.21.qml
@@ -19,7 +19,8 @@ import QtQuick 2.6
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
-import org.kde.plasma.components 2.0 as PlasmaComponents
+import org.kde.plasma.components 2.0 as PlasmaComponents // For Highlight
+import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.milou 0.1 as Milou
@@ -28,6 +29,7 @@ ColumnLayout {
property string query
property string runner
property bool showHistory: false
+ property alias runnerManager: results.runnerManager
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true
@@ -38,22 +40,44 @@ ColumnLayout {
Connections {
target: runnerWindow
- onVisibleChanged: {
+ function onVisibleChanged() {
if (runnerWindow.visible) {
queryField.forceActiveFocus();
listView.currentIndex = -1
+ if (runnerManager.retainPriorSearch) {
+ // If we manually specified a query(D-Bus invocation) we don't want to retain the prior search
+ if (!query) {
+ queryField.text = runnerManager.priorSearch
+ queryField.select(root.query.length, 0)
+ }
+ }
} else {
- root.query = "";
+ if (runnerManager.retainPriorSearch) {
+ runnerManager.priorSearch = root.query
+ }
root.runner = ""
+ root.query = ""
root.showHistory = false
}
}
}
+ Connections {
+ target: root
+ function onShowHistoryChanged() {
+ if (showHistory) {
+ // we store 50 entries in the history but only show 20 in the UI so it doesn't get too huge
+ listView.model = runnerManager.history.slice(0, 20)
+ } else {
+ listView.model = []
+ }
+ }
+ }
+
RowLayout {
Layout.alignment: Qt.AlignTop
- PlasmaComponents.ToolButton {
- iconSource: "configure"
+ PlasmaComponents3.ToolButton {
+ icon.name: "configure"
onClicked: {
runnerWindow.visible = false
runnerWindow.displayConfiguration()
@@ -61,13 +85,17 @@ ColumnLayout {
Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Configure")
Accessible.description: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Configure Search Plugins")
visible: runnerWindow.canConfigure
+ PlasmaComponents3.ToolTip {
+ text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Configure KRunner...")
+ }
}
- PlasmaComponents.TextField {
+ PlasmaComponents3.TextField {
id: queryField
property bool allowCompletion: false
clearButtonShown: true
Layout.minimumWidth: units.gridUnit * 25
+ Layout.maximumWidth: units.gridUnit * 25
activeFocusOnPress: true
placeholderText: results.runnerName ? i18ndc("plasma_lookandfeel_org.kde.lookandfeel",
@@ -76,27 +104,32 @@ ColumnLayout {
: i18ndc("plasma_lookandfeel_org.kde.lookandfeel",
"Textfield placeholder text", "Search...")
- onTextChanged: {
- root.query = queryField.text
- if (allowCompletion && length > 0) {
- var history = runnerWindow.history
-
- // search the first item in the history rather than the shortest matching one
- // this way more recently used entries take precedence over older ones (Bug 358985)
- for (var i = 0, j = history.length; i < j; ++i) {
- var item = history[i]
+ PlasmaComponents3.BusyIndicator {
+ anchors {
+ right: parent.right
+ top: parent.top
+ bottom: parent.bottom
+ margins: units.smallSpacing
+ rightMargin: height
+ }
- if (item.toLowerCase().indexOf(text.toLowerCase()) === 0) {
- var oldText = text
- text = text + item.substr(oldText.length)
- select(text.length, oldText.length)
- break
- }
+ Timer {
+ id: queryTimer
+ property bool queryDisplay: false
+ running: results.querying
+ repeat: true
+ onRunningChanged: if (queryDisplay && !running) {
+ queryDisplay = false
}
+ onTriggered: if (!queryDisplay) {
+ queryDisplay = true
+ }
+ interval: 500
}
+
+ running: queryTimer.queryDisplay
}
- Keys.onPressed: allowCompletion = (event.key !== Qt.Key_Backspace && event.key !== Qt.Key_Delete)
- Keys.onUpPressed: {
+ function move_up() {
if (length === 0) {
root.showHistory = true;
listView.forceActiveFocus();
@@ -105,7 +138,8 @@ ColumnLayout {
results.decrementCurrentIndex();
}
}
- Keys.onDownPressed: {
+
+ function move_down() {
if (length === 0) {
root.showHistory = true;
listView.forceActiveFocus();
@@ -114,8 +148,43 @@ ColumnLayout {
results.incrementCurrentIndex();
}
}
- Keys.onEnterPressed: results.runCurrentIndex(event)
- Keys.onReturnPressed: results.runCurrentIndex(event)
+
+ onTextChanged: {
+ root.query = queryField.text
+ if (allowCompletion && length > 0 && runnerManager.historyEnabled) {
+ var oldText = text
+ var suggestedText = runnerManager.getHistorySuggestion(text);
+ if (suggestedText.length > 0) {
+ text = text + suggestedText.substr(oldText.length)
+ select(text.length, oldText.length)
+ }
+ }
+ }
+ Keys.onPressed: {
+ allowCompletion = (event.key !== Qt.Key_Backspace && event.key !== Qt.Key_Delete)
+
+ if (event.modifiers & Qt.ControlModifier) {
+ if (event.key === Qt.Key_J) {
+ move_down()
+ event.accepted = true;
+ } else if (event.key === Qt.Key_K) {
+ move_up()
+ event.accepted = true;
+ }
+ }
+ }
+ Keys.onUpPressed: move_up()
+ Keys.onDownPressed: move_down()
+ function closeOrRun(event) {
+ // Close KRunner if no text was typed and enter was pressed, FEATURE: 211225
+ if (!root.query) {
+ runnerWindow.visible = false
+ } else {
+ results.runCurrentIndex(event)
+ }
+ }
+ Keys.onEnterPressed: closeOrRun(event)
+ Keys.onReturnPressed: closeOrRun(event)
Keys.onEscapePressed: {
runnerWindow.visible = false
@@ -135,7 +204,7 @@ ColumnLayout {
colorGroup: PlasmaCore.Theme.ButtonColorGroup
}
elementId: "down-arrow"
- visible: queryField.length === 0
+ visible: queryField.length === 0 && runnerManager.historyEnabled
MouseArea {
anchors.fill: parent
@@ -150,11 +219,16 @@ ColumnLayout {
}
}
}
- PlasmaComponents.ToolButton {
- iconSource: "window-close"
- onClicked: runnerWindow.visible = false
- Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Close")
- Accessible.description: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Close Search")
+ PlasmaComponents3.ToolButton {
+ checkable: true
+ checked: runnerWindow.pinned
+ onToggled: runnerWindow.pinned = checked
+ icon.name: "window-pin"
+ Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Pin")
+ Accessible.description: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Pin Search")
+ PlasmaComponents3.ToolTip {
+ text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Keep Open")
+ }
}
}
@@ -171,14 +245,21 @@ ColumnLayout {
runner: root.runner
Keys.onPressed: {
- if (event.text != "") {
- queryField.text += event.text;
+ var ctrl = event.modifiers & Qt.ControlModifier;
+ if (ctrl && event.key === Qt.Key_J) {
+ incrementCurrentIndex()
+ } else if (ctrl && event.key === Qt.Key_K) {
+ decrementCurrentIndex()
+ } else if (event.text !== "") {
+ // This prevents unprintable control characters from being inserted
+ if (!/[\x00-\x1F\x7F]/.test(event.text)) {
+ queryField.text += event.text;
+ }
queryField.focus = true;
}
}
onActivated: {
- runnerWindow.addToHistory(queryString)
runnerWindow.visible = false
}
@@ -203,8 +284,7 @@ ColumnLayout {
highlight: PlasmaComponents.Highlight {}
highlightMoveDuration: 0
activeFocusOnTab: true
- // we store 50 entries in the history but only show 20 in the UI so it doesn't get too huge
- model: root.showHistory ? runnerWindow.history.slice(0, 20) : []
+ model: []
delegate: Milou.ResultDelegate {
id: resultDelegate
width: listView.width
@@ -221,8 +301,8 @@ ColumnLayout {
currentIndex = 0;
}
}
- Keys.onReturnPressed: runCurrentIndex()
- Keys.onEnterPressed: runCurrentIndex()
+ Keys.onReturnPressed: runCurrentIndex(event)
+ Keys.onEnterPressed: runCurrentIndex(event)
Keys.onTabPressed: {
if (currentIndex == listView.count-1) {
@@ -239,8 +319,18 @@ ColumnLayout {
}
}
Keys.onPressed: {
- if (event.text != "") {
- queryField.text += event.text;
+ var ctrl = event.modifiers & Qt.ControlModifier;
+ if (ctrl && event.key === Qt.Key_J) {
+ incrementCurrentIndex()
+ } else if (ctrl && event.key === Qt.Key_K) {
+ decrementCurrentIndex()
+ } else if (event.text !== "") {
+ // This prevents unprintable control characters from being inserted
+ if (event.key == Qt.Key_Escape) {
+ root.showHistory = false
+ } else if (!/[\x00-\x1F\x7F]/.test(event.text)) {
+ queryField.text += event.text;
+ }
queryField.focus = true;
}
}
@@ -248,9 +338,16 @@ ColumnLayout {
Keys.onUpPressed: decrementCurrentIndex()
Keys.onDownPressed: incrementCurrentIndex()
- function runCurrentIndex() {
- var entry = runnerWindow.history[currentIndex]
+ function runCurrentIndex(event) {
+ var entry = runnerManager.history[currentIndex]
if (entry) {
+ // If user presses Shift+Return to invoke an action, invoke the first runner action
+ if (event && event.modifiers === Qt.ShiftModifier
+ && currentItem.additionalActions && currentItem.additionalActions.length > 0) {
+ runAction(0);
+ return
+ }
+
queryField.text = entry
queryField.forceActiveFocus();
}
@@ -260,7 +357,8 @@ ColumnLayout {
if (actionIndex === 0) {
// QStringList changes just reset the model, so we'll remember the index and set it again
var currentIndex = listView.currentIndex
- runnerWindow.removeFromHistory(currentIndex)
+ runnerManager.removeFromHistory(currentIndex)
+ model = runnerManager.history
listView.currentIndex = currentIndex
}
}
Also note that there has been a few changes in git master that will land in Plasma 5.22.
diff --git a/./RunCommand-5.21.qml b/./RunCommand-master.qml
index 27170d9d8..c4b1c6c6e 100644
--- a/./RunCommand-5.21.qml
+++ b/./RunCommand-master.qml
@@ -94,8 +94,8 @@ ColumnLayout {
property bool allowCompletion: false
clearButtonShown: true
- Layout.minimumWidth: units.gridUnit * 25
- Layout.maximumWidth: units.gridUnit * 25
+ Layout.minimumWidth: PlasmaCore.Units.gridUnit * 25
+ Layout.maximumWidth: PlasmaCore.Units.gridUnit * 25
activeFocusOnPress: true
placeholderText: results.runnerName ? i18ndc("plasma_lookandfeel_org.kde.lookandfeel",
@@ -109,7 +109,7 @@ ColumnLayout {
right: parent.right
top: parent.top
bottom: parent.bottom
- margins: units.smallSpacing
+ margins: PlasmaCore.Units.smallSpacing
rightMargin: height
}
@@ -132,7 +132,9 @@ ColumnLayout {
function move_up() {
if (length === 0) {
root.showHistory = true;
- listView.forceActiveFocus();
+ if (listView.count > 0) {
+ listView.forceActiveFocus();
+ }
} else if (results.count > 0) {
results.forceActiveFocus();
results.decrementCurrentIndex();
@@ -142,7 +144,9 @@ ColumnLayout {
function move_down() {
if (length === 0) {
root.showHistory = true;
- listView.forceActiveFocus();
+ if (listView.count > 0) {
+ listView.forceActiveFocus();
+ }
} else if (results.count > 0) {
results.forceActiveFocus();
results.incrementCurrentIndex();
@@ -197,7 +201,7 @@ ColumnLayout {
verticalCenter: parent.verticalCenter
}
// match clear button
- width: Math.max(parent.height * 0.8, units.iconSizes.small)
+ width: Math.max(parent.height * 0.8, PlasmaCore.Units.iconSizes.small)
height: width
svg: PlasmaCore.Svg {
imagePath: "widgets/arrows"