Browse Source

#74, #42 - Show a warning if there are no peers/internet is off

recurring
adityapk 5 years ago
parent
commit
077b1896a8
  1. 13
      src/confirm.ui
  2. 22
      src/rpc.cpp
  3. 3
      src/sendtab.cpp
  4. 6
      src/settings.cpp
  5. 5
      src/settings.h

13
src/confirm.ui

@ -146,6 +146,19 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="nopeersWarning">
<property name="styleSheet">
<string notr="true">color: red;</string>
</property>
<property name="text">
<string>zcashd doesn't seem to have any peers. You might not be connected to the internet, so this Transaction might not work.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="syncingWarning">
<property name="styleSheet">

22
src/rpc.cpp

@ -531,10 +531,17 @@ void RPC::getInfoThenRefresh(bool force) {
refreshTransactions();
}
int connections = reply["connections"].get<json::number_integer_t>();
Settings::getInstance()->setPeers(connections);
if (connections == 0) {
// If there are no peers connected, then the internet is probably off or something else is wrong.
QIcon i = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning);
main->statusIcon->setPixmap(i.pixmap(16, 16));
}
// Get network sol/s
if (ezcashd) {
int conns = reply["connections"].get<json::number_integer_t>();
json payload = {
{"jsonrpc", "1.0"},
{"id", "someid"},
@ -544,7 +551,7 @@ void RPC::getInfoThenRefresh(bool force) {
conn->doRPCIgnoreError(payload, [=](const json& reply) {
qint64 solrate = reply.get<json::number_unsigned_t>();
ui->numconnections->setText(QString::number(conns));
ui->numconnections->setText(QString::number(connections));
ui->solrate->setText(QString::number(solrate) % " Sol/s");
});
}
@ -596,7 +603,14 @@ void RPC::getInfoThenRefresh(bool force) {
main->statusLabel->setText(statusText);
auto zecPrice = Settings::getUSDFormat(1);
QString tooltip = QObject::tr("Connected to zcashd");
QString tooltip;
if (connections > 0) {
tooltip = QObject::tr("Connected to zcashd");
}
else {
tooltip = QObject::tr("zcashd has no peer connections");
}
if (!zecPrice.isEmpty()) {
tooltip = "1 ZEC = " % zecPrice % "\n" % tooltip;
}

3
src/sendtab.cpp

@ -581,6 +581,9 @@ bool MainWindow::confirmTx(Tx tx) {
// Syncing warning
confirm.syncingWarning->setVisible(Settings::getInstance()->isSyncing());
// No peers warning
confirm.nopeersWarning->setVisible(Settings::getInstance()->getPeers() == 0);
// And FromAddress in the confirm dialog
confirm.sendFrom->setText(fnSplitAddressForWrap(tx.fromAddr));
QString tooltip = tr("Current balance : ") +

6
src/settings.cpp

@ -134,7 +134,13 @@ void Settings::setSaveZtxs(bool save) {
QSettings().setValue("options/savesenttx", save);
}
void Settings::setPeers(int peers) {
_peerConnections = peers;
}
int Settings::getPeers() {
return _peerConnections;
}
//=================================
// Static Stuff
//=================================

5
src/settings.h

@ -53,6 +53,9 @@ public:
void setZECPrice(double p) { zecPrice = p; }
double getZECPrice();
void setPeers(int peers);
int getPeers();
// Static stuff
static const QString txidStatusMessage;
@ -98,7 +101,7 @@ private:
bool _isSyncing = false;
int _blockNumber = 0;
bool _useEmbedded = false;
int _peerConnections = 0;
double zecPrice = 0.0;
};

Loading…
Cancel
Save