bitcoin/src/qt
MarcoFalke cd66d8b1d8
Merge #20429: refactor: replace (sizeof(a)/sizeof(a[0])) with C++17 std::size
e829c9afbf refactor: replace sizeof(a)/sizeof(a[0]) by std::size (C++17) (Sebastian Falbesoner)
365539c846 refactor: init vectors via std::{begin,end} to avoid pointer arithmetic (Sebastian Falbesoner)
63d4ee1968 refactor: iterate arrays via C++11 range-based for loops if idx is not needed (Sebastian Falbesoner)

Pull request description:

  This refactoring PR picks up the idea of #19626 and replaces all occurences of `sizeof(x)/sizeof(x[0])` (or `sizeof(x)/sizeof(*x)`, respectively) with the now-available C++17 [`std::size`](https://en.cppreference.com/w/cpp/iterator/size)  (as [suggested by sipa](https://github.com/bitcoin/bitcoin/pull/19626#issuecomment-666487228)), making the macro `ARRAYLEN` obsolete.

  As preparation for this, two other changes are done to eliminate `sizeof(x)/sizeof(x[0])` usage:
  * all places where arrays are iterated via an index are changed to use C++11 range-based for loops If the index' only purpose is to access the array element (as [suggested by MarcoFalke](https://github.com/bitcoin/bitcoin/pull/19626#discussion_r463404541)).
  * `std::vector` initializations are done via `std::begin` and `std::end` rather than using pointer arithmetic to calculate the end (also [suggested by MarcoFalke](https://github.com/bitcoin/bitcoin/pull/20429#discussion_r567418821)).

ACKs for top commit:
  practicalswift:
    cr ACK e829c9afbf: patch looks correct
  fanquake:
    ACK e829c9afbf
  MarcoFalke:
    review ACK e829c9afbf 🌩

Tree-SHA512: b01d32c04b9e04d562b7717cae00a651ec9a718645047a90761be6959e0cc2adbd67494e058fe894641076711bb09c3b47a047d0275c736f0b2218e1ce0d193d
2021-02-18 07:53:37 +01:00
..
forms Merge #180: Peer details: connection type follow-ups 2021-01-27 20:33:52 +01:00
locale qt: Pre-splitoff translations update 2020-11-16 11:15:11 +01:00
res scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
test rpc: Remove duplicate name and argNames from CRPCCommand 2021-01-28 08:19:52 +01:00
addressbookpage.cpp Merge bitcoin-core/gui#85: Remove unused "What's This" button in dialogs on Windows OS 2021-01-28 10:16:55 +01:00
addressbookpage.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
addresstablemodel.cpp Merge #20480: Replace boost::variant with std::variant 2021-01-11 12:05:46 +08:00
addresstablemodel.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
askpassphrasedialog.cpp Merge bitcoin-core/gui#85: Remove unused "What's This" button in dialogs on Windows OS 2021-01-28 10:16:55 +01:00
askpassphrasedialog.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
bantablemodel.cpp qt: Follow Qt docs when implementing rowCount and columnCount 2021-01-02 21:40:53 +02:00
bantablemodel.h refactor: Use override for non-final overriders 2020-05-08 10:36:58 +03:00
bitcoin.cpp qt: Use "fusion" style on macOS Big Sur with old Qt 2021-01-08 16:20:49 +02:00
bitcoin.h gui: Replace interface::Node references with pointers 2020-08-26 05:52:31 -04:00
bitcoin.qrc scripted-diff: rename movie folder to animation 2020-06-29 18:49:13 +01:00
bitcoin_locale.qrc qt: Pre-splitoff translations update 2020-10-27 19:40:44 +01:00
bitcoinaddressvalidator.cpp Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
bitcoinaddressvalidator.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
bitcoinamountfield.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
bitcoinamountfield.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
bitcoingui.cpp Merge bitcoin-core/gui#183: Add include for std::bind. 2021-01-26 11:14:27 +01:00
bitcoingui.h Merge bitcoin-core/gui#115: Replace "Hide tray icon" option with positive "Show tray icon" one 2020-12-15 09:28:50 +01:00
bitcoinstrings.cpp qt: Pre-splitoff translations update 2020-11-16 11:15:11 +01:00
bitcoinunits.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
bitcoinunits.h scripted-diff: Make SeparatorStyle a scoped enum 2020-06-18 15:30:15 +03:00
clientmodel.cpp Add include for std::bind. 2021-01-13 02:05:00 +01:00
clientmodel.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
coincontroldialog.cpp Merge bitcoin-core/gui#85: Remove unused "What's This" button in dialogs on Windows OS 2021-01-28 10:16:55 +01:00
coincontroldialog.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
coincontroltreewidget.cpp Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
coincontroltreewidget.h refactor: Use override for non-final overriders 2020-05-08 10:36:58 +03:00
createwalletdialog.cpp Merge bitcoin-core/gui#85: Remove unused "What's This" button in dialogs on Windows OS 2021-01-28 10:16:55 +01:00
createwalletdialog.h Be able to create new wallets with DescriptorScriptPubKeyMans as backing 2020-04-23 13:59:48 -04:00
csvmodelwriter.cpp Don't use zero as null pointer constant (-Wzero-as-null-pointer-constant) 2019-01-13 03:25:14 -08:00
csvmodelwriter.h scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
editaddressdialog.cpp Merge bitcoin-core/gui#85: Remove unused "What's This" button in dialogs on Windows OS 2021-01-28 10:16:55 +01:00
editaddressdialog.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
guiconstants.h qt: update QT to support signet network 2020-09-18 09:37:57 +09:00
guiutil.cpp gui: display plain "Inbound" in peer details 2021-01-30 20:28:37 +01:00
guiutil.h gui: display plain "Inbound" in peer details 2021-01-30 20:28:37 +01:00
intro.cpp scripted-diff: Remove unused "What's This" button in dialogs on Windows 2020-09-07 19:09:33 +03:00
intro.h gui: Remove unused interfaces::Node references 2020-08-26 05:52:31 -04:00
macdockiconhandler.h Remove obj_c for macOS Dock icon menu 2018-11-04 02:42:18 +02:00
macdockiconhandler.mm qt: Replace objc_msgSend with native syntax 2019-08-31 12:25:34 +03:00
macnotificationhandler.h convert C-style (void) parameter lists to C++ style () 2018-09-13 10:36:41 -07:00
macnotificationhandler.mm scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
macos_appnap.h macOS: disable AppNap during sync 2018-11-01 18:22:06 +03:00
macos_appnap.mm macOS: disable AppNap during sync 2018-11-01 18:22:06 +03:00
main.cpp scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
Makefile
modaloverlay.cpp qt: Disable toolbar when overlay is shown 2020-07-11 12:59:58 +03:00
modaloverlay.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
networkstyle.cpp refactor: iterate arrays via C++11 range-based for loops if idx is not needed 2021-01-31 17:07:46 +01:00
networkstyle.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
notificator.cpp doc: Use https URLs where possible 2021-01-04 12:23:16 +08:00
notificator.h Remove misplaced Q_UNUSED and others enhancements 2018-12-20 01:06:37 +02:00
openuridialog.cpp scripted-diff: Remove unused "What's This" button in dialogs on Windows 2020-09-07 19:09:33 +03:00
openuridialog.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
optionsdialog.cpp Merge bitcoin-core/gui#85: Remove unused "What's This" button in dialogs on Windows OS 2021-01-28 10:16:55 +01:00
optionsdialog.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
optionsmodel.cpp net: Add -natpmp command line option 2021-01-07 18:07:09 +02:00
optionsmodel.h net: Add -natpmp command line option 2021-01-07 18:07:09 +02:00
overviewpage.cpp Merge bitcoin-core/gui#189: qt: drop workaround for QTBUG-42503 which was fixed in Qt 5.5.0 2021-01-26 10:41:23 +01:00
overviewpage.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
paymentserver.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
paymentserver.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
peertablemodel.cpp Merge bitcoin-core/gui#161: Add PeerTableModel::StatsRole to prevent data layer violation 2021-01-11 09:06:21 +01:00
peertablemodel.h qt, refactor: Drop no longer used PeerTableModel::getNodeStats function 2020-12-30 21:01:20 +02:00
platformstyle.cpp refactor: iterate arrays via C++11 range-based for loops if idx is not needed 2021-01-31 17:07:46 +01:00
platformstyle.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
psbtoperationsdialog.cpp scripted-diff: Remove unused "What's This" button in dialogs on Windows 2020-09-07 19:09:33 +03:00
psbtoperationsdialog.h [gui] PSBT Operations Dialog (sign & broadcast) 2020-06-19 02:20:04 -07:00
qrimagewidget.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
qrimagewidget.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
qvalidatedlineedit.cpp Replace remaining 0 with nullptr in Qt code 2019-01-13 03:25:14 -08:00
qvalidatedlineedit.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
qvaluecombobox.cpp qt: Use new Qt5 connect syntax 2018-08-21 09:43:54 +01:00
qvaluecombobox.h scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
README.md Improve gui/src/qt README.md 2021-01-28 14:03:21 -05:00
receivecoinsdialog.cpp Merge bitcoin-core/gui#85: Remove unused "What's This" button in dialogs on Windows OS 2021-01-28 10:16:55 +01:00
receivecoinsdialog.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
receiverequestdialog.cpp Merge bitcoin-core/gui#85: Remove unused "What's This" button in dialogs on Windows OS 2021-01-28 10:16:55 +01:00
receiverequestdialog.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
recentrequeststablemodel.cpp Merge #20464: refactor: Treat CDataStream bytes as uint8_t 2021-02-01 15:17:28 +01:00
recentrequeststablemodel.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
rpcconsole.cpp [net processing] Move ping data fields to net processing 2021-02-15 16:15:51 +00:00
rpcconsole.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
sendcoinsdialog.cpp Merge bitcoin-core/gui#85: Remove unused "What's This" button in dialogs on Windows OS 2021-01-28 10:16:55 +01:00
sendcoinsdialog.h Merge bitcoin-core/gui#148: Bugfix: GUI: Restore SendConfirmationDialog button default to "Yes" 2021-01-13 17:47:46 +01:00
sendcoinsentry.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
sendcoinsentry.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
sendcoinsrecipient.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
signverifymessagedialog.cpp Merge bitcoin-core/gui#85: Remove unused "What's This" button in dialogs on Windows OS 2021-01-28 10:16:55 +01:00
signverifymessagedialog.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
splashscreen.cpp Add include for std::bind. 2021-01-13 02:05:00 +01:00
splashscreen.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
trafficgraphwidget.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
trafficgraphwidget.h refactor: Use override for non-final overriders 2020-05-08 10:36:58 +03:00
transactiondesc.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
transactiondesc.h Remove unused adjustedTime parameter 2018-10-28 09:04:10 +02:00
transactiondescdialog.cpp Merge bitcoin-core/gui#85: Remove unused "What's This" button in dialogs on Windows OS 2021-01-28 10:16:55 +01:00
transactiondescdialog.h scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
transactionfilterproxy.cpp Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
transactionfilterproxy.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
transactionoverviewwidget.h qt: Add TransactionOverviewWidget class 2021-01-05 22:10:10 +02:00
transactionrecord.cpp Replace boost::variant with std::variant 2021-01-05 10:10:50 +01:00
transactionrecord.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
transactiontablemodel.cpp Add include for std::bind. 2021-01-13 02:05:00 +01:00
transactiontablemodel.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
transactionview.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
transactionview.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
utilitydialog.cpp scripted-diff: Remove unused "What's This" button in dialogs on Windows 2020-09-07 19:09:33 +03:00
utilitydialog.h gui: Remove unused interfaces::Node references 2020-08-26 05:52:31 -04:00
walletcontroller.cpp doc: fix various typos 2021-01-04 12:31:31 +08:00
walletcontroller.h gui: Add closeAllWallets to WalletController 2020-06-01 00:54:00 +01:00
walletframe.cpp qt: Stop the effect of hidden widgets on the size of QStackedWidget 2021-01-08 16:53:20 +02:00
walletframe.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
walletmodel.cpp Merge #20464: refactor: Treat CDataStream bytes as uint8_t 2021-02-01 15:17:28 +01:00
walletmodel.h qt, wallet: Drop unused parameter in WalletModel::setWalletEncrypted 2020-10-28 18:44:55 +02:00
walletmodeltransaction.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
walletmodeltransaction.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
walletview.cpp qt, wallet: Drop unused parameter in Wallet{Frame|View}::encryptWallet 2020-10-23 20:09:55 +03:00
walletview.h qt, wallet: Drop unused parameter in Wallet{Frame|View}::encryptWallet 2020-10-23 20:09:55 +03:00
winshutdownmonitor.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
winshutdownmonitor.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00

This directory contains the source code for the Bitcoin Core graphical user interface (GUI). It uses the Qt cross-platform framework.

The current precise version for Qt 5 is specified in qt.mk.

Compile and run

See build instructions: Unix, macOS, Windows, FreeBSD, NetBSD, OpenBSD

When following your systems build instructions, make sure to install the Qt dependencies.

To run:

./src/qt/bitcoin-qt

Files and Directories

forms/

  • A directory that contains Designer UI files. These files specify the characteristics of form elements in XML. Qt UI files can be edited with Qt Creator or using any text editor.

locale/

  • Contains translations. They are periodically updated and an effort is made to support as many languages as possible. The process of contributing translations is described in doc/translation_process.md.

res/

  • Contains graphical resources used to enhance the UI experience.

test/

  • Functional tests used to ensure proper functionality of the GUI. Significant changes to the GUI code normally require new or updated tests.

bitcoingui.(h/cpp)

  • Represents the main window of the Bitcoin UI.

*model.(h/cpp)

  • The model. When it has a corresponding controller, it generally inherits from QAbstractTableModel. Models that are used by controllers as helpers inherit from other Qt classes like QValidator.
  • ClientModel is used by the main application bitcoingui and several models like peertablemodel.

*page.(h/cpp)

  • A controller. :NAMEpage.cpp generally includes :NAMEmodel.h and forms/:NAME.page.ui with a similar :NAME.

*dialog.(h/cpp)

  • Various dialogs, e.g. to open a URL. Inherit from QDialog.

paymentserver.(h/cpp)

  • (Deprecated) Used to process BIP21 payment URI requests. Also handles URI-based application switching (e.g. when following a bitcoin:... link from a browser).

walletview.(h/cpp)

  • Represents the view to a single wallet.

Other .h/cpp files

  • UI elements like BitcoinAmountField, which inherit from QWidget.
  • bitcoinstrings.cpp: automatically generated
  • bitcoinunits.(h/cpp): BTC / mBTC / etc. handling
  • callback.h
  • guiconstants.h: UI colors, app name, etc.
  • guiutil.h: several helper functions
  • macdockiconhandler.(h/mm): macOS dock icon handler
  • macnotificationhandler.(h/mm): display notifications in macOS

Contribute

See CONTRIBUTING.md for general guidelines.

Note: Do not change local/bitcoin_en.ts. It is updated automatically.

Using Qt Creator as an IDE

Qt Creator is a powerful tool which packages a UI designer tool (Qt Designer) and a C++ IDE into one application. This is especially useful if you want to change the UI layout.

Download Qt Creator

On Unix and macOS, Qt Creator can be installed through your package manager. Alternatively, you can download a binary from the Qt Website.

Note: If installing from a binary grabbed from the Qt Website: During the installation process, uncheck everything except for Qt Creator.

macOS
brew install qt-creator
Ubuntu & Debian
sudo apt-get install qtcreator

Setup Qt Creator

  1. Make sure you've installed all dependencies specified in your systems build instructions
  2. Follow the compile instructions for your system, run ./configure with the --enable-debug flag
  3. Start Qt Creator. At the start page, do: New -> Import Project -> Import Existing Project
  4. Enter bitcoin-qt as the Project Name and enter the absolute path to src/qt as Location
  5. Check over the file selection, you may need to select the forms directory (necessary if you intend to edit *.ui files)
  6. Confirm the Summary page
  7. In the Projects tab, select Manage Kits...

macOS

  • Under Kits: select the default "Desktop" kit
  • Under Compilers: select "Clang (x86 64bit in /usr/bin)"
  • Under Debuggers: select "LLDB" as debugger (you might need to set the path to your LLDB installation)

Ubuntu & Debian

Note: Some of these options may already be set

  • Under Kits: select the default "Desktop" kit
  • Under Compilers: select "GCC (x86 64bit in /usr/bin)"
  • Under Debuggers: select "GDB" as debugger
  1. While in the Projects tab, ensure that you have the bitcoin-qt executable specified under Run
  • If the executable is not specified: click "Choose...", navigate to src/qt, and select bitcoin-qt
  1. You're all set! Start developing, building, and debugging the Bitcoin Core GUI