Skip to content

Commit 3f35bc8

Browse files
committed
Merge #698: [Qt] Remove Qt4 build support & code fallbacks
bc1fb93 gui: Remove QT_VERSION fallbacks for Qt < 5 (Wladimir J. van der Laan) cd75495 build: Build system changes to support only Qt5 (Wladimir J. van der Laan) Tree-SHA512: 8de2e99190e125285c8e6d69164defa4b4441b761befa3faaf96f77eaae2fa07e345673d28b54784a9c1b0a491a5fcf6260e7583b04eec0970af4fd08cf57d8a
2 parents 8b1f68d + bc1fb93 commit 3f35bc8

24 files changed

+155
-339
lines changed

build-aux/m4/bitcoin_qt.m4

Lines changed: 90 additions & 148 deletions
Large diffs are not rendered by default.

configure.ac

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ fi
682682
BITCOIN_QT_INIT
683683

684684
dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
685-
BITCOIN_QT_CONFIGURE([$use_pkgconfig], [qt5])
685+
BITCOIN_QT_CONFIGURE([$use_pkgconfig])
686686

687687
if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests = xnononono; then
688688
use_boost=no
@@ -1243,7 +1243,6 @@ echo "Options used to compile and link:"
12431243
echo " with wallet = $enable_wallet"
12441244
echo " with gui / qt = $bitcoin_enable_qt"
12451245
if test x$bitcoin_enable_qt != xno; then
1246-
echo " qt version = $bitcoin_qt_got_major_vers"
12471246
echo " with qr = $use_qr"
12481247
fi
12491248
echo " with zmq = $use_zmq"

src/qt/addressbookpage.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,9 @@ void AddressBookPage::setModel(AddressTableModel* model)
132132
ui->tableView->setModel(proxyModel);
133133
ui->tableView->sortByColumn(0, Qt::AscendingOrder);
134134

135-
// Set column widths
136-
#if QT_VERSION < 0x050000
137-
ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
138-
ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
139-
#else
135+
// Set column widths
140136
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
141137
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
142-
#endif
143138

144139
connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
145140
this, SLOT(selectionChanged()));

src/qt/bantablemodel.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ class BanTablePriv
5252
CNode::GetBanned(banMap);
5353

5454
cachedBanlist.clear();
55-
#if QT_VERSION >= 0x040700
5655
cachedBanlist.reserve(banMap.size());
57-
#endif
5856
for (banmap_t::iterator it = banMap.begin(); it != banMap.end(); it++)
5957
{
6058
CCombinedBan banEntry;

src/qt/bip38tooldialog.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ Bip38ToolDialog::Bip38ToolDialog(QWidget* parent) : QDialog(parent, Qt::WindowSy
2626
{
2727
ui->setupUi(this);
2828

29-
#if QT_VERSION >= 0x040700
3029
ui->decryptedKeyOut_DEC->setPlaceholderText(tr("Click \"Decrypt Key\" to compute key"));
31-
#endif
3230

3331
GUIUtil::setupAddressWidget(ui->addressIn_ENC, this);
3432
ui->addressIn_ENC->installEventFilter(this);

src/qt/bitcoingui.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,8 @@
5454
#include <QStyle>
5555
#include <QTimer>
5656
#include <QToolBar>
57-
#include <QVBoxLayout>
58-
59-
#if QT_VERSION < 0x050000
60-
#include <QTextDocument>
61-
#include <QUrl>
62-
#else
6357
#include <QUrlQuery>
64-
#endif
58+
#include <QVBoxLayout>
6559

6660
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
6761

@@ -140,12 +134,6 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle* networkStyle, QWidget* parent) : QMai
140134
#endif
141135
setWindowTitle(windowTitle);
142136

143-
#if defined(Q_OS_MAC) && QT_VERSION < 0x050000
144-
// This property is not implemented in Qt 5. Setting it has no effect.
145-
// A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
146-
setUnifiedTitleAndToolBarOnMac(true);
147-
#endif
148-
149137
rpcConsole = new RPCConsole(enableWallet ? this : 0);
150138
#ifdef ENABLE_WALLET
151139
if (enableWallet) {
@@ -235,7 +223,7 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle* networkStyle, QWidget* parent) : QMai
235223

236224
// Override style sheet for progress bar for styles that have a segmented progress bar,
237225
// as they make the text unreadable (workaround for issue #1071)
238-
// See https://qt-project.org/doc/qt-4.8/gallery.html
226+
// See https://doc.qt.io/qt-5/gallery.html
239227
QString curStyle = QApplication::style()->metaObject()->className();
240228
if (curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle") {
241229
progressBar->setStyleSheet("QProgressBar { background-color: #F8F8F8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #00CCFF, stop: 1 #33CCFF); border-radius: 7px; margin: 0px; }");
@@ -401,11 +389,7 @@ void BitcoinGUI::createActions(const NetworkStyle* networkStyle)
401389
aboutAction = new QAction(networkStyle->getAppIcon(), tr("&About PIVX Core"), this);
402390
aboutAction->setStatusTip(tr("Show information about PIVX Core"));
403391
aboutAction->setMenuRole(QAction::AboutRole);
404-
#if QT_VERSION < 0x050000
405-
aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
406-
#else
407392
aboutQtAction = new QAction(QIcon(":/qt-project.org/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
408-
#endif
409393
aboutQtAction->setStatusTip(tr("Show information about Qt"));
410394
aboutQtAction->setMenuRole(QAction::AboutQtRole);
411395
optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);

src/qt/coincontroldialog.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,8 @@ CoinControlDialog::CoinControlDialog(QWidget* parent, bool fMultisigEnabled) : Q
110110
// click on checkbox
111111
connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(viewItemChanged(QTreeWidgetItem*, int)));
112112

113-
// click on header
114-
#if QT_VERSION < 0x050000
115-
ui->treeWidget->header()->setClickable(true);
116-
#else
113+
// click on header
117114
ui->treeWidget->header()->setSectionsClickable(true);
118-
#endif
119115
connect(ui->treeWidget->header(), SIGNAL(sectionClicked(int)), this, SLOT(headerSectionClicked(int)));
120116

121117
// ok button
@@ -445,16 +441,14 @@ void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column)
445441
updateDialogLabels();
446442
}
447443
}
448-
// todo: this is a temporary qt5 fix: when clicking a parent node in tree mode, the parent node
449-
// including all childs are partially selected. But the parent node should be fully selected
450-
// as well as the childs. Childs should never be partially selected in the first place.
451-
// Please remove this ugly fix, once the bug is solved upstream.
452-
#if QT_VERSION >= 0x050000
453-
else if (column == COLUMN_CHECKBOX && item->childCount() > 0) {
444+
445+
// TODO: Remove this temporary qt5 fix after Qt5.3 and Qt5.4 are no longer used.
446+
// Fixed in Qt5.5 and above: https://bugreports.qt.io/browse/QTBUG-43473
447+
else if (column == COLUMN_CHECKBOX && item->childCount() > 0)
448+
{
454449
if (item->checkState(COLUMN_CHECKBOX) == Qt::PartiallyChecked && item->child(0)->checkState(COLUMN_CHECKBOX) == Qt::PartiallyChecked)
455450
item->setCheckState(COLUMN_CHECKBOX, Qt::Checked);
456451
}
457-
#endif
458452
}
459453

460454
// return human readable label for priority number

src/qt/guiutil.cpp

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,9 @@
5656
#include <QSettings>
5757
#include <QTextDocument> // for Qt::mightBeRichText
5858
#include <QThread>
59-
60-
#if QT_VERSION < 0x050000
61-
#include <QUrl>
62-
#else
6359
#include <QUrlQuery>
64-
#endif
60+
#include <QMouseEvent>
61+
6562

6663
#if BOOST_FILESYSTEM_VERSION >= 3
6764
static boost::filesystem::detail::utf8_codecvt_facet utf8;
@@ -94,11 +91,7 @@ QString dateTimeStr(qint64 nTime)
9491
QFont bitcoinAddressFont()
9592
{
9693
QFont font("Monospace");
97-
#if QT_VERSION >= 0x040800
9894
font.setStyleHint(QFont::Monospace);
99-
#else
100-
font.setStyleHint(QFont::TypeWriter);
101-
#endif
10295
return font;
10396
}
10497

@@ -107,11 +100,9 @@ void setupAddressWidget(QValidatedLineEdit* widget, QWidget* parent)
107100
parent->setFocusProxy(widget);
108101

109102
widget->setFont(bitcoinAddressFont());
110-
#if QT_VERSION >= 0x040700
111103
// We don't want translators to use own addresses in translations
112104
// and this is the only place, where this address is supplied.
113105
widget->setPlaceholderText(QObject::tr("Enter a PIVX address (e.g. %1)").arg("D7VFR83SQbiezrW72hjcWJtcfip5krte2Z"));
114-
#endif
115106
widget->setValidator(new BitcoinAddressEntryValidator(parent));
116107
widget->setCheckValidator(new BitcoinAddressCheckValidator(parent));
117108
}
@@ -139,13 +130,10 @@ bool parseBitcoinURI(const QUrl& uri, SendCoinsRecipient* out)
139130
}
140131
rv.amount = 0;
141132

142-
#if QT_VERSION < 0x050000
143-
QList<QPair<QString, QString> > items = uri.queryItems();
144-
#else
145133
QUrlQuery uriQuery(uri);
146134
QList<QPair<QString, QString> > items = uriQuery.queryItems();
147-
#endif
148-
for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++) {
135+
for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
136+
{
149137
bool fShouldReturnFalse = false;
150138
if (i->first.startsWith("req-")) {
151139
i->first.remove(0, 4);
@@ -225,11 +213,7 @@ bool isDust(const QString& address, const CAmount& amount)
225213

226214
QString HtmlEscape(const QString& str, bool fMultiLine)
227215
{
228-
#if QT_VERSION < 0x050000
229-
QString escaped = Qt::escape(str);
230-
#else
231216
QString escaped = str.toHtmlEscaped();
232-
#endif
233217
escaped = escaped.replace(" ", "&nbsp;");
234218
if (fMultiLine) {
235219
escaped = escaped.replace("\n", "<br>\n");
@@ -273,12 +257,10 @@ QString getSaveFileName(QWidget* parent, const QString& caption, const QString&
273257
QString myDir;
274258
if (dir.isEmpty()) // Default to user documents location
275259
{
276-
#if QT_VERSION < 0x050000
277-
myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
278-
#else
279260
myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
280-
#endif
281-
} else {
261+
}
262+
else
263+
{
282264
myDir = dir;
283265
}
284266
/* Directly convert path to native OS path separators */
@@ -315,12 +297,10 @@ QString getOpenFileName(QWidget* parent, const QString& caption, const QString&
315297
QString myDir;
316298
if (dir.isEmpty()) // Default to user documents location
317299
{
318-
#if QT_VERSION < 0x050000
319-
myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
320-
#else
321300
myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
322-
#endif
323-
} else {
301+
}
302+
else
303+
{
324304
myDir = dir;
325305
}
326306
/* Directly convert path to native OS path separators */
@@ -470,11 +450,7 @@ void TableViewLastColumnResizingFixer::disconnectViewHeadersSignals()
470450
// Refactored here for readability.
471451
void TableViewLastColumnResizingFixer::setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode)
472452
{
473-
#if QT_VERSION < 0x050000
474-
tableView->horizontalHeader()->setResizeMode(logicalIndex, resizeMode);
475-
#else
476453
tableView->horizontalHeader()->setSectionResizeMode(logicalIndex, resizeMode);
477-
#endif
478454
}
479455

480456
void TableViewLastColumnResizingFixer::resizeColumn(int nColumnIndex, int width)

src/qt/guiutil.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,18 @@ QString formatPingTime(double dPingTime);
228228
/* Format a CNodeCombinedStats.nTimeOffset into a user-readable string. */
229229
QString formatTimeOffset(int64_t nTimeOffset);
230230

231-
#if defined(Q_OS_MAC) && QT_VERSION >= 0x050000
232-
// workaround for Qt OSX Bug:
233-
// https://bugreports.qt-project.org/browse/QTBUG-15631
234-
// QProgressBar uses around 10% CPU even when app is in background
235-
class ProgressBar : public QProgressBar
236-
{
237-
bool event(QEvent* e)
231+
#if defined(Q_OS_MAC)
232+
// workaround for Qt OSX Bug:
233+
// https://bugreports.qt-project.org/browse/QTBUG-15631
234+
// QProgressBar uses around 10% CPU even when app is in background
235+
class ProgressBar : public QProgressBar
238236
{
239-
return (e->type() != QEvent::StyleAnimationUpdate) ? QProgressBar::event(e) : false;
240-
}
241-
};
237+
bool event(QEvent *e) {
238+
return (e->type() != QEvent::StyleAnimationUpdate) ? QProgressBar::event(e) : false;
239+
}
240+
};
242241
#else
243-
typedef QProgressBar ProgressBar;
242+
typedef QProgressBar ProgressBar;
244243
#endif
245244

246245
} // namespace GUIUtil

src/qt/macdockiconhandler.mm

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,22 @@
1414
#include <objc/objc.h>
1515
#include <objc/message.h>
1616

17-
#if QT_VERSION < 0x050000
18-
extern void qt_mac_set_dock_menu(QMenu *);
19-
#endif
20-
21-
static MacDockIconHandler *s_instance = NULL;
17+
static MacDockIconHandler *s_instance = nullptr;
2218

2319
bool dockClickHandler(id self,SEL _cmd,...) {
2420
Q_UNUSED(self)
2521
Q_UNUSED(_cmd)
26-
22+
2723
s_instance->handleDockIconClickEvent();
28-
24+
2925
// Return NO (false) to suppress the default OS X actions
3026
return false;
3127
}
3228

3329
void setupDockClickHandler() {
3430
Class cls = objc_getClass("NSApplication");
3531
id appInst = objc_msgSend((id)cls, sel_registerName("sharedApplication"));
36-
32+
3733
if (appInst != NULL) {
3834
id delegate = objc_msgSend(appInst, sel_registerName("delegate"));
3935
Class delClass = (Class)objc_msgSend(delegate, sel_registerName("class"));
@@ -53,10 +49,8 @@ void setupDockClickHandler() {
5349
setupDockClickHandler();
5450
this->m_dummyWidget = new QWidget();
5551
this->m_dockMenu = new QMenu(this->m_dummyWidget);
56-
this->setMainWindow(NULL);
57-
#if QT_VERSION < 0x050000
58-
qt_mac_set_dock_menu(this->m_dockMenu);
59-
#elif QT_VERSION >= 0x050200
52+
this->setMainWindow(nullptr);
53+
#if QT_VERSION >= 0x050200
6054
this->m_dockMenu->setAsDockMenu();
6155
#endif
6256
[pool release];

0 commit comments

Comments
 (0)