From 689f0415e7e0d47b765b18d370fc6c2cf1edb990 Mon Sep 17 00:00:00 2001 From: "moneromooo.monero" Date: Mon, 7 Nov 2016 12:02:27 +0000 Subject: [PATCH] Report when the GUI is connected to a daemon with mismatched version This will cause various errors confusing to the user, as they stem for the daemon returning replies with missing information, etc. --- LeftPanel.qml | 3 ++- components/NetworkStatusItem.qml | 34 +++++++++++++++++++++++++++----- main.qml | 7 +++++-- src/libwalletqt/Wallet.cpp | 4 ++-- src/libwalletqt/Wallet.h | 14 ++++++++++--- 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/LeftPanel.qml b/LeftPanel.qml index 6aeacdfd..cf2b3722 100644 --- a/LeftPanel.qml +++ b/LeftPanel.qml @@ -28,6 +28,7 @@ import QtQuick 2.2 import QtGraphicalEffects 1.0 +import moneroComponents.Wallet 1.0 import "components" Rectangle { @@ -356,7 +357,7 @@ Rectangle { anchors.left: parent.left anchors.right: parent.right anchors.bottom: (daemonProgress.visible)? daemonProgress.top : parent.bottom; - connected: false + connected: Wallet.ConnectionStatus_Disconnected } DaemonProgress { diff --git a/components/NetworkStatusItem.qml b/components/NetworkStatusItem.qml index 6fb1d2eb..6667b974 100644 --- a/components/NetworkStatusItem.qml +++ b/components/NetworkStatusItem.qml @@ -27,10 +27,35 @@ // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import QtQuick 2.0 +import moneroComponents.Wallet 1.0 Row { id: item - property bool connected: false + property var connected: Wallet.ConnectionStatus_Disconnected + + function getConnectionStatusImage(status) { + if (status == Wallet.ConnectionStatus_Connected) + return "../images/statusConnected.png" + else + return "../images/statusDisconnected.png" + } + + function getConnectionStatusColor(status) { + if (status == Wallet.ConnectionStatus_Connected) + return "#FF6C3B" + else + return "#AAAAAA" + } + + function getConnectionStatusString(status) { + if (status == Wallet.ConnectionStatus_Connected) + return qsTr("Connected") + if (status == Wallet.ConnectionStatus_WrongVersion) + return qsTr("Wrong version") + if (status == Wallet.ConnectionStatus_Disconnected) + return qsTr("Disconnected") + return qsTr("Invalid connection status") + } Item { id: iconItem @@ -40,8 +65,7 @@ Row { Image { anchors.centerIn: parent - source: item.connected ? "../images/statusConnected.png" : - "../images/statusDisconnected.png" + source: getConnectionStatusImage(item.connected) } } @@ -62,8 +86,8 @@ Row { anchors.left: parent.left font.family: "Arial" font.pixelSize: 18 - color: item.connected ? "#FF6C3B" : "#AAAAAA" - text: (item.connected ? qsTr("Connected") : qsTr("Disconnected")) + translationManager.emptyString + color: getConnectionStatusColor(item.connected) + text: getConnectionStatusString(item.connected) + translationManager.emptyString } } } diff --git a/main.qml b/main.qml index 7b023c87..ff08d31f 100644 --- a/main.qml +++ b/main.qml @@ -264,7 +264,7 @@ ApplicationWindow { // Daemon fully synced // TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced - daemonSynced = (currentWallet.connected && dCurrentBlock >= dTargetBlock) + daemonSynced = (currentWallet.connected != Wallet.ConnectionStatus_Disconnected && dCurrentBlock >= dTargetBlock) @@ -387,7 +387,10 @@ ApplicationWindow { if (transaction.status !== PendingTransaction.Status_Ok) { console.error("Can't create transaction: ", transaction.errorString); informationPopup.title = qsTr("Error") + translationManager.emptyString; - informationPopup.text = qsTr("Can't create transaction: ") + transaction.errorString + if (currentWallet.connected == Wallet.ConnectionStatus_WrongVersion) + informationPopup.text = qsTr("Can't create transaction: Wrong daemon version: ") + transaction.errorString + else + informationPopup.text = qsTr("Can't create transaction: ") + transaction.errorString informationPopup.icon = StandardIcon.Critical informationPopup.onCloseCallback = null informationPopup.open(); diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index ef98828c..2def00e7 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -86,9 +86,9 @@ Wallet::Status Wallet::status() const return static_cast(m_walletImpl->status()); } -bool Wallet::connected() const +Wallet::ConnectionStatus Wallet::connected() const { - return m_walletImpl->connected(); + return static_cast(m_walletImpl->connected()); } bool Wallet::synchronized() const diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 303dfd24..e74745bf 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -22,7 +22,7 @@ class Wallet : public QObject Q_PROPERTY(QString seed READ getSeed) Q_PROPERTY(QString seedLanguage READ getSeedLanguage) Q_PROPERTY(Status status READ status) - Q_PROPERTY(bool connected READ connected) + Q_PROPERTY(ConnectionStatus connected READ connected) Q_PROPERTY(bool synchronized READ synchronized) Q_PROPERTY(QString errorString READ errorString) Q_PROPERTY(QString address READ address) @@ -42,6 +42,14 @@ public: Q_ENUM(Status) + enum ConnectionStatus { + ConnectionStatus_Connected = Bitmonero::Wallet::ConnectionStatus_Connected, + ConnectionStatus_Disconnected = Bitmonero::Wallet::ConnectionStatus_Disconnected, + ConnectionStatus_WrongVersion = Bitmonero::Wallet::ConnectionStatus_WrongVersion + }; + + Q_ENUM(ConnectionStatus) + //! returns mnemonic seed QString getSeed() const; @@ -54,8 +62,8 @@ public: //! returns last operation's status Status status() const; - //! returns true if wallet connected - bool connected() const; + //! returns whether the wallet is connected, and version status + ConnectionStatus connected() const; //! returns true if wallet was ever synchronized bool synchronized() const;