Added component WarningBox and added a warning to remote node page

pull/2/head
Sander Ferdinand 6 years ago
parent a9fa808dd1
commit 0fed21d6de

@ -0,0 +1,63 @@
import QtQuick 2.7
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.0
import "." as MoneroComponents
Rectangle {
id: root
property alias text: content.text
property int fontSize: 15 * scaleRatio
Layout.fillWidth: true
Layout.preferredHeight: warningLayout.height
color: "#09FFFFFF"
radius: 4
border.color: MoneroComponents.Style.inputBorderColorInActive
border.width: 1
signal linkActivated;
RowLayout {
id: warningLayout
spacing: 0
anchors.left: parent.left
anchors.right: parent.right
Image {
Layout.alignment: Qt.AlignVCenter
Layout.preferredHeight: 33
Layout.preferredWidth: 33
Layout.rightMargin: 14
Layout.leftMargin: 14
Layout.topMargin: 12
Layout.bottomMargin: 12
source: "../images/warning.png"
}
TextArea {
id: content
Layout.fillWidth: true
color: MoneroComponents.Style.defaultFontColor
font.family: MoneroComponents.Style.fontRegular.name
font.pixelSize: root.fontSize
horizontalAlignment: TextInput.AlignLeft
selectByMouse: false
textFormat: Text.RichText
wrapMode: Text.WordWrap
textMargin: 0
leftPadding: 0
topPadding: 6
readOnly: true
onLinkActivated: root.linkActivated();
// @TODO: Legacy. Remove after Qt 5.8.
// https://stackoverflow.com/questions/41990013
MouseArea {
anchors.fill: parent
enabled: false
}
}
}
}

@ -33,6 +33,7 @@ import moneroComponents.Clipboard 1.0
import moneroComponents.PendingTransaction 1.0 import moneroComponents.PendingTransaction 1.0
import moneroComponents.Wallet 1.0 import moneroComponents.Wallet 1.0
import "../components" import "../components"
import "../components" as MoneroComponents
import "." 1.0 import "." 1.0
@ -43,6 +44,7 @@ Rectangle {
signal sweepUnmixableClicked() signal sweepUnmixableClicked()
color: "transparent" color: "transparent"
property string warningContent: ""
property string startLinkText: qsTr("<style type='text/css'>a {text-decoration: none; color: #FF6C3C; font-size: 14px;}</style><font size='2'> (</font><a href='#'>Start daemon</a><font size='2'>)</font>") + translationManager.emptyString property string startLinkText: qsTr("<style type='text/css'>a {text-decoration: none; color: #FF6C3C; font-size: 14px;}</style><font size='2'> (</font><a href='#'>Start daemon</a><font size='2'>)</font>") + translationManager.emptyString
property bool showAdvanced: false property bool showAdvanced: false
@ -122,47 +124,13 @@ Rectangle {
spacing: 30 * scaleRatio spacing: 30 * scaleRatio
RowLayout{ RowLayout {
visible: warningText.text !== "" visible: root.warningContent !== ""
Rectangle {
id: statusRect
Layout.preferredHeight: warningText.height + 40
Layout.fillWidth: true
radius: 2
border.color: Style.inputBorderColorInActive
border.width: 1
color: "transparent"
GridLayout{
Layout.fillWidth: true
Layout.preferredHeight: warningText.height + 40
Image {
Layout.alignment: Qt.AlignVCenter
Layout.preferredHeight: 33
Layout.preferredWidth: 33
Layout.leftMargin: 10
Layout.topMargin: 10
source: "../images/warning.png"
}
Text { MoneroComponents.WarningBox {
id: warningText text: warningContent
Layout.topMargin: 12 * scaleRatio onLinkActivated: {
Layout.preferredWidth: statusRect.width - 80 appWindow.startDaemon(appWindow.persistentSettings.daemonFlags);
Layout.leftMargin: 6
text: qsTr("This page lets you sign/verify a message (or file contents) with your address.") + translationManager.emptyString
wrapMode: Text.Wrap
font.family: Style.fontRegular.name
font.pixelSize: 14 * scaleRatio
color: Style.defaultFontColor
textFormat: Text.RichText
onLinkActivated: {
appWindow.startDaemon(appWindow.persistentSettings.daemonFlags);
}
}
} }
} }
} }
@ -356,7 +324,7 @@ Rectangle {
} }
// There is no warning box displayed // There is no warning box displayed
if(warningText.text !== ''){ if(root.warningContent !== ''){
return false; return false;
} }
@ -711,7 +679,7 @@ Rectangle {
function updateStatus() { function updateStatus() {
pageRoot.enabled = true; pageRoot.enabled = true;
if(typeof currentWallet === "undefined") { if(typeof currentWallet === "undefined") {
warningText.text = qsTr("Wallet is not connected to daemon.") + root.startLinkText root.warningContent = qsTr("Wallet is not connected to daemon.") + root.startLinkText
return; return;
} }
@ -723,20 +691,20 @@ Rectangle {
switch (currentWallet.connected()) { switch (currentWallet.connected()) {
case Wallet.ConnectionStatus_Disconnected: case Wallet.ConnectionStatus_Disconnected:
warningText.text = qsTr("Wallet is not connected to daemon.") + root.startLinkText root.warningContent = qsTr("Wallet is not connected to daemon.") + root.startLinkText
break break
case Wallet.ConnectionStatus_WrongVersion: case Wallet.ConnectionStatus_WrongVersion:
warningText.text = qsTr("Connected daemon is not compatible with GUI. \n" + root.warningContent = qsTr("Connected daemon is not compatible with GUI. \n" +
"Please upgrade or connect to another daemon") "Please upgrade or connect to another daemon")
break break
default: default:
if(!appWindow.daemonSynced){ if(!appWindow.daemonSynced){
warningText.text = qsTr("Waiting on daemon synchronization to finish") root.warningContent = qsTr("Waiting on daemon synchronization to finish")
} else { } else {
// everything OK, enable transfer page // everything OK, enable transfer page
// Light wallet is always ready // Light wallet is always ready
pageRoot.enabled = true; pageRoot.enabled = true;
warningText.text = ""; root.warningContent = "";
} }
} }
} }

@ -271,26 +271,10 @@ Rectangle{
Layout.topMargin: 20 Layout.topMargin: 20
visible: !isMobile && persistentSettings.useRemoteNode visible: !isMobile && persistentSettings.useRemoteNode
TextArea { MoneroComponents.WarningBox {
color: MoneroComponents.Style.dimmedFontColor Layout.topMargin: 26 * scaleRatio
font.family: MoneroComponents.Style.fontRegular.name Layout.bottomMargin: 6 * scaleRatio
font.pixelSize: 15 * scaleRatio text: qsTr("To find a remote node, type 'Monero remote node' into your favorite search engine. Please ensure the node is run by a trusted third-party.") + translationManager.emptyString
horizontalAlignment: TextInput.AlignLeft
text: qsTr("To find a remote node, type 'Monero remote node' into your favorite search engine. Please ensure the node is run by a trusted third party. For more details, view this tutorial.") + translationManager.emptyString
width: parent.width - (remoteNodeIcon.width + remoteNodeIcon.anchors.leftMargin + anchors.leftMargin)
activeFocusOnPress: false
selectByMouse: false
wrapMode: Text.WordWrap
textMargin: 0
leftPadding: 0
topPadding: 0
// @TODO: Legacy. Remove after Qt 5.8.
// https://stackoverflow.com/questions/41990013
MouseArea {
anchors.fill: parent
enabled: false
}
} }
MoneroComponents.RemoteNodeEdit { MoneroComponents.RemoteNodeEdit {

@ -219,5 +219,6 @@
<file>images/settings_navbar_side.png</file> <file>images/settings_navbar_side.png</file>
<file>images/settings_navbar_side_active.png</file> <file>images/settings_navbar_side_active.png</file>
<file>images/settings_local.png</file> <file>images/settings_local.png</file>
<file>components/WarningBox.qml</file>
</qresource> </qresource>
</RCC> </RCC>