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 *) View::View(QWindow *)
: PlasmaQuick::Dialog(), : PlasmaQuick::Dialog(),
m_offset(.5), m_offset(.5),
m_floating(false) m_floating(false),
m_retainPriorSearch(false)
{ {
setClearBeforeRendering(true); setClearBeforeRendering(true);
setColor(QColor(Qt::transparent)); setColor(QColor(Qt::transparent));
@ -163,6 +164,11 @@ void View::loadConfig()
m_history = history; m_history = history;
emit historyChanged(); emit historyChanged();
} }
bool retainPriorSearch = m_config.readEntry("RetainPriorSearch", true);
if (retainPriorSearch != m_retainPriorSearch) {
m_retainPriorSearch = retainPriorSearch;
Q_EMIT retainPriorSearchChanged();
}
} }
bool View::event(QEvent *event) bool View::event(QEvent *event)
@ -432,3 +438,7 @@ void View::setVisible(bool visible)
PlasmaQuick::Dialog::setVisible(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(bool canConfigure READ canConfigure CONSTANT)
Q_PROPERTY(QStringList history READ history NOTIFY historyChanged) Q_PROPERTY(QStringList history READ history NOTIFY historyChanged)
Q_PROPERTY(bool retainPriorSearch READ retainPriorSearch NOTIFY retainPriorSearchChanged)
public: public:
explicit View(QWindow *parent = nullptr); explicit View(QWindow *parent = nullptr);
@ -65,8 +66,11 @@ public:
Q_INVOKABLE void addToHistory(const QString &item); Q_INVOKABLE void addToHistory(const QString &item);
Q_INVOKABLE void removeFromHistory(int index); Q_INVOKABLE void removeFromHistory(int index);
bool retainPriorSearch() const;
Q_SIGNALS: Q_SIGNALS:
void historyChanged(); void historyChanged();
void retainPriorSearchChanged();
protected: protected:
bool event(QEvent* event) override; bool event(QEvent* event) override;
@ -101,6 +105,7 @@ private:
bool m_floating : 1; bool m_floating : 1;
bool m_requestedVisible = false; bool m_requestedVisible = false;
QStringList m_history; QStringList m_history;
bool m_retainPriorSearch;
}; };

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

Loading…
Cancel
Save