From 756e4086b3089ce06cfa57b5bfc273528f824dd8 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Mon, 27 Jul 2026 09:14:13 +0200 Subject: [PATCH] gui: Ctrl+N new window shortcut + KF5 draft persistence - Expose GuiActivator as "activator" context property - Add Ctrl+N shortcut to open a new window (both KF5 and KF6) - Add per-session draft text persistence to main-kf5.qml (KF6 ChatPane.qml already had this from previous commit) --- gui/main-kf5.qml | 25 ++++++++++++++++++++++++- gui/main.cpp | 1 + gui/main.qml | 6 ++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/gui/main-kf5.qml b/gui/main-kf5.qml index 506aafe..d7aa7e9 100644 --- a/gui/main-kf5.qml +++ b/gui/main-kf5.qml @@ -708,6 +708,12 @@ ApplicationWindow { } } + // --- Window shortcuts --- + Shortcut { + sequence: "Ctrl+N" + onActivated: activator.NewWindow() + } + // --- Split pane shortcuts --- Shortcut { sequence: "Ctrl+\\" @@ -819,6 +825,10 @@ ApplicationWindow { property string paneCwd: "" property int chatOffset: 0 + // Per-session draft text storage + property var _drafts: ({}) + property string _prevSessionId: "" + Component.onCompleted: { // Create a dedicated ChatBlockModel for this pane paneModel = Qt.createQmlObject( @@ -844,7 +854,20 @@ ApplicationWindow { } } - onSessionIdChanged: refreshPaneChat() + onSessionIdChanged: { + // Save draft from previous session + if (_prevSessionId !== "") { + _drafts[_prevSessionId] = panePrompt.text + } + refreshPaneChat() + // Restore draft for new session (or empty) + if (sessionId !== "") { + panePrompt.text = _drafts[sessionId] || "" + } else { + panePrompt.text = "" + } + _prevSessionId = sessionId + } Connections { target: dbus diff --git a/gui/main.cpp b/gui/main.cpp index ed5daa8..2a45637 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -148,6 +148,7 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty("dbus", dbus); engine.rootContext()->setContextProperty("theme", theme); engine.rootContext()->setContextProperty("chatModel", chatModel); + engine.rootContext()->setContextProperty("activator", &activator); engine.rootContext()->setContextProperty("systemTrayAvailable", QSystemTrayIcon::isSystemTrayAvailable()); diff --git a/gui/main.qml b/gui/main.qml index 25be535..fac6395 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -529,6 +529,12 @@ ApplicationWindow { } } + // --- Window shortcuts --- + Shortcut { + sequence: "Ctrl+N" + onActivated: activator.NewWindow() + } + // --- Split pane shortcuts --- Shortcut { sequence: "Ctrl+\\"