Insert character popup's characters are now contextually aware.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
7542d63121
commit
bc35b18da0
7 changed files with 62 additions and 10 deletions
|
@ -54,6 +54,7 @@ Item {
|
|||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
placeholderText: qsTr("Filter...")
|
||||
category: "all"
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
|
|
|
@ -103,14 +103,21 @@ Repeater {
|
|||
height: 30
|
||||
label: propertyLabel
|
||||
icon: `settings/custom/${propertyIcon}.svg`
|
||||
isDouble: propertyType == 'number'
|
||||
isDouble: propertyType == "number"
|
||||
defValue: obj[propertyName] == null ? '' : obj[propertyName].toString()
|
||||
category: {
|
||||
return {
|
||||
"Domain": "domain",
|
||||
"string": "all",
|
||||
"number": "all"
|
||||
}[propertyType]
|
||||
}
|
||||
onChanged: function(newValue) {
|
||||
try {
|
||||
var newValueParsed = {
|
||||
'Domain': () => MathLib.parseDomain(newValue),
|
||||
'string': () => newValue,
|
||||
'number': () => parseFloat(newValue)
|
||||
"Domain": () => MathLib.parseDomain(newValue),
|
||||
"string": () => newValue,
|
||||
"number": () => parseFloat(newValue)
|
||||
}[propertyType]()
|
||||
|
||||
// Ensuring old and new values are different to prevent useless adding to history.
|
||||
|
|
|
@ -107,6 +107,7 @@ Popup.BaseDialog {
|
|||
height: 30
|
||||
label: qsTr("Name")
|
||||
icon: "common/label.svg"
|
||||
category: "name"
|
||||
width: dlgProperties.width
|
||||
value: objEditor.obj.name
|
||||
onChanged: function(newValue) {
|
||||
|
|
|
@ -31,8 +31,19 @@ Popup {
|
|||
|
||||
signal selected(string character)
|
||||
|
||||
/*!
|
||||
\qmlproperty string InsertCharacter::category
|
||||
Type of special character to insert.
|
||||
Possible values:
|
||||
- expression
|
||||
- domain
|
||||
- name
|
||||
- all
|
||||
*/
|
||||
property string category: 'all'
|
||||
|
||||
width: 280
|
||||
height: insertGrid.insertChars.length/insertGrid.columns*(width/insertGrid.columns)
|
||||
height: Math.ceil(insertGrid.insertChars.length/insertGrid.columns)*(width/insertGrid.columns)+5
|
||||
modal: true
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
||||
|
||||
|
@ -41,18 +52,40 @@ Popup {
|
|||
width: parent.width
|
||||
columns: 7
|
||||
|
||||
property var insertChars: [
|
||||
"∞","π","ℝ","ℕ","ℤ","∪","∩",
|
||||
property var insertCharsExpression: [
|
||||
"∞","π","¹","²","³","⁴","⁵",
|
||||
"⁶","⁷","⁸","⁹","⁰"
|
||||
]
|
||||
|
||||
property var insertCharsDomain: [
|
||||
"∅","∪","∩","∖","ℝ","ℕ","ℤ",
|
||||
"⁺","⁻",...insertCharsExpression
|
||||
]
|
||||
|
||||
property var insertCharsName: [
|
||||
"α","β","γ","δ","ε","ζ","η",
|
||||
"π","θ","κ","λ","μ","ξ","ρ",
|
||||
"ς","σ","τ","φ","χ","ψ","ω",
|
||||
"Γ","Δ","Θ","Λ","Ξ","Π","Σ",
|
||||
"Φ","Ψ","Ω","ₐ","ₑ","ₒ","ₓ",
|
||||
"ₕ","ₖ","ₗ","ₘ","ₙ","ₚ","ₛ",
|
||||
"ₜ","¹","²","³","⁴","⁵","⁶",
|
||||
"⁷","⁸","⁹","⁰","₁","₂","₃",
|
||||
"₄","₅","₆","₇","₈","₉","₀"
|
||||
"ₜ","₁","₂","₃","₄","₅","₆",
|
||||
"₇","₈","₉","₀"
|
||||
]
|
||||
|
||||
property var insertCharsAll: [
|
||||
...insertCharsName, ...insertCharsDomain
|
||||
]
|
||||
|
||||
property var insertChars: {
|
||||
return {
|
||||
"expression": insertCharsExpression,
|
||||
"domain": insertCharsDomain,
|
||||
"name": insertCharsName,
|
||||
"all": insertCharsAll
|
||||
}[insertPopup.category]
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: parent.insertChars.length
|
||||
|
||||
|
|
|
@ -507,6 +507,8 @@ Item {
|
|||
x: Math.round((parent.width - width) / 2)
|
||||
y: Math.round((parent.height - height) / 2)
|
||||
|
||||
category: "expression"
|
||||
|
||||
onSelected: function(c) {
|
||||
editor.insert(editor.cursorPosition, c)
|
||||
insertPopup.close()
|
||||
|
|
|
@ -49,6 +49,12 @@ Item {
|
|||
If true, the input is being parsed an double before being emitting the \a changed signal.
|
||||
*/
|
||||
property bool isDouble: false
|
||||
/*!
|
||||
\qmlproperty bool TextSetting::category
|
||||
Type of special character to insert from the popup.
|
||||
\sa InsertCharacter::category
|
||||
*/
|
||||
property alias category: insertPopup.category
|
||||
/*!
|
||||
\qmlproperty double TextSetting::min
|
||||
Minimum value for numbers that can be entered into the input.
|
||||
|
|
|
@ -255,6 +255,7 @@ ScrollView {
|
|||
Setting.TextSetting {
|
||||
id: xAxisStep
|
||||
height: 30
|
||||
category: "expression"
|
||||
label: qsTr("X Axis Step")
|
||||
icon: "settings/xaxisstep.svg"
|
||||
width: settings.settingWidth
|
||||
|
@ -269,6 +270,7 @@ ScrollView {
|
|||
Setting.TextSetting {
|
||||
id: yAxisStep
|
||||
height: 30
|
||||
category: "expression"
|
||||
label: qsTr("Y Axis Step")
|
||||
icon: "settings/yaxisstep.svg"
|
||||
width: settings.settingWidth
|
||||
|
|
Loading…
Reference in a new issue