Commit 0004a1f8 authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Implement Pin feature for KRunner

BUG: 353026
FIXED-IN: 5.21

For this the close button has been replaced with a checkable button which pins the window. Just like in the system tray.
parent 7e2c1e68
......@@ -129,7 +129,7 @@ void View::objectIncubated()
void View::slotFocusWindowChanged()
{
if (!QGuiApplication::focusWindow()) {
if (!QGuiApplication::focusWindow() && !m_pinned) {
setVisible(false);
}
}
......@@ -455,3 +455,18 @@ void View::setVisible(bool visible)
bool View::retainPriorSearch() const {
return m_retainPriorSearch;
}
bool View::pinned() const
{
return m_pinned;
}
void View::setPinned(bool pinned)
{
if (m_pinned != pinned) {
m_pinned = pinned;
m_config.writeEntry("Pinned", pinned);
Q_EMIT pinnedChanged();
}
}
......@@ -50,6 +50,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)
Q_PROPERTY(bool pinned READ pinned WRITE setPinned NOTIFY pinnedChanged)
public:
explicit View(QWindow *parent = nullptr);
......@@ -68,9 +69,13 @@ public:
bool retainPriorSearch() const;
bool pinned() const;
void setPinned(bool pinned);
Q_SIGNALS:
void historyChanged();
void retainPriorSearchChanged();
void pinnedChanged();
protected:
bool event(QEvent* event) override;
......@@ -107,6 +112,7 @@ private:
QStringList m_history;
bool m_retainPriorSearch;
bool m_historyEnabled;
bool m_pinned = false;
};
......
......@@ -207,14 +207,14 @@ ColumnLayout {
}
}
PlasmaComponents3.ToolButton {
icon.name: "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")
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", "Close")
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Keep Open")
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment