From 0fed21d6de9a0b1b12a3512ceb14b160c63f680c Mon Sep 17 00:00:00 2001 From: Sander Ferdinand <sa.ferdinand@gmail.com> Date: Sun, 5 Aug 2018 22:54:11 +0200 Subject: [PATCH] Added component WarningBox and added a warning to remote node page --- components/WarningBox.qml | 63 +++++++++++++++++++++++++++++++++ pages/Transfer.qml | 60 ++++++++----------------------- pages/settings/SettingsNode.qml | 24 +++---------- qml.qrc | 1 + 4 files changed, 82 insertions(+), 66 deletions(-) create mode 100644 components/WarningBox.qml diff --git a/components/WarningBox.qml b/components/WarningBox.qml new file mode 100644 index 00000000..9ea868eb --- /dev/null +++ b/components/WarningBox.qml @@ -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 + } + } + } +} diff --git a/pages/Transfer.qml b/pages/Transfer.qml index d7f009d8..c398eaf8 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -33,6 +33,7 @@ import moneroComponents.Clipboard 1.0 import moneroComponents.PendingTransaction 1.0 import moneroComponents.Wallet 1.0 import "../components" +import "../components" as MoneroComponents import "." 1.0 @@ -43,6 +44,7 @@ Rectangle { signal sweepUnmixableClicked() 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 bool showAdvanced: false @@ -122,47 +124,13 @@ Rectangle { spacing: 30 * scaleRatio - RowLayout{ - visible: warningText.text !== "" + RowLayout { + 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 { - id: warningText - Layout.topMargin: 12 * scaleRatio - Layout.preferredWidth: statusRect.width - 80 - 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); - } - } + MoneroComponents.WarningBox { + text: warningContent + onLinkActivated: { + appWindow.startDaemon(appWindow.persistentSettings.daemonFlags); } } } @@ -356,7 +324,7 @@ Rectangle { } // There is no warning box displayed - if(warningText.text !== ''){ + if(root.warningContent !== ''){ return false; } @@ -711,7 +679,7 @@ Rectangle { function updateStatus() { pageRoot.enabled = true; 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; } @@ -723,20 +691,20 @@ Rectangle { switch (currentWallet.connected()) { 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 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") break default: if(!appWindow.daemonSynced){ - warningText.text = qsTr("Waiting on daemon synchronization to finish") + root.warningContent = qsTr("Waiting on daemon synchronization to finish") } else { // everything OK, enable transfer page // Light wallet is always ready pageRoot.enabled = true; - warningText.text = ""; + root.warningContent = ""; } } } diff --git a/pages/settings/SettingsNode.qml b/pages/settings/SettingsNode.qml index d14ac4d0..b5bf6d48 100644 --- a/pages/settings/SettingsNode.qml +++ b/pages/settings/SettingsNode.qml @@ -271,26 +271,10 @@ Rectangle{ Layout.topMargin: 20 visible: !isMobile && persistentSettings.useRemoteNode - TextArea { - color: MoneroComponents.Style.dimmedFontColor - font.family: MoneroComponents.Style.fontRegular.name - font.pixelSize: 15 * scaleRatio - 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.WarningBox { + Layout.topMargin: 26 * scaleRatio + Layout.bottomMargin: 6 * 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 } MoneroComponents.RemoteNodeEdit { diff --git a/qml.qrc b/qml.qrc index 3b007013..5416a402 100644 --- a/qml.qrc +++ b/qml.qrc @@ -219,5 +219,6 @@ <file>images/settings_navbar_side.png</file> <file>images/settings_navbar_side_active.png</file> <file>images/settings_local.png</file> + <file>components/WarningBox.qml</file> </qresource> </RCC>