Merge pull request #3613

6739b51 WizardWalletInput: red border if error; error messages; remove placeholders; smaller font; icon for browse button (rating89us)
This commit is contained in:
luigi1111 2021-07-10 17:54:34 -04:00
commit f81bfa1865
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
5 changed files with 104 additions and 24 deletions

View file

@ -78,9 +78,9 @@ ColumnLayout {
property bool borderDisabled: false property bool borderDisabled: false
property string borderColor: { property string borderColor: {
if(error && input.text !== ""){ if ((error && input.text !== "") || (errorWhenEmpty && input.text == "")) {
return MoneroComponents.Style.inputBorderColorInvalid; return MoneroComponents.Style.inputBorderColorInvalid;
} else if(input.activeFocus){ } else if (input.activeFocus) {
return MoneroComponents.Style.inputBorderColorActive; return MoneroComponents.Style.inputBorderColorActive;
} else { } else {
return MoneroComponents.Style.inputBorderColorInActive; return MoneroComponents.Style.inputBorderColorInActive;
@ -92,6 +92,7 @@ ColumnLayout {
property bool fontBold: false property bool fontBold: false
property alias fontColor: input.color property alias fontColor: input.color
property bool error: false property bool error: false
property bool errorWhenEmpty: false
property alias labelText: inputLabel.text property alias labelText: inputLabel.text
property alias labelColor: inputLabel.color property alias labelColor: inputLabel.color
property alias labelTextFormat: inputLabel.textFormat property alias labelTextFormat: inputLabel.textFormat

View file

@ -80,7 +80,7 @@ Rectangle {
ColumnLayout { ColumnLayout {
spacing: 0 spacing: 0
Layout.topMargin: 10 Layout.topMargin: -10
Layout.fillWidth: true Layout.fillWidth: true
MoneroComponents.StandardDropdown { MoneroComponents.StandardDropdown {

View file

@ -71,7 +71,7 @@ Rectangle {
ColumnLayout { ColumnLayout {
spacing: 0 spacing: 0
Layout.topMargin: 10 Layout.topMargin: -10
Layout.fillWidth: true Layout.fillWidth: true
MoneroComponents.LineEditMulti { MoneroComponents.LineEditMulti {

View file

@ -111,7 +111,7 @@ Rectangle {
} }
RowLayout { RowLayout {
Layout.topMargin: 10 Layout.topMargin: -10
spacing: 30 spacing: 30
Layout.fillWidth: true Layout.fillWidth: true

View file

@ -30,6 +30,7 @@ import QtQuick 2.9
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2 import QtQuick.Layouts 1.2
import QtQuick.Controls 2.0 import QtQuick.Controls 2.0
import FontAwesome 1.0
import "../js/Wizard.js" as Wizard import "../js/Wizard.js" as Wizard
import "../components" import "../components"
@ -42,11 +43,11 @@ GridLayout {
property alias walletLocation: walletLocation property alias walletLocation: walletLocation
columnSpacing: 20 columnSpacing: 20
columns: 3 columns: 2
function verify() { function verify() {
if(walletName.text !== '' && walletLocation.text !== ''){ if (walletName.text !== '' && walletLocation.text !== '') {
if(!walletName.error){ if (!walletName.error && !walletLocation.error) {
return true; return true;
} }
} }
@ -55,26 +56,41 @@ GridLayout {
function reset() { function reset() {
walletName.error = !walletName.verify(); walletName.error = !walletName.verify();
walletLocation.error = walletLocation.text === ""; walletLocation.error = !walletLocation.verify();
walletLocation.text = appWindow.accountsDir; walletLocation.text = appWindow.accountsDir;
walletName.text = Wizard.unusedWalletName(appWindow.accountsDir, defaultAccountName, walletManager); walletName.text = Wizard.unusedWalletName(appWindow.accountsDir, defaultAccountName, walletManager);
} }
MoneroComponents.LineEdit { MoneroComponents.LineEdit {
id: walletName id: walletName
Layout.preferredWidth: grid.width/3 Layout.preferredWidth: grid.width/5
function verify(){ function verify(){
if(walletLocation === "" || /[\\\/]/.test(walletName.text)) return false; if (walletName.text === "") {
errorMessageWalletName.text = qsTr("Wallet name is empty") + translationManager.emptyString;
var exists = Wizard.walletPathExists(appWindow.accountsDir, walletLocation.text, walletName.text, isIOS, walletManager); return false;
return !exists && walletLocation.error === false; }
if (/[\\\/]/.test(walletName.text)) {
errorMessageWalletName.text = qsTr("Wallet name is invalid") + translationManager.emptyString;
return false;
}
if (walletLocation.text !== "") {
var walletAlreadyExists = Wizard.walletPathExists(appWindow.accountsDir, walletLocation.text, walletName.text, isIOS, walletManager);
if (walletAlreadyExists) {
errorMessageWalletName.text = qsTr("Wallet already exists") + translationManager.emptyString;
return false;
}
}
errorMessageWalletName.text = "";
return true;
} }
labelText: qsTr("Wallet name") + translationManager.emptyString labelText: qsTr("Wallet name") + translationManager.emptyString
labelFontSize: 14 labelFontSize: 14
fontSize: 16
placeholderFontSize: 16 placeholderFontSize: 16
placeholderText: "-" placeholderText: ""
errorWhenEmpty: true
text: defaultAccountName text: defaultAccountName
onTextChanged: walletName.error = !walletName.verify(); onTextChanged: walletName.error = !walletName.verify();
@ -85,18 +101,35 @@ GridLayout {
id: walletLocation id: walletLocation
Layout.preferredWidth: grid.width/3 Layout.preferredWidth: grid.width/3
labelText: qsTr("Wallet location") + translationManager.emptyString function verify() {
labelFontSize: 14 if (walletLocation.text == "") {
placeholderText: "..." errorMessageWalletLocation.text = qsTr("Wallet location is empty") + translationManager.emptyString;
placeholderFontSize: 16 return false;
text: appWindow.accountsDir + "/" }
onTextChanged: { errorMessageWalletLocation.text = "";
walletLocation.error = walletLocation.text === ""; return true;
} }
labelText: qsTr("Wallet location") + translationManager.emptyString
labelFontSize: 14
fontSize: 16
placeholderText: ""
placeholderFontSize: 16
errorWhenEmpty: true
text: appWindow.accountsDir + "/"
onTextChanged: {
walletLocation.error = !walletLocation.verify();
walletName.error = !walletName.verify();
}
Component.onCompleted: walletLocation.error = !walletLocation.verify();
MoneroComponents.InlineButton { MoneroComponents.InlineButton {
small: true fontFamily: FontAwesome.fontFamilySolid
text: qsTr("Browse") + translationManager.emptyString fontStyleName: "Solid"
fontPixelSize: 18
text: FontAwesome.folderOpen
tooltip: qsTr("Browse") + translationManager.emptyString
tooltipLeft: true
onClicked: { onClicked: {
fileWalletDialog.folder = walletManager.localPathToUrl(walletLocation.text) fileWalletDialog.folder = walletManager.localPathToUrl(walletLocation.text)
fileWalletDialog.open() fileWalletDialog.open()
@ -119,4 +152,50 @@ GridLayout {
fileWalletDialog.visible = false; fileWalletDialog.visible = false;
} }
} }
RowLayout {
Layout.preferredWidth: grid.width/5
MoneroComponents.TextPlain {
visible: errorMessageWalletName.text != ""
font.family: FontAwesome.fontFamilySolid
font.styleName: "Solid"
font.pixelSize: 15
text: FontAwesome.exclamationCircle
color: "#FF0000"
themeTransition: false
}
MoneroComponents.TextPlain {
id: errorMessageWalletName
textFormat: Text.PlainText
font.family: MoneroComponents.Style.fontRegular.name
font.pixelSize: 14
color: "#FF0000"
themeTransition: false
}
}
RowLayout {
Layout.preferredWidth: grid.width/3
MoneroComponents.TextPlain {
visible: errorMessageWalletLocation.text != ""
font.family: FontAwesome.fontFamilySolid
font.styleName: "Solid"
font.pixelSize: 15
text: FontAwesome.exclamationCircle
color: "#FF0000"
themeTransition: false
}
MoneroComponents.TextPlain {
id: errorMessageWalletLocation
textFormat: Text.PlainText
font.family: MoneroComponents.Style.fontRegular.name
font.pixelSize: 14
color: "#FF0000"
themeTransition: false
}
}
} }