Fix small issue with project editor float validator

This commit is contained in:
Alex Spataru 2024-09-22 20:07:03 -05:00
parent d7a8fa97e8
commit 4a1555e3fa
8 changed files with 30 additions and 15 deletions

View File

@ -91,7 +91,7 @@ Window {
Label { Label {
text: root.title text: root.title
visible: root.titlebarHeight > 0 visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["titlebar_text"] color: Cpp_ThemeManager.colors["text"]
font: Cpp_Misc_CommonFonts.customUiFont(13, true) font: Cpp_Misc_CommonFonts.customUiFont(13, true)
anchors { anchors {

View File

@ -86,7 +86,7 @@ Window {
Label { Label {
text: root.title text: root.title
visible: root.titlebarHeight > 0 visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["titlebar_text"] color: Cpp_ThemeManager.colors["text"]
font: Cpp_Misc_CommonFonts.customUiFont(13, true) font: Cpp_Misc_CommonFonts.customUiFont(13, true)
anchors { anchors {

View File

@ -89,7 +89,7 @@ Window {
Label { Label {
text: root.title text: root.title
visible: root.titlebarHeight > 0 visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["titlebar_text"] color: Cpp_ThemeManager.colors["text"]
font: Cpp_Misc_CommonFonts.customUiFont(13, true) font: Cpp_Misc_CommonFonts.customUiFont(13, true)
anchors { anchors {

View File

@ -87,7 +87,7 @@ Window {
Label { Label {
text: root.title text: root.title
visible: root.titlebarHeight > 0 visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["titlebar_text"] color: Cpp_ThemeManager.colors["text"]
font: Cpp_Misc_CommonFonts.customUiFont(13, true) font: Cpp_Misc_CommonFonts.customUiFont(13, true)
anchors { anchors {

View File

@ -85,7 +85,7 @@ Window {
Label { Label {
text: root.title text: root.title
visible: root.titlebarHeight > 0 visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["titlebar_text"] color: Cpp_ThemeManager.colors["text"]
font: Cpp_Misc_CommonFonts.customUiFont(13, true) font: Cpp_Misc_CommonFonts.customUiFont(13, true)
anchors { anchors {

View File

@ -92,7 +92,7 @@ Window {
Label { Label {
text: root.title text: root.title
visible: root.titlebarHeight > 0 visible: root.titlebarHeight > 0
color: Cpp_ThemeManager.colors["titlebar_text"] color: Cpp_ThemeManager.colors["text"]
font: Cpp_Misc_CommonFonts.customUiFont(13, true) font: Cpp_Misc_CommonFonts.customUiFont(13, true)
anchors { anchors {

View File

@ -122,7 +122,7 @@ Widgets.Pane {
// //
Label { Label {
text: window.title text: window.title
color: Cpp_ThemeManager.colors["titlebar_text"] color: Cpp_ThemeManager.colors["text"]
font: Cpp_Misc_CommonFonts.customUiFont(13, true) font: Cpp_Misc_CommonFonts.customUiFont(13, true)
visible: Cpp_NativeWindow.titlebarHeight(window) > 0 visible: Cpp_NativeWindow.titlebarHeight(window) > 0

View File

@ -250,10 +250,13 @@ ColumnLayout {
color: Cpp_ThemeManager.colors["table_text"] color: Cpp_ThemeManager.colors["table_text"]
onTextEdited: { onTextEdited: {
root.modelPointer.setData( const num = Number(text);
view.index(row, column), if (!isNaN(num)) {
Number(text), root.modelPointer.setData(
ProjectModel.EditableValue) view.index(row, column),
Number(text),
ProjectModel.EditableValue)
}
} }
validator: IntValidator { validator: IntValidator {
@ -282,13 +285,25 @@ ColumnLayout {
color: Cpp_ThemeManager.colors["table_text"] color: Cpp_ThemeManager.colors["table_text"]
onTextEdited: { onTextEdited: {
root.modelPointer.setData( // Don't convert or set the data if it's an incomplete number
view.index(row, column), if (text === "-" || text === "." || text === "-.")
Number(text), return;
ProjectModel.EditableValue)
// 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 { validator: DoubleValidator {
id: validator
bottom: -1000000
top: 1000000
} }
background: Item {} background: Item {}