[games/chessament] src: Add hack around onEditingFinished not being emitted

Manuel Alcaraz Zambrano <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 8c109fa834f236c3424065d81f23c1b4423f0e6f by Manuel Alcaraz Zambrano.
Committed on 16/08/2026 at 14:21.
Pushed by manuelal into branch 'master'.

Add hack around onEditingFinished not being emitted

M  +3    -3    src/qml/components/ArbiterDelegate.qml
M  +2    -0    src/tournament/CMakeLists.txt
A  +20   -0    src/tournament/qml/FieldSaverHack.qml     [License: GPL(v3.0+)]
M  +2    -0    src/tournament/qml/SettingsInformationPage.qml

https://invent.kde.org/games/chessament/-/commit/8c109fa834f236c3424065d81f23c1b4423f0e6f

diff --git a/src/qml/components/ArbiterDelegate.qml b/src/qml/components/ArbiterDelegate.qml
index 748f693..66d3b79 100644
--- a/src/qml/components/ArbiterDelegate.qml
+++ b/src/qml/components/ArbiterDelegate.qml
@@ -51,21 +51,21 @@ FormCard.AbstractFormDelegate {
             Layout.preferredWidth: Kirigami.Units.gridUnit * 3
             text: delegate.title
             placeholderText: KI18n.i18nc("@info:placeholder Arbiter's Title", "Title")
-            onTextEdited: delegate.title = text
+            onEditingFinished: delegate.title = text
         }
 
         Controls.TextField {
             Layout.fillWidth: true
             text: delegate.name
             placeholderText: KI18n.i18nc("@info:placeholder Arbiter's Name", "Name")
-            onTextEdited: delegate.name = text
+            onEditingFinished: delegate.name = text
         }
 
         Controls.TextField {
             Layout.preferredWidth: Kirigami.Units.gridUnit * 5
             text: delegate.arbiterId
             placeholderText: KI18n.i18nc("@info:placeholder Arbiter's ID", "ID")
-            onTextEdited: delegate.arbiterId = text
+            onEditingFinished: delegate.arbiterId = text
         }
 
         Controls.Button {
diff --git a/src/tournament/CMakeLists.txt b/src/tournament/CMakeLists.txt
index 774743c..04d4d7d 100644
--- a/src/tournament/CMakeLists.txt
+++ b/src/tournament/CMakeLists.txt
@@ -30,6 +30,8 @@ ecm_add_qml_module(tournament
     OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/chessament/tournament
     GENERATE_PLUGIN_SOURCE
     QML_FILES
+        qml/FieldSaverHack.qml
+
         qml/SettingsDialog.qml
         qml/SettingsCalendarPage.qml
         qml/SettingsCloudPage.qml
diff --git a/src/tournament/qml/FieldSaverHack.qml b/src/tournament/qml/FieldSaverHack.qml
new file mode 100644
index 0000000..13a5388
--- /dev/null
+++ b/src/tournament/qml/FieldSaverHack.qml
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Manuel Alcaraz Zambrano <[email protected]>
+
+import QtQuick
+import QtQuick.Controls as Controls
+
+// This is a dummy item to be used in ConfigurationView pages so that when it
+// closes the onEditingFinished signal gets emited by the focused text field.
+// Otherwise we'll may lose the data of the focused text field.
+Item {
+    id: root
+
+    Connections {
+        target: root.Controls.ApplicationWindow.window
+
+        function onClosing(event): void {
+            root.forceActiveFocus();
+        }
+    }
+}
diff --git a/src/tournament/qml/SettingsInformationPage.qml b/src/tournament/qml/SettingsInformationPage.qml
index a48c248..6d89e5f 100644
--- a/src/tournament/qml/SettingsInformationPage.qml
+++ b/src/tournament/qml/SettingsInformationPage.qml
@@ -79,4 +79,6 @@ FormCard.FormCardPage {
             }
         }
     }
+
+    FieldSaverHack {}
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.