Skip to content

Commit

Permalink
wallet sync signal connected to dashboard warning, askkpassphrasedial…
Browse files Browse the repository at this point in the history
…og title changes on every action.
  • Loading branch information
furszy committed Aug 28, 2019
1 parent 4eb1ee5 commit 1605e65
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 37 deletions.
24 changes: 19 additions & 5 deletions src/qt/askpassphrasedialog.cpp
Expand Up @@ -14,6 +14,7 @@
#include "qt/pivx/qtutils.h"
#include "qt/pivx/loadingdialog.h"
#include "qt/pivx/PIVXGUI.h"
#include <QDebug>

#include <QKeyEvent>
#include <QMessageBox>
Expand Down Expand Up @@ -123,24 +124,32 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel

this->model = model;

QString title;
switch (mode) {
case Mode::Encrypt: // Ask passphrase x2
ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>."));
ui->passLabel1->hide();
ui->passEdit1->hide();
ui->layoutEdit->hide();
setWindowTitle(tr("Encrypt wallet"));
title = tr("Encrypt wallet");
break;
case Mode::UnlockAnonymize:
//ui->anonymizationCheckBox->show();
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->layoutEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
title = tr("Unlock wallet\nfor staking");
break;
case Mode::Unlock: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->layoutEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Unlock wallet"));
title = tr("Unlock wallet");
break;
case Mode::Decrypt: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet."));
Expand All @@ -149,15 +158,17 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
ui->layoutEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Decrypt wallet"));
title = tr("Decrypt wallet");
break;
case Mode::ChangePass: // Ask old passphrase + new passphrase x2
setWindowTitle(tr("Change passphrase"));
title = tr("Change passphrase");
btnWatch2->hide();
ui->warningLabel->setText(tr("Enter the old and new passphrase to the wallet."));
break;
}

ui->labelTitle->setText(title);

textChanged();
connect(btnWatch2, SIGNAL(clicked()), this, SLOT(onWatch2Clicked()));
connect(btnWatch, SIGNAL(clicked()), this, SLOT(onWatchClicked()));
Expand Down Expand Up @@ -340,6 +351,7 @@ bool AskPassphraseDialog::eventFilter(QObject* object, QEvent* event)
void AskPassphraseDialog::run(int type){
if (type == 1) {
if (!newpassCache.empty()) {
qDebug() << __func__ << ": starting wallet encryption";
if (model->setWalletEncrypted(true, newpassCache)) {
QMessageBox::warning(this, tr("Wallet encrypted"),
"<qt>" +
Expand All @@ -359,8 +371,10 @@ void AskPassphraseDialog::run(int type){
}
newpassCache = "";
QDialog::accept(); // Success
qDebug() << __func__ << ": encryption finished";
} else {
// no pass..
qDebug() << __func__ << ": no pass for encryption";
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/PIVXGUI.cpp
Expand Up @@ -221,13 +221,13 @@ void PIVXGUI::handleRestart(QStringList args){
void PIVXGUI::setClientModel(ClientModel* clientModel) {
this->clientModel = clientModel;
if(this->clientModel) {
// TODO: Complete me..
topBar->setClientModel(clientModel);
sendWidget->setClientModel(clientModel);
settingsWidget->setClientModel(clientModel);

// Receive and report messages from client model
connect(clientModel, SIGNAL(message(QString, QString, unsigned int)), this, SLOT(message(QString, QString, unsigned int)));
connect(topBar, SIGNAL(walletSynced()), dashboard, SLOT(walletSynced()));

// Get restart command-line parameters and handle restart
connect(settingsWidget, &SettingsWidget::handleRestart, [this](QStringList arg){handleRestart(arg);});
Expand Down
4 changes: 4 additions & 0 deletions src/qt/pivx/dashboardwidget.cpp
Expand Up @@ -339,6 +339,10 @@ void DashboardWidget::onSortChanged(const QString& value){
}
}

void DashboardWidget::walletSynced(bool isSync){
ui->layoutWarning->setVisible(!isSync);
}

void DashboardWidget::changeTheme(bool isLightTheme, QString& theme){
static_cast<TxViewHolder*>(this->txViewDelegate->getRowFactory())->isLightTheme = isLightTheme;
this->changeChartColors();
Expand Down
3 changes: 3 additions & 0 deletions src/qt/pivx/dashboardwidget.h
Expand Up @@ -56,6 +56,9 @@ class DashboardWidget : public PWidget

void loadWalletModel() override ;
void loadChart();

public slots:
void walletSynced(bool isSync);
private slots:
void handleTransactionClicked(const QModelIndex &index);

Expand Down
16 changes: 8 additions & 8 deletions src/qt/pivx/settings/forms/settingsfaqwidget.ui
Expand Up @@ -36,13 +36,13 @@
<number>36</number>
</property>
<property name="topMargin">
<number>50</number>
<number>44</number>
</property>
<property name="rightMargin">
<number>36</number>
</property>
<property name="bottomMargin">
<number>50</number>
<number>44</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
Expand Down Expand Up @@ -429,6 +429,9 @@
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollAreaFaq">
<property name="styleSheet">
Expand All @@ -452,9 +455,9 @@ background:transparent;
<property name="geometry">
<rect>
<x>0</x>
<y>-367</y>
<width>622</width>
<height>1948</height>
<y>0</y>
<width>628</width>
<height>1820</height>
</rect>
</property>
<property name="autoFillBackground">
Expand Down Expand Up @@ -1215,9 +1218,6 @@ If you want more zPIV you will need to mint your balance in the “Privacy” ta
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7"/>
</item>
</layout>
</widget>
</item>
Expand Down
29 changes: 8 additions & 21 deletions src/qt/pivx/topbar.cpp
Expand Up @@ -78,9 +78,7 @@ TopBar::TopBar(PIVXGUI* _mainWindow, QWidget *parent) :
progressBar->raise();
progressBar->move(0, 34);


// New button

ui->pushButtonPeers->setButtonClassStyle("cssClass", "btn-check-peers");
ui->pushButtonPeers->setButtonText("No Online Peers");

Expand Down Expand Up @@ -126,12 +124,7 @@ TopBar::TopBar(PIVXGUI* _mainWindow, QWidget *parent) :

connect(ui->pushButtonQR, SIGNAL(clicked()), this, SLOT(onBtnReceiveClicked()));
connect(ui->btnQr, SIGNAL(clicked()), this, SLOT(onBtnReceiveClicked()));


connect(ui->pushButtonLock, SIGNAL(Mouse_Pressed()), this, SLOT(onBtnLockClicked()));
//connect(ui->pushButtonLock, SIGNAL(Mouse_Hover()), this, SLOT(onBtnLockHover()));
//connect(ui->pushButtonLock, SIGNAL(Mouse_HoverLeave()), this, SLOT(onBtnLockHoverLeave()));

connect(ui->pushButtonTheme, SIGNAL(Mouse_Pressed()), this, SLOT(onThemeClicked()));
}

Expand Down Expand Up @@ -234,7 +227,7 @@ void TopBar::lockDropdownClicked(const StateClicked& state){
dlg->adjustSize();
openDialogWithOpaqueBackgroundY(dlg, window);
if (this->walletModel->getEncryptionStatus() == WalletModel::UnlockedForAnonymizationOnly) {
ui->pushButtonLock->setButtonText("Wallet Unlocked for staking");
ui->pushButtonLock->setButtonText(tr("Wallet Unlocked for staking"));
ui->pushButtonLock->setButtonClassStyle("cssClass", "btn-check-status-staking", true);
}
break;
Expand Down Expand Up @@ -315,16 +308,6 @@ void TopBar::loadClientModel(){
connect(timerStakingIcon, SIGNAL(timeout()), this, SLOT(updateStakingStatus()));
timerStakingIcon->start(50000);
updateStakingStatus();

// Show progress dialog
connect(clientModel, SIGNAL(showProgress(QString, int)), this, SLOT(showProgress(QString, int)));

}
}

void TopBar::showProgress(const QString& title, int nProgress){
if (nProgress > 0 && nProgress <= 100) {
progressBar->setValue(nProgress);
}
}

Expand Down Expand Up @@ -395,17 +378,19 @@ void TopBar::setNumBlocks(int count) {
// Node synced
// TODO: Set synced icon to pushButtonSync here..
ui->pushButtonSync->setButtonText(tr("Synchronized"));
emit walletSynced(true);
return;
}else{

// TODO: Show out of sync warning

int nAttempt = masternodeSync.RequestedMasternodeAttempt < MASTERNODE_SYNC_THRESHOLD ?
masternodeSync.RequestedMasternodeAttempt + 1 :
MASTERNODE_SYNC_THRESHOLD;
int progress = nAttempt + (masternodeSync.RequestedMasternodeAssets - 1) * MASTERNODE_SYNC_THRESHOLD;
if(progress >= 0){
text = std::string("Synchronizing additional data: %p%", progress);
progressBar->setMaximum(4 * MASTERNODE_SYNC_THRESHOLD);
progressBar->setValue(progress);
needState = false;
}
}
Expand Down Expand Up @@ -437,15 +422,17 @@ void TopBar::setNumBlocks(int count) {
QString timeBehind(" behind. Scanning block ");
QString str = timeBehindText + timeBehind + QString::number(count);
text = str.toUtf8().constData();

progressBar->setMaximum(1000000000);
progressBar->setValue(clientModel->getVerificationProgress() * 1000000000.0 + 0.5);
}

if(text.empty()){
text = "No block source available..";
}

ui->pushButtonSync->setButtonText(tr(text.data()));


emit walletSynced(false);
}

void TopBar::loadWalletModel(){
Expand Down
3 changes: 1 addition & 2 deletions src/qt/pivx/topbar.h
Expand Up @@ -42,11 +42,10 @@ public slots:
void setNumBlocks(int count);
void updateAutoMintStatus();
void updateStakingStatus();
/** Show progress dialog e.g. for verifychain */
void showProgress(const QString& title, int nProgress);

signals:
void changeTheme(bool isLight);
void walletSynced(bool isSync);
private slots:
void onBtnReceiveClicked();
void onThemeClicked();
Expand Down

0 comments on commit 1605e65

Please sign in to comment.