From 4a1555e3fa02dbf178f8257000df49cc2e978f62 Mon Sep 17 00:00:00 2001 From: Alex Spataru Date: Sun, 22 Sep 2024 20:07:03 -0500 Subject: [PATCH] Fix small issue with project editor float validator --- app/qml/Dialogs/About.qml | 2 +- app/qml/Dialogs/Acknowledgements.qml | 2 +- app/qml/Dialogs/CsvPlayer.qml | 2 +- app/qml/Dialogs/Donate.qml | 2 +- app/qml/Dialogs/ExternalConsole.qml | 2 +- app/qml/Dialogs/MQTTConfiguration.qml | 2 +- .../MainWindow/Dashboard/WidgetDelegate.qml | 2 +- app/qml/ProjectEditor/Views/TableDelegate.qml | 31 ++++++++++++++----- 8 files changed, 30 insertions(+), 15 deletions(-) diff --git a/app/qml/Dialogs/About.qml b/app/qml/Dialogs/About.qml index af31bc89..71cd1630 100644 --- a/app/qml/Dialogs/About.qml +++ b/app/qml/Dialogs/About.qml @@ -91,7 +91,7 @@ Window { Label { text: root.title visible: root.titlebarHeight > 0 - color: Cpp_ThemeManager.colors["titlebar_text"] + color: Cpp_ThemeManager.colors["text"] font: Cpp_Misc_CommonFonts.customUiFont(13, true) anchors { diff --git a/app/qml/Dialogs/Acknowledgements.qml b/app/qml/Dialogs/Acknowledgements.qml index 412ba5fa..71df3795 100644 --- a/app/qml/Dialogs/Acknowledgements.qml +++ b/app/qml/Dialogs/Acknowledgements.qml @@ -86,7 +86,7 @@ Window { Label { text: root.title visible: root.titlebarHeight > 0 - color: Cpp_ThemeManager.colors["titlebar_text"] + color: Cpp_ThemeManager.colors["text"] font: Cpp_Misc_CommonFonts.customUiFont(13, true) anchors { diff --git a/app/qml/Dialogs/CsvPlayer.qml b/app/qml/Dialogs/CsvPlayer.qml index 8d5d4f5a..db22116a 100644 --- a/app/qml/Dialogs/CsvPlayer.qml +++ b/app/qml/Dialogs/CsvPlayer.qml @@ -89,7 +89,7 @@ Window { Label { text: root.title visible: root.titlebarHeight > 0 - color: Cpp_ThemeManager.colors["titlebar_text"] + color: Cpp_ThemeManager.colors["text"] font: Cpp_Misc_CommonFonts.customUiFont(13, true) anchors { diff --git a/app/qml/Dialogs/Donate.qml b/app/qml/Dialogs/Donate.qml index 0b599bdd..a04b5a45 100644 --- a/app/qml/Dialogs/Donate.qml +++ b/app/qml/Dialogs/Donate.qml @@ -87,7 +87,7 @@ Window { Label { text: root.title visible: root.titlebarHeight > 0 - color: Cpp_ThemeManager.colors["titlebar_text"] + color: Cpp_ThemeManager.colors["text"] font: Cpp_Misc_CommonFonts.customUiFont(13, true) anchors { diff --git a/app/qml/Dialogs/ExternalConsole.qml b/app/qml/Dialogs/ExternalConsole.qml index a2b7c667..733d638b 100644 --- a/app/qml/Dialogs/ExternalConsole.qml +++ b/app/qml/Dialogs/ExternalConsole.qml @@ -85,7 +85,7 @@ Window { Label { text: root.title visible: root.titlebarHeight > 0 - color: Cpp_ThemeManager.colors["titlebar_text"] + color: Cpp_ThemeManager.colors["text"] font: Cpp_Misc_CommonFonts.customUiFont(13, true) anchors { diff --git a/app/qml/Dialogs/MQTTConfiguration.qml b/app/qml/Dialogs/MQTTConfiguration.qml index 23fdd9aa..505c363c 100644 --- a/app/qml/Dialogs/MQTTConfiguration.qml +++ b/app/qml/Dialogs/MQTTConfiguration.qml @@ -92,7 +92,7 @@ Window { Label { text: root.title visible: root.titlebarHeight > 0 - color: Cpp_ThemeManager.colors["titlebar_text"] + color: Cpp_ThemeManager.colors["text"] font: Cpp_Misc_CommonFonts.customUiFont(13, true) anchors { diff --git a/app/qml/MainWindow/Dashboard/WidgetDelegate.qml b/app/qml/MainWindow/Dashboard/WidgetDelegate.qml index 38b5f9b6..55177fda 100644 --- a/app/qml/MainWindow/Dashboard/WidgetDelegate.qml +++ b/app/qml/MainWindow/Dashboard/WidgetDelegate.qml @@ -122,7 +122,7 @@ Widgets.Pane { // Label { text: window.title - color: Cpp_ThemeManager.colors["titlebar_text"] + color: Cpp_ThemeManager.colors["text"] font: Cpp_Misc_CommonFonts.customUiFont(13, true) visible: Cpp_NativeWindow.titlebarHeight(window) > 0 diff --git a/app/qml/ProjectEditor/Views/TableDelegate.qml b/app/qml/ProjectEditor/Views/TableDelegate.qml index 0f05facb..1152be39 100644 --- a/app/qml/ProjectEditor/Views/TableDelegate.qml +++ b/app/qml/ProjectEditor/Views/TableDelegate.qml @@ -250,10 +250,13 @@ ColumnLayout { color: Cpp_ThemeManager.colors["table_text"] onTextEdited: { - root.modelPointer.setData( - view.index(row, column), - Number(text), - ProjectModel.EditableValue) + const num = Number(text); + if (!isNaN(num)) { + root.modelPointer.setData( + view.index(row, column), + Number(text), + ProjectModel.EditableValue) + } } validator: IntValidator { @@ -282,13 +285,25 @@ ColumnLayout { color: Cpp_ThemeManager.colors["table_text"] onTextEdited: { - root.modelPointer.setData( - view.index(row, column), - Number(text), - ProjectModel.EditableValue) + // Don't convert or set the data if it's an incomplete number + if (text === "-" || text === "." || text === "-.") + return; + + // Convert to number only if the input is valid + const num = Number(text); + if (!isNaN(num)) { + root.modelPointer.setData( + view.index(row, column), + num, + ProjectModel.EditableValue + ); + } } validator: DoubleValidator { + id: validator + bottom: -1000000 + top: 1000000 } background: Item {}