Merge pull request #18 from feather-wallet/qt6

Qt 6 support
This commit is contained in:
tobtoht
2022-05-24 16:46:36 +00:00
committed by GitHub
19 changed files with 83 additions and 53 deletions
+3
View File
@@ -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")
+50 -39
View File
@@ -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)
+1 -1
View File
@@ -6,7 +6,7 @@
#include <QMenu>
#include <QWidget>
#include <QtSvg/QSvgWidget>
#include <QSvgWidget>
#include "appcontext.h"
#include "model/CoinsModel.h"
+3 -2
View File
@@ -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();
}
+1 -1
View File
@@ -6,7 +6,7 @@
#include <QMenu>
#include <QWidget>
#include <QtSvg/QSvgWidget>
#include <QSvgWidget>
#include "appcontext.h"
#include "libwalletqt/Subaddress.h"
+4
View File
@@ -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);
+4
View File
@@ -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;
};
+1 -1
View File
@@ -7,7 +7,7 @@
#include <QDialog>
#include <QTextCharFormat>
#include <QTextEdit>
#include <QtSvg/QSvgWidget>
#include <QSvgWidget>
#include "appcontext.h"
#include "dialog/TxProofDialog.h"
+1 -1
View File
@@ -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;
+2
View File
@@ -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);
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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
}
+1 -1
View File
@@ -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))
+1 -1
View File
@@ -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() {
+3 -1
View File
@@ -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
}
}
#endif
+2
View File
@@ -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
};
+1
View File
@@ -55,6 +55,7 @@
#include <QtDebug>
#include <QApplication>
#include <QScrollBar>
#include <QFile>
TextEdit::TextEdit(QWidget *parent) : QTextEdit(parent) { }