m_wallet->setSelectedInputs({});
});
- m_walletUnlockWidget = new WalletUnlockWidget(this);
+ m_walletUnlockWidget = new WalletUnlockWidget(this, m_wallet);
m_walletUnlockWidget->setWalletName(this->walletName());
ui->walletUnlockLayout->addWidget(m_walletUnlockWidget);
void MainWindow::initWalletContext() {
connect(m_wallet, &Wallet::balanceUpdated, this, &MainWindow::onBalanceUpdated);
- connect(m_wallet, &Wallet::synchronized, this, &MainWindow::onSynchronized); //TODO
- connect(m_wallet, &Wallet::blockchainSync, this, &MainWindow::onBlockchainSync);
- connect(m_wallet, &Wallet::refreshSync, this, &MainWindow::onRefreshSync);
+ connect(m_wallet, &Wallet::syncStatus, this, &MainWindow::onSyncStatus);
connect(m_wallet, &Wallet::transactionCreated, this, &MainWindow::onTransactionCreated);
connect(m_wallet, &Wallet::transactionCommitted, this, &MainWindow::onTransactionCommitted);
connect(m_wallet, &Wallet::initiateTransaction, this, &MainWindow::onInitiateTransaction);
}
}
-void MainWindow::onSynchronized() {
- this->updateNetStats();
- this->setStatusText("Synchronized");
-}
-
-void MainWindow::onBlockchainSync(int height, int target) {
- QString blocks = (target >= height) ? QString::number(target - height) : "?";
- QString heightText = QString("Blockchain sync: %1 blocks remaining").arg(blocks);
- this->setStatusText(heightText);
-}
-
-void MainWindow::onRefreshSync(int height, int target) {
- QString blocks = (target >= height) ? QString::number(target - height) : "?";
- QString heightText = QString("Wallet sync: %1 blocks remaining").arg(blocks);
- this->setStatusText(heightText);
+void MainWindow::onSyncStatus(quint64 height, quint64 target, bool daemonSync) {
+ if (height >= (target - 1)) {
+ this->updateNetStats();
+ }
+ this->setStatusText(Utils::formatSyncStatus(height, target, daemonSync));
}
void MainWindow::onConnectionStatusChanged(int status)
// libwalletqt
void onBalanceUpdated(quint64 balance, quint64 spendable);
- void onSynchronized();
+ void onSyncStatus(quint64 height, quint64 target, bool daemonSync);
void onWalletOpened();
void onConnectionStatusChanged(int status);
void onTransactionCreated(PendingTransaction *tx, const QVector<QString> &address);
void payToMany();
void showHistoryTab();
void skinChanged(const QString &skinName);
- void onBlockchainSync(int height, int target);
- void onRefreshSync(int height, int target);
void onViewOnBlockExplorer(const QString &txid);
void onResendTransaction(const QString &txid);
void importContacts();
quint64 walletHeight = blockChainHeight();
if (daemonHeight < targetHeight) {
- emit blockchainSync(daemonHeight, targetHeight);
+ emit syncStatus(daemonHeight, targetHeight, true);
}
else {
this->syncStatusUpdated(walletHeight, daemonHeight);
}
void Wallet::syncStatusUpdated(quint64 height, quint64 target) {
- if (height < (target - 1)) {
- emit refreshSync(height, target);
- }
- else {
+ if (height >= (target - 1)) {
+ // TODO: is this needed?
this->updateBalance();
- emit synchronized();
}
+
+ emit syncStatus(height, target, false);
}
void Wallet::onNewBlock(uint64_t walletHeight) {
void connectionStatusChanged(int status) const;
void currentSubaddressAccountChanged() const;
- void refreshSync(int height, int target);
- void blockchainSync(int height, int target);
- void synchronized();
+
+ void syncStatus(quint64 height, quint64 target, bool daemonSync = false);
+
void balanceUpdated(quint64 balance, quint64 spendable);
void keysCorrupted();
delete item;
}
}
+
+QString formatSyncStatus(quint64 height, quint64 target, bool daemonSync) {
+ if (height < (target - 1)) {
+ QString blocks = (target >= height) ? QString::number(target - height) : "?";
+ QString type = daemonSync ? "Blockchain" : "Wallet";
+ return QString("%1 sync: %2 blocks remaining").arg(type, blocks);
+ }
+
+ return "Synchronized";
+}
}
QWindow* windowForQObject(QObject* object);
void clearLayout(QLayout *layout, bool deleteWidgets = true);
+
+ QString formatSyncStatus(quint64 height, quint64 target, bool daemonSync = false);
}
#endif //FEATHER_UTILS_H
#include <QKeyEvent>
#include <QPushButton>
-WalletUnlockWidget::WalletUnlockWidget(QWidget *parent)
+#include "utils/Utils.h"
+
+WalletUnlockWidget::WalletUnlockWidget(QWidget *parent, Wallet *wallet)
: QWidget(parent)
, ui(new Ui::WalletUnlockWidget)
+ , m_wallet(wallet)
{
ui->setupUi(this);
this->reset();
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &WalletUnlockWidget::tryUnlock);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &WalletUnlockWidget::closeWallet);
+
+ ui->frame_sync->hide();
+ if (m_wallet) {
+ connect(m_wallet, &Wallet::syncStatus, [this](quint64 height, quint64 target, bool daemonSync){
+ ui->frame_sync->show();
+ ui->label_sync->setText(Utils::formatSyncStatus(height, target, daemonSync));
+ });
+ }
}
void WalletUnlockWidget::setWalletName(const QString &walletName) {
#include <QWidget>
#include <QMenu>
+#include "Wallet.h"
+
namespace Ui {
class WalletUnlockWidget;
}
Q_OBJECT
public:
- explicit WalletUnlockWidget(QWidget *parent = nullptr);
+ explicit WalletUnlockWidget(QWidget *parent, Wallet *wallet = nullptr);
~WalletUnlockWidget();
void setWalletName(const QString &walletName);
private:
QScopedPointer<Ui::WalletUnlockWidget> ui;
+ Wallet *m_wallet;
};
#endif //FEATHER_WALLETUNLOCKWIDGET_H
<x>0</x>
<y>0</y>
<width>918</width>
- <height>255</height>
+ <height>440</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
+ <property name="bottomMargin">
+ <number>2</number>
+ </property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<property name="font">
<font>
<pointsize>12</pointsize>
- <weight>75</weight>
<bold>true</bold>
</font>
</property>
</item>
</layout>
</item>
+ <item>
+ <widget class="QFrame" name="frame_sync">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_sync">
+ <property name="text">
+ <string>Sync:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>