1
mirror of https://github.com/monero-project/monero-gui synced 2024-11-25 10:47:19 +01:00

LineEdit: fix padding, fix inline buttons layout, multiple btns support

This commit is contained in:
xiphon 2020-12-24 08:05:14 +00:00
parent fed00a5662
commit ba4d6993b7
7 changed files with 85 additions and 99 deletions

View File

@ -30,30 +30,26 @@ import QtQuick 2.9
import QtQuick.Layouts 1.1
import QtGraphicalEffects 1.0
import FontAwesome 1.0
import "." as MoneroComponents
import "./effects/" as MoneroEffects
Item {
id: inlineButton
height: parent.height
anchors.top: parent.top
anchors.bottom: parent.bottom
property bool small: false
property string shadowPressedColor: "#B32D00"
property string shadowReleasedColor: "#FF4304"
property string pressedColor: "#FF4304"
property string releasedColor: "#FF6C3C"
property string icon: ""
property string textColor: MoneroComponents.Style.inlineButtonTextColor
property int fontSize: small ? 14 : 16
property int rectHeight: small ? 24 : 24
property int rectHMargin: small ? 16 : 22
property alias text: inlineText.text
property alias fontPixelSize: inlineText.font.pixelSize
property alias fontFamily: inlineText.font.family
property bool isFontAwesomeIcon: fontFamily == FontAwesome.fontFamily || fontFamily == FontAwesome.fontFamilySolid
property alias buttonColor: rect.color
property alias buttonHeight: rect.height
Layout.rightMargin: isFontAwesomeIcon ? 0 : 4
height: isFontAwesomeIcon ? 30 : 24
width: isFontAwesomeIcon ? height : inlineText.width + 16
signal clicked()
function doClick() {
@ -64,20 +60,16 @@ Item {
Rectangle{
id: rect
anchors.fill: parent
color: MoneroComponents.Style.buttonInlineBackgroundColor
height: 24
width: inlineText.text ? (inlineText.width + 16) : inlineButton.icon ? (inlineImage.width + 16) : rect.height
radius: 4
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 4
MoneroComponents.TextPlain {
id: inlineText
font.family: MoneroComponents.Style.fontBold.name
font.bold: true
font.pixelSize: inlineButton.fontSize
font.pixelSize: inlineButton.isFontAwesomeIcon ? 22 : inlineButton.small ? 14 : 16
color: inlineButton.textColor
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
@ -90,13 +82,6 @@ Item {
}
}
Image {
id: inlineImage
visible: inlineButton.icon !== ""
anchors.centerIn: parent
source: inlineButton.icon
}
MouseArea {
id: buttonArea
cursorShape: rect.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor

View File

@ -29,11 +29,15 @@
import FontAwesome 1.0
import QtQuick 2.9
import QtGraphicalEffects 1.0
import QtQuick.Layouts 1.1
import "../components" as MoneroComponents
Item {
id: item
default property alias content: inlineButtons.children
property alias input: input
property alias text: input.text
@ -53,8 +57,6 @@ Item {
property alias validator: input.validator
property alias readOnly : input.readOnly
property alias cursorPosition: input.cursorPosition
property alias inlineButton: inlineButtonId
property alias inlineButtonText: inlineButtonId.text
property alias inlineIcon: inlineIcon.visible
property bool copyButton: false
property alias copyButtonText: copyButtonId.text
@ -239,6 +241,7 @@ Item {
onEditingFinished: item.editingFinished()
onAccepted: item.accepted();
onTextChanged: item.textUpdated()
rightPadding: inlineButtons.width + 14
topPadding: 10
bottomPadding: 10
echoMode: isPasswordHidden() ? TextInput.Password : TextInput.Normal
@ -262,13 +265,15 @@ Item {
onClicked: passwordToggle()
}
}
}
MoneroComponents.InlineButton {
id: inlineButtonId
visible: item.inlineButtonText ? true : false
anchors.right: parent.right
anchors.rightMargin: 8
RowLayout {
id: inlineButtons
anchors.bottom: parent.bottom
anchors.top: parent.top
anchors.right: parent.right
anchors.margins: 4
spacing: 4
}
}
}
}

View File

@ -36,13 +36,15 @@ ColumnLayout {
Layout.fillWidth: true
default property alias content: inlineButtons.children
property alias text: input.text
property alias labelText: inputLabel.text
property alias labelButtonText: labelButton.text
property alias placeholderText: placeholderLabel.text
property int inputPaddingLeft: 10
property int inputPaddingRight: 10
property alias inputPaddingRight: input.rightPadding
property int inputPaddingTop: 10
property int inputPaddingBottom: 10
property int inputRadius: 4
@ -85,11 +87,6 @@ ColumnLayout {
property alias addressValidation: input.addressValidation
property string backgroundColor: "" // mock
property alias inlineButton: inlineButtonId
property bool inlineButtonVisible: false
property alias inlineButton2: inlineButton2Id
property bool inlineButton2Visible: false
signal labelButtonClicked();
signal inputLabelLinkActivated();
signal editingFinished();
@ -166,7 +163,7 @@ ColumnLayout {
Layout.fillWidth: true
leftPadding: item.inputPaddingLeft
rightPadding: item.inputPaddingRight
rightPadding: inlineButtons.width + 14
topPadding: item.inputPaddingTop
bottomPadding: item.inputPaddingBottom
@ -202,18 +199,12 @@ ColumnLayout {
visible: !item.borderDisabled
}
MoneroComponents.InlineButton {
id: inlineButtonId
visible: (inlineButtonId.text || inlineButtonId.icon) && inlineButtonVisible ? true : false
RowLayout {
id: inlineButtons
anchors.top: parent.top
anchors.right: parent.right
anchors.rightMargin: 8
}
MoneroComponents.InlineButton {
id: inlineButton2Id
visible: (inlineButton2Id.text || inlineButton2Id.icon) && inlineButton2Visible ? true : false
anchors.right: parent.right
anchors.rightMargin: inlineButtonVisible ? 48 : 8
anchors.margins: 4
spacing: 4
}
}
}

View File

@ -314,16 +314,16 @@ Rectangle {
}
}
inlineButton.text: FontAwesome.qrcode
inlineButton.fontPixelSize: 22
inlineButton.fontFamily: FontAwesome.fontFamily
inlineButton.textColor: MoneroComponents.Style.defaultFontColor
inlineButton.buttonColor: MoneroComponents.Style.orange
inlineButton.onClicked: {
cameraUi.state = "Capture"
cameraUi.qrcode_decoded.connect(root.updateFromQrCode)
MoneroComponents.InlineButton {
buttonColor: MoneroComponents.Style.orange
fontFamily: FontAwesome.fontFamily
text: FontAwesome.qrcode
visible : appWindow.qrScannerEnabled && !addressLine.text
onClicked: {
cameraUi.state = "Capture"
cameraUi.qrcode_decoded.connect(root.updateFromQrCode)
}
}
inlineButtonVisible : appWindow.qrScannerEnabled && !addressLine.text
}
MoneroComponents.StandardButton {

View File

@ -172,7 +172,6 @@ Rectangle {
id: addressLine
KeyNavigation.tab: amountLine
spacing: 0
inputPaddingRight: inlineButtonVisible && inlineButton2Visible ? 100 : 60
fontBold: true
labelText: qsTr("Address") + translationManager.emptyString
labelButtonText: qsTr("Resolve") + translationManager.emptyString
@ -196,27 +195,25 @@ Rectangle {
setDescription(parsed.tx_description);
}
}
inlineButton.text: FontAwesome.addressBook
inlineButton.buttonHeight: 30
inlineButton.fontPixelSize: 22
inlineButton.fontFamily: FontAwesome.fontFamily
inlineButton.textColor: MoneroComponents.Style.defaultFontColor
inlineButton.onClicked: {
middlePanel.addressBookView.selectAndSend = true;
appWindow.showPageRequest("AddressBook");
}
inlineButtonVisible: true
inlineButton2.text: FontAwesome.qrcode
inlineButton2.buttonHeight: 30
inlineButton2.fontPixelSize: 22
inlineButton2.fontFamily: FontAwesome.fontFamily
inlineButton2.textColor: MoneroComponents.Style.defaultFontColor
inlineButton2.onClicked: {
cameraUi.state = "Capture"
cameraUi.qrcode_decoded.connect(updateFromQrCode)
}
inlineButton2Visible: appWindow.qrScannerEnabled
MoneroComponents.InlineButton {
fontFamily: FontAwesome.fontFamily
text: FontAwesome.addressBook
onClicked: {
middlePanel.addressBookView.selectAndSend = true;
appWindow.showPageRequest("AddressBook");
}
}
MoneroComponents.InlineButton {
fontFamily: FontAwesome.fontFamily
text: FontAwesome.qrcode
visible: appWindow.qrScannerEnabled
onClicked: {
cameraUi.state = "Capture"
cameraUi.qrcode_decoded.connect(updateFromQrCode)
}
}
}
}
@ -295,8 +292,6 @@ Rectangle {
placeholderText: "0.00"
width: 100
fontBold: true
inlineButtonText: qsTr("All") + translationManager.emptyString
inlineButton.onClicked: amountLine.text = "(all)"
onTextChanged: {
amountLine.text = amountLine.text.replace(",", ".");
const match = amountLine.text.match(/^0+(\d.*)/);
@ -312,10 +307,14 @@ Rectangle {
}
amountLine.error = walletManager.amountFromString(amountLine.text) > appWindow.getUnlockedBalance()
}
validator: RegExpValidator {
regExp: /^(\d{1,8})?([\.,]\d{1,12})?$/
}
MoneroComponents.InlineButton {
text: qsTr("All") + translationManager.emptyString
onClicked: amountLine.text = "(all)"
}
}
MoneroComponents.TextPlain {

View File

@ -81,13 +81,16 @@ ColumnLayout {
placeholderText: qsTr("Default") + translationManager.emptyString
placeholderFontSize: 15
text: persistentSettings.blockchainDataDir
inlineButton.small: true
inlineButtonText: qsTr("Browse") + translationManager.emptyString
inlineButton.onClicked: {
if(persistentSettings.blockchainDataDir != "");
blockchainFileDialog.folder = "file://" + persistentSettings.blockchainDataDir;
blockchainFileDialog.open();
blockchainFolder.focus = true;
MoneroComponents.InlineButton {
small: true
text: qsTr("Browse") + translationManager.emptyString
onClicked: {
if(persistentSettings.blockchainDataDir != "");
blockchainFileDialog.folder = "file://" + persistentSettings.blockchainDataDir;
blockchainFileDialog.open();
blockchainFolder.focus = true;
}
}
}

View File

@ -89,16 +89,19 @@ GridLayout {
placeholderText: "..."
placeholderFontSize: 16
text: appWindow.accountsDir + "/"
inlineButton.small: true
inlineButtonText: qsTr("Browse") + translationManager.emptyString
inlineButton.onClicked: {
fileWalletDialog.folder = walletManager.localPathToUrl(walletLocation.text)
fileWalletDialog.open()
walletLocation.focus = true
}
onTextChanged: {
walletLocation.error = walletLocation.text === "";
}
MoneroComponents.InlineButton {
small: true
text: qsTr("Browse") + translationManager.emptyString
onClicked: {
fileWalletDialog.folder = walletManager.localPathToUrl(walletLocation.text)
fileWalletDialog.open()
walletLocation.focus = true
}
}
}
FileDialog {