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 {
|
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 {
|
||||||
|
@ -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 {
|
||||||
|
@ -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 {
|
||||||
|
@ -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 {
|
||||||
|
@ -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 {
|
||||||
|
@ -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 {
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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 {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user