From ba4d6993b78a3a0e7c0d0b0f09ab071b1bb5e447 Mon Sep 17 00:00:00 2001 From: xiphon Date: Thu, 24 Dec 2020 08:05:14 +0000 Subject: [PATCH] LineEdit: fix padding, fix inline buttons layout, multiple btns support --- components/InlineButton.qml | 35 +++++++---------------- components/LineEdit.qml | 21 ++++++++------ components/LineEditMulti.qml | 27 ++++++------------ pages/AddressBook.qml | 18 ++++++------ pages/Transfer.qml | 49 ++++++++++++++++----------------- wizard/WizardDaemonSettings.qml | 17 +++++++----- wizard/WizardWalletInput.qml | 17 +++++++----- 7 files changed, 85 insertions(+), 99 deletions(-) diff --git a/components/InlineButton.qml b/components/InlineButton.qml index 299f1ae6..107614d5 100644 --- a/components/InlineButton.qml +++ b/components/InlineButton.qml @@ -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 diff --git a/components/LineEdit.qml b/components/LineEdit.qml index aad42895..516cee2d 100644 --- a/components/LineEdit.qml +++ b/components/LineEdit.qml @@ -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 + } } } } diff --git a/components/LineEditMulti.qml b/components/LineEditMulti.qml index 4e971285..7f2e377e 100644 --- a/components/LineEditMulti.qml +++ b/components/LineEditMulti.qml @@ -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 } } } diff --git a/pages/AddressBook.qml b/pages/AddressBook.qml index db2e7c05..e0a26c70 100644 --- a/pages/AddressBook.qml +++ b/pages/AddressBook.qml @@ -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 { diff --git a/pages/Transfer.qml b/pages/Transfer.qml index 44edd403..dc4687dd 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -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 { diff --git a/wizard/WizardDaemonSettings.qml b/wizard/WizardDaemonSettings.qml index 7155db10..3f1f2204 100644 --- a/wizard/WizardDaemonSettings.qml +++ b/wizard/WizardDaemonSettings.qml @@ -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; + } } } diff --git a/wizard/WizardWalletInput.qml b/wizard/WizardWalletInput.qml index 5b2f3b69..e754a4f1 100644 --- a/wizard/WizardWalletInput.qml +++ b/wizard/WizardWalletInput.qml @@ -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 {