Skip to content

Commit 907f73b

Browse files
committed
gui: Remove QT_VERSION fallbacks for Qt < 5
There were surprisingly many `#ifdef` fallbacks for Qt 4. Remiving them simplifies maintenance, as well as adding new GUI functionality.
1 parent bad068a commit 907f73b

23 files changed

+8
-175
lines changed

src/qt/addressbookpage.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,8 @@ void AddressBookPage::setModel(AddressTableModel *_model)
160160
ui->tableView->sortByColumn(0, Qt::AscendingOrder);
161161

162162
// Set column widths
163-
#if QT_VERSION < 0x050000
164-
ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
165-
ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
166-
#else
167163
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
168164
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
169-
#endif
170165

171166
connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
172167
this, SLOT(selectionChanged()));

src/qt/bantablemodel.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ class BanTablePriv
5252
node.getBanned(banMap);
5353

5454
cachedBanlist.clear();
55-
#if QT_VERSION >= 0x040700
5655
cachedBanlist.reserve(banMap.size());
57-
#endif
5856
for (const auto& entry : banMap)
5957
{
6058
CCombinedBan banEntry;

src/qt/bitcoin.cpp

+1-35
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@
5555

5656
#if defined(QT_STATICPLUGIN)
5757
#include <QtPlugin>
58-
#if QT_VERSION < 0x050000
59-
Q_IMPORT_PLUGIN(qcncodecs)
60-
Q_IMPORT_PLUGIN(qjpcodecs)
61-
Q_IMPORT_PLUGIN(qtwcodecs)
62-
Q_IMPORT_PLUGIN(qkrcodecs)
63-
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
64-
#else
6558
#if QT_VERSION < 0x050400
6659
Q_IMPORT_PLUGIN(AccessibleFactory)
6760
#endif
@@ -73,11 +66,6 @@ Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
7366
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
7467
#endif
7568
#endif
76-
#endif
77-
78-
#if QT_VERSION < 0x050000
79-
#include <QTextCodec>
80-
#endif
8169

8270
// Declare meta types used for QMetaObject::invokeMethod
8371
Q_DECLARE_METATYPE(bool*)
@@ -151,16 +139,6 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
151139
}
152140

153141
/* qDebug() message handler --> debug.log */
154-
#if QT_VERSION < 0x050000
155-
void DebugMessageHandler(QtMsgType type, const char *msg)
156-
{
157-
if (type == QtDebugMsg) {
158-
LogPrint(BCLog::QT, "GUI: %s\n", msg);
159-
} else {
160-
LogPrintf("GUI: %s\n", msg);
161-
}
162-
}
163-
#else
164142
void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg)
165143
{
166144
Q_UNUSED(context);
@@ -170,7 +148,6 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons
170148
LogPrintf("GUI: %s\n", msg.toStdString());
171149
}
172150
}
173-
#endif
174151

175152
/** Class encapsulating Bitcoin Core startup and shutdown.
176153
* Allows running startup and shutdown in a different thread from the UI thread.
@@ -572,12 +549,6 @@ int main(int argc, char *argv[])
572549
// Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory
573550

574551
/// 1. Basic Qt initialization (not dependent on parameters or configuration)
575-
#if QT_VERSION < 0x050000
576-
// Internal string conversion is all UTF-8
577-
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
578-
QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
579-
#endif
580-
581552
Q_INIT_RESOURCE(bitcoin);
582553
Q_INIT_RESOURCE(bitcoin_locale);
583554

@@ -708,17 +679,12 @@ int main(int argc, char *argv[])
708679
/// 9. Main GUI initialization
709680
// Install global event filter that makes sure that long tooltips can be word-wrapped
710681
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
711-
#if QT_VERSION < 0x050000
712-
// Install qDebug() message handler to route to debug.log
713-
qInstallMsgHandler(DebugMessageHandler);
714-
#else
715682
#if defined(Q_OS_WIN)
716683
// Install global event filter for processing Windows session related Windows messages (WM_QUERYENDSESSION and WM_ENDSESSION)
717684
qApp->installNativeEventFilter(new WinShutdownMonitor());
718685
#endif
719686
// Install qDebug() message handler to route to debug.log
720687
qInstallMessageHandler(DebugMessageHandler);
721-
#endif
722688
// Allow parameter interaction before we create the options model
723689
app.parameterSetup();
724690
// Load GUI settings from QSettings
@@ -739,7 +705,7 @@ int main(int argc, char *argv[])
739705
// so the GUI thread won't be held up.
740706
if (node->baseInitialize()) {
741707
app.requestInitialize();
742-
#if defined(Q_OS_WIN) && QT_VERSION >= 0x050000
708+
#if defined(Q_OS_WIN)
743709
WinShutdownMonitor::registerShutdownBlockReason(QObject::tr("%1 didn't yet exit safely...").arg(QObject::tr(PACKAGE_NAME)), (HWND)app.getMainWinId());
744710
#endif
745711
app.exec();

src/qt/bitcoingui.cpp

+2-14
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,8 @@
5555
#include <QStyle>
5656
#include <QTimer>
5757
#include <QToolBar>
58-
#include <QVBoxLayout>
59-
60-
#if QT_VERSION < 0x050000
61-
#include <QTextDocument>
62-
#include <QUrl>
63-
#else
6458
#include <QUrlQuery>
65-
#endif
59+
#include <QVBoxLayout>
6660

6761
const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
6862
#if defined(Q_OS_MAC)
@@ -147,12 +141,6 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
147141
#endif
148142
setWindowTitle(windowTitle);
149143

150-
#if defined(Q_OS_MAC) && QT_VERSION < 0x050000
151-
// This property is not implemented in Qt 5. Setting it has no effect.
152-
// A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
153-
setUnifiedTitleAndToolBarOnMac(true);
154-
#endif
155-
156144
rpcConsole = new RPCConsole(node, _platformStyle, 0);
157145
helpMessageDialog = new HelpMessageDialog(node, this, false);
158146
#ifdef ENABLE_WALLET
@@ -229,7 +217,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
229217

230218
// Override style sheet for progress bar for styles that have a segmented progress bar,
231219
// as they make the text unreadable (workaround for issue #1071)
232-
// See https://qt-project.org/doc/qt-4.8/gallery.html
220+
// See https://doc.qt.io/qt-5/gallery.html
233221
QString curStyle = QApplication::style()->metaObject()->className();
234222
if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
235223
{

src/qt/coincontroldialog.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,7 @@ CoinControlDialog::CoinControlDialog(const PlatformStyle *_platformStyle, QWidge
109109
connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(viewItemChanged(QTreeWidgetItem*, int)));
110110

111111
// click on header
112-
#if QT_VERSION < 0x050000
113-
ui->treeWidget->header()->setClickable(true);
114-
#else
115112
ui->treeWidget->header()->setSectionsClickable(true);
116-
#endif
117113
connect(ui->treeWidget->header(), SIGNAL(sectionClicked(int)), this, SLOT(headerSectionClicked(int)));
118114

119115
// ok button
@@ -392,13 +388,11 @@ void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column)
392388

393389
// TODO: Remove this temporary qt5 fix after Qt5.3 and Qt5.4 are no longer used.
394390
// Fixed in Qt5.5 and above: https://bugreports.qt.io/browse/QTBUG-43473
395-
#if QT_VERSION >= 0x050000
396391
else if (column == COLUMN_CHECKBOX && item->childCount() > 0)
397392
{
398393
if (item->checkState(COLUMN_CHECKBOX) == Qt::PartiallyChecked && item->child(0)->checkState(COLUMN_CHECKBOX) == Qt::PartiallyChecked)
399394
item->setCheckState(COLUMN_CHECKBOX, Qt::Checked);
400395
}
401-
#endif
402396
}
403397

404398
// shows count of locked unspent outputs

src/qt/guiutil.cpp

+1-31
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,9 @@
5353
#include <QSettings>
5454
#include <QTextDocument> // for Qt::mightBeRichText
5555
#include <QThread>
56+
#include <QUrlQuery>
5657
#include <QMouseEvent>
5758

58-
#if QT_VERSION < 0x050000
59-
#include <QUrl>
60-
#else
61-
#include <QUrlQuery>
62-
#endif
6359

6460
#if QT_VERSION >= 0x50200
6561
#include <QFontDatabase>
@@ -95,11 +91,7 @@ QFont fixedPitchFont()
9591
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
9692
#else
9793
QFont font("Monospace");
98-
#if QT_VERSION >= 0x040800
9994
font.setStyleHint(QFont::Monospace);
100-
#else
101-
font.setStyleHint(QFont::TypeWriter);
102-
#endif
10395
return font;
10496
#endif
10597
}
@@ -127,12 +119,10 @@ void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
127119
parent->setFocusProxy(widget);
128120

129121
widget->setFont(fixedPitchFont());
130-
#if QT_VERSION >= 0x040700
131122
// We don't want translators to use own addresses in translations
132123
// and this is the only place, where this address is supplied.
133124
widget->setPlaceholderText(QObject::tr("Enter a Bitcoin address (e.g. %1)").arg(
134125
QString::fromStdString(DummyAddress(Params()))));
135-
#endif
136126
widget->setValidator(new BitcoinAddressEntryValidator(parent));
137127
widget->setCheckValidator(new BitcoinAddressCheckValidator(parent));
138128
}
@@ -151,12 +141,8 @@ bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
151141
}
152142
rv.amount = 0;
153143

154-
#if QT_VERSION < 0x050000
155-
QList<QPair<QString, QString> > items = uri.queryItems();
156-
#else
157144
QUrlQuery uriQuery(uri);
158145
QList<QPair<QString, QString> > items = uriQuery.queryItems();
159-
#endif
160146
for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
161147
{
162148
bool fShouldReturnFalse = false;
@@ -242,11 +228,7 @@ bool isDust(interfaces::Node& node, const QString& address, const CAmount& amoun
242228

243229
QString HtmlEscape(const QString& str, bool fMultiLine)
244230
{
245-
#if QT_VERSION < 0x050000
246-
QString escaped = Qt::escape(str);
247-
#else
248231
QString escaped = str.toHtmlEscaped();
249-
#endif
250232
if(fMultiLine)
251233
{
252234
escaped = escaped.replace("\n", "<br>\n");
@@ -287,11 +269,7 @@ QString getSaveFileName(QWidget *parent, const QString &caption, const QString &
287269
QString myDir;
288270
if(dir.isEmpty()) // Default to user documents location
289271
{
290-
#if QT_VERSION < 0x050000
291-
myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
292-
#else
293272
myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
294-
#endif
295273
}
296274
else
297275
{
@@ -337,11 +315,7 @@ QString getOpenFileName(QWidget *parent, const QString &caption, const QString &
337315
QString myDir;
338316
if(dir.isEmpty()) // Default to user documents location
339317
{
340-
#if QT_VERSION < 0x050000
341-
myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
342-
#else
343318
myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
344-
#endif
345319
}
346320
else
347321
{
@@ -495,11 +469,7 @@ void TableViewLastColumnResizingFixer::disconnectViewHeadersSignals()
495469
// Refactored here for readability.
496470
void TableViewLastColumnResizingFixer::setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode)
497471
{
498-
#if QT_VERSION < 0x050000
499-
tableView->horizontalHeader()->setResizeMode(logicalIndex, resizeMode);
500-
#else
501472
tableView->horizontalHeader()->setSectionResizeMode(logicalIndex, resizeMode);
502-
#endif
503473
}
504474

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

src/qt/guiutil.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ namespace GUIUtil
233233
void mouseReleaseEvent(QMouseEvent *event);
234234
};
235235

236-
#if defined(Q_OS_MAC) && QT_VERSION >= 0x050000
236+
#if defined(Q_OS_MAC)
237237
// workaround for Qt OSX Bug:
238238
// https://bugreports.qt-project.org/browse/QTBUG-15631
239239
// QProgressBar uses around 10% CPU even when app is in background

src/qt/macdockiconhandler.mm

+1-7
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
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-
2117
static MacDockIconHandler *s_instance = nullptr;
2218

2319
bool dockClickHandler(id self,SEL _cmd,...) {
@@ -54,9 +50,7 @@ void setupDockClickHandler() {
5450
this->m_dummyWidget = new QWidget();
5551
this->m_dockMenu = new QMenu(this->m_dummyWidget);
5652
this->setMainWindow(nullptr);
57-
#if QT_VERSION < 0x050000
58-
qt_mac_set_dock_menu(this->m_dockMenu);
59-
#elif QT_VERSION >= 0x050200
53+
#if QT_VERSION >= 0x050200
6054
this->m_dockMenu->setAsDockMenu();
6155
#endif
6256
[pool release];

src/qt/networkstyle.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ NetworkStyle::NetworkStyle(const QString &_appName, const int iconColorHueShift,
6868
}
6969

7070
//convert back to QPixmap
71-
#if QT_VERSION >= 0x040700
7271
pixmap.convertFromImage(img);
73-
#else
74-
pixmap = QPixmap::fromImage(img);
75-
#endif
7672
}
7773

7874
appIcon = QIcon(pixmap);

src/qt/openuridialog.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ OpenURIDialog::OpenURIDialog(QWidget *parent) :
1515
ui(new Ui::OpenURIDialog)
1616
{
1717
ui->setupUi(this);
18-
#if QT_VERSION >= 0x040700
1918
ui->uriEdit->setPlaceholderText("bitcoin:");
20-
#endif
2119
}
2220

2321
OpenURIDialog::~OpenURIDialog()

src/qt/optionsdialog.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,16 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
9797
/** check if the locale name consists of 2 parts (language_country) */
9898
if(langStr.contains("_"))
9999
{
100-
#if QT_VERSION >= 0x040800
101100
/** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */
102101
ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
103-
#else
104-
/** display language strings as "language - country (locale name)", e.g. "German - Germany (de)" */
105-
ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" - ") + QLocale::countryToString(locale.country()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
106-
#endif
107102
}
108103
else
109104
{
110-
#if QT_VERSION >= 0x040800
111105
/** display language strings as "native language (locale name)", e.g. "Deutsch (de)" */
112106
ui->lang->addItem(locale.nativeLanguageName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
113-
#else
114-
/** display language strings as "language (locale name)", e.g. "German (de)" */
115-
ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
116-
#endif
117107
}
118108
}
119-
#if QT_VERSION >= 0x040700
120109
ui->thirdPartyTxUrls->setPlaceholderText("https://example.com/tx/%s");
121-
#endif
122110

123111
ui->unit->setModel(new BitcoinUnits(this));
124112

src/qt/paymentrequestplus.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,10 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
9797
qWarning() << "PaymentRequestPlus::getMerchant: Payment request: certificate expired or not yet active: " << qCert;
9898
return false;
9999
}
100-
#if QT_VERSION >= 0x050000
101100
if (qCert.isBlacklisted()) {
102101
qWarning() << "PaymentRequestPlus::getMerchant: Payment request: certificate blacklisted: " << qCert;
103102
return false;
104103
}
105-
#endif
106104
const unsigned char *data = (const unsigned char *)certChain.certificate(i).data();
107105
X509 *cert = d2i_X509(nullptr, &data, certChain.certificate(i).size());
108106
if (cert)

0 commit comments

Comments
 (0)