Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QSortFilterProxyModel>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QRegularExpression>
#else
#include <QRegExp>
#endif

class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel
{
Expand Down Expand Up @@ -47,11 +43,7 @@ class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel

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

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
const auto pattern = filterRegularExpression();
#else
const auto pattern = filterRegExp();
#endif
return (model->data(address).toString().contains(pattern) ||
model->data(label).toString().contains(pattern));
}
Expand Down
15 changes: 0 additions & 15 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,7 @@ static void RegisterMetaTypes()
qRegisterMetaType<std::function<void()>>("std::function<void()>");
qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon");
qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>("interfaces::BlockAndHeaderTipInfo");

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qRegisterMetaTypeStreamOperators<BitcoinUnit>("BitcoinUnit");
#else
qRegisterMetaType<BitcoinUnit>("BitcoinUnit");
#endif
}

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

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
const QString translation_path{QLibraryInfo::location(QLibraryInfo::TranslationsPath)};
#else
const QString translation_path{QLibraryInfo::path(QLibraryInfo::TranslationsPath)};
#endif
// Load e.g. qt_de.qm
if (qtTranslatorBase.load("qt_" + lang, translation_path)) {
QApplication::installTranslator(&qtTranslatorBase);
Expand Down Expand Up @@ -508,12 +499,6 @@ int GuiMain(int argc, char* argv[])
Q_INIT_RESOURCE(bitcoin);
Q_INIT_RESOURCE(bitcoin_locale);

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// Generate high-dpi pixmaps
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif

#if defined(QT_QPA_PLATFORM_ANDROID)
QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
Expand Down
21 changes: 0 additions & 21 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,33 +954,12 @@ void PopupMenu(QMenu* menu, const QPoint& point, QAction* at_action)

QDateTime StartOfDay(const QDate& date)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return date.startOfDay();
#else
return QDateTime(date);
#endif
}

bool HasPixmap(const QLabel* label)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
return !label->pixmap(Qt::ReturnByValue).isNull();
#else
return label->pixmap() != nullptr;
#endif
}

QImage GetImage(const QLabel* label)
{
if (!HasPixmap(label)) {
return QImage();
}

#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
return label->pixmap(Qt::ReturnByValue).toImage();
#else
return label->pixmap()->toImage();
#endif
}

QString MakeHtmlLink(const QString& source, const QString& link)
Expand Down
22 changes: 0 additions & 22 deletions src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,28 +347,6 @@ namespace GUIUtil
* QPixmap* QLabel::pixmap() is deprecated since Qt 5.15.
*/
bool HasPixmap(const QLabel* label);
QImage GetImage(const QLabel* label);

/**
* Splits the string into substrings wherever separator occurs, and returns
* the list of those strings. Empty strings do not appear in the result.
*
* QString::split() signature differs in different Qt versions:
* - QString::SplitBehavior is deprecated since Qt 5.15
* - Qt::SplitBehavior was introduced in Qt 5.14
* If {QString|Qt}::SkipEmptyParts behavior is required, use this
* function instead of QString::split().
*/
template <typename SeparatorType>
QStringList SplitSkipEmptyParts(const QString& string, const SeparatorType& separator)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return string.split(separator, Qt::SkipEmptyParts);
#else
return string.split(separator, QString::SkipEmptyParts);
#endif
}


/**
* Replaces a plain text link with an HTML tagged one.
Expand Down
4 changes: 0 additions & 4 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,7 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
{
/** display language strings as "native language - native country/territory (locale name)", e.g. "Deutsch - Deutschland (de)" */
ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") +
#if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0))
locale.nativeTerritoryName() +
#else
locale.nativeCountryName() +
#endif
QString(" (") + langStr + QString(")"), QVariant(langStr));

}
Expand Down
6 changes: 5 additions & 1 deletion src/qt/qrimagewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ bool QRImageWidget::setQR(const QString& data, const QString& text)

QImage QRImageWidget::exportImage()
{
return GUIUtil::GetImage(this);
if (!GUIUtil::HasPixmap(this)) {
return QImage();
}

return this->pixmap(Qt::ReturnByValue).toImage();
Copy link
Contributor

@davidgumberg davidgumberg Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Micro-Nit:

As far as I understand this is deprecated in favor of QLabel::pixmap() at least as early as QT 6.2 (https://doc.qt.io/archives/qt-6.2/qlabel-obsolete.html#pixmap) and was marked obsolete in 6.0 (https://doc.qt.io/archives/qt-6.0/qlabel-obsolete.html#pixmap)

Previously, it was recommended to use QLabel::pixmap(Qt::ReturnByValue) to maintain compatibility with old code, since previously QLabel::pixmap() returned a pixmap by pointer. (https://doc.qt.io/qt-5/qlabel.html#pixmap-prop)

Suggested change
return this->pixmap(Qt::ReturnByValue).toImage();
return this->pixmap().toImage();

}

void QRImageWidget::mousePressEvent(QMouseEvent *event)
Expand Down
5 changes: 0 additions & 5 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,8 @@ void SendCoinsDialog::setModel(WalletModel *_model)
connect(ui->confTargetSelector, qOverload<int>(&QComboBox::currentIndexChanged), this, &SendCoinsDialog::updateSmartFeeLabel);
connect(ui->confTargetSelector, qOverload<int>(&QComboBox::currentIndexChanged), this, &SendCoinsDialog::coinControlUpdateLabels);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
connect(ui->groupFee, &QButtonGroup::idClicked, this, &SendCoinsDialog::updateFeeSectionControls);
connect(ui->groupFee, &QButtonGroup::idClicked, this, &SendCoinsDialog::coinControlUpdateLabels);
#else
connect(ui->groupFee, qOverload<int>(&QButtonGroup::buttonClicked), this, &SendCoinsDialog::updateFeeSectionControls);
connect(ui->groupFee, qOverload<int>(&QButtonGroup::buttonClicked), this, &SendCoinsDialog::coinControlUpdateLabels);
#endif

connect(ui->customFee, &BitcoinAmountField::valueChanged, this, &SendCoinsDialog::coinControlUpdateLabels);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void TransactionView::setModel(WalletModel *_model)
if (_model->getOptionsModel())
{
// Add third party transaction URLs to context menu
QStringList listUrls = GUIUtil::SplitSkipEmptyParts(_model->getOptionsModel()->getThirdPartyTxUrls(), "|");
QStringList listUrls = _model->getOptionsModel()->getThirdPartyTxUrls().split("|", Qt::SkipEmptyParts);
bool actions_created = false;
for (int i = 0; i < listUrls.size(); ++i)
{
Expand Down
4 changes: 0 additions & 4 deletions src/qt/winshutdownmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@

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

Expand Down
4 changes: 0 additions & 4 deletions src/qt/winshutdownmonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ class WinShutdownMonitor : public QAbstractNativeEventFilter
WinShutdownMonitor(std::function<void()> shutdown_fn) : m_shutdown_fn{std::move(shutdown_fn)} {}

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

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