1
mirror of https://github.com/monero-project/monero-gui synced 2024-12-20 04:15:53 +01:00

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.
This commit is contained in:
moneromooo.monero 2016-11-07 12:02:27 +00:00
parent c9bb2f5718
commit 689f0415e7
5 changed files with 49 additions and 13 deletions

View File

@ -28,6 +28,7 @@
import QtQuick 2.2 import QtQuick 2.2
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import moneroComponents.Wallet 1.0
import "components" import "components"
Rectangle { Rectangle {
@ -356,7 +357,7 @@ Rectangle {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: (daemonProgress.visible)? daemonProgress.top : parent.bottom; anchors.bottom: (daemonProgress.visible)? daemonProgress.top : parent.bottom;
connected: false connected: Wallet.ConnectionStatus_Disconnected
} }
DaemonProgress { DaemonProgress {

View File

@ -27,10 +27,35 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import QtQuick 2.0 import QtQuick 2.0
import moneroComponents.Wallet 1.0
Row { Row {
id: item 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 { Item {
id: iconItem id: iconItem
@ -40,8 +65,7 @@ Row {
Image { Image {
anchors.centerIn: parent anchors.centerIn: parent
source: item.connected ? "../images/statusConnected.png" : source: getConnectionStatusImage(item.connected)
"../images/statusDisconnected.png"
} }
} }
@ -62,8 +86,8 @@ Row {
anchors.left: parent.left anchors.left: parent.left
font.family: "Arial" font.family: "Arial"
font.pixelSize: 18 font.pixelSize: 18
color: item.connected ? "#FF6C3B" : "#AAAAAA" color: getConnectionStatusColor(item.connected)
text: (item.connected ? qsTr("Connected") : qsTr("Disconnected")) + translationManager.emptyString text: getConnectionStatusString(item.connected) + translationManager.emptyString
} }
} }
} }

View File

@ -264,7 +264,7 @@ ApplicationWindow {
// Daemon fully synced // Daemon fully synced
// TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is 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) { if (transaction.status !== PendingTransaction.Status_Ok) {
console.error("Can't create transaction: ", transaction.errorString); console.error("Can't create transaction: ", transaction.errorString);
informationPopup.title = qsTr("Error") + translationManager.emptyString; 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.icon = StandardIcon.Critical
informationPopup.onCloseCallback = null informationPopup.onCloseCallback = null
informationPopup.open(); informationPopup.open();

View File

@ -86,9 +86,9 @@ Wallet::Status Wallet::status() const
return static_cast<Status>(m_walletImpl->status()); return static_cast<Status>(m_walletImpl->status());
} }
bool Wallet::connected() const Wallet::ConnectionStatus Wallet::connected() const
{ {
return m_walletImpl->connected(); return static_cast<ConnectionStatus>(m_walletImpl->connected());
} }
bool Wallet::synchronized() const bool Wallet::synchronized() const

View File

@ -22,7 +22,7 @@ class Wallet : public QObject
Q_PROPERTY(QString seed READ getSeed) Q_PROPERTY(QString seed READ getSeed)
Q_PROPERTY(QString seedLanguage READ getSeedLanguage) Q_PROPERTY(QString seedLanguage READ getSeedLanguage)
Q_PROPERTY(Status status READ status) 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(bool synchronized READ synchronized)
Q_PROPERTY(QString errorString READ errorString) Q_PROPERTY(QString errorString READ errorString)
Q_PROPERTY(QString address READ address) Q_PROPERTY(QString address READ address)
@ -42,6 +42,14 @@ public:
Q_ENUM(Status) 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 //! returns mnemonic seed
QString getSeed() const; QString getSeed() const;
@ -54,8 +62,8 @@ public:
//! returns last operation's status //! returns last operation's status
Status status() const; Status status() const;
//! returns true if wallet connected //! returns whether the wallet is connected, and version status
bool connected() const; ConnectionStatus connected() const;
//! returns true if wallet was ever synchronized //! returns true if wallet was ever synchronized
bool synchronized() const; bool synchronized() const;