mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-31 17:42:55 +08:00
Fix small issue with project editor float validator
This commit is contained in:
parent
d7a8fa97e8
commit
4a1555e3fa
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user