Merge pull request 'History: add sync notice' (#271) from tobtoht/feather:history_sync_notice into master

Reviewed-on: https://git.wownero.com/feather/feather/pulls/271
This commit is contained in:
tobtoht 2021-01-21 00:23:16 +00:00
commit 58c9c1a006
8 changed files with 103 additions and 4 deletions

View file

@ -316,6 +316,7 @@ void AppContext::onWalletOpened(Wallet *wallet) {
return; return;
} }
this->refreshed = false;
this->currentWallet = wallet; this->currentWallet = wallet;
this->walletPath = this->currentWallet->path() + ".keys"; this->walletPath = this->currentWallet->path() + ".keys";
this->walletViewOnly = this->currentWallet->viewOnly(); this->walletViewOnly = this->currentWallet->viewOnly();
@ -716,6 +717,7 @@ void AppContext::onWalletRefreshed(bool success) {
if (!this->refreshed) { if (!this->refreshed) {
refreshModels(); refreshModels();
this->refreshed = true; this->refreshed = true;
emit walletRefreshed();
// store wallet immediately upon finishing synchronization // store wallet immediately upon finishing synchronization
this->currentWallet->store(); this->currentWallet->store();
} }

View file

@ -150,7 +150,7 @@ signals:
void refreshSync(int height, int target); void refreshSync(int height, int target);
void synchronized(); void synchronized();
void blockHeightWSUpdated(QMap<QString, int> heights); void blockHeightWSUpdated(QMap<QString, int> heights);
void walletSynchronized(); void walletRefreshed();
void walletOpened(); void walletOpened();
void walletCreatedError(const QString &msg); void walletCreatedError(const QString &msg);
void walletCreated(Wallet *wallet); void walletCreated(Wallet *wallet);

View file

@ -4,6 +4,7 @@
#include "historywidget.h" #include "historywidget.h"
#include "ui_historywidget.h" #include "ui_historywidget.h"
#include "dialog/transactioninfodialog.h" #include "dialog/transactioninfodialog.h"
#include <QMessageBox>
HistoryWidget::HistoryWidget(QWidget *parent) HistoryWidget::HistoryWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
@ -33,6 +34,11 @@ HistoryWidget::HistoryWidget(QWidget *parent)
} }
}); });
connect(ui->btn_moreInfo, &QPushButton::clicked, this, &HistoryWidget::showSyncNoticeMsg);
connect(ui->btn_close, &QPushButton::clicked, [this]{
config()->set(Config::showHistorySyncNotice, false);
ui->syncNotice->hide();
});
} }
void HistoryWidget::showContextMenu(const QPoint &point) { void HistoryWidget::showContextMenu(const QPoint &point) {
@ -143,6 +149,23 @@ void HistoryWidget::copy(copyField field) {
Utils::copyToClipboard(data); Utils::copyToClipboard(data);
} }
void HistoryWidget::onWalletOpened() {
ui->syncNotice->setVisible(config()->get(Config::showHistorySyncNotice).toBool());
}
void HistoryWidget::onWalletRefreshed() {
ui->syncNotice->hide();
}
void HistoryWidget::showSyncNoticeMsg() {
QMessageBox::information(this, "Sync notice",
"The wallet needs to scan the blockchain to find your transactions. "
"The status bar will show you how many blocks are still remaining.\n"
"\n"
"The history page will update once synchronization has finished. "
"To update the history page during synchronization press Ctrl+R.");
}
HistoryWidget::~HistoryWidget() { HistoryWidget::~HistoryWidget() {
delete ui; delete ui;
} }

View file

@ -28,6 +28,8 @@ public:
public slots: public slots:
void setSearchText(const QString &text); void setSearchText(const QString &text);
void resetModel(); void resetModel();
void onWalletRefreshed();
void onWalletOpened();
signals: signals:
void viewOnBlockExplorer(QString txid); void viewOnBlockExplorer(QString txid);
@ -48,6 +50,7 @@ private:
void copy(copyField field); void copy(copyField field);
void showContextMenu(const QPoint &point); void showContextMenu(const QPoint &point);
void showSyncNoticeMsg();
Ui::HistoryWidget *ui; Ui::HistoryWidget *ui;
QMenu *m_contextMenu; QMenu *m_contextMenu;

View file

@ -33,6 +33,73 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QFrame" name="syncNotice">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>History may appear incomplete during synchronization.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btn_moreInfo">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>More info</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_close">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Close</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QTreeView" name="history"> <widget class="QTreeView" name="history">
<property name="rootIsDecorated"> <property name="rootIsDecorated">

View file

@ -292,6 +292,8 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
// History // History
connect(ui->historyWidget, &HistoryWidget::viewOnBlockExplorer, this, &MainWindow::onViewOnBlockExplorer); connect(ui->historyWidget, &HistoryWidget::viewOnBlockExplorer, this, &MainWindow::onViewOnBlockExplorer);
connect(ui->historyWidget, &HistoryWidget::resendTransaction, this, &MainWindow::onResendTransaction); connect(ui->historyWidget, &HistoryWidget::resendTransaction, this, &MainWindow::onResendTransaction);
connect(m_ctx, &AppContext::walletRefreshed, ui->historyWidget, &HistoryWidget::onWalletRefreshed);
connect(m_ctx, &AppContext::walletOpened, ui->historyWidget, &HistoryWidget::onWalletOpened);
// Contacts // Contacts
connect(ui->contactWidget, &ContactsWidget::fillAddress, ui->sendWidget, &SendWidget::fillAddress); connect(ui->contactWidget, &ContactsWidget::fillAddress, ui->sendWidget, &SendWidget::fillAddress);
@ -693,7 +695,7 @@ void MainWindow::onBlockchainSync(int height, int target) {
void MainWindow::onRefreshSync(int height, int target) { void MainWindow::onRefreshSync(int height, int target) {
QString blocks = (target >= height) ? QString::number(target - height) : "?"; QString blocks = (target >= height) ? QString::number(target - height) : "?";
QString heightText = QString("Wallet refresh: %1 blocks remaining").arg(blocks); QString heightText = QString("Wallet sync: %1 blocks remaining").arg(blocks);
this->setStatusText(heightText); this->setStatusText(heightText);
} }

View file

@ -45,7 +45,8 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
{Config::windowState, {QS("windowState"), {}}}, {Config::windowState, {QS("windowState"), {}}},
{Config::firstRun,{QS("firstRun"), false}}, {Config::firstRun,{QS("firstRun"), false}},
{Config::hideBalance, {QS("hideBalance"), false}}, {Config::hideBalance, {QS("hideBalance"), false}},
{Config::redditFrontend, {QS("redditFrontend"), "old.reddit.com"}} {Config::redditFrontend, {QS("redditFrontend"), "old.reddit.com"}},
{Config::showHistorySyncNotice, {QS("showHistorySyncNotice"), true}}
}; };

View file

@ -47,7 +47,8 @@ public:
windowState, windowState,
firstRun, firstRun,
hideBalance, hideBalance,
redditFrontend redditFrontend,
showHistorySyncNotice
}; };
~Config() override; ~Config() override;