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 {
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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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

View File

@ -250,11 +250,14 @@ ColumnLayout {
color: Cpp_ThemeManager.colors["table_text"]
onTextEdited: {
const num = Number(text);
if (!isNaN(num)) {
root.modelPointer.setData(
view.index(row, column),
Number(text),
ProjectModel.EditableValue)
}
}
validator: IntValidator {
bottom: 1
@ -282,13 +285,25 @@ ColumnLayout {
color: Cpp_ThemeManager.colors["table_text"]
onTextEdited: {
// 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),
Number(text),
ProjectModel.EditableValue)
num,
ProjectModel.EditableValue
);
}
}
validator: DoubleValidator {
id: validator
bottom: -1000000
top: 1000000
}
background: Item {}