LineEdit: fontFamily and inputPadding properties, fix backtab

This commit is contained in:
xiphon 2021-02-05 13:04:06 +00:00
parent c1573c2c2a
commit 16fd2b4447

View file

@ -52,6 +52,15 @@ Item {
property int placeholderFontSize: 18 property int placeholderFontSize: 18
property string placeholderColor: MoneroComponents.Style.defaultFontColor property string placeholderColor: MoneroComponents.Style.defaultFontColor
property real placeholderOpacity: 0.35 property real placeholderOpacity: 0.35
property real placeholderLeftMargin: {
if (placeholderCenter) {
return undefined;
} else if (inlineIcon.visible) {
return inlineIcon.width + inlineIcon.anchors.leftMargin + inputPadding;
} else {
return inputPadding;
}
}
property alias acceptableInput: input.acceptableInput property alias acceptableInput: input.acceptableInput
property alias validator: input.validator property alias validator: input.validator
@ -73,6 +82,7 @@ Item {
} }
} }
property string fontFamily: MoneroComponents.Style.fontRegular.name
property int fontSize: 18 property int fontSize: 18
property bool fontBold: false property bool fontBold: false
property alias fontColor: input.color property alias fontColor: input.color
@ -88,13 +98,14 @@ Item {
property alias labelHorizontalAlignment: inputLabel.horizontalAlignment property alias labelHorizontalAlignment: inputLabel.horizontalAlignment
property bool showingHeader: inputLabel.text !== "" || copyButton property bool showingHeader: inputLabel.text !== "" || copyButton
property int inputHeight: 42 property int inputHeight: 42
property int inputPadding: 10
signal labelLinkActivated(); // input label, rich text <a> signal signal labelLinkActivated(); // input label, rich text <a> signal
signal editingFinished(); signal editingFinished();
signal accepted(); signal accepted();
signal textUpdated(); signal textUpdated();
height: showingHeader ? (inputLabel.height + inputItem.height + 2) : 42 height: showingHeader ? (inputLabel.height + inputItem.height + 2) : inputHeight
onActiveFocusChanged: activeFocus && input.forceActiveFocus() onActiveFocusChanged: activeFocus && input.forceActiveFocus()
onTextUpdated: { onTextUpdated: {
@ -177,7 +188,7 @@ Item {
id: inputItem id: inputItem
height: inputHeight height: inputHeight
anchors.top: showingHeader ? inputLabel.bottom : parent.top anchors.top: showingHeader ? inputLabel.bottom : parent.top
anchors.topMargin: showingHeader ? 12 : 2 anchors.topMargin: showingHeader ? 12 : 0
width: parent.width width: parent.width
clip: true clip: true
@ -187,13 +198,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: placeholderCenter ? parent.horizontalCenter : undefined anchors.horizontalCenter: placeholderCenter ? parent.horizontalCenter : undefined
anchors.left: placeholderCenter ? undefined : parent.left anchors.left: placeholderCenter ? undefined : parent.left
anchors.leftMargin: { anchors.leftMargin: placeholderLeftMargin
if(placeholderCenter){
return undefined;
}
else if(inlineIcon.visible){ return 50; }
else { return 10; }
}
opacity: item.placeholderOpacity opacity: item.placeholderOpacity
color: item.placeholderColor color: item.placeholderColor
@ -235,15 +240,18 @@ Item {
id: input id: input
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: inlineIcon.visible ? 44 : 0 anchors.leftMargin: inlineIcon.visible ? 44 : 0
font.family: item.fontFamily
font.pixelSize: item.fontSize font.pixelSize: item.fontSize
font.bold: item.fontBold font.bold: item.fontBold
KeyNavigation.backtab: item.KeyNavigation.backtab
KeyNavigation.tab: item.KeyNavigation.tab KeyNavigation.tab: item.KeyNavigation.tab
onEditingFinished: item.editingFinished() onEditingFinished: item.editingFinished()
onAccepted: item.accepted(); onAccepted: item.accepted();
onTextChanged: item.textUpdated() onTextChanged: item.textUpdated()
rightPadding: inlineButtons.width + 14 leftPadding: inputPadding
topPadding: 10 rightPadding: (inlineButtons.width > 0 ? inlineButtons.width + inlineButtons.spacing : 0) + inputPadding
bottomPadding: 10 topPadding: inputPadding
bottomPadding: inputPadding
echoMode: isPasswordHidden() ? TextInput.Password : TextInput.Normal echoMode: isPasswordHidden() ? TextInput.Password : TextInput.Normal
MoneroComponents.Label { MoneroComponents.Label {
@ -271,7 +279,9 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
anchors.margins: 4 anchors.topMargin: inputPadding
anchors.bottomMargin: inputPadding
anchors.rightMargin: inputPadding
spacing: 4 spacing: 4
} }
} }