mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 12:09:57 +00:00
Wallet: implement 'Connecting' status, add 'disconnected' property
This commit is contained in:
parent
6de8547047
commit
6940390a5e
7 changed files with 73 additions and 48 deletions
|
@ -667,7 +667,7 @@ Rectangle {
|
||||||
anchors.bottom: daemonProgressBar.top
|
anchors.bottom: daemonProgressBar.top
|
||||||
height: 48
|
height: 48
|
||||||
syncType: qsTr("Wallet") + translationManager.emptyString
|
syncType: qsTr("Wallet") + translationManager.emptyString
|
||||||
visible: networkStatus.connected
|
visible: !appWindow.disconnected
|
||||||
}
|
}
|
||||||
|
|
||||||
MoneroComponents.ProgressBar {
|
MoneroComponents.ProgressBar {
|
||||||
|
@ -676,7 +676,7 @@ Rectangle {
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
syncType: qsTr("Daemon") + translationManager.emptyString
|
syncType: qsTr("Daemon") + translationManager.emptyString
|
||||||
visible: networkStatus.connected
|
visible: !appWindow.disconnected
|
||||||
height: 62
|
height: 62
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,23 +39,25 @@ Rectangle {
|
||||||
property var connected: Wallet.ConnectionStatus_Disconnected
|
property var connected: Wallet.ConnectionStatus_Disconnected
|
||||||
|
|
||||||
function getConnectionStatusString(status) {
|
function getConnectionStatusString(status) {
|
||||||
if (status == Wallet.ConnectionStatus_Connected) {
|
switch (status) {
|
||||||
if(!appWindow.daemonSynced)
|
case Wallet.ConnectionStatus_Connected:
|
||||||
return qsTr("Synchronizing")
|
if (!appWindow.daemonSynced)
|
||||||
if(persistentSettings.useRemoteNode)
|
return qsTr("Synchronizing");
|
||||||
return qsTr("Remote node")
|
if (persistentSettings.useRemoteNode)
|
||||||
return appWindow.isMining ? qsTr("Connected") + " + " + qsTr("Mining"): qsTr("Connected")
|
return qsTr("Remote node");
|
||||||
}
|
return appWindow.isMining ? qsTr("Connected") + " + " + qsTr("Mining"): qsTr("Connected");
|
||||||
if (status == Wallet.ConnectionStatus_WrongVersion)
|
case Wallet.ConnectionStatus_WrongVersion:
|
||||||
return qsTr("Wrong version")
|
return qsTr("Wrong version");
|
||||||
if (status == Wallet.ConnectionStatus_Disconnected){
|
case Wallet.ConnectionStatus_Disconnected:
|
||||||
if(appWindow.walletMode <= 1){
|
if (appWindow.walletMode <= 1) {
|
||||||
return qsTr("Searching node") + translationManager.emptyString;
|
return qsTr("Searching node") + translationManager.emptyString;
|
||||||
}
|
}
|
||||||
return qsTr("Disconnected")
|
return qsTr("Disconnected");
|
||||||
|
case Wallet.ConnectionStatus_Connecting:
|
||||||
|
return qsTr("Connecting");
|
||||||
|
default:
|
||||||
|
return qsTr("Invalid connection status");
|
||||||
}
|
}
|
||||||
|
|
||||||
return qsTr("Invalid connection status")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
@ -159,7 +161,7 @@ Rectangle {
|
||||||
opacity: iconItem.opacity * (refreshMouseArea.visible ? 1 : 0.5)
|
opacity: iconItem.opacity * (refreshMouseArea.visible ? 1 : 0.5)
|
||||||
text: FontAwesome.random
|
text: FontAwesome.random
|
||||||
visible: (
|
visible: (
|
||||||
item.connected != Wallet.ConnectionStatus_Disconnected &&
|
!appWindow.disconnected &&
|
||||||
!persistentSettings.useRemoteNode &&
|
!persistentSettings.useRemoteNode &&
|
||||||
persistentSettings.bootstrapNodeAddress == "auto"
|
persistentSettings.bootstrapNodeAddress == "auto"
|
||||||
)
|
)
|
||||||
|
|
21
main.qml
21
main.qml
|
@ -57,6 +57,7 @@ ApplicationWindow {
|
||||||
property bool ctrlPressed: false
|
property bool ctrlPressed: false
|
||||||
property alias persistentSettings : persistentSettings
|
property alias persistentSettings : persistentSettings
|
||||||
property var currentWallet;
|
property var currentWallet;
|
||||||
|
property bool disconnected: currentWallet ? currentWallet.disconnected : false
|
||||||
property var transaction;
|
property var transaction;
|
||||||
property var transactionDescription;
|
property var transactionDescription;
|
||||||
property var walletPassword
|
property var walletPassword
|
||||||
|
@ -64,7 +65,7 @@ ApplicationWindow {
|
||||||
property bool daemonSynced: false
|
property bool daemonSynced: false
|
||||||
property bool walletSynced: false
|
property bool walletSynced: false
|
||||||
property int maxWindowHeight: (isAndroid || isIOS)? screenHeight : (screenHeight < 900)? 720 : 800;
|
property int maxWindowHeight: (isAndroid || isIOS)? screenHeight : (screenHeight < 900)? 720 : 800;
|
||||||
property bool daemonRunning: false
|
property bool daemonRunning: !persistentSettings.useRemoteNode && !disconnected
|
||||||
property alias toolTip: toolTip
|
property alias toolTip: toolTip
|
||||||
property string walletName
|
property string walletName
|
||||||
property bool viewOnly: false
|
property bool viewOnly: false
|
||||||
|
@ -474,19 +475,11 @@ ApplicationWindow {
|
||||||
middlePanel.updateStatus();
|
middlePanel.updateStatus();
|
||||||
leftPanel.networkStatus.connected = status
|
leftPanel.networkStatus.connected = status
|
||||||
|
|
||||||
// update local daemon status.
|
|
||||||
const isDisconnected = status === Wallet.ConnectionStatus_Disconnected;
|
|
||||||
if (!persistentSettings.useRemoteNode) {
|
|
||||||
daemonRunning = !isDisconnected;
|
|
||||||
} else {
|
|
||||||
daemonRunning = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update fee multiplier dropdown on transfer page
|
// Update fee multiplier dropdown on transfer page
|
||||||
middlePanel.transferView.updatePriorityDropdown();
|
middlePanel.transferView.updatePriorityDropdown();
|
||||||
|
|
||||||
// If wallet isnt connected, advanced wallet mode and no daemon is running - Ask
|
// If wallet isnt connected, advanced wallet mode and no daemon is running - Ask
|
||||||
if (appWindow.walletMode >= 2 && !persistentSettings.useRemoteNode && !walletInitialized && isDisconnected) {
|
if (appWindow.walletMode >= 2 && !persistentSettings.useRemoteNode && !walletInitialized && disconnected) {
|
||||||
daemonManager.runningAsync(persistentSettings.nettype, function(running) {
|
daemonManager.runningAsync(persistentSettings.nettype, function(running) {
|
||||||
if (!running) {
|
if (!running) {
|
||||||
daemonManagerDialog.open();
|
daemonManagerDialog.open();
|
||||||
|
@ -642,7 +635,7 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update wallet sync progress
|
// Update wallet sync progress
|
||||||
leftPanel.isSyncing = (currentWallet.connected() !== Wallet.ConnectionStatus_Disconnected) && !daemonSynced
|
leftPanel.isSyncing = !disconnected && !daemonSynced;
|
||||||
// Update transfer page status
|
// Update transfer page status
|
||||||
middlePanel.updateStatus();
|
middlePanel.updateStatus();
|
||||||
|
|
||||||
|
@ -692,7 +685,6 @@ ApplicationWindow {
|
||||||
|
|
||||||
function onDaemonStarted(){
|
function onDaemonStarted(){
|
||||||
console.log("daemon started");
|
console.log("daemon started");
|
||||||
daemonRunning = true;
|
|
||||||
hideProcessingSplash();
|
hideProcessingSplash();
|
||||||
currentWallet.connected(true);
|
currentWallet.connected(true);
|
||||||
// resume refresh
|
// resume refresh
|
||||||
|
@ -704,7 +696,6 @@ ApplicationWindow {
|
||||||
function onDaemonStopped(){
|
function onDaemonStopped(){
|
||||||
console.log("daemon stopped");
|
console.log("daemon stopped");
|
||||||
hideProcessingSplash();
|
hideProcessingSplash();
|
||||||
daemonRunning = false;
|
|
||||||
currentWallet.connected(true);
|
currentWallet.connected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,7 +704,6 @@ ApplicationWindow {
|
||||||
hideProcessingSplash();
|
hideProcessingSplash();
|
||||||
// resume refresh
|
// resume refresh
|
||||||
currentWallet.startRefresh();
|
currentWallet.startRefresh();
|
||||||
daemonRunning = false;
|
|
||||||
informationPopup.title = qsTr("Daemon failed to start") + translationManager.emptyString;
|
informationPopup.title = qsTr("Daemon failed to start") + translationManager.emptyString;
|
||||||
informationPopup.text = qsTr("Please check your wallet and daemon log for errors. You can also try to start %1 manually.").arg((isWindows)? "monerod.exe" : "monerod")
|
informationPopup.text = qsTr("Please check your wallet and daemon log for errors. You can also try to start %1 manually.").arg((isWindows)? "monerod.exe" : "monerod")
|
||||||
informationPopup.icon = StandardIcon.Critical
|
informationPopup.icon = StandardIcon.Critical
|
||||||
|
@ -1867,11 +1857,10 @@ ApplicationWindow {
|
||||||
const disconnectedTimeoutSec = 30;
|
const disconnectedTimeoutSec = 30;
|
||||||
const firstCheckDelaySec = 2;
|
const firstCheckDelaySec = 2;
|
||||||
|
|
||||||
const connected = leftPanel.networkStatus.connected !== Wallet.ConnectionStatus_Disconnected;
|
|
||||||
const firstRun = appWindow.disconnectedEpoch == 0;
|
const firstRun = appWindow.disconnectedEpoch == 0;
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
appWindow.disconnectedEpoch = Utils.epoch() + firstCheckDelaySec - disconnectedTimeoutSec;
|
appWindow.disconnectedEpoch = Utils.epoch() + firstCheckDelaySec - disconnectedTimeoutSec;
|
||||||
} else if (connected) {
|
} else if (!disconnected) {
|
||||||
appWindow.disconnectedEpoch = Utils.epoch();
|
appWindow.disconnectedEpoch = Utils.epoch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -717,6 +717,7 @@ Rectangle {
|
||||||
//pageRoot.enabled = false;
|
//pageRoot.enabled = false;
|
||||||
|
|
||||||
switch (currentWallet.connected()) {
|
switch (currentWallet.connected()) {
|
||||||
|
case Wallet.ConnectionStatus_Connecting:
|
||||||
case Wallet.ConnectionStatus_Disconnected:
|
case Wallet.ConnectionStatus_Disconnected:
|
||||||
root.warningContent = messageNotConnected;
|
root.warningContent = messageNotConnected;
|
||||||
break
|
break
|
||||||
|
|
|
@ -582,7 +582,7 @@ Item {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appWindow.currentWallet.connected() == Wallet.ConnectionStatus_Disconnected) {
|
if (appWindow.disconnected) {
|
||||||
root.trackingError = qsTr("WARNING: no connection to daemon");
|
root.trackingError = qsTr("WARNING: no connection to daemon");
|
||||||
trackingModel.clear();
|
trackingModel.clear();
|
||||||
return
|
return
|
||||||
|
|
|
@ -153,12 +153,14 @@ NetworkType::Type Wallet::nettype() const
|
||||||
void Wallet::updateConnectionStatusAsync()
|
void Wallet::updateConnectionStatusAsync()
|
||||||
{
|
{
|
||||||
m_scheduler.run([this] {
|
m_scheduler.run([this] {
|
||||||
|
if (m_connectionStatus == Wallet::ConnectionStatus_Disconnected)
|
||||||
|
{
|
||||||
|
setConnectionStatus(ConnectionStatus_Connecting);
|
||||||
|
}
|
||||||
ConnectionStatus newStatus = static_cast<ConnectionStatus>(m_walletImpl->connected());
|
ConnectionStatus newStatus = static_cast<ConnectionStatus>(m_walletImpl->connected());
|
||||||
if (newStatus != m_connectionStatus || !m_initialized) {
|
if (newStatus != m_connectionStatus || !m_initialized) {
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
m_connectionStatus = newStatus;
|
setConnectionStatus(newStatus);
|
||||||
qDebug() << "NEW STATUS " << newStatus;
|
|
||||||
emit connectionStatusChanged(newStatus);
|
|
||||||
}
|
}
|
||||||
// Release lock
|
// Release lock
|
||||||
m_connectionStatusRunning = false;
|
m_connectionStatusRunning = false;
|
||||||
|
@ -178,6 +180,31 @@ Wallet::ConnectionStatus Wallet::connected(bool forceCheck)
|
||||||
return m_connectionStatus;
|
return m_connectionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Wallet::disconnected() const
|
||||||
|
{
|
||||||
|
return m_disconnected;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Wallet::setConnectionStatus(ConnectionStatus value)
|
||||||
|
{
|
||||||
|
if (m_connectionStatus == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_connectionStatus = value;
|
||||||
|
emit connectionStatusChanged(m_connectionStatus);
|
||||||
|
|
||||||
|
bool disconnected = m_connectionStatus == Wallet::ConnectionStatus_Connecting ||
|
||||||
|
m_connectionStatus == Wallet::ConnectionStatus_Disconnected;
|
||||||
|
|
||||||
|
if (m_disconnected != disconnected)
|
||||||
|
{
|
||||||
|
m_disconnected = disconnected;
|
||||||
|
emit disconnectedChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Wallet::synchronized() const
|
bool Wallet::synchronized() const
|
||||||
{
|
{
|
||||||
return m_walletImpl->synchronized();
|
return m_walletImpl->synchronized();
|
||||||
|
@ -237,13 +264,7 @@ void Wallet::setDaemonLogin(const QString &daemonUsername, const QString &daemon
|
||||||
void Wallet::initAsync(const QString &daemonAddress, bool trustedDaemon, quint64 upperTransactionLimit, bool isRecovering, bool isRecoveringFromDevice, quint64 restoreHeight)
|
void Wallet::initAsync(const QString &daemonAddress, bool trustedDaemon, quint64 upperTransactionLimit, bool isRecovering, bool isRecoveringFromDevice, quint64 restoreHeight)
|
||||||
{
|
{
|
||||||
qDebug() << "initAsync: " + daemonAddress;
|
qDebug() << "initAsync: " + daemonAddress;
|
||||||
// Change status to disconnected if connected
|
const auto future = m_scheduler.run([this, daemonAddress, trustedDaemon, upperTransactionLimit, isRecovering, isRecoveringFromDevice, restoreHeight] {
|
||||||
if(m_connectionStatus != Wallet::ConnectionStatus_Disconnected) {
|
|
||||||
m_connectionStatus = Wallet::ConnectionStatus_Disconnected;
|
|
||||||
emit connectionStatusChanged(m_connectionStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_scheduler.run([this, daemonAddress, trustedDaemon, upperTransactionLimit, isRecovering, isRecoveringFromDevice, restoreHeight] {
|
|
||||||
bool success = init(daemonAddress, trustedDaemon, upperTransactionLimit, isRecovering, isRecoveringFromDevice, restoreHeight);
|
bool success = init(daemonAddress, trustedDaemon, upperTransactionLimit, isRecovering, isRecoveringFromDevice, restoreHeight);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
@ -253,6 +274,10 @@ void Wallet::initAsync(const QString &daemonAddress, bool trustedDaemon, quint64
|
||||||
m_walletImpl->startRefresh();
|
m_walletImpl->startRefresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (future.first)
|
||||||
|
{
|
||||||
|
setConnectionStatus(Wallet::ConnectionStatus_Connecting);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wallet::isHwBacked() const
|
bool Wallet::isHwBacked() const
|
||||||
|
@ -985,7 +1010,9 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
|
||||||
, m_daemonBlockChainHeightTtl(DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS)
|
, m_daemonBlockChainHeightTtl(DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS)
|
||||||
, m_daemonBlockChainTargetHeight(0)
|
, m_daemonBlockChainTargetHeight(0)
|
||||||
, m_daemonBlockChainTargetHeightTtl(DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS)
|
, m_daemonBlockChainTargetHeightTtl(DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS)
|
||||||
|
, m_connectionStatus(Wallet::ConnectionStatus_Disconnected)
|
||||||
, m_connectionStatusTtl(WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS)
|
, m_connectionStatusTtl(WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS)
|
||||||
|
, m_disconnected(true)
|
||||||
, m_currentSubaddressAccount(0)
|
, m_currentSubaddressAccount(0)
|
||||||
, m_subaddress(nullptr)
|
, m_subaddress(nullptr)
|
||||||
, m_subaddressModel(nullptr)
|
, m_subaddressModel(nullptr)
|
||||||
|
@ -999,7 +1026,6 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
|
||||||
m_subaddressAccount = new SubaddressAccount(m_walletImpl->subaddressAccount(), this);
|
m_subaddressAccount = new SubaddressAccount(m_walletImpl->subaddressAccount(), this);
|
||||||
m_walletListener = new WalletListenerImpl(this);
|
m_walletListener = new WalletListenerImpl(this);
|
||||||
m_walletImpl->setListener(m_walletListener);
|
m_walletImpl->setListener(m_walletListener);
|
||||||
m_connectionStatus = Wallet::ConnectionStatus_Disconnected;
|
|
||||||
m_currentSubaddressAccount = getCacheAttribute(ATTRIBUTE_SUBADDRESS_ACCOUNT).toUInt();
|
m_currentSubaddressAccount = getCacheAttribute(ATTRIBUTE_SUBADDRESS_ACCOUNT).toUInt();
|
||||||
// start cache timers
|
// start cache timers
|
||||||
m_connectionStatusTime.restart();
|
m_connectionStatusTime.restart();
|
||||||
|
|
|
@ -60,6 +60,7 @@ class SubaddressAccountModel;
|
||||||
class Wallet : public QObject
|
class Wallet : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool disconnected READ disconnected NOTIFY disconnectedChanged)
|
||||||
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)
|
||||||
|
@ -100,7 +101,8 @@ public:
|
||||||
enum ConnectionStatus {
|
enum ConnectionStatus {
|
||||||
ConnectionStatus_Connected = Monero::Wallet::ConnectionStatus_Connected,
|
ConnectionStatus_Connected = Monero::Wallet::ConnectionStatus_Connected,
|
||||||
ConnectionStatus_Disconnected = Monero::Wallet::ConnectionStatus_Disconnected,
|
ConnectionStatus_Disconnected = Monero::Wallet::ConnectionStatus_Disconnected,
|
||||||
ConnectionStatus_WrongVersion = Monero::Wallet::ConnectionStatus_WrongVersion
|
ConnectionStatus_WrongVersion = Monero::Wallet::ConnectionStatus_WrongVersion,
|
||||||
|
ConnectionStatus_Connecting
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_ENUM(ConnectionStatus)
|
Q_ENUM(ConnectionStatus)
|
||||||
|
@ -368,6 +370,7 @@ signals:
|
||||||
|
|
||||||
void connectionStatusChanged(int status) const;
|
void connectionStatusChanged(int status) const;
|
||||||
void currentSubaddressAccountChanged() const;
|
void currentSubaddressAccountChanged() const;
|
||||||
|
void disconnectedChanged() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Wallet(QObject * parent = nullptr);
|
Wallet(QObject * parent = nullptr);
|
||||||
|
@ -387,6 +390,9 @@ private:
|
||||||
//! initializes wallet
|
//! initializes wallet
|
||||||
bool init(const QString &daemonAddress, bool trustedDaemon, quint64 upperTransactionLimit, bool isRecovering, bool isRecoveringFromDevice, quint64 restoreHeight);
|
bool init(const QString &daemonAddress, bool trustedDaemon, quint64 upperTransactionLimit, bool isRecovering, bool isRecoveringFromDevice, quint64 restoreHeight);
|
||||||
|
|
||||||
|
bool disconnected() const;
|
||||||
|
void setConnectionStatus(ConnectionStatus value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class WalletManager;
|
friend class WalletManager;
|
||||||
friend class WalletListenerImpl;
|
friend class WalletListenerImpl;
|
||||||
|
@ -409,6 +415,7 @@ private:
|
||||||
mutable ConnectionStatus m_connectionStatus;
|
mutable ConnectionStatus m_connectionStatus;
|
||||||
int m_connectionStatusTtl;
|
int m_connectionStatusTtl;
|
||||||
mutable QTime m_connectionStatusTime;
|
mutable QTime m_connectionStatusTime;
|
||||||
|
bool m_disconnected;
|
||||||
mutable bool m_initialized;
|
mutable bool m_initialized;
|
||||||
uint32_t m_currentSubaddressAccount;
|
uint32_t m_currentSubaddressAccount;
|
||||||
Subaddress * m_subaddress;
|
Subaddress * m_subaddress;
|
||||||
|
|
Loading…
Reference in a new issue