Add option to retain prior search

FEATURE: 397092
FIXED-IN: 5.20
wilder-portage-prov
Alexander Lohnau 6 years ago
parent 32e5ee16c0
commit ddd005b1f5
  1. 12
      krunner/view.cpp
  2. 5
      krunner/view.h
  3. 16
      lookandfeel/contents/runcommand/RunCommand.qml

@ -51,7 +51,8 @@
View::View(QWindow *)
: PlasmaQuick::Dialog(),
m_offset(.5),
m_floating(false)
m_floating(false),
m_retainPriorSearch(false)
{
setClearBeforeRendering(true);
setColor(QColor(Qt::transparent));
@ -163,6 +164,11 @@ void View::loadConfig()
m_history = history;
emit historyChanged();
}
bool retainPriorSearch = m_config.readEntry("RetainPriorSearch", true);
if (retainPriorSearch != m_retainPriorSearch) {
m_retainPriorSearch = retainPriorSearch;
Q_EMIT retainPriorSearchChanged();
}
}
bool View::event(QEvent *event)
@ -432,3 +438,7 @@ void View::setVisible(bool visible)
PlasmaQuick::Dialog::setVisible(visible);
}
}
bool View::retainPriorSearch() const {
return m_retainPriorSearch;
}

@ -49,6 +49,7 @@ class View : public PlasmaQuick::Dialog
Q_PROPERTY(bool canConfigure READ canConfigure CONSTANT)
Q_PROPERTY(QStringList history READ history NOTIFY historyChanged)
Q_PROPERTY(bool retainPriorSearch READ retainPriorSearch NOTIFY retainPriorSearchChanged)
public:
explicit View(QWindow *parent = nullptr);
@ -65,8 +66,11 @@ public:
Q_INVOKABLE void addToHistory(const QString &item);
Q_INVOKABLE void removeFromHistory(int index);
bool retainPriorSearch() const;
Q_SIGNALS:
void historyChanged();
void retainPriorSearchChanged();
protected:
bool event(QEvent* event) override;
@ -101,6 +105,7 @@ private:
bool m_floating : 1;
bool m_requestedVisible = false;
QStringList m_history;
bool m_retainPriorSearch;
};

@ -29,6 +29,7 @@ ColumnLayout {
property string query
property string runner
property bool showHistory: false
property string priorSearch
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true
@ -44,8 +45,13 @@ ColumnLayout {
queryField.forceActiveFocus();
listView.currentIndex = -1
} else {
root.query = "";
root.runner = ""
if (runnerWindow.retainPriorSearch) {
root.query = priorSearch
queryField.select(priorSearch.length, 0)
} else {
root.query = ""
}
root.showHistory = false
}
}
@ -56,6 +62,7 @@ ColumnLayout {
PlasmaComponents3.ToolButton {
icon.name: "configure"
onClicked: {
priorSearch = query
runnerWindow.visible = false
runnerWindow.displayConfiguration()
}
@ -165,6 +172,7 @@ ColumnLayout {
Keys.onReturnPressed: results.runCurrentIndex(event)
Keys.onEscapePressed: {
priorSearch = query
runnerWindow.visible = false
}
@ -199,7 +207,10 @@ ColumnLayout {
}
PlasmaComponents3.ToolButton {
icon.name: "window-close"
onClicked: runnerWindow.visible = false
onClicked: {
priorSearch = query
runnerWindow.visible = false
}
Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Close")
Accessible.description: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Close Search")
PlasmaComponents3.ToolTip {
@ -237,6 +248,7 @@ ColumnLayout {
onActivated: {
runnerWindow.addToHistory(queryString)
priorSearch = query
runnerWindow.visible = false
}

Loading…
Cancel
Save