Skip to content

Commit df82a24

Browse files
committed
Merge #863: refactor: Post Qt 6 cleanup
3aa58be qt, refactor: Inline `GUIUtil::SplitSkipEmptyParts` function (Hennadii Stepanov) d1ec6db qt, refactor: Inline `GUIUtil::GetImage` function (Hennadii Stepanov) 4b36ab3 qt, refactor: Remove outdated Qt version-specific code (Hennadii Stepanov) Pull request description: This PR: - Removes outdated Qt version-specific code. - Inlines two functions from `GUIUtil`. ACKs for top commit: davidgumberg: crACK 3aa58be Tree-SHA512: f56f6e3a219a5378d986bcb5fbfc50dcd752c080a92055da1f859433214c999905b456a12f6ac3d5b4871656dbf43a732adf04536c3479b1aa93110beafb2478
2 parents 77dff37 + 3aa58be commit df82a24

10 files changed

+6
-85
lines changed

src/qt/addressbookpage.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
#include <QMenu>
1616
#include <QMessageBox>
1717
#include <QSortFilterProxyModel>
18-
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1918
#include <QRegularExpression>
20-
#else
21-
#include <QRegExp>
22-
#endif
2319

2420
class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel
2521
{
@@ -47,11 +43,7 @@ class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel
4743

4844
auto address = model->index(row, AddressTableModel::Address, parent);
4945

50-
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
5146
const auto pattern = filterRegularExpression();
52-
#else
53-
const auto pattern = filterRegExp();
54-
#endif
5547
return (model->data(address).toString().contains(pattern) ||
5648
model->data(label).toString().contains(pattern));
5749
}

src/qt/bitcoin.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,7 @@ static void RegisterMetaTypes()
9090
qRegisterMetaType<std::function<void()>>("std::function<void()>");
9191
qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon");
9292
qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>("interfaces::BlockAndHeaderTipInfo");
93-
94-
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
95-
qRegisterMetaTypeStreamOperators<BitcoinUnit>("BitcoinUnit");
96-
#else
9793
qRegisterMetaType<BitcoinUnit>("BitcoinUnit");
98-
#endif
9994
}
10095

10196
static QString GetLangTerritory()
@@ -134,11 +129,7 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
134129
// - First load the translator for the base language, without territory
135130
// - Then load the more specific locale translator
136131

137-
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
138-
const QString translation_path{QLibraryInfo::location(QLibraryInfo::TranslationsPath)};
139-
#else
140132
const QString translation_path{QLibraryInfo::path(QLibraryInfo::TranslationsPath)};
141-
#endif
142133
// Load e.g. qt_de.qm
143134
if (qtTranslatorBase.load("qt_" + lang, translation_path)) {
144135
QApplication::installTranslator(&qtTranslatorBase);
@@ -508,12 +499,6 @@ int GuiMain(int argc, char* argv[])
508499
Q_INIT_RESOURCE(bitcoin);
509500
Q_INIT_RESOURCE(bitcoin_locale);
510501

511-
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
512-
// Generate high-dpi pixmaps
513-
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
514-
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
515-
#endif
516-
517502
#if defined(QT_QPA_PLATFORM_ANDROID)
518503
QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
519504
QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);

src/qt/guiutil.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -954,33 +954,12 @@ void PopupMenu(QMenu* menu, const QPoint& point, QAction* at_action)
954954

955955
QDateTime StartOfDay(const QDate& date)
956956
{
957-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
958957
return date.startOfDay();
959-
#else
960-
return QDateTime(date);
961-
#endif
962958
}
963959

964960
bool HasPixmap(const QLabel* label)
965961
{
966-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
967962
return !label->pixmap(Qt::ReturnByValue).isNull();
968-
#else
969-
return label->pixmap() != nullptr;
970-
#endif
971-
}
972-
973-
QImage GetImage(const QLabel* label)
974-
{
975-
if (!HasPixmap(label)) {
976-
return QImage();
977-
}
978-
979-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
980-
return label->pixmap(Qt::ReturnByValue).toImage();
981-
#else
982-
return label->pixmap()->toImage();
983-
#endif
984963
}
985964

986965
QString MakeHtmlLink(const QString& source, const QString& link)

src/qt/guiutil.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -347,28 +347,6 @@ namespace GUIUtil
347347
* QPixmap* QLabel::pixmap() is deprecated since Qt 5.15.
348348
*/
349349
bool HasPixmap(const QLabel* label);
350-
QImage GetImage(const QLabel* label);
351-
352-
/**
353-
* Splits the string into substrings wherever separator occurs, and returns
354-
* the list of those strings. Empty strings do not appear in the result.
355-
*
356-
* QString::split() signature differs in different Qt versions:
357-
* - QString::SplitBehavior is deprecated since Qt 5.15
358-
* - Qt::SplitBehavior was introduced in Qt 5.14
359-
* If {QString|Qt}::SkipEmptyParts behavior is required, use this
360-
* function instead of QString::split().
361-
*/
362-
template <typename SeparatorType>
363-
QStringList SplitSkipEmptyParts(const QString& string, const SeparatorType& separator)
364-
{
365-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
366-
return string.split(separator, Qt::SkipEmptyParts);
367-
#else
368-
return string.split(separator, QString::SkipEmptyParts);
369-
#endif
370-
}
371-
372350

373351
/**
374352
* Replaces a plain text link with an HTML tagged one.

src/qt/optionsdialog.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,7 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
164164
{
165165
/** display language strings as "native language - native country/territory (locale name)", e.g. "Deutsch - Deutschland (de)" */
166166
ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") +
167-
#if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0))
168167
locale.nativeTerritoryName() +
169-
#else
170-
locale.nativeCountryName() +
171-
#endif
172168
QString(" (") + langStr + QString(")"), QVariant(langStr));
173169

174170
}

src/qt/qrimagewidget.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ bool QRImageWidget::setQR(const QString& data, const QString& text)
9292

9393
QImage QRImageWidget::exportImage()
9494
{
95-
return GUIUtil::GetImage(this);
95+
if (!GUIUtil::HasPixmap(this)) {
96+
return QImage();
97+
}
98+
99+
return this->pixmap(Qt::ReturnByValue).toImage();
96100
}
97101

98102
void QRImageWidget::mousePressEvent(QMouseEvent *event)

src/qt/sendcoinsdialog.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,8 @@ void SendCoinsDialog::setModel(WalletModel *_model)
178178
connect(ui->confTargetSelector, qOverload<int>(&QComboBox::currentIndexChanged), this, &SendCoinsDialog::updateSmartFeeLabel);
179179
connect(ui->confTargetSelector, qOverload<int>(&QComboBox::currentIndexChanged), this, &SendCoinsDialog::coinControlUpdateLabels);
180180

181-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
182181
connect(ui->groupFee, &QButtonGroup::idClicked, this, &SendCoinsDialog::updateFeeSectionControls);
183182
connect(ui->groupFee, &QButtonGroup::idClicked, this, &SendCoinsDialog::coinControlUpdateLabels);
184-
#else
185-
connect(ui->groupFee, qOverload<int>(&QButtonGroup::buttonClicked), this, &SendCoinsDialog::updateFeeSectionControls);
186-
connect(ui->groupFee, qOverload<int>(&QButtonGroup::buttonClicked), this, &SendCoinsDialog::coinControlUpdateLabels);
187-
#endif
188183

189184
connect(ui->customFee, &BitcoinAmountField::valueChanged, this, &SendCoinsDialog::coinControlUpdateLabels);
190185
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))

src/qt/transactionview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void TransactionView::setModel(WalletModel *_model)
221221
if (_model->getOptionsModel())
222222
{
223223
// Add third party transaction URLs to context menu
224-
QStringList listUrls = GUIUtil::SplitSkipEmptyParts(_model->getOptionsModel()->getThirdPartyTxUrls(), "|");
224+
QStringList listUrls = _model->getOptionsModel()->getThirdPartyTxUrls().split("|", Qt::SkipEmptyParts);
225225
bool actions_created = false;
226226
for (int i = 0; i < listUrls.size(); ++i)
227227
{

src/qt/winshutdownmonitor.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212

1313
// If we don't want a message to be processed by Qt, return true and set result to
1414
// the value that the window procedure should return. Otherwise return false.
15-
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1615
bool WinShutdownMonitor::nativeEventFilter(const QByteArray &eventType, void *pMessage, qintptr *pnResult)
17-
#else
18-
bool WinShutdownMonitor::nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pnResult)
19-
#endif
2016
{
2117
Q_UNUSED(eventType);
2218

src/qt/winshutdownmonitor.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ class WinShutdownMonitor : public QAbstractNativeEventFilter
2020
WinShutdownMonitor(std::function<void()> shutdown_fn) : m_shutdown_fn{std::move(shutdown_fn)} {}
2121

2222
/** Implements QAbstractNativeEventFilter interface for processing Windows messages */
23-
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
2423
bool nativeEventFilter(const QByteArray &eventType, void *pMessage, qintptr *pnResult) override;
25-
#else
26-
bool nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pnResult) override;
27-
#endif
2824

2925
/** Register the reason for blocking shutdown on Windows to allow clean client exit */
3026
static void registerShutdownBlockReason(const QString& strReason, const HWND& mainWinId);

0 commit comments

Comments
 (0)