diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c758330..6572ef01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,9 @@ project(feather) message(STATUS "Initiating compile using CMake ${CMAKE_VERSION}") +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(VERSION_MAJOR "1") set(VERSION_MINOR "0") set(VERSION_REVISION "1") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d453f930..651b9633 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,7 @@ set(CMAKE_AUTOUIC ON) # pthread find_package(Threads REQUIRED) -set(QT5_COMPONENTS +set(QT_COMPONENTS Core Widgets Gui @@ -16,19 +16,22 @@ set(QT5_COMPONENTS ) if (WITH_SCANNER) - list(APPEND QT5_COMPONENTS + list(APPEND QT_COMPONENTS Multimedia MultimediaWidgets) endif() -find_package(Qt5 REQUIRED COMPONENTS ${QT5_COMPONENTS}) +find_package(Qt6 COMPONENTS ${QT_COMPONENTS} SvgWidgets) +if (NOT Qt6_FOUND) + find_package(Qt5 5.15 REQUIRED COMPONENTS ${QT_COMPONENTS}) +endif() set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication") add_subdirectory(third-party/singleapplication) add_subdirectory(openpgp) -qt5_add_resources(RESOURCES assets.qrc assets_tor.qrc) +qt_add_resources(RESOURCES assets.qrc assets_tor.qrc) # Compile source files (.h/.cpp) file(GLOB SOURCE_FILES @@ -67,7 +70,7 @@ file(GLOB SOURCE_FILES "qrcode_scanner/QrCodeUtils.h" ) -if (WITH_SCANNER) +if (WITH_SCANNER AND NOT Qt6_FOUND) file(GLOB SCANNER_FILES "qrcode_scanner/*.h" "qrcode_scanner/*.cpp") @@ -84,8 +87,8 @@ if(MINGW) set(ICON_RC ${CMAKE_CURRENT_BINARY_DIR}/icon.rc) set(ICON_RES ${CMAKE_CURRENT_BINARY_DIR}/icon.o) file(WRITE ${ICON_RC} "IDI_ICON1 ICON DISCARDABLE \"${ICON}\"") - find_program(Qt5_WINDRES_EXECUTABLE NAMES windres x86_64-w64-mingw32-windres REQUIRED CMAKE_FIND_ROOT_PATH_BOTH) - add_custom_command(OUTPUT ${ICON_RES} COMMAND ${Qt5_WINDRES_EXECUTABLE} ${ICON_RC} ${ICON_RES} MAIN_DEPENDENCY ${ICON_RC}) + find_program(Qt_WINDRES_EXECUTABLE NAMES windres x86_64-w64-mingw32-windres REQUIRED CMAKE_FIND_ROOT_PATH_BOTH) + add_custom_command(OUTPUT ${ICON_RES} COMMAND ${Qt_WINDRES_EXECUTABLE} ${ICON_RC} ${ICON_RES} MAIN_DEPENDENCY ${ICON_RC}) list(APPEND RESOURCES ${ICON_RES}) endif() @@ -112,7 +115,7 @@ set_target_properties(feather PROPERTIES set_property(TARGET feather PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -target_include_directories(feather PUBLIC ${Qt5Gui_PRIVATE_INCLUDE_DIRS}) +target_include_directories(feather PUBLIC ${QtGui_PRIVATE_INCLUDE_DIRS}) target_include_directories(feather PUBLIC ${CMAKE_BINARY_DIR}/src/feather_autogen/include @@ -130,13 +133,14 @@ target_include_directories(feather PUBLIC ${X11_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} - ${Qt5Core_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5Gui_INCLUDE_DIRS} - ${Qt5Network_INCLUDE_DIRS} - ${Qt5Svg_INCLUDE_DIRS} - ${Qt5Xml_INCLUDE_DIRS} - ${Qt5WebSockets_INCLUDE_DIRS} + ${QtCore_INCLUDE_DIRS} + ${QtWidgets_INCLUDE_DIRS} + ${QtGui_INCLUDE_DIRS} + ${QtNetwork_INCLUDE_DIRS} + ${QtSvg_INCLUDE_DIRS} + ${QtSvgWidgets_INCLUDE_DIRS} + ${QtXml_INCLUDE_DIRS} + ${QtWebSockets_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${LIBZIP_INCLUDE_DIRS} ${ZBAR_INCLUDE_DIR} @@ -145,8 +149,8 @@ target_include_directories(feather PUBLIC if(WITH_SCANNER) target_include_directories(feather PUBLIC - ${Qt5Multimedia_INCLUDE_DIRS} - ${Qt5MultimediaWidgets_INCLUDE_DIRS} + ${QtMultimedia_INCLUDE_DIRS} + ${QtMultimediaWidgets_INCLUDE_DIRS} ) endif() @@ -174,7 +178,7 @@ if(XMRIG) target_compile_definitions(feather PRIVATE HAS_XMRIG=1) endif() -if(WITH_SCANNER) +if(WITH_SCANNER AND NOT Qt6_FOUND) target_compile_definitions(feather PRIVATE WITH_SCANNER=1) endif() @@ -203,23 +207,24 @@ endif() target_compile_definitions(feather PUBLIC - ${Qt5Core_DEFINITIONS} - ${Qt5Widgets_DEFINITIONS} - ${Qt5Gui_DEFINITIONS} - ${Qt5Network_DEFINITIONS} - ${Qt5Svg_DEFINITIONS} - ${Qt5Xml_DEFINITIONS} - ${Qt5WebSockets_DEFINITIONS} + ${QtCore_DEFINITIONS} + ${QtWidgets_DEFINITIONS} + ${QtGui_DEFINITIONS} + ${QtNetwork_DEFINITIONS} + ${QtSvg_DEFINITIONS} + ${QtSvgWidgets_DEFINITIONS} + ${QtXml_DEFINITIONS} + ${QtWebSockets_DEFINITIONS} ) if (WITH_SCANNER) target_compile_definitions(feather PUBLIC - ${Qt5Multimedia_DEFINITIONS} - ${Qt5MultimediaWidgets_DEFINITIONS} + ${QtMultimedia_DEFINITIONS} + ${QtMultimediaWidgets_DEFINITIONS} ) endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QtWidgets_EXECUTABLE_COMPILE_FLAGS}") if(UNIX AND NOT APPLE) # https://stackoverflow.com/questions/57766620/cmake-add-library-doesnt-initialize-static-global-variable @@ -242,13 +247,13 @@ target_link_libraries(feather ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} ${EXTRA_LIBRARIES} - Qt5::Core - Qt5::Widgets - Qt5::Gui - Qt5::Network - Qt5::Svg - Qt5::Xml - Qt5::WebSockets + Qt::Core + Qt::Widgets + Qt::Gui + Qt::Network + Qt::Svg + Qt::Xml + Qt::WebSockets ${ICU_LIBRARIES} openpgp Threads::Threads @@ -260,28 +265,34 @@ target_link_libraries(feather SingleApplication::SingleApplication ) +if(Qt6_FOUND) + target_link_libraries(feather Qt::SvgWidgets) +endif() + if(DEVICE_TREZOR_READY) target_link_libraries(feather ${TREZOR_DEP_LIBS}) endif() if (WITH_SCANNER) target_link_libraries(feather - Qt5::Multimedia - Qt5::MultimediaWidgets + Qt::Multimedia + Qt::MultimediaWidgets ) endif() -if(NOT APPLE) +if(NOT APPLE AND NOT Qt6_FOUND) target_link_libraries(feather Qt5::QSvgIconPlugin Qt5::QSvgPlugin ) endif() -if(STATIC) +if(STATIC AND NOT Qt6_FOUND) + if(NOT Qt6_FOUND) target_link_libraries(feather Qt5::QSvgIconPlugin Qt5::QSvgPlugin) + endif() if(UNIX AND NOT APPLE) target_link_libraries(feather Qt5::QXcbIntegrationPlugin) diff --git a/src/CoinsWidget.h b/src/CoinsWidget.h index f0978d7d..bb45e744 100644 --- a/src/CoinsWidget.h +++ b/src/CoinsWidget.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include "appcontext.h" #include "model/CoinsModel.h" diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index c0a010bb..35b6b00c 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1665,11 +1665,12 @@ void MainWindow::checkUserActivity() { this->setEnabled(false); this->close(); // This doesn't close the wallet immediately. - do { + // FIXME +// do { QApplication::processEvents(); // Because running it a single time is apparently not enough. // TODO: Qt bug? Need proper fix for this. - } while (QApplication::hasPendingEvents()); +// } while (QApplication::hasPendingEvents()); } else { m_checkUserActivity.start(); } diff --git a/src/ReceiveWidget.h b/src/ReceiveWidget.h index 05e7ae05..9bd19e0f 100644 --- a/src/ReceiveWidget.h +++ b/src/ReceiveWidget.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include "appcontext.h" #include "libwalletqt/Subaddress.h" diff --git a/src/components.cpp b/src/components.cpp index 5d625767..87a7eab4 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -89,7 +89,11 @@ void HelpLabel::mouseReleaseEvent(QMouseEvent *event) QMessageBox::information(this, "Help", this->help_text); } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void HelpLabel::enterEvent(QEvent *event) +#else +void HelpLabel::enterEvent(QEnterEvent *event) +#endif { font.setUnderline(true); setFont(font); diff --git a/src/components.h b/src/components.h index fb03aaaf..938a006d 100644 --- a/src/components.h +++ b/src/components.h @@ -102,7 +102,11 @@ public: protected: void mouseReleaseEvent(QMouseEvent *event) override; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void enterEvent(QEvent *event) override; +#else + void enterEvent(QEnterEvent *event) override; +#endif void leaveEvent(QEvent *event) override; }; diff --git a/src/dialog/TxInfoDialog.h b/src/dialog/TxInfoDialog.h index 61234dec..e00381f8 100644 --- a/src/dialog/TxInfoDialog.h +++ b/src/dialog/TxInfoDialog.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "appcontext.h" #include "dialog/TxProofDialog.h" diff --git a/src/libwalletqt/TransactionHistory.cpp b/src/libwalletqt/TransactionHistory.cpp index 66352826..b6aacc2f 100644 --- a/src/libwalletqt/TransactionHistory.cpp +++ b/src/libwalletqt/TransactionHistory.cpp @@ -202,7 +202,7 @@ bool TransactionHistory::writeCSV(const QString &path) { // format and write QString line = QString("\n%1,%2,\"%3\",%4,\"%5\",%6,%7,%8,\"%9\",\"%10\",\"%11\",%12,\"%13\"") - .arg(QString::number(info.blockHeight()), QString::number(timeStamp.toTime_t()), date, + .arg(QString::number(info.blockHeight()), QString::number(timeStamp.toSecsSinceEpoch()), date, QString::number(info.subaddrAccount()), direction, balanceDelta, info.displayAmount(), info.fee(), info.hash(), info.description(), paymentId, fiatAmount, preferredFiatSymbol); data += line; diff --git a/src/main.cpp b/src/main.cpp index 243b3f4b..477df638 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,8 +114,10 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) { constants::networkType = NetworkType::MAINNET; // Setup QApplication +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton); +#endif QApplication::setDesktopSettingsAware(true); // use system font QApplication::setApplicationVersion(FEATHER_VERSION); diff --git a/src/model/LocalMoneroModel.cpp b/src/model/LocalMoneroModel.cpp index ca74eb61..7a8e95fa 100644 --- a/src/model/LocalMoneroModel.cpp +++ b/src/model/LocalMoneroModel.cpp @@ -156,8 +156,8 @@ void LocalMoneroModel::setPaymentMethods(const QJsonObject &data) { m_paymentMethods = data; m_paymentMethodNames.clear(); for (const auto &payment_method : data) { - auto code = payment_method["code"].toString(); - auto name = payment_method["name"].toString(); + auto code = payment_method.toObject()["code"].toString(); + auto name = payment_method.toObject()["name"].toString(); if (!code.isEmpty() && !name.isEmpty()) { m_paymentMethodNames[code] = name; diff --git a/src/model/WalletKeysFilesModel.cpp b/src/model/WalletKeysFilesModel.cpp index 4fe4bdcb..fd2f80b0 100644 --- a/src/model/WalletKeysFilesModel.cpp +++ b/src/model/WalletKeysFilesModel.cpp @@ -98,7 +98,7 @@ void WalletKeysFilesModel::findWallets() { if (Utils::fileExists(basePath + ".address.txt")) { QFile file(basePath + ".address.txt"); file.open(QFile::ReadOnly | QFile::Text); - const QString _address = QTextCodec::codecForMib(106)->toUnicode(file.readAll()); + const QString _address = QString::fromUtf8(file.readAll()); if (!_address.isEmpty()) { addr = _address; diff --git a/src/utils/ColorScheme.cpp b/src/utils/ColorScheme.cpp index 6dffe26b..32e8f640 100644 --- a/src/utils/ColorScheme.cpp +++ b/src/utils/ColorScheme.cpp @@ -15,7 +15,7 @@ ColorSchemeItem ColorScheme::GRAY = ColorSchemeItem("gray", "gray"); bool ColorScheme::hasDarkBackground(QWidget *widget) { int r, g, b; - widget->palette().color(QPalette::Background).getRgb(&r, &g, &b); + widget->palette().color(QPalette::Window).getRgb(&r, &g, &b); auto brightness = r + g + b; return brightness < (255*3/2); } diff --git a/src/utils/TxFiatHistory.cpp b/src/utils/TxFiatHistory.cpp index 725cbc18..6736de08 100644 --- a/src/utils/TxFiatHistory.cpp +++ b/src/utils/TxFiatHistory.cpp @@ -14,7 +14,7 @@ TxFiatHistory::TxFiatHistory(int genesis_timestamp, const QString &configDirecto double TxFiatHistory::get(int timestamp) { QDateTime ts; - ts.setTime_t(timestamp); + ts.setSecsSinceEpoch(timestamp); auto key = ts.toString("yyyyMMdd"); return this->get(key); // USD } diff --git a/src/utils/Updater.cpp b/src/utils/Updater.cpp index 649eb6a3..138d27de 100644 --- a/src/utils/Updater.cpp +++ b/src/utils/Updater.cpp @@ -32,7 +32,7 @@ QByteArray Updater::getHash(const void *data, size_t size) const QByteArray Updater::parseShasumOutput(const QString &message, const QString &filename) const { - for (const auto &line : message.splitRef("\n")) + for (const auto &line : message.split("\n")) { const auto trimmed = line.trimmed(); if (trimmed.endsWith(filename)) diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp index 8bcba474..997fb4af 100644 --- a/src/utils/Utils.cpp +++ b/src/utils/Utils.cpp @@ -516,7 +516,7 @@ void applicationLogHandler(QtMsgType type, const QMessageLogContext &context, co } QString barrayToString(const QByteArray &data) { - return QString(QTextCodec::codecForMib(106)->toUnicode(data)); + return QString::fromUtf8(data); } QString getAccountName() { diff --git a/src/utils/childproc.cpp b/src/utils/childproc.cpp index 671b1b4e..a5690601 100644 --- a/src/utils/childproc.cpp +++ b/src/utils/childproc.cpp @@ -6,9 +6,11 @@ ChildProcess::ChildProcess(QObject* parent) {} ChildProcess::~ChildProcess() {} +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void ChildProcess::setupChildProcess() { #if defined(HAVE_SYS_PRCTL_H) && defined(Q_OS_UNIX) // https://smackerelofopinion.blogspot.com/2015/11/using-prsetpdeathsig-to-reap-child.html ::prctl(PR_SET_PDEATHSIG, SIGKILL); #endif -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/utils/childproc.h b/src/utils/childproc.h index 89ba2aa8..6b87e1ab 100644 --- a/src/utils/childproc.h +++ b/src/utils/childproc.h @@ -17,7 +17,9 @@ public: explicit ChildProcess(QObject* parent = nullptr); ~ChildProcess() override; protected: +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void setupChildProcess() override; +#endif }; diff --git a/src/utils/textedit.cpp b/src/utils/textedit.cpp index 51f2dbf2..30a74b95 100644 --- a/src/utils/textedit.cpp +++ b/src/utils/textedit.cpp @@ -55,6 +55,7 @@ #include #include #include +#include TextEdit::TextEdit(QWidget *parent) : QTextEdit(parent) { }