From a76eb10f25ffa22a6ec602ed25dc616e7c8767b0 Mon Sep 17 00:00:00 2001 From: pablomartin4btc Date: Thu, 11 Apr 2024 15:38:08 -0300 Subject: [PATCH] qml, refactoring: Separate guiconstants from QT Separating guiconstants.h file from QT, copying it from src/qt to src/qml and updating QAPP_APP_NAME_* constants values so Bitcoin*.conf files with same name currently in both QT and QML gui apps don't clash with each other (e.g. configuration file for QT on signet will be still named as Bitcoin-Qt-signet.conf, as of today, while QML will start using a separate file named Bitcoin-Qml-signet.conf). This could be a temporary fix so instances from both QT and QML gui apps don't interfere between them during QML development. This change will be transparent for both QT app and users. --- src/Makefile.qt.include | 2 +- src/qml/bitcoin.cpp | 2 +- src/qml/guiconstants.h | 62 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/qml/guiconstants.h diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index c9bdb051e8..293e117352 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -123,6 +123,7 @@ BITCOIN_QT_H = \ qml/models/peerlistsortproxy.h \ qml/appmode.h \ qml/bitcoin.h \ + qml/guiconstants.h \ qml/imageprovider.h \ qml/util.h \ qt/addressbookpage.h \ @@ -140,7 +141,6 @@ BITCOIN_QT_H = \ qt/createwalletdialog.h \ qt/csvmodelwriter.h \ qt/editaddressdialog.h \ - qt/guiconstants.h \ qt/guiutil.h \ qt/initexecutor.h \ qt/intro.h \ diff --git a/src/qml/bitcoin.cpp b/src/qml/bitcoin.cpp index d87386cbd5..32375bf7d4 100644 --- a/src/qml/bitcoin.cpp +++ b/src/qml/bitcoin.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/qml/guiconstants.h b/src/qml/guiconstants.h new file mode 100644 index 0000000000..3251de2dc9 --- /dev/null +++ b/src/qml/guiconstants.h @@ -0,0 +1,62 @@ +// Copyright (c) 2011-2024 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QML_GUICONSTANTS_H +#define BITCOIN_QML_GUICONSTANTS_H + +#include +#include + +using namespace std::chrono_literals; + +/* A delay between model updates */ +static constexpr auto MODEL_UPDATE_DELAY{250ms}; + +/* A delay between shutdown pollings */ +static constexpr auto SHUTDOWN_POLLING_DELAY{200ms}; + +/* AskPassphraseDialog -- Maximum passphrase length */ +static const int MAX_PASSPHRASE_SIZE = 1024; + +/* BitcoinGUI -- Size of icons in status bar */ +static const int STATUSBAR_ICONSIZE = 16; + +static const bool DEFAULT_SPLASHSCREEN = true; + +/* Invalid field background style */ +#define STYLE_INVALID "background:#FF8080" + +/* Transaction list -- unconfirmed transaction */ +#define COLOR_UNCONFIRMED QColor(128, 128, 128) +/* Transaction list -- negative amount */ +#define COLOR_NEGATIVE QColor(255, 0, 0) +/* Transaction list -- bare address (without label) */ +#define COLOR_BAREADDRESS QColor(140, 140, 140) +/* Transaction list -- TX status decoration - danger, tx needs attention */ +#define COLOR_TX_STATUS_DANGER QColor(200, 100, 100) +/* Transaction list -- TX status decoration - default color */ +#define COLOR_BLACK QColor(0, 0, 0) + +/* Tooltips longer than this (in characters) are converted into rich text, + so that they can be word-wrapped. + */ +static const int TOOLTIP_WRAP_THRESHOLD = 80; + +/* Number of frames in spinner animation */ +#define SPINNER_FRAMES 36 + +#define QAPP_ORG_NAME "Bitcoin" +#define QAPP_ORG_DOMAIN "bitcoin.org" +#define QAPP_APP_NAME_DEFAULT "Bitcoin-Qml" +#define QAPP_APP_NAME_TESTNET "Bitcoin-Qml-testnet" +#define QAPP_APP_NAME_SIGNET "Bitcoin-Qml-signet" +#define QAPP_APP_NAME_REGTEST "Bitcoin-Qml-regtest" + +/* One gigabyte (GB) in bytes */ +static constexpr uint64_t GB_BYTES{1000000000}; + +// Default prune target displayed in GUI. +static constexpr int DEFAULT_PRUNE_TARGET_GB{2}; + +#endif // BITCOIN_QML_GUICONSTANTS_H