Merge pull request #10 from CryptoCanary/master

Qt5 ready.
This commit is contained in:
cygnusxi 2017-05-10 04:13:21 -04:00 committed by GitHub
commit 4f82c05182
22 changed files with 47 additions and 36 deletions

View File

@ -4,6 +4,12 @@ VERSION = 1.0.0
INCLUDEPATH += src src/json src/qt INCLUDEPATH += src src/json src/qt
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN __NO_SYSTEM_INCLUDES DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN __NO_SYSTEM_INCLUDES
CONFIG += no_include_pwd CONFIG += no_include_pwd
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4) {
QT += widgets printsupport
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
}
#uncomment the following section to enable building on windows: #uncomment the following section to enable building on windows:
#windows:LIBS += -lshlwapi #windows:LIBS += -lshlwapi

View File

@ -389,7 +389,7 @@ int ReadHTTPStatus(std::basic_istream<char>& stream, int &proto)
int ReadHTTPHeader(std::basic_istream<char>& stream, map<string, string>& mapHeadersRet) int ReadHTTPHeader(std::basic_istream<char>& stream, map<string, string>& mapHeadersRet)
{ {
int nLen = 0; int nLen = 0;
loop while (true)
{ {
string str; string str;
std::getline(stream, str); std::getline(stream, str);
@ -939,7 +939,7 @@ void ThreadRPCServer3(void* parg)
AcceptedConnection *conn = (AcceptedConnection *) parg; AcceptedConnection *conn = (AcceptedConnection *) parg;
bool fRun = true; bool fRun = true;
loop { while (true) {
if (fShutdown || !fRun) if (fShutdown || !fRun)
{ {
conn->close(); conn->close();

View File

@ -802,7 +802,7 @@ bool CTxDB::LoadBlockIndexGuts()
// Load mapBlockIndex // Load mapBlockIndex
unsigned int fFlags = DB_SET_RANGE; unsigned int fFlags = DB_SET_RANGE;
loop while (true)
{ {
// Read next record // Read next record
CDataStream ssKey(SER_DISK, CLIENT_VERSION); CDataStream ssKey(SER_DISK, CLIENT_VERSION);

View File

@ -77,7 +77,7 @@ static bool Send(SOCKET hSocket, const char* pszSend)
bool RecvLineIRC(SOCKET hSocket, string& strLine) bool RecvLineIRC(SOCKET hSocket, string& strLine)
{ {
loop while (true)
{ {
bool fRet = RecvLine(hSocket, strLine); bool fRet = RecvLine(hSocket, strLine);
if (fRet) if (fRet)
@ -100,7 +100,7 @@ bool RecvLineIRC(SOCKET hSocket, string& strLine)
int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL, const char* psz4=NULL) int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL, const char* psz4=NULL)
{ {
loop while (true)
{ {
string strLine; string strLine;
strLine.reserve(10000); strLine.reserve(10000);
@ -135,7 +135,7 @@ bool Wait(int nSeconds)
bool RecvCodeLine(SOCKET hSocket, const char* psz1, string& strRet) bool RecvCodeLine(SOCKET hSocket, const char* psz1, string& strRet)
{ {
strRet.clear(); strRet.clear();
loop while (true)
{ {
string strLine; string strLine;
if (!RecvLineIRC(hSocket, strLine)) if (!RecvLineIRC(hSocket, strLine))

View File

@ -24,7 +24,8 @@ static std::map<int, unsigned int> mapStakeModifierCheckpoints =
( 11000, 0x97a10217u ) ( 11000, 0x97a10217u )
( 130000, 0xf3878d42u ) ( 130000, 0xf3878d42u )
( 148000, 0x111af91cu ) ( 148000, 0x111af91cu )
; ;
// Get the last stake modifier and its generation time from a given block // Get the last stake modifier and its generation time from a given block
static bool GetLastStakeModifier(const CBlockIndex* pindex, uint64& nStakeModifier, int64& nModifierTime) static bool GetLastStakeModifier(const CBlockIndex* pindex, uint64& nStakeModifier, int64& nModifierTime)

View File

@ -2574,7 +2574,7 @@ static unsigned int nCurrentBlockFile = 1;
FILE* AppendBlockFile(unsigned int& nFileRet) FILE* AppendBlockFile(unsigned int& nFileRet)
{ {
nFileRet = 0; nFileRet = 0;
loop while (true)
{ {
FILE* file = OpenBlockFile(nCurrentBlockFile, 0, "ab"); FILE* file = OpenBlockFile(nCurrentBlockFile, 0, "ab");
if (!file) if (!file)
@ -3656,7 +3656,7 @@ bool ProcessMessages(CNode* pfrom)
// (x) data // (x) data
// //
loop while (true)
{ {
// Don't bother if send buffer is too full to respond anyway // Don't bother if send buffer is too full to respond anyway
if (pfrom->vSend.size() >= SendBufferSize()) if (pfrom->vSend.size() >= SendBufferSize())
@ -4538,7 +4538,7 @@ void curecoinMiner(CWallet *pwallet, bool fProofOfStake)
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
uint256 hashbuf[2]; uint256 hashbuf[2];
uint256& hash = *alignup<16>(hashbuf); uint256& hash = *alignup<16>(hashbuf);
loop while (true)
{ {
unsigned int nHashesDone = 0; unsigned int nHashesDone = 0;
unsigned int nNonceFound; unsigned int nNonceFound;

View File

@ -140,7 +140,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer)
bool RecvLine(SOCKET hSocket, string& strLine) bool RecvLine(SOCKET hSocket, string& strLine)
{ {
strLine = ""; strLine = "";
loop while (true)
{ {
char c; char c;
int nBytes = recv(hSocket, &c, 1, 0); int nBytes = recv(hSocket, &c, 1, 0);
@ -313,7 +313,7 @@ bool GetMyExternalIP2(const CService& addrConnect, const char* pszGet, const cha
{ {
if (strLine.empty()) // HTTP response is separated from headers by blank line if (strLine.empty()) // HTTP response is separated from headers by blank line
{ {
loop while (true)
{ {
if (!RecvLine(hSocket, strLine)) if (!RecvLine(hSocket, strLine))
{ {
@ -665,7 +665,7 @@ void ThreadSocketHandler2(void* parg)
list<CNode*> vNodesDisconnected; list<CNode*> vNodesDisconnected;
unsigned int nPrevNodeCount = 0; unsigned int nPrevNodeCount = 0;
loop while (true)
{ {
// //
// Disconnect nodes // Disconnect nodes
@ -1078,7 +1078,7 @@ void ThreadMapPort2(void* parg)
else else
printf("UPnP Port Mapping successful.\n"); printf("UPnP Port Mapping successful.\n");
int i = 1; int i = 1;
loop { while (true) {
if (fShutdown || !fUseUPnP) if (fShutdown || !fUseUPnP)
{ {
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0); r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
@ -1113,7 +1113,7 @@ void ThreadMapPort2(void* parg)
freeUPNPDevlist(devlist); devlist = 0; freeUPNPDevlist(devlist); devlist = 0;
if (r != 0) if (r != 0)
FreeUPNPUrls(&urls); FreeUPNPUrls(&urls);
loop { while (true) {
if (fShutdown || !fUseUPnP) if (fShutdown || !fUseUPnP)
return; return;
Sleep(2000); Sleep(2000);
@ -1349,7 +1349,7 @@ void ThreadOpenConnections2(void* parg)
// Initiate network connections // Initiate network connections
int64 nStart = GetTime(); int64 nStart = GetTime();
loop while (true)
{ {
ProcessOneShot(); ProcessOneShot();
@ -1408,7 +1408,7 @@ void ThreadOpenConnections2(void* parg)
int64 nANow = GetAdjustedTime(); int64 nANow = GetAdjustedTime();
int nTries = 0; int nTries = 0;
loop while (true)
{ {
// use an nUnkBias between 10 (no outgoing connections) and 90 (8 outgoing connections) // use an nUnkBias between 10 (no outgoing connections) and 90 (8 outgoing connections)
CAddress addr = addrman.Select(10 + min(nOutbound,8)*10); CAddress addr = addrman.Select(10 + min(nOutbound,8)*10);
@ -1501,7 +1501,7 @@ void ThreadOpenAddedConnections2(void* parg)
} }
} }
} }
loop while (true)
{ {
vector<vector<CService> > vservConnectAddresses = vservAddressesToAdd; vector<vector<CService> > vservConnectAddresses = vservAddressesToAdd;
// Attempt to connect to each IP for each addnode entry until at least one is successful per addnode entry // Attempt to connect to each IP for each addnode entry until at least one is successful per addnode entry

View File

@ -134,7 +134,7 @@ void AddressBookPage::setModel(AddressTableModel *model)
// Set column widths // Set column widths
ui->tableView->horizontalHeader()->resizeSection( ui->tableView->horizontalHeader()->resizeSection(
AddressTableModel::Address, 320); AddressTableModel::Address, 320);
ui->tableView->horizontalHeader()->setResizeMode( ui->tableView->horizontalHeader()->setSectionResizeMode(
AddressTableModel::Label, QHeaderView::Stretch); AddressTableModel::Label, QHeaderView::Stretch);
connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),

View File

@ -115,11 +115,11 @@ int main(int argc, char *argv[])
{ {
// Do this early as we don't want to bother initializing if we are just calling IPC // Do this early as we don't want to bother initializing if we are just calling IPC
ipcScanRelay(argc, argv); ipcScanRelay(argc, argv);
#if QT_VERSION < 0x050000
// Internal string conversion is all UTF-8 // Internal string conversion is all UTF-8
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForTr()); QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
#endif
Q_INIT_RESOURCE(curecoin); Q_INIT_RESOURCE(curecoin);
QApplication app(argc, argv); QApplication app(argc, argv);

View File

@ -54,6 +54,7 @@
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QUrl> #include <QUrl>
#include <QStyle> #include <QStyle>
#include <QtWidgets>
#include <iostream> #include <iostream>
@ -820,7 +821,7 @@ void curecoinGUI::encryptWallet(bool status)
void curecoinGUI::backupWallet() void curecoinGUI::backupWallet()
{ {
QString saveDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); QString saveDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
QString filename = QFileDialog::getSaveFileName(this, tr("Backup Wallet"), saveDir, tr("Wallet Data (*.dat)")); QString filename = QFileDialog::getSaveFileName(this, tr("Backup Wallet"), saveDir, tr("Wallet Data (*.dat)"));
if(!filename.isEmpty()) { if(!filename.isEmpty()) {
if(!walletModel->backupWallet(filename)) { if(!walletModel->backupWallet(filename)) {

View File

@ -18,6 +18,9 @@
#include <QFileDialog> #include <QFileDialog>
#include <QDesktopServices> #include <QDesktopServices>
#include <QThread> #include <QThread>
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
#include <QUrlQuery>
#endif
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
@ -84,6 +87,7 @@ bool parsecurecoinURI(const QUrl &uri, SendCoinsRecipient *out)
rv.address = uri.path(); rv.address = uri.path();
rv.amount = 0; rv.amount = 0;
QList<QPair<QString, QString> > items = uri.queryItems(); QList<QPair<QString, QString> > items = uri.queryItems();
for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++) for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
{ {
bool fShouldReturnFalse = false; bool fShouldReturnFalse = false;
@ -136,7 +140,7 @@ bool parsecurecoinURI(QString uri, SendCoinsRecipient *out)
QString HtmlEscape(const QString& str, bool fMultiLine) QString HtmlEscape(const QString& str, bool fMultiLine)
{ {
QString escaped = Qt::escape(str); QString escaped = QString(str.toHtmlEscaped());
if(fMultiLine) if(fMultiLine)
{ {
escaped = escaped.replace("\n", "<br>\n"); escaped = escaped.replace("\n", "<br>\n");
@ -171,7 +175,7 @@ QString getSaveFileName(QWidget *parent, const QString &caption,
QString myDir; QString myDir;
if(dir.isEmpty()) // Default to user documents location if(dir.isEmpty()) // Default to user documents location
{ {
myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
} }
else else
{ {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -98,7 +98,7 @@ static void ipcThread2(void* pArg)
size_t nSize = 0; size_t nSize = 0;
unsigned int nPriority = 0; unsigned int nPriority = 0;
loop while (true)
{ {
ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(100); ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(100);
if (mq->timed_receive(&buffer, sizeof(buffer), nSize, nPriority, d)) if (mq->timed_receive(&buffer, sizeof(buffer), nSize, nPriority, d))

View File

@ -99,7 +99,7 @@ void SendCoinsDialog::on_sendButton_clicked()
QStringList formatted; QStringList formatted;
foreach(const SendCoinsRecipient &rcp, recipients) foreach(const SendCoinsRecipient &rcp, recipients)
{ {
formatted.append(tr("<b>%1</b> to %2 (%3)").arg(curecoinUnits::formatWithUnit(curecoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address)); formatted.append(tr("<b>%1</b> to %2 (%3)").arg(curecoinUnits::formatWithUnit(curecoinUnits::BTC, rcp.amount), QString(rcp.label).toHtmlEscaped(), rcp.address));
} }
fNewRecipientAllowed = false; fNewRecipientAllowed = false;

View File

@ -1257,7 +1257,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
// Compare // Compare
CScript::const_iterator pc1 = script1.begin(); CScript::const_iterator pc1 = script1.begin();
CScript::const_iterator pc2 = script2.begin(); CScript::const_iterator pc2 = script2.begin();
loop while (true)
{ {
if (pc1 == script1.end() && pc2 == script2.end()) if (pc1 == script1.end() && pc2 == script2.end())
{ {

View File

@ -290,7 +290,7 @@ string vstrprintf(const char *format, va_list ap)
char* p = buffer; char* p = buffer;
int limit = sizeof(buffer); int limit = sizeof(buffer);
int ret; int ret;
loop while (true)
{ {
va_list arg_ptr; va_list arg_ptr;
va_copy(arg_ptr, ap); va_copy(arg_ptr, ap);
@ -350,7 +350,7 @@ void ParseString(const string& str, char c, vector<string>& v)
return; return;
string::size_type i1 = 0; string::size_type i1 = 0;
string::size_type i2; string::size_type i2;
loop while (true)
{ {
i2 = str.find(c, i1); i2 = str.find(c, i1);
if (i2 == str.npos) if (i2 == str.npos)
@ -466,7 +466,7 @@ vector<unsigned char> ParseHex(const char* psz)
{ {
// convert hex dump to vector // convert hex dump to vector
vector<unsigned char> vch; vector<unsigned char> vch;
loop while (true)
{ {
while (isspace(*psz)) while (isspace(*psz))
psz++; psz++;
@ -920,7 +920,7 @@ string DecodeBase32(const string& str)
bool WildcardMatch(const char* psz, const char* mask) bool WildcardMatch(const char* psz, const char* mask)
{ {
loop while (true)
{ {
switch (*mask) switch (*mask)
{ {

View File

@ -35,7 +35,6 @@ typedef unsigned long long uint64;
static const int64 COIN = 1000000; static const int64 COIN = 1000000;
static const int64 CENT = 10000; static const int64 CENT = 10000;
#define loop for (;;)
#define BEGIN(a) ((char*)&(a)) #define BEGIN(a) ((char*)&(a))
#define END(a) ((char*)&((&(a))[1])) #define END(a) ((char*)&((&(a))[1]))
#define UBEGIN(a) ((unsigned char*)&(a)) #define UBEGIN(a) ((unsigned char*)&(a))

View File

@ -1232,7 +1232,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CW
CTxDB txdb("r"); CTxDB txdb("r");
{ {
nFeeRet = nTransactionFee; nFeeRet = nTransactionFee;
loop while (true)
{ {
wtxNew.vin.clear(); wtxNew.vin.clear();
wtxNew.vout.clear(); wtxNew.vout.clear();
@ -1495,7 +1495,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
} }
int64 nMinFee = 0; int64 nMinFee = 0;
loop while (true)
{ {
// Set output amount // Set output amount
if (txNew.vout.size() == 3) if (txNew.vout.size() == 3)

View File

@ -73,7 +73,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
if (!pcursor) if (!pcursor)
throw runtime_error("CWalletDB::ListAccountCreditDebit() : cannot create DB cursor"); throw runtime_error("CWalletDB::ListAccountCreditDebit() : cannot create DB cursor");
unsigned int fFlags = DB_SET_RANGE; unsigned int fFlags = DB_SET_RANGE;
loop while (true)
{ {
// Read next record // Read next record
CDataStream ssKey(SER_DISK, CLIENT_VERSION); CDataStream ssKey(SER_DISK, CLIENT_VERSION);
@ -414,7 +414,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
return DB_CORRUPT; return DB_CORRUPT;
} }
loop while (true)
{ {
// Read next record // Read next record
CDataStream ssKey(SER_DISK, CLIENT_VERSION); CDataStream ssKey(SER_DISK, CLIENT_VERSION);