From 2fe4e9e4b4b4ca0508f7c834e81bd537313345ec Mon Sep 17 00:00:00 2001 From: tobtoht Date: Wed, 19 Apr 2023 17:41:46 +0200 Subject: [PATCH] CMake: minimize dependencies for CHECK_UPDATES=Off, WITH_SCANNER=Off --- CMakeLists.txt | 27 +++++++++------- src/CMakeLists.txt | 31 ++++++++++++++----- src/MainWindow.cpp | 17 ++++++++-- src/MainWindow.h | 7 ++++- src/qrcode/{ => utils}/QrCodeUtils.cpp | 0 src/qrcode/{ => utils}/QrCodeUtils.h | 0 .../updater}/UpdateDialog.cpp | 2 +- src/{dialog => utils/updater}/UpdateDialog.h | 2 +- src/{dialog => utils/updater}/UpdateDialog.ui | 0 src/utils/{ => updater}/Updater.cpp | 0 src/utils/{ => updater}/Updater.h | 0 src/widgets/PayToEdit.cpp | 7 ++++- 12 files changed, 68 insertions(+), 25 deletions(-) rename src/qrcode/{ => utils}/QrCodeUtils.cpp (100%) rename src/qrcode/{ => utils}/QrCodeUtils.h (100%) rename src/{dialog => utils/updater}/UpdateDialog.cpp (99%) rename src/{dialog => utils/updater}/UpdateDialog.h (97%) rename src/{dialog => utils/updater}/UpdateDialog.ui (100%) rename src/utils/{ => updater}/Updater.cpp (100%) rename src/utils/{ => updater}/Updater.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29a1020..4e5809e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,9 @@ get_directory_property(UNBOUND_LIBRARY DIRECTORY "monero" DEFINITION UNBOUND_LIB get_directory_property(DEVICE_TREZOR_READY DIRECTORY "monero" DEFINITION DEVICE_TREZOR_READY) get_directory_property(TREZOR_DEP_LIBS DIRECTORY "monero" DEFINITION TREZOR_DEP_LIBS) +# pthread +find_package(Threads REQUIRED) + # Easylogging include_directories(${EASYLOGGING_INCLUDE}) link_directories(${EASYLOGGING_LIBRARY_DIRS}) @@ -75,22 +78,26 @@ message(STATUS "libsodium: libraries at ${SODIUM_LIBRARY}") # QrEncode find_package(QREncode REQUIRED) -# ZBAR -find_package(ZBAR REQUIRED) -message(STATUS "libzbar: include dir at ${ZBAR_INCLUDE_DIR}") -message(STATUS "libzbar: libraries at ${ZBAR_LIBRARIES}") - # Polyseed find_package(Polyseed REQUIRED) if(Polyseed_SUBMODULE) add_subdirectory(src/third-party/polyseed EXCLUDE_FROM_ALL) endif() +# ZBAR +if(WITH_SCANNER) + find_package(ZBAR REQUIRED) + message(STATUS "libzbar: include dir at ${ZBAR_INCLUDE_DIR}") + message(STATUS "libzbar: libraries at ${ZBAR_LIBRARIES}") +endif() + # libzip -set(ZLIB_USE_STATIC_LIBS "ON") -find_package(ZLIB REQUIRED) -find_path(LIBZIP_INCLUDE_DIRS zip.h) -find_library(LIBZIP_LIBRARIES zip) +if(CHECK_UPDATES) + set(ZLIB_USE_STATIC_LIBS "ON") + find_package(ZLIB REQUIRED) + find_path(LIBZIP_INCLUDE_DIRS zip.h) + find_library(LIBZIP_LIBRARIES zip) +endif() # Boost if(DEBUG) @@ -182,8 +189,6 @@ elseif(NOT MSVC AND NOT DEPENDS) set(EXTRA_LIBRARIES ${RT}) endif() -list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS}) - if(APPLE) cmake_policy(SET CMP0042 NEW) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -std=c++11") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fd20683..2421163 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,9 +2,6 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -# pthread -find_package(Threads REQUIRED) - set(QT_COMPONENTS Core Widgets @@ -28,7 +25,9 @@ endif() set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication") add_subdirectory(third-party/singleapplication) -add_subdirectory(openpgp) +if (CHECK_UPDATES) + add_subdirectory(openpgp) +endif() qt_add_resources(RESOURCES assets.qrc assets_tor.qrc) @@ -74,6 +73,18 @@ file(GLOB SOURCE_FILES "plugins/*/*.h" ) +if (CHECK_UPDATES) + file(GLOB UPDATER_FILES + "utils/updater/*.h" + "utils/updater/*.cpp") +endif() + +if (WITH_SCANNER) + file(GLOB QRCODE_UTILS_FILES + "qrcode/utils/*.h" + "qrcode/utils/*.cpp") +endif() + if (WITH_SCANNER AND NOT Qt6_FOUND) file(GLOB SCANNER_FILES "qrcode/scanner/*.h" @@ -87,6 +98,8 @@ if (WITH_SCANNER AND Qt6_FOUND) endif() list(APPEND SOURCE_FILES + ${UPDATER_FILES} + ${QRCODE_UTILS_FILES} ${SCANNER_FILES}) set(EXECUTABLE_FLAG) @@ -143,12 +156,12 @@ target_include_directories(feather PUBLIC ${QtWebSockets_INCLUDE_DIRS} ${LIBZIP_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} - ${ZBAR_INCLUDE_DIR} ${POLYSEED_INCLUDE_DIR} ) if(WITH_SCANNER) target_include_directories(feather PUBLIC + ${ZBAR_INCLUDE_DIR} ${QtMultimedia_INCLUDE_DIRS} ${QtMultimediaWidgets_INCLUDE_DIRS} ) @@ -230,7 +243,6 @@ target_link_libraries(feather ringct ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} - ${CMAKE_DL_LIBS} ${EXTRA_LIBRARIES} Qt::Core Qt::Widgets @@ -238,10 +250,8 @@ target_link_libraries(feather Qt::Network Qt::Svg Qt::WebSockets - openpgp Threads::Threads ${QRENCODE_LIBRARY} - ${ZBAR_LIBRARIES} ${POLYSEED_LIBRARY} SingleApplication::SingleApplication ${ICU_LIBRARIES} @@ -249,6 +259,10 @@ target_link_libraries(feather ${ZLIB_LIBRARIES} ) +if(CHECK_UPDATES) + target_link_libraries(feather openpgp) +endif() + if(DEPENDS) target_link_libraries(feather ${ICONV_LIBRARIES}) endif() @@ -263,6 +277,7 @@ endif() if (WITH_SCANNER) target_link_libraries(feather + ${ZBAR_LIBRARIES} Qt::Multimedia Qt::MultimediaWidgets ) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 899cea5..d5cb903 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -21,7 +21,6 @@ #include "dialog/ViewOnlyDialog.h" #include "dialog/WalletInfoDialog.h" #include "dialog/WalletCacheDebugDialog.h" -#include "dialog/UpdateDialog.h" #include "libwalletqt/AddressBook.h" #include "libwalletqt/CoinsInfo.h" #include "libwalletqt/Transfer.h" @@ -31,9 +30,11 @@ #include "utils/Icons.h" #include "utils/SemanticVersion.h" #include "utils/TorManager.h" -#include "utils/Updater.h" #include "utils/WebsocketNotifier.h" +#ifdef CHECK_UPDATES +#include "utils/updater/UpdateDialog.h" +#endif //#include "misc_log_ex.h" MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *parent) @@ -55,7 +56,9 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa m_splashDialog = new SplashDialog(this); m_accountSwitcherDialog = new AccountSwitcherDialog(m_wallet, this); +#ifdef CHECK_UPDATES m_updater = QSharedPointer(new Updater(this)); +#endif this->restoreGeo(); @@ -70,7 +73,9 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa connect(websocketNotifier(), &WebsocketNotifier::BountyReceived, ui->bountiesWidget->model(), &BountiesModel::updateBounties); connect(websocketNotifier(), &WebsocketNotifier::RedditReceived, ui->redditWidget->model(), &RedditModel::updatePosts); connect(websocketNotifier(), &WebsocketNotifier::RevuoReceived, ui->revuoWidget, &RevuoWidget::updateItems); +#ifdef CHECK_UPDATES connect(websocketNotifier(), &WebsocketNotifier::UpdatesReceived, m_updater.data(), &Updater::wsUpdatesReceived); +#endif #ifdef HAS_XMRIG connect(websocketNotifier(), &WebsocketNotifier::XMRigDownloadsReceived, m_xmrig, &XMRigWidget::onDownloads); #endif @@ -86,7 +91,9 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa connect(torManager(), &TorManager::connectionStateChanged, this, &MainWindow::onTorConnectionStateChanged); this->onTorConnectionStateChanged(torManager()->torConnected); +#ifdef CHECK_UPDATES connect(m_updater.data(), &Updater::updateAvailable, this, &MainWindow::showUpdateNotification); +#endif ColorScheme::updateFromWidget(this); QTimer::singleShot(1, [this]{this->updateWidgetIcons();}); @@ -1402,9 +1409,11 @@ void MainWindow::onHideUpdateNotifications(bool hidden) { if (hidden) { m_statusUpdateAvailable->hide(); } +#ifdef CHECK_UPDATES else if (m_updater->state == Updater::State::UPDATE_AVAILABLE) { m_statusUpdateAvailable->show(); } +#endif } void MainWindow::onTorConnectionStateChanged(bool connected) { @@ -1419,6 +1428,7 @@ void MainWindow::onTorConnectionStateChanged(bool connected) { } void MainWindow::showUpdateNotification() { +#ifdef CHECK_UPDATES if (config()->get(Config::hideUpdateNotifications).toBool()) { return; } @@ -1432,12 +1442,15 @@ void MainWindow::showUpdateNotification() { m_statusUpdateAvailable->disconnect(); connect(m_statusUpdateAvailable, &StatusBarButton::clicked, this, &MainWindow::showUpdateDialog); +#endif } void MainWindow::showUpdateDialog() { +#ifdef CHECK_UPDATES UpdateDialog updateDialog{this, m_updater}; connect(&updateDialog, &UpdateDialog::restartWallet, m_windowManager, &WindowManager::restartApplication); updateDialog.exec(); +#endif } void MainWindow::onInitiateTransaction() { diff --git a/src/MainWindow.h b/src/MainWindow.h index ca51f86..f05000f 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -31,7 +31,6 @@ #include "utils/config.h" #include "utils/daemonrpc.h" #include "utils/EventFilter.h" -#include "utils/Updater.h" #include "plugins/ccs/CCSWidget.h" #include "plugins/reddit/RedditWidget.h" #include "widgets/TickerWidget.h" @@ -46,6 +45,10 @@ #include "WindowManager.h" +#ifdef CHECK_UPDATES +#include "utils/updater/Updater.h" +#endif + #ifdef HAS_LOCALMONERO #include "plugins/localmonero/LocalMoneroWidget.h" #endif @@ -294,7 +297,9 @@ private: EventFilter *m_eventFilter = nullptr; qint64 m_userLastActive = QDateTime::currentSecsSinceEpoch(); +#ifdef CHECK_UPDATES QSharedPointer m_updater = nullptr; +#endif }; #endif // FEATHER_MAINWINDOW_H diff --git a/src/qrcode/QrCodeUtils.cpp b/src/qrcode/utils/QrCodeUtils.cpp similarity index 100% rename from src/qrcode/QrCodeUtils.cpp rename to src/qrcode/utils/QrCodeUtils.cpp diff --git a/src/qrcode/QrCodeUtils.h b/src/qrcode/utils/QrCodeUtils.h similarity index 100% rename from src/qrcode/QrCodeUtils.h rename to src/qrcode/utils/QrCodeUtils.h diff --git a/src/dialog/UpdateDialog.cpp b/src/utils/updater/UpdateDialog.cpp similarity index 99% rename from src/dialog/UpdateDialog.cpp rename to src/utils/updater/UpdateDialog.cpp index e11b5a0..da09d19 100644 --- a/src/dialog/UpdateDialog.cpp +++ b/src/utils/updater/UpdateDialog.cpp @@ -10,7 +10,7 @@ #include "utils/AsyncTask.h" #include "utils/Networking.h" #include "utils/NetworkManager.h" -#include "utils/Updater.h" +#include "utils/updater/Updater.h" #include "utils/Utils.h" #include "utils/SemanticVersion.h" diff --git a/src/dialog/UpdateDialog.h b/src/utils/updater/UpdateDialog.h similarity index 97% rename from src/dialog/UpdateDialog.h rename to src/utils/updater/UpdateDialog.h index 3779131..bb06660 100644 --- a/src/dialog/UpdateDialog.h +++ b/src/utils/updater/UpdateDialog.h @@ -8,7 +8,7 @@ #include #include -#include "utils/Updater.h" +#include "utils/updater/Updater.h" namespace Ui { class UpdateDialog; diff --git a/src/dialog/UpdateDialog.ui b/src/utils/updater/UpdateDialog.ui similarity index 100% rename from src/dialog/UpdateDialog.ui rename to src/utils/updater/UpdateDialog.ui diff --git a/src/utils/Updater.cpp b/src/utils/updater/Updater.cpp similarity index 100% rename from src/utils/Updater.cpp rename to src/utils/updater/Updater.cpp diff --git a/src/utils/Updater.h b/src/utils/updater/Updater.h similarity index 100% rename from src/utils/Updater.h rename to src/utils/updater/Updater.h diff --git a/src/widgets/PayToEdit.cpp b/src/widgets/PayToEdit.cpp index 1e095ec..104144a 100644 --- a/src/widgets/PayToEdit.cpp +++ b/src/widgets/PayToEdit.cpp @@ -10,9 +10,12 @@ #include #include "libwalletqt/WalletManager.h" -#include "qrcode/QrCodeUtils.h" #include "utils/Utils.h" +#if defined(WITH_SCANNER) +#include "qrcode/utils/QrCodeUtils.h" +#endif + PayToEdit::PayToEdit(QWidget *parent) : QPlainTextEdit(parent) { this->setFont(Utils::getMonospaceFont()); @@ -108,10 +111,12 @@ void PayToEdit::pasteEvent(const QMimeData *mimeData) { return; } +#if defined(WITH_SCANNER) image.convertTo(QImage::Format_RGB32); QString result = QrCodeUtils::scanImage(image); dataPasted(result); +#endif } void PayToEdit::checkText() {