mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-09 19:32:03 +02:00
LineEdit: fix padding, fix inline buttons layout, multiple btns support
This commit is contained in:
parent
fed00a5662
commit
ba4d6993b7
@ -30,30 +30,26 @@ import QtQuick 2.9
|
|||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
|
import FontAwesome 1.0
|
||||||
|
|
||||||
import "." as MoneroComponents
|
import "." as MoneroComponents
|
||||||
import "./effects/" as MoneroEffects
|
import "./effects/" as MoneroEffects
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: inlineButton
|
id: inlineButton
|
||||||
height: parent.height
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
|
|
||||||
property bool small: false
|
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 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 text: inlineText.text
|
||||||
property alias fontPixelSize: inlineText.font.pixelSize
|
property alias fontPixelSize: inlineText.font.pixelSize
|
||||||
property alias fontFamily: inlineText.font.family
|
property alias fontFamily: inlineText.font.family
|
||||||
|
property bool isFontAwesomeIcon: fontFamily == FontAwesome.fontFamily || fontFamily == FontAwesome.fontFamilySolid
|
||||||
property alias buttonColor: rect.color
|
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()
|
signal clicked()
|
||||||
|
|
||||||
function doClick() {
|
function doClick() {
|
||||||
@ -64,20 +60,16 @@ Item {
|
|||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id: rect
|
id: rect
|
||||||
|
anchors.fill: parent
|
||||||
color: MoneroComponents.Style.buttonInlineBackgroundColor
|
color: MoneroComponents.Style.buttonInlineBackgroundColor
|
||||||
height: 24
|
|
||||||
width: inlineText.text ? (inlineText.width + 16) : inlineButton.icon ? (inlineImage.width + 16) : rect.height
|
|
||||||
radius: 4
|
radius: 4
|
||||||
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: 4
|
|
||||||
|
|
||||||
MoneroComponents.TextPlain {
|
MoneroComponents.TextPlain {
|
||||||
id: inlineText
|
id: inlineText
|
||||||
font.family: MoneroComponents.Style.fontBold.name
|
font.family: MoneroComponents.Style.fontBold.name
|
||||||
font.bold: true
|
font.bold: true
|
||||||
font.pixelSize: inlineButton.fontSize
|
font.pixelSize: inlineButton.isFontAwesomeIcon ? 22 : inlineButton.small ? 14 : 16
|
||||||
color: inlineButton.textColor
|
color: inlineButton.textColor
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
@ -90,13 +82,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
|
||||||
id: inlineImage
|
|
||||||
visible: inlineButton.icon !== ""
|
|
||||||
anchors.centerIn: parent
|
|
||||||
source: inlineButton.icon
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: buttonArea
|
id: buttonArea
|
||||||
cursorShape: rect.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
cursorShape: rect.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||||
|
@ -29,11 +29,15 @@
|
|||||||
import FontAwesome 1.0
|
import FontAwesome 1.0
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
import "../components" as MoneroComponents
|
import "../components" as MoneroComponents
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: item
|
id: item
|
||||||
|
|
||||||
|
default property alias content: inlineButtons.children
|
||||||
|
|
||||||
property alias input: input
|
property alias input: input
|
||||||
property alias text: input.text
|
property alias text: input.text
|
||||||
|
|
||||||
@ -53,8 +57,6 @@ Item {
|
|||||||
property alias validator: input.validator
|
property alias validator: input.validator
|
||||||
property alias readOnly : input.readOnly
|
property alias readOnly : input.readOnly
|
||||||
property alias cursorPosition: input.cursorPosition
|
property alias cursorPosition: input.cursorPosition
|
||||||
property alias inlineButton: inlineButtonId
|
|
||||||
property alias inlineButtonText: inlineButtonId.text
|
|
||||||
property alias inlineIcon: inlineIcon.visible
|
property alias inlineIcon: inlineIcon.visible
|
||||||
property bool copyButton: false
|
property bool copyButton: false
|
||||||
property alias copyButtonText: copyButtonId.text
|
property alias copyButtonText: copyButtonId.text
|
||||||
@ -239,6 +241,7 @@ Item {
|
|||||||
onEditingFinished: item.editingFinished()
|
onEditingFinished: item.editingFinished()
|
||||||
onAccepted: item.accepted();
|
onAccepted: item.accepted();
|
||||||
onTextChanged: item.textUpdated()
|
onTextChanged: item.textUpdated()
|
||||||
|
rightPadding: inlineButtons.width + 14
|
||||||
topPadding: 10
|
topPadding: 10
|
||||||
bottomPadding: 10
|
bottomPadding: 10
|
||||||
echoMode: isPasswordHidden() ? TextInput.Password : TextInput.Normal
|
echoMode: isPasswordHidden() ? TextInput.Password : TextInput.Normal
|
||||||
@ -262,13 +265,15 @@ Item {
|
|||||||
onClicked: passwordToggle()
|
onClicked: passwordToggle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
MoneroComponents.InlineButton {
|
RowLayout {
|
||||||
id: inlineButtonId
|
id: inlineButtons
|
||||||
visible: item.inlineButtonText ? true : false
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.top: parent.top
|
||||||
anchors.rightMargin: 8
|
anchors.right: parent.right
|
||||||
|
anchors.margins: 4
|
||||||
|
spacing: 4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,15 @@ ColumnLayout {
|
|||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
default property alias content: inlineButtons.children
|
||||||
|
|
||||||
property alias text: input.text
|
property alias text: input.text
|
||||||
property alias labelText: inputLabel.text
|
property alias labelText: inputLabel.text
|
||||||
property alias labelButtonText: labelButton.text
|
property alias labelButtonText: labelButton.text
|
||||||
property alias placeholderText: placeholderLabel.text
|
property alias placeholderText: placeholderLabel.text
|
||||||
|
|
||||||
property int inputPaddingLeft: 10
|
property int inputPaddingLeft: 10
|
||||||
property int inputPaddingRight: 10
|
property alias inputPaddingRight: input.rightPadding
|
||||||
property int inputPaddingTop: 10
|
property int inputPaddingTop: 10
|
||||||
property int inputPaddingBottom: 10
|
property int inputPaddingBottom: 10
|
||||||
property int inputRadius: 4
|
property int inputRadius: 4
|
||||||
@ -85,11 +87,6 @@ ColumnLayout {
|
|||||||
property alias addressValidation: input.addressValidation
|
property alias addressValidation: input.addressValidation
|
||||||
property string backgroundColor: "" // mock
|
property string backgroundColor: "" // mock
|
||||||
|
|
||||||
property alias inlineButton: inlineButtonId
|
|
||||||
property bool inlineButtonVisible: false
|
|
||||||
property alias inlineButton2: inlineButton2Id
|
|
||||||
property bool inlineButton2Visible: false
|
|
||||||
|
|
||||||
signal labelButtonClicked();
|
signal labelButtonClicked();
|
||||||
signal inputLabelLinkActivated();
|
signal inputLabelLinkActivated();
|
||||||
signal editingFinished();
|
signal editingFinished();
|
||||||
@ -166,7 +163,7 @@ ColumnLayout {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
leftPadding: item.inputPaddingLeft
|
leftPadding: item.inputPaddingLeft
|
||||||
rightPadding: item.inputPaddingRight
|
rightPadding: inlineButtons.width + 14
|
||||||
topPadding: item.inputPaddingTop
|
topPadding: item.inputPaddingTop
|
||||||
bottomPadding: item.inputPaddingBottom
|
bottomPadding: item.inputPaddingBottom
|
||||||
|
|
||||||
@ -202,18 +199,12 @@ ColumnLayout {
|
|||||||
visible: !item.borderDisabled
|
visible: !item.borderDisabled
|
||||||
}
|
}
|
||||||
|
|
||||||
MoneroComponents.InlineButton {
|
RowLayout {
|
||||||
id: inlineButtonId
|
id: inlineButtons
|
||||||
visible: (inlineButtonId.text || inlineButtonId.icon) && inlineButtonVisible ? true : false
|
anchors.top: parent.top
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 8
|
anchors.margins: 4
|
||||||
}
|
spacing: 4
|
||||||
|
|
||||||
MoneroComponents.InlineButton {
|
|
||||||
id: inlineButton2Id
|
|
||||||
visible: (inlineButton2Id.text || inlineButton2Id.icon) && inlineButton2Visible ? true : false
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: inlineButtonVisible ? 48 : 8
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,16 +314,16 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inlineButton.text: FontAwesome.qrcode
|
MoneroComponents.InlineButton {
|
||||||
inlineButton.fontPixelSize: 22
|
buttonColor: MoneroComponents.Style.orange
|
||||||
inlineButton.fontFamily: FontAwesome.fontFamily
|
fontFamily: FontAwesome.fontFamily
|
||||||
inlineButton.textColor: MoneroComponents.Style.defaultFontColor
|
text: FontAwesome.qrcode
|
||||||
inlineButton.buttonColor: MoneroComponents.Style.orange
|
visible : appWindow.qrScannerEnabled && !addressLine.text
|
||||||
inlineButton.onClicked: {
|
onClicked: {
|
||||||
cameraUi.state = "Capture"
|
cameraUi.state = "Capture"
|
||||||
cameraUi.qrcode_decoded.connect(root.updateFromQrCode)
|
cameraUi.qrcode_decoded.connect(root.updateFromQrCode)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
inlineButtonVisible : appWindow.qrScannerEnabled && !addressLine.text
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MoneroComponents.StandardButton {
|
MoneroComponents.StandardButton {
|
||||||
|
@ -172,7 +172,6 @@ Rectangle {
|
|||||||
id: addressLine
|
id: addressLine
|
||||||
KeyNavigation.tab: amountLine
|
KeyNavigation.tab: amountLine
|
||||||
spacing: 0
|
spacing: 0
|
||||||
inputPaddingRight: inlineButtonVisible && inlineButton2Visible ? 100 : 60
|
|
||||||
fontBold: true
|
fontBold: true
|
||||||
labelText: qsTr("Address") + translationManager.emptyString
|
labelText: qsTr("Address") + translationManager.emptyString
|
||||||
labelButtonText: qsTr("Resolve") + translationManager.emptyString
|
labelButtonText: qsTr("Resolve") + translationManager.emptyString
|
||||||
@ -196,27 +195,25 @@ Rectangle {
|
|||||||
setDescription(parsed.tx_description);
|
setDescription(parsed.tx_description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inlineButton.text: FontAwesome.addressBook
|
|
||||||
inlineButton.buttonHeight: 30
|
MoneroComponents.InlineButton {
|
||||||
inlineButton.fontPixelSize: 22
|
fontFamily: FontAwesome.fontFamily
|
||||||
inlineButton.fontFamily: FontAwesome.fontFamily
|
text: FontAwesome.addressBook
|
||||||
inlineButton.textColor: MoneroComponents.Style.defaultFontColor
|
onClicked: {
|
||||||
inlineButton.onClicked: {
|
middlePanel.addressBookView.selectAndSend = true;
|
||||||
middlePanel.addressBookView.selectAndSend = true;
|
appWindow.showPageRequest("AddressBook");
|
||||||
appWindow.showPageRequest("AddressBook");
|
}
|
||||||
}
|
}
|
||||||
inlineButtonVisible: true
|
|
||||||
|
MoneroComponents.InlineButton {
|
||||||
inlineButton2.text: FontAwesome.qrcode
|
fontFamily: FontAwesome.fontFamily
|
||||||
inlineButton2.buttonHeight: 30
|
text: FontAwesome.qrcode
|
||||||
inlineButton2.fontPixelSize: 22
|
visible: appWindow.qrScannerEnabled
|
||||||
inlineButton2.fontFamily: FontAwesome.fontFamily
|
onClicked: {
|
||||||
inlineButton2.textColor: MoneroComponents.Style.defaultFontColor
|
cameraUi.state = "Capture"
|
||||||
inlineButton2.onClicked: {
|
cameraUi.qrcode_decoded.connect(updateFromQrCode)
|
||||||
cameraUi.state = "Capture"
|
}
|
||||||
cameraUi.qrcode_decoded.connect(updateFromQrCode)
|
}
|
||||||
}
|
|
||||||
inlineButton2Visible: appWindow.qrScannerEnabled
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,8 +292,6 @@ Rectangle {
|
|||||||
placeholderText: "0.00"
|
placeholderText: "0.00"
|
||||||
width: 100
|
width: 100
|
||||||
fontBold: true
|
fontBold: true
|
||||||
inlineButtonText: qsTr("All") + translationManager.emptyString
|
|
||||||
inlineButton.onClicked: amountLine.text = "(all)"
|
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
amountLine.text = amountLine.text.replace(",", ".");
|
amountLine.text = amountLine.text.replace(",", ".");
|
||||||
const match = amountLine.text.match(/^0+(\d.*)/);
|
const match = amountLine.text.match(/^0+(\d.*)/);
|
||||||
@ -312,10 +307,14 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
amountLine.error = walletManager.amountFromString(amountLine.text) > appWindow.getUnlockedBalance()
|
amountLine.error = walletManager.amountFromString(amountLine.text) > appWindow.getUnlockedBalance()
|
||||||
}
|
}
|
||||||
|
|
||||||
validator: RegExpValidator {
|
validator: RegExpValidator {
|
||||||
regExp: /^(\d{1,8})?([\.,]\d{1,12})?$/
|
regExp: /^(\d{1,8})?([\.,]\d{1,12})?$/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MoneroComponents.InlineButton {
|
||||||
|
text: qsTr("All") + translationManager.emptyString
|
||||||
|
onClicked: amountLine.text = "(all)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MoneroComponents.TextPlain {
|
MoneroComponents.TextPlain {
|
||||||
|
@ -81,13 +81,16 @@ ColumnLayout {
|
|||||||
placeholderText: qsTr("Default") + translationManager.emptyString
|
placeholderText: qsTr("Default") + translationManager.emptyString
|
||||||
placeholderFontSize: 15
|
placeholderFontSize: 15
|
||||||
text: persistentSettings.blockchainDataDir
|
text: persistentSettings.blockchainDataDir
|
||||||
inlineButton.small: true
|
|
||||||
inlineButtonText: qsTr("Browse") + translationManager.emptyString
|
MoneroComponents.InlineButton {
|
||||||
inlineButton.onClicked: {
|
small: true
|
||||||
if(persistentSettings.blockchainDataDir != "");
|
text: qsTr("Browse") + translationManager.emptyString
|
||||||
blockchainFileDialog.folder = "file://" + persistentSettings.blockchainDataDir;
|
onClicked: {
|
||||||
blockchainFileDialog.open();
|
if(persistentSettings.blockchainDataDir != "");
|
||||||
blockchainFolder.focus = true;
|
blockchainFileDialog.folder = "file://" + persistentSettings.blockchainDataDir;
|
||||||
|
blockchainFileDialog.open();
|
||||||
|
blockchainFolder.focus = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,16 +89,19 @@ GridLayout {
|
|||||||
placeholderText: "..."
|
placeholderText: "..."
|
||||||
placeholderFontSize: 16
|
placeholderFontSize: 16
|
||||||
text: appWindow.accountsDir + "/"
|
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: {
|
onTextChanged: {
|
||||||
walletLocation.error = walletLocation.text === "";
|
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 {
|
FileDialog {
|
||||||
|
Loading…
Reference in New Issue
Block a user