From 1baf07fafcb556f41932d60d6e4015ad895879ea Mon Sep 17 00:00:00 2001 From: gg Date: Thu, 15 Jan 2026 05:38:56 -0500 Subject: [PATCH] Qt5 compat --- src/CoinsWidget.cpp | 6 ++++++ src/MainWindow.cpp | 30 +++++++++++++++--------------- src/SendWidget.cpp | 20 +++++++++++++++++--- src/WindowManager.cpp | 18 +++++++++--------- src/components.cpp | 4 ++++ src/components.h | 4 ++++ src/dialog/HistoryExportDialog.cpp | 3 ++- src/libwalletqt/PassphraseHelper.h | 1 + src/main.cpp | 16 ++++++++-------- src/model/CoinsModel.h | 1 + 10 files changed, 67 insertions(+), 36 deletions(-) diff --git a/src/CoinsWidget.cpp b/src/CoinsWidget.cpp index edee303b..8259c22e 100644 --- a/src/CoinsWidget.cpp +++ b/src/CoinsWidget.cpp @@ -275,10 +275,16 @@ void CoinsWidget::onSweepOutputs() { bool churn = dialog.churn(); int outputs = dialog.outputs(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QtFuture::connect(m_wallet, &Wallet::preTransactionChecksComplete) .then([this, keyImages, address, churn, outputs](int feeLevel){ m_wallet->sweepOutputs(keyImages, address, churn, outputs, feeLevel); }); +#else + QObject::connect(m_wallet, &Wallet::preTransactionChecksComplete, [this, keyImages, address, churn, outputs](int feeLevel){ + m_wallet->sweepOutputs(keyImages, address, churn, outputs, feeLevel); + }); +#endif m_wallet->preTransactionChecks(dialog.feeLevel()); } diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index a1323e7e..b0db7d49 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1188,19 +1188,19 @@ void MainWindow::onTransactionCreated(PendingTransaction *tx, const QVector= QT_VERSION_CHECK(6, 0, 0) QtFuture::connect(m_wallet, &Wallet::preTransactionChecksComplete) .then([this, addresses, amounts, description, subtractFeeFromAmount](int feeLevel){ m_wallet->createTransactionMultiDest(addresses, amounts, description, feeLevel, subtractFeeFromAmount); }); + #else + // Qt 5 Fallback + connect(m_wallet, &Wallet::preTransactionChecksComplete, this, [this, addresses, amounts, description, subtractFeeFromAmount](int feeLevel){ + m_wallet->createTransactionMultiDest(addresses, amounts, description, feeLevel, subtractFeeFromAmount); + }); + #endif m_wallet->preTransactionChecks(ui->combo_feePriority->currentIndex()); @@ -249,10 +256,17 @@ void SendWidget::sendClicked() { #endif } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QtFuture::connect(m_wallet, &Wallet::preTransactionChecksComplete) - .then([this, recipient, amount, description, sendAll, subtractFeeFromAmount](int feeLevel){ - m_wallet->createTransaction(recipient, amount, description, sendAll, feeLevel, subtractFeeFromAmount); - }); + .then([this, recipient, amount, description, sendAll, subtractFeeFromAmount](int feeLevel){ + m_wallet->createTransaction(recipient, amount, description, sendAll, feeLevel, subtractFeeFromAmount); + }); +#else + // Qt 5 Fallback + connect(m_wallet, &Wallet::preTransactionChecksComplete, this, [this, recipient, amount, description, sendAll, subtractFeeFromAmount](int feeLevel){ + m_wallet->createTransaction(recipient, amount, description, sendAll, feeLevel, subtractFeeFromAmount); + }); +#endif m_wallet->preTransactionChecks(ui->combo_feePriority->currentIndex()); } diff --git a/src/WindowManager.cpp b/src/WindowManager.cpp index 2417e61f..0b95825d 100644 --- a/src/WindowManager.cpp +++ b/src/WindowManager.cpp @@ -520,12 +520,12 @@ void WindowManager::handleDeviceError(const QString &error, Utils::Message &msg) // Ledger if (error.contains("No device found")) { msg.description = "No Ledger device found."; - msg.helpItems = {"Make sure the Monero app is open on the device.", "If the problem persists, try restarting Feather."}; + msg.helpItems = QStringList{"Make sure the Monero app is open on the device.", "If the problem persists, try restarting Feather."}; msg.doc = "create_wallet_hardware_device"; } else if (error.contains("Unable to open device")) { msg.description = "Unable to open device."; - msg.helpItems = {"The device might be in use by a different application."}; + msg.helpItems = QStringList{"The device might be in use by a different application."}; #if defined(Q_OS_LINUX) msg.helpItems.append("On Linux you may need to follow the instructions in the link below before the device can be opened:\n" "https://support.ledger.com/hc/en-us/articles/115005165269-Fix-connection-issues"); @@ -536,15 +536,15 @@ void WindowManager::handleDeviceError(const QString &error, Utils::Message &msg) // Trezor else if (error.contains("Unable to claim libusb device")) { msg.description = "Unable to claim Trezor device"; - msg.helpItems = {"Please make sure the device is not used by another program, like Trezor Suite or trezord, and try again."}; + msg.helpItems = QStringList{"Please make sure the device is not used by another program, like Trezor Suite or trezord, and try again."}; } else if (error.contains("Cannot get a device address")) { msg.description = "Cannot get a device address"; - msg.helpItems = {"Reattach the Trezor device and try again"}; + msg.helpItems = QStringList{"Reattach the Trezor device and try again"}; } else if (error.contains("Could not connect to the device Trezor") || error.contains("Device connect failed")) { msg.description = "Could not connect to the Trezor device"; - msg.helpItems = {"Make sure the device is connected to your computer and unlocked."}; + msg.helpItems = QStringList{"Make sure the device is connected to your computer and unlocked."}; #if defined(Q_OS_LINUX) msg.helpItems.append("On Linux you may need to follow the instructions in the link below before the device can be opened:\n" "https://wiki.trezor.io/Udev_rules"); @@ -552,17 +552,17 @@ void WindowManager::handleDeviceError(const QString &error, Utils::Message &msg) #endif } else if (error.contains("Failed to acquire device")) { - msg.helpItems = {"Make sure Trezor Suite and trezord are closed."}; + msg.helpItems = QStringList{"Make sure Trezor Suite and trezord are closed."}; } else if (error.contains("SW_CLIENT_NOT_SUPPORTED")) { - msg.helpItems = {"Upgrade your Ledger device firmware to the latest version using Ledger Live.\n" + msg.helpItems = QStringList{"Upgrade your Ledger device firmware to the latest version using Ledger Live.\n" "Then upgrade the Monero app for the Ledger device to the latest version."}; } else if (error.contains("Wrong Device Status")) { - msg.helpItems = {"The device may need to be unlocked."}; + msg.helpItems = QStringList{"The device may need to be unlocked."}; } else if (error.contains("Wrong Channel")) { - msg.helpItems = {"Restart the hardware device and try again."}; + msg.helpItems = QStringList{"Restart the hardware device and try again."}; } else { msg.doc = "report_an_issue"; diff --git a/src/components.cpp b/src/components.cpp index 43949431..8c6b9878 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -52,7 +52,11 @@ void HelpLabel::mouseReleaseEvent(QMouseEvent *event) Utils::showInfo(this, m_text, m_informativeText, {}, m_doc); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) void HelpLabel::enterEvent(QEnterEvent *event) +#else +void HelpLabel::enterEvent(QEvent *event) +#endif { font.setUnderline(true); setFont(font); diff --git a/src/components.h b/src/components.h index 4d7b8a82..57ec4d68 100644 --- a/src/components.h +++ b/src/components.h @@ -50,7 +50,11 @@ public: protected: void mouseReleaseEvent(QMouseEvent *event) override; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) void enterEvent(QEnterEvent *event) override; +#else + void enterEvent(QEvent *event) override; +#endif void leaveEvent(QEvent *event) override; private: diff --git a/src/dialog/HistoryExportDialog.cpp b/src/dialog/HistoryExportDialog.cpp index 766f4fc3..5a63e7f9 100644 --- a/src/dialog/HistoryExportDialog.cpp +++ b/src/dialog/HistoryExportDialog.cpp @@ -39,7 +39,8 @@ HistoryExportDialog::HistoryExportDialog(Wallet *wallet, QWidget *parent) ui->date_max->setDate(QDate::currentDate()); }); - connect(ui->spin_days, &QSpinBox::valueChanged, [this] { + // Works on Qt 5 and Qt 6 + connect(ui->spin_days, QOverload::of(&QSpinBox::valueChanged), [this] { ui->date_min->setDate(QDate::currentDate().addDays(-ui->spin_days->value() + 1)); ui->date_max->setDate(QDate::currentDate()); }); diff --git a/src/libwalletqt/PassphraseHelper.h b/src/libwalletqt/PassphraseHelper.h index d9b8b450..ff964baf 100644 --- a/src/libwalletqt/PassphraseHelper.h +++ b/src/libwalletqt/PassphraseHelper.h @@ -7,6 +7,7 @@ #include #include #include +#include // For Qt5 compatibility /** * Implements component responsible for showing entry prompt to the user, diff --git a/src/main.cpp b/src/main.cpp index 4b57478e..79306493 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -214,14 +214,14 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) { if (!quiet && !conf()->get(Config::disableLogging).toBool()) { QList> info; - info.emplace_back("Feather", FEATHER_VERSION); - info.emplace_back("Monero", MONERO_VERSION); - info.emplace_back("Qt", QT_VERSION_STR); - info.emplace_back("Tor", TOR_VERSION); - info.emplace_back("SSL", QSslSocket::sslLibraryVersionString()); - info.emplace_back("Mode", stagenet ? "Stagenet" : (testnet ? "Testnet" : "Mainnet")); - info.emplace_back("Network", conf()->get(Config::syncPaused).toBool() ? "PAUSED" : "ACTIVE"); - info.emplace_back("Config dir", configDir); + info.push_back({"Feather", FEATHER_VERSION}); + info.push_back({"Monero", MONERO_VERSION}); + info.push_back({"Qt", QT_VERSION_STR}); + info.push_back({"Tor", TOR_VERSION}); + info.push_back({"SSL", QSslSocket::sslLibraryVersionString()}); + info.push_back({"Mode", stagenet ? "Stagenet" : (testnet ? "Testnet" : "Mainnet")}); + info.push_back({"Network", conf()->get(Config::syncPaused).toBool() ? "PAUSED" : "ACTIVE"}); + info.push_back({"Config dir", configDir}); for (const auto &k: info) { qWarning().nospace().noquote() << QString("%1: %2").arg(k.first, k.second); diff --git a/src/model/CoinsModel.h b/src/model/CoinsModel.h index 827724b4..57bcb23e 100644 --- a/src/model/CoinsModel.h +++ b/src/model/CoinsModel.h @@ -5,6 +5,7 @@ #define FEATHER_COINSMODEL_H #include +#include // For Qt5 compatibility class Coins; class CoinsInfo; -- 2.52.0