Skip to content

Commit dcbfe17

Browse files
committed
[Build][UI] Provisional move of the QTCharts library to optional dependency for local build.
[Travis] provisional removal of qtcharts from travis building.
1 parent f23a8f9 commit dcbfe17

File tree

4 files changed

+79
-40
lines changed

4 files changed

+79
-40
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
env: >-
152152
HOST=x86_64-unknown-linux-gnu
153153
DOCKER_NAME_TAG=ubuntu:14.04
154-
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libicu-dev libpng-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.1++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev libgmp-dev"
154+
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libicu-dev libpng-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.1++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev libgmp-dev"
155155
NO_DEPENDS=1
156156
RUN_FUNCTIONAL_TESTS=false
157157
GOAL="install"
@@ -162,7 +162,7 @@ jobs:
162162
env: >-
163163
HOST=x86_64-unknown-linux-gnu
164164
DOCKER_NAME_TAG=ubuntu:16.04
165-
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev libgmp-dev"
165+
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev libgmp-dev"
166166
NO_DEPENDS=1
167167
GOAL="install"
168168
BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER --disable-hardening --disable-asm"

configure.ac

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ AC_ARG_ENABLE([extended-functional-tests],
138138
[use_extended_functional_tests=$enableval],
139139
[use_extended_functional_tests=no])
140140

141-
AC_ARG_WITH([qrencode],
142-
[AS_HELP_STRING([--with-qrencode],
143-
[enable QR code support (default is yes if qt is enabled and libqrencode is found)])],
144-
[use_qr=$withval],
145-
[use_qr=auto])
141+
AC_ARG_WITH([qtcharts],
142+
[AS_HELP_STRING([--with-qtcharts],
143+
[enable QTCHARTS code support (default is yes if qt is enabled and qtchartview is found)])],
144+
[use_qtcharts=$withval],
145+
[use_qtcharts=auto])
146146

147147
AC_ARG_ENABLE([hardening],
148148
[AS_HELP_STRING([--disable-hardening],
@@ -1024,11 +1024,12 @@ if test x$use_pkgconfig = xyes; then
10241024
PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)])
10251025
PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)])
10261026
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])])
1027-
if test x$use_qr != xno; then
1028-
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])])
1027+
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])])
1028+
if test x$use_qtcharts != xno; then
1029+
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([CHARTS], [Qt5Charts],[have_qtcharts=yes], [have_qtcharts=no])])
10291030
fi
10301031
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([SVG], [Qt5Svg],,[BITCOIN_QT_FAIL(qtsvg not found)])])
1031-
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([CHARTS], [Qt5Charts],,[BITCOIN_QT_FAIL(qtcharts not found)])])
1032+
10321033
if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then
10331034
PKG_CHECK_MODULES([EVENT], [libevent],, [AC_MSG_ERROR(libevent not found.)])
10341035
if test x$TARGET_OS != xwindows; then
@@ -1088,9 +1089,12 @@ else
10881089
BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],[PROTOBUF_LIBS=-lprotobuf], BITCOIN_QT_FAIL(libprotobuf not found)))
10891090
BITCOIN_QT_CHECK([AC_CHECK_LIB([Qt5Svg], [main],[SVG_LIBS=-lQt5Svg], BITCOIN_QT_FAIL(svg not found))])
10901091
BITCOIN_QT_CHECK([AC_CHECK_LIB([Qt5Charts], [main],[CHARTS_LIBS=-lQt5Charts], BITCOIN_QT_FAIL(charts not found))])
1091-
if test x$use_qr != xno; then
1092-
BITCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],[QR_LIBS=-lqrencode], [have_qrencode=no])])
1093-
BITCOIN_QT_CHECK([AC_CHECK_HEADER([qrencode.h],, have_qrencode=no)])
1092+
1093+
BITCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],[QR_LIBS=-lqrencode], [have_qrencode=no])])
1094+
BITCOIN_QT_CHECK([AC_CHECK_HEADER([qrencode.h],, have_qrencode=no)])
1095+
if test x$use_qtcharts != xno; then
1096+
BITCOIN_QT_CHECK([AC_CHECK_LIB([Qt5Charts], [main],[CHARTS_LIBS=-lQt5Charts], [have_qtcharts=no])])
1097+
BITCOIN_QT_CHECK([AC_CHECK_HEADER([qchartview.h],, have_qtcharts=no)])
10941098
fi
10951099
fi
10961100

@@ -1269,18 +1273,18 @@ if test x$bitcoin_enable_qt != xno; then
12691273
fi
12701274
AC_MSG_RESULT($bitcoin_enable_qt_dbus)
12711275

1272-
dnl enable qr support
1273-
AC_MSG_CHECKING([whether to build GUI with support for QR codes])
1274-
if test x$have_qrencode = xno; then
1275-
if test x$use_qr = xyes; then
1276-
AC_MSG_ERROR("QR support requested but cannot be built. use --without-qrencode")
1276+
dnl enable qtcharts support
1277+
AC_MSG_CHECKING([whether to build GUI with support for qtcharts codes])
1278+
if test x$have_qtcharts = xno; then
1279+
if test x$use_qtcharts = xyes; then
1280+
AC_MSG_ERROR("QTCharts support requested but cannot be built. use --without-qtcharts")
12771281
fi
12781282
AC_MSG_RESULT(no)
12791283
else
1280-
if test x$use_qr != xno; then
1284+
if test x$use_qtcharts != xno; then
12811285
AC_MSG_RESULT(yes)
1282-
AC_DEFINE([USE_QRCODE],[1],[Define if QR support should be compiled in])
1283-
use_qr=yes
1286+
AC_DEFINE([USE_QTCHARTS],[1],[Define if QTCHARTS support should be compiled in])
1287+
use_qtcharts=yes
12841288
else
12851289
AC_MSG_RESULT(no)
12861290
fi
@@ -1345,7 +1349,7 @@ AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
13451349
AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
13461350
AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes])
13471351
AM_CONDITIONAL([ENABLE_BENCH],[test x$use_bench = xyes])
1348-
AM_CONDITIONAL([USE_QRCODE], [test x$use_qr = xyes])
1352+
AM_CONDITIONAL([USE_QTCHARTS], [test x$use_qtcharts = xyes])
13491353
AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
13501354
AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
13511355
AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes])
@@ -1394,7 +1398,7 @@ AC_SUBST(AVX2_CXXFLAGS)
13941398
AC_SUBST(SHANI_CXXFLAGS)
13951399
AC_SUBST(LIBTOOL_APP_LDFLAGS)
13961400
AC_SUBST(USE_UPNP)
1397-
AC_SUBST(USE_QRCODE)
1401+
AC_SUBST(USE_QTCHARTS)
13981402
AC_SUBST(BOOST_LIBS)
13991403
AC_SUBST(TESTDEFS)
14001404
AC_SUBST(LEVELDB_TARGET_FLAGS)
@@ -1473,7 +1477,7 @@ echo "Options used to compile and link:"
14731477
echo " with wallet = $enable_wallet"
14741478
echo " with gui / qt = $bitcoin_enable_qt"
14751479
if test x$bitcoin_enable_qt != xno; then
1476-
echo " with qr = $use_qr"
1480+
echo " with QTCHARTS = $use_qtcharts"
14771481
fi
14781482
echo " with zmq = $use_zmq"
14791483
echo " with bignum = $set_bignum"

src/qt/pivx/dashboardwidget.cpp

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ DashboardWidget::DashboardWidget(PIVXGUI* parent) :
7979
ui->comboBoxYears->setView(new QListView());
8080
ui->comboBoxYears->setStyleSheet("selection-background-color:transparent; selection-color:transparent;");
8181
ui->pushButtonYear->setChecked(true);
82-
setChartShow(YEAR);
8382

8483
setCssProperty(ui->pushButtonChartArrow, "btn-chart-arrow");
8584

@@ -137,9 +136,8 @@ DashboardWidget::DashboardWidget(PIVXGUI* parent) :
137136
ui->btnHowTo->setText(tr("How to get PIV or zPIV"));
138137
setCssBtnSecondary(ui->btnHowTo);
139138

140-
ui->labelEmptyChart->setText(tr("You have no staking rewards"));
141-
setCssProperty(ui->labelEmptyChart, "text-empty");
142139

140+
setCssProperty(ui->labelEmptyChart, "text-empty");
143141
ui->labelMessageEmpty->setText(tr("You can verify the staking activity in the status bar at the top right of the wallet.\nIt will start automatically as soon as the wallet has enough confirmations on any unspent balances, and the wallet has synced."));
144142
setCssSubtitleScreen(ui->labelMessageEmpty);
145143

@@ -152,19 +150,20 @@ DashboardWidget::DashboardWidget(PIVXGUI* parent) :
152150
if (window)
153151
connect(window, SIGNAL(windowResizeEvent(QResizeEvent*)), this, SLOT(windowResizeEvent(QResizeEvent*)));
154152

153+
bool hasCharts = false;
154+
#ifdef USE_QTCHARTS
155+
hasCharts = true;
156+
setChartShow(YEAR);
155157
connect(ui->pushButtonYear, &QPushButton::clicked, [this](){setChartShow(YEAR);});
156158
connect(ui->pushButtonMonth, &QPushButton::clicked, [this](){setChartShow(MONTH);});
157159
connect(ui->pushButtonAll, &QPushButton::clicked, [this](){setChartShow(ALL);});
158-
}
160+
#endif
159161

160-
void DashboardWidget::setChartShow(ChartShowType type) {
161-
this->chartShow = type;
162-
if (chartShow == MONTH) {
163-
ui->containerChartArrow->setVisible(true);
162+
if (hasCharts) {
163+
ui->labelEmptyChart->setText(tr("You have no staking rewards"));
164164
} else {
165-
ui->containerChartArrow->setVisible(false);
165+
ui->labelEmptyChart->setText(tr("No charts library"));
166166
}
167-
if (isChartInitialized) refreshChart();
168167
}
169168

170169
void DashboardWidget::handleTransactionClicked(const QModelIndex &index){
@@ -214,23 +213,26 @@ void DashboardWidget::loadWalletModel(){
214213
// Notification pop-up for new transaction
215214
connect(txModel, SIGNAL(rowsInserted(QModelIndex, int, int)),
216215
this, SLOT(processNewTransaction(QModelIndex, int, int)));
217-
216+
#ifdef USE_QTCHARTS
218217
// chart filter
219218
stakesFilter = new TransactionFilterProxy();
220219
stakesFilter->setSourceModel(txModel);
221220
stakesFilter->sort(TransactionTableModel::Date, Qt::AscendingOrder);
222221
stakesFilter->setOnlyStakes(true);
223222
loadChart();
223+
#endif
224224
}
225225
// update the display unit, to not use the default ("PIV")
226226
updateDisplayUnit();
227227
}
228228

229229
void DashboardWidget::onTxArrived(const QString& hash) {
230230
showList();
231+
#ifdef USE_QTCHARTS
231232
if (hasStakes() && walletModel->isCoinStakeMine(hash)) {
232233
refreshChart();
233234
}
235+
#endif
234236
}
235237

236238
void DashboardWidget::showList(){
@@ -308,7 +310,22 @@ void DashboardWidget::walletSynced(bool sync){
308310

309311
void DashboardWidget::changeTheme(bool isLightTheme, QString& theme){
310312
static_cast<TxViewHolder*>(this->txViewDelegate->getRowFactory())->isLightTheme = isLightTheme;
313+
#ifdef USE_QTCHARTS
311314
if (chart) this->changeChartColors();
315+
#endif
316+
317+
}
318+
319+
#ifdef USE_QTCHARTS
320+
321+
void DashboardWidget::setChartShow(ChartShowType type) {
322+
this->chartShow = type;
323+
if (chartShow == MONTH) {
324+
ui->containerChartArrow->setVisible(true);
325+
} else {
326+
ui->containerChartArrow->setVisible(false);
327+
}
328+
if (isChartInitialized) refreshChart();
312329
}
313330

314331
const QStringList monthsNames = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
@@ -698,6 +715,8 @@ bool DashboardWidget::hasStakes() {
698715
return stakesFilter->rowCount() > 0;
699716
}
700717

718+
#endif
719+
701720
void DashboardWidget::processNewTransaction(const QModelIndex& parent, int start, int /*end*/) {
702721
// Prevent notifications-spam when initial block download is in progress
703722
if (!walletModel || !clientModel || clientModel->inInitialBlockDownload())
@@ -715,6 +734,8 @@ void DashboardWidget::processNewTransaction(const QModelIndex& parent, int start
715734
}
716735

717736
DashboardWidget::~DashboardWidget(){
737+
#ifdef USE_QTCHARTS
718738
delete chart;
739+
#endif
719740
delete ui;
720741
}

src/qt/pivx/dashboardwidget.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
#include "qt/pivx/txviewholder.h"
1313
#include "transactionfilterproxy.h"
1414

15-
#include <iostream>
1615
#include <cstdlib>
17-
1816
#include <QWidget>
1917
#include <QLineEdit>
2018
#include <QMap>
2119

20+
#if defined(HAVE_CONFIG_H)
21+
#include "config/pivx-config.h" /* for USE_QTCHARTS */
22+
#endif
23+
24+
#ifdef USE_QTCHARTS
25+
2226
#include <QtCharts/QChartView>
2327
#include <QtCharts/QBarSeries>
2428
#include <QtCharts/QBarCategoryAxis>
@@ -30,6 +34,8 @@ QT_CHARTS_USE_NAMESPACE
3034

3135
using namespace QtCharts;
3236

37+
#endif
38+
3339
class PIVXGUI;
3440
class WalletModel;
3541

@@ -93,30 +99,35 @@ public slots:
9399
/** Notify that a new transaction appeared */
94100
void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address);
95101
private slots:
96-
void windowResizeEvent(QResizeEvent *event);
97102
void handleTransactionClicked(const QModelIndex &index);
98103
void changeTheme(bool isLightTheme, QString &theme) override;
99-
void changeChartColors();
100104
void onSortChanged(const QString&);
101105
void onSortTypeChanged(const QString& value);
102106
void updateDisplayUnit();
103107
void showList();
104108
void onTxArrived(const QString& hash);
109+
110+
#ifdef USE_QTCHARTS
111+
void windowResizeEvent(QResizeEvent *event);
112+
void changeChartColors();
105113
void onChartYearChanged(const QString&);
106114
void onChartMonthChanged(const QString&);
107115
void onChartArrowClicked();
116+
#endif
108117

109118
private:
110119
Ui::DashboardWidget *ui;
111120
FurAbstractListItemDelegate* txViewDelegate;
112121
TransactionFilterProxy* filter;
113-
TransactionFilterProxy* stakesFilter;
114122
TxViewHolder* txHolder;
115123
TransactionTableModel* txModel;
116124
int nDisplayUnit = -1;
117125
bool isSync = false;
118126

127+
#ifdef USE_QTCHARTS
128+
119129
// Chart
130+
TransactionFilterProxy* stakesFilter = nullptr;
120131
bool isChartInitialized = false;
121132
QChartView *chartView = nullptr;
122133
QBarSeries *series = nullptr;
@@ -143,6 +154,9 @@ private slots:
143154
void setChartShow(ChartShowType type);
144155
std::pair<int, int> getChartRange(QMap<int, std::pair<qint64, qint64>> amountsBy);
145156
bool hasStakes();
157+
158+
#endif
159+
146160
};
147161

148162
#endif // DASHBOARDWIDGET_H

0 commit comments

Comments
 (0)