From bc35b18da06464a924f75b101621c0686be7d962 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Mon, 9 Oct 2023 17:55:06 +0200 Subject: [PATCH] Insert character popup's characters are now contextually aware. --- .../History/HistoryBrowser.qml | 1 + .../ObjectLists/Editor/CustomPropertyList.qml | 15 +++++-- .../ObjectLists/Editor/Dialog.qml | 1 + .../Popup/InsertCharacter.qml | 45 ++++++++++++++++--- .../Setting/ExpressionEditor.qml | 2 + .../LogarithmPlotter/Setting/TextSetting.qml | 6 +++ .../eu/ad5001/LogarithmPlotter/Settings.qml | 2 + 7 files changed, 62 insertions(+), 10 deletions(-) diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History/HistoryBrowser.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History/HistoryBrowser.qml index 16feace..b6562e3 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History/HistoryBrowser.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History/HistoryBrowser.qml @@ -54,6 +54,7 @@ Item { anchors.right: parent.right anchors.top: parent.top placeholderText: qsTr("Filter...") + category: "all" } ScrollView { diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/CustomPropertyList.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/CustomPropertyList.qml index a800c6e..63acf76 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/CustomPropertyList.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/CustomPropertyList.qml @@ -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. diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/Dialog.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/Dialog.qml index a9b8052..44e4b73 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/Dialog.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/Dialog.qml @@ -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) { diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Popup/InsertCharacter.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Popup/InsertCharacter.qml index d893d43..fbd1a64 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Popup/InsertCharacter.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Popup/InsertCharacter.qml @@ -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 diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/ExpressionEditor.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/ExpressionEditor.qml index 897abda..5a758b5 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/ExpressionEditor.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/ExpressionEditor.qml @@ -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() diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/TextSetting.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/TextSetting.qml index 539ea96..00c1347 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/TextSetting.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/TextSetting.qml @@ -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. diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Settings.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Settings.qml index 39c508f..ceca22f 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Settings.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Settings.qml @@ -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