Skip to content

Commit

Permalink
Minor refinements to project properties dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
mathesoncalum committed Sep 9, 2024
1 parent 2f5cf79 commit 420e010
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 53 deletions.
115 changes: 63 additions & 52 deletions src/framework/uicomponents/qml/Muse/UiComponents/TextInputArea.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ FocusScope {

property bool hasText: valueInput.text.length > 0

property bool resizeVerticallyWithText: false

property real textSidePadding: 12

readonly property alias inputField: valueInput
Expand Down Expand Up @@ -66,9 +68,11 @@ FocusScope {
}
}

implicitHeight: 90
implicitHeight: root.resizeVerticallyWithText ? Math.max(valueInput.height, 90) : 90
implicitWidth: parent.width

height: implicitHeight

opacity: root.enabled ? 1.0 : ui.theme.itemOpacityDisabled

FocusListener {
Expand Down Expand Up @@ -125,76 +129,83 @@ FocusScope {
anchors.right: parent.right
}

TextArea {
id: valueInput

objectName: "TextArea"
contentWidth: valueInput.width
contentHeight: root.resizeVerticallyWithText ? -1 : valueInput.height

padding: root.textSidePadding
// When a TextArea component is set as a direct child of a ScrollView, the result will always be scrollable in both directions. To override this,
// we need to place the TextArea inside an Item and manually define contentWidth/Height
Item {
TextArea {
id: valueInput

color: ui.theme.fontPrimaryColor
font: ui.theme.bodyFont
objectName: "TextArea"

background: Item {}
padding: root.textSidePadding

focus: false
activeFocusOnPress: false
selectByMouse: true
selectionColor: Utils.colorWithAlpha(ui.theme.accentColor, ui.theme.accentOpacityNormal)
selectedTextColor: ui.theme.fontPrimaryColor
placeholderTextColor: Utils.colorWithAlpha(ui.theme.fontPrimaryColor, 0.3)
visible: true
color: ui.theme.fontPrimaryColor
font: ui.theme.bodyFont

text: root.currentText === undefined ? "" : root.currentText
background: Item {}

TextInputModel {
id: textInputModel
}
focus: false
activeFocusOnPress: false
selectByMouse: true
selectionColor: Utils.colorWithAlpha(ui.theme.accentColor, ui.theme.accentOpacityNormal)
selectedTextColor: ui.theme.fontPrimaryColor
placeholderTextColor: Utils.colorWithAlpha(ui.theme.fontPrimaryColor, 0.3)
visible: true

Component.onCompleted: {
textInputModel.init()
}
text: root.currentText === undefined ? "" : root.currentText

Keys.onShortcutOverride: function(event) {
if (readOnly) {
return
TextInputModel {
id: textInputModel
}

if (event.key === Qt.Key_Escape) {
event.accepted = true
return
Component.onCompleted: {
textInputModel.init()
}

if (textInputModel.isShortcutAllowedOverride(event.key, event.modifiers)) {
event.accepted = true
} else {
event.accepted = false
Keys.onShortcutOverride: function(event) {
if (readOnly) {
return
}

if (event.key === Qt.Key_Escape) {
event.accepted = true
return
}

root.focus = false
root.textEditingFinished(valueInput.text)
if (textInputModel.isShortcutAllowedOverride(event.key, event.modifiers)) {
event.accepted = true
} else {
event.accepted = false

root.focus = false
root.textEditingFinished(valueInput.text)
}
}
}

Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) {
root.focus = false
root.textEditingFinished(valueInput.text)
root.escaped()
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) {
root.focus = false
root.textEditingFinished(valueInput.text)
root.escaped()
}
}
}

onActiveFocusChanged: {
if (activeFocus) {
navCtrl.requestActive()
selectAll()
} else {
deselect()
root.textEditingFinished(valueInput.text)
onActiveFocusChanged: {
if (activeFocus) {
navCtrl.requestActive()
selectAll()
} else {
deselect()
root.textEditingFinished(valueInput.text)
}
}
}

onTextChanged: {
root.textChanged(text)
onTextChanged: {
root.textChanged(text)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ RowLayout {
currentText: root.propertyValue ? root.propertyValue : ""
hint: root.isStandardProperty ? "" : qsTrc("project/properties", "Value")

resizeVerticallyWithText: true

navigation.name: root.propertyName + "PropertyValue"
navigation.panel: root.navigationPanel
navigation.column: prv.navigationStartIndex + 1
Expand Down Expand Up @@ -146,7 +148,7 @@ RowLayout {
Layout.fillWidth: root.valueFillWidth

text: root.propertyValue ? root.propertyValue : ""
font: ui.theme.bodyBoldFont
font: ui.theme.bodyFont
horizontalAlignment: Qt.AlignLeft
visible: root.isFileInfoPanelProperty
}
Expand Down

0 comments on commit 420e010

Please sign in to comment.