Merge pull request #1956 from laanwj/2012_10_prerelease_warning

Show warning when using prerelease version
This commit is contained in:
Wladimir J. van der Laan 2012-10-25 05:52:55 -07:00
commit 7a1786084d
9 changed files with 339 additions and 295 deletions

View File

@ -2,7 +2,7 @@
* update (commit) version in sources
bitcoin-qt.pro
src/clientversion.h
src/clientversion.h (change CLIENT_VERSION_IS_RELEASE to true)
share/setup.nsi
doc/README*

View File

@ -11,6 +11,9 @@
#define CLIENT_VERSION_REVISION 99
#define CLIENT_VERSION_BUILD 0
// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE false
// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
#define STRINGIZE(X) DO_STRINGIZE(X)

View File

@ -2617,9 +2617,13 @@ string GetWarnings(string strFor)
int nPriority = 0;
string strStatusBar;
string strRPC;
if (GetBoolArg("-testsafemode"))
strRPC = "test";
if (!CLIENT_VERSION_IS_RELEASE)
strStatusBar = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
// Misc warnings like out of disk space and clock is wrong
if (strMiscWarning != "")
{

View File

@ -356,6 +356,7 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
// Report errors from network/worker thread
connect(clientModel, SIGNAL(error(QString,QString,bool)), this, SLOT(error(QString,QString,bool)));
overviewPage->setClientModel(clientModel);
rpcConsole->setClientModel(clientModel);
addressBookPage->setOptionsModel(clientModel->getOptionsModel());
receiveCoinsPage->setOptionsModel(clientModel->getOptionsModel());
@ -372,8 +373,7 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel)
// Put transaction list in tabs
transactionView->setModel(walletModel);
overviewPage->setModel(walletModel);
overviewPage->setWalletModel(walletModel);
addressBookPage->setModel(walletModel->getAddressTableModel());
receiveCoinsPage->setModel(walletModel->getAddressTableModel());
sendCoinsPage->setModel(walletModel);
@ -481,7 +481,6 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
return;
}
QString strStatusBarWarnings = clientModel->getStatusBarWarnings();
QString tooltip;
if(count < nTotalBlocks)
@ -489,35 +488,23 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
int nRemainingBlocks = nTotalBlocks - count;
float nPercentageDone = count / (nTotalBlocks * 0.01f);
if (strStatusBarWarnings.isEmpty())
{
progressBarLabel->setText(tr(clientModel->isImporting() ? "Importing blocks..." : "Synchronizing with network..."));
progressBarLabel->setVisible(true);
progressBar->setFormat(tr("~%n block(s) remaining", "", nRemainingBlocks));
progressBar->setMaximum(nTotalBlocks);
progressBar->setValue(count);
progressBar->setVisible(true);
}
tooltip = tr("Downloaded %1 of %2 blocks of transaction history (%3% done).").arg(count).arg(nTotalBlocks).arg(nPercentageDone, 0, 'f', 2);
}
else
{
if (strStatusBarWarnings.isEmpty())
progressBarLabel->setVisible(false);
progressBar->setVisible(false);
tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count);
}
// Override progressBarLabel text and hide progress bar, when we have warnings to display
if (!strStatusBarWarnings.isEmpty())
{
progressBarLabel->setText(strStatusBarWarnings);
progressBarLabel->setVisible(true);
progressBar->setVisible(false);
}
QDateTime lastBlockDate = clientModel->getLastBlockDate();
int secs = lastBlockDate.secsTo(QDateTime::currentDateTime());
QString text;

View File

@ -88,9 +88,7 @@ void ClientModel::updateAlert(const QString &hash, int status)
}
}
// Emit a numBlocksChanged when the status message changes,
// so that the view recomputes and updates the status bar.
emit numBlocksChanged(getNumBlocks(), getNumBlocksOfPeers());
emit alertsChanged(getStatusBarWarnings());
}
bool ClientModel::isTestNet() const
@ -133,6 +131,11 @@ QString ClientModel::formatBuildDate() const
return QString::fromStdString(CLIENT_DATE);
}
bool ClientModel::isReleaseVersion() const
{
return CLIENT_VERSION_IS_RELEASE;
}
QString ClientModel::clientName() const
{
return QString::fromStdString(CLIENT_NAME);

View File

@ -42,6 +42,7 @@ public:
QString formatFullVersion() const;
QString formatBuildDate() const;
bool isReleaseVersion() const;
QString clientName() const;
QString formatClientStartupTime() const;
@ -60,6 +61,7 @@ private:
signals:
void numConnectionsChanged(int count);
void numBlocksChanged(int count, int countOfPeers);
void alertsChanged(const QString &warnings);
//! Asynchronous error notification
void error(const QString &title, const QString &message, bool modal);

View File

@ -13,6 +13,25 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="topLayout">
<item>
<widget class="QLabel" name="labelAlerts">
<property name="visible">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop:0 #F0D0A0, stop:1 #F8D488); color:#000000
</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>3</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -293,6 +312,8 @@
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>

View File

@ -1,6 +1,7 @@
#include "overviewpage.h"
#include "ui_overviewpage.h"
#include "clientmodel.h"
#include "walletmodel.h"
#include "bitcoinunits.h"
#include "optionsmodel.h"
@ -92,6 +93,8 @@ public:
OverviewPage::OverviewPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::OverviewPage),
clientModel(0),
walletModel(0),
currentBalance(-1),
currentUnconfirmedBalance(-1),
currentImmatureBalance(-1),
@ -129,7 +132,7 @@ OverviewPage::~OverviewPage()
void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance)
{
int unit = model->getOptionsModel()->getDisplayUnit();
int unit = walletModel->getOptionsModel()->getDisplayUnit();
currentBalance = balance;
currentUnconfirmedBalance = unconfirmedBalance;
currentImmatureBalance = immatureBalance;
@ -149,9 +152,20 @@ void OverviewPage::setNumTransactions(int count)
ui->labelNumTransactions->setText(QLocale::system().toString(count));
}
void OverviewPage::setModel(WalletModel *model)
void OverviewPage::setClientModel(ClientModel *model)
{
this->model = model;
this->clientModel = model;
if(model)
{
// Show warning if this is a prerelease version
connect(model, SIGNAL(alertsChanged(QString)), this, SLOT(updateAlerts(QString)));
updateAlerts(model->getStatusBarWarnings());
}
}
void OverviewPage::setWalletModel(WalletModel *model)
{
this->walletModel = model;
if(model && model->getOptionsModel())
{
// Set up transaction list
@ -181,18 +195,24 @@ void OverviewPage::setModel(WalletModel *model)
void OverviewPage::updateDisplayUnit()
{
if(model && model->getOptionsModel())
if(walletModel && walletModel->getOptionsModel())
{
if(currentBalance != -1)
setBalance(currentBalance, currentUnconfirmedBalance, currentImmatureBalance);
// Update txdelegate->unit with the current unit
txdelegate->unit = model->getOptionsModel()->getDisplayUnit();
txdelegate->unit = walletModel->getOptionsModel()->getDisplayUnit();
ui->listTransactions->update();
}
}
void OverviewPage::updateAlerts(const QString &warnings)
{
this->ui->labelAlerts->setVisible(!warnings.isEmpty());
this->ui->labelAlerts->setText(warnings);
}
void OverviewPage::showOutOfSyncWarning(bool fShow)
{
ui->labelWalletStatus->setVisible(fShow);

View File

@ -10,6 +10,7 @@ QT_END_NAMESPACE
namespace Ui {
class OverviewPage;
}
class ClientModel;
class WalletModel;
class TxViewDelegate;
class TransactionFilterProxy;
@ -23,7 +24,8 @@ public:
explicit OverviewPage(QWidget *parent = 0);
~OverviewPage();
void setModel(WalletModel *model);
void setClientModel(ClientModel *clientModel);
void setWalletModel(WalletModel *walletModel);
void showOutOfSyncWarning(bool fShow);
public slots:
@ -35,7 +37,8 @@ signals:
private:
Ui::OverviewPage *ui;
WalletModel *model;
ClientModel *clientModel;
WalletModel *walletModel;
qint64 currentBalance;
qint64 currentUnconfirmedBalance;
qint64 currentImmatureBalance;
@ -46,6 +49,7 @@ private:
private slots:
void updateDisplayUnit();
void handleTransactionClicked(const QModelIndex &index);
void updateAlerts(const QString &warnings);
};
#endif // OVERVIEWPAGE_H