|
1 |
| -= GUI |
| 1 | +include::gui.adoc[] |
2 | 2 |
|
3 |
| -TIP: This section has been updated to Bitcoin Core @ https://github.com/bitcoin/bitcoin/tree/v23.0[v23.0^] |
| 3 | +include::gui-motivation.adoc[] |
4 | 4 |
|
5 |
| -The GUI has its own separate repo at https://github.com/bitcoin-core/gui[bitcoin-core/gui^]. |
6 |
| -PRs which primarily target the GUI should be made here, and then they will get merged into the primary repo. |
7 |
| -Developer Marco Falke created https://github.com/MarcoFalke/bitcoin-core/issues/26[an issue^] in his fork which detailed some of the rationale for the split, but essentially it came down to: |
| 5 | +include::gui-building.adoc[] |
8 | 6 |
|
9 |
| -. Separate issue and patch management |
10 |
| -. More focused review and interests |
11 |
| -. Maintain high quality assurance |
| 7 | +include::gui-initialization.adoc[] |
12 | 8 |
|
13 |
| -He also stated that: |
| 9 | +include::qml-gui.adoc[] |
14 | 10 |
|
15 |
| -[quote, Marco Falke] |
16 |
| -____ |
17 |
| -Splitting up the GUI (and splitting out modules in general) has been brought up often in recent years. Now that the GUI is primarily connected through interfaces with a bitcoin node, it seems an appropriate time to revive this discussion. |
18 |
| -____ |
| 11 | +include::bitcoin-design.adoc[] |
19 | 12 |
|
20 |
| -https://github.com/bitcoin/bitcoin/pull/19071[PR#19071^] contained the documentation change now contained in the Bitcoin Core primary repository, along with details of the monotree approach that was ultimately taken. |
21 |
| -The documentation change provides guidance on what a "GUI change" is: |
22 |
| - |
23 |
| -[quote, src/CONTRIBUTING.md] |
24 |
| -____ |
25 |
| -As a rule of thumb, everything that only modifies `src/qt` is a GUI-only pull |
26 |
| -request. However: |
27 |
| -
|
28 |
| -* For global refactoring or other transversal changes the node repository |
29 |
| - should be used. |
30 |
| -* For GUI-related build system changes, the node repository should be used |
31 |
| - because the change needs review by the build systems reviewers. |
32 |
| -* Changes in `src/interfaces` need to go to the node repository because they |
33 |
| - might affect other components like the wallet. |
34 |
| -
|
35 |
| -For large GUI changes that include build system and interface changes, it is |
36 |
| -recommended to first open a PR against the GUI repository. When there |
37 |
| -is agreement to proceed with the changes, a PR with the build system |
38 |
| -and interfaces changes can be submitted to the node repository. |
39 |
| -____ |
40 |
| - |
41 |
| -On a related note, another https://github.com/bitcoin/bitcoin/issues/24045[issue^] was recently opened by Falke, to discuss the possibility of instituting the same monotree changes for wallet code. |
42 |
| - |
43 |
| -== Motivation for a GUI |
44 |
| - |
45 |
| -Bitcoin Core has shipped with a GUI since the first version. |
46 |
| -Originally this was a wxWidgets GUI, but in 2011 a move to QT was https://github.com/bitcoin/bitcoin/pull/521[completed]. |
47 |
| -Satoshi originally had plans to have a decentralized market place and even poker game inside Bitcoin, so including a GUI, which also had wallet and address book functionality, made sense from the get-go. |
48 |
| - |
49 |
| -The motivation to _continue_ to include a GUI with Bitcoin Core today is for accessibility. |
50 |
| -New users can access a best-in-class Bitcoin experience via a single software package. |
51 |
| -It's not safe or realistic to expect users to download multiple programs and connect them securely into a software suite, just to use bitcoin. |
52 |
| - |
53 |
| -It does not have to be the prettiest UI, but needs to provide the functionality to use bitcoin. |
54 |
| -It is possible to connect other frontends to Bitcoin Core, but they are connected via RPCs, and do not have the first-class interface (to the node component) that the bundled GUI has. |
55 |
| - |
56 |
| -== Building the GUI |
57 |
| - |
58 |
| -`bitcoin-qt`, which includes the QT GUI with the node, is built automatically when the build dependencies are met. |
59 |
| -Required packages to meet dependencies can be found in the build instructions in _src/doc/build-*.md_ as appropriate for your platform. |
60 |
| -If you have the required packages installed but do not wish to build the `bitcoin-qt` then you must run `./configure` with the option `--with-gui=no`. |
61 |
| - |
62 |
| -[NOTE] |
63 |
| -==== |
64 |
| -If the build is configured with `--enable-multiprocess` then additional binaries will be built: |
65 |
| -
|
66 |
| -. `bitcoin-node` |
67 |
| -. `bitcoin-wallet` |
68 |
| -. `bitcoin-gui` |
69 |
| -==== |
70 |
| - |
71 |
| -== Qt |
72 |
| - |
73 |
| -QT is currently very intertwined with the rest of the codebase. |
74 |
| -See the library <<library-dependency-graph,depencency graph>> for more context. |
75 |
| - |
76 |
| -Developers would ideally like to reduce these dependencies in the future. |
77 |
| - |
78 |
| -== Qt documentation |
79 |
| - |
80 |
| -There is useful documentation for developers looking to contribute to the Qt side of the codebase found at https://github.com/bitcoin-core/bitcoin-devwiki/wiki//Developer-Notes-for-Qt-Code[Developer Notes for Qt Code^]. |
81 |
| - |
82 |
| -== Main GUI program |
83 |
| - |
84 |
| -The loading point for the GUI is _src/qt/main.cpp_. |
85 |
| -`main()` calls `GuiMain()` from _src/qt/bitcoin.cpp_, passing along any program arguments with it. |
86 |
| -`GuiMain` starts by calling `SetupEnvironment()` which amongst other things, configures the runtime locale and charset. |
87 |
| - |
88 |
| -Next an empty `NodeContext` is set up, which is then populated into a fully-fledged node interface via being passed to `interfaces::MakeNode()`, which returns an `interfaces::Node`. |
89 |
| -Recall that in <<Wallet component initialisation>> we also saw the wallet utilizing a `NodeContext` as part of its `WalletInitInterface`. |
90 |
| -In both cases the `NodeContext` is being used to pass chain and network references around without needing to create globals. |
91 |
| - |
92 |
| -After some QT setup, command-line and application arguments are parsed. |
93 |
| -What follows can be outlined from the code comments: |
94 |
| - |
95 |
| -[start=3] |
96 |
| -. Application identification |
97 |
| -. Initialization of translations, so that intro dialogue is in user's language |
98 |
| -. Now that settings and translations are available, ask user for data directory |
99 |
| -. Determine availability of data directory and parse bitcoin.conf |
100 |
| -. Determine network (and switch to network specific options) |
101 |
| -. URI IPC sending |
102 |
| -. Main GUI initialization |
103 |
| - |
104 |
| -== GUI initialisation |
105 |
| - |
106 |
| -After configuration the GUI is initialized. |
107 |
| -Here the `Node` object created earlier is passed to `app.SetNode()` before a window is created and the application executed. |
108 |
| - |
109 |
| -The bulk of the Qt GUI classes are defined in _src/qt/bitcoingui.{h|cpp}_. |
110 |
| - |
111 |
| -== QML GUI |
112 |
| - |
113 |
| -Since writing this documentation focus has been directed towards re-writing the Qt code leveraging the https://doc.qt.io/qt-5/qtqml-index.html[Qt QML^] framework. |
114 |
| -This will allow developers to create visually-superior, and easier to write and reason-about GUI code, whilst also lowering the barriers to entry for potential new developers who want to be able to focus on GUI code. |
115 |
| - |
116 |
| -The recommendation therefore is to familiarise yourself with Qt QML and review the current codebase for the latest developments. |
117 |
| -You can follow along with the latest QML work in the specific https://github.com/bitcoin-core/gui-qml/blob/main/src/qml/README.md[bitcoin-core/qml-gui^] repo. |
118 |
| - |
119 |
| -== Bitcoin design |
120 |
| - |
121 |
| -The https://bitcoin.design/guide/[Bitcoin design guide^] provides some guidance on common pitfalls that Bitcoin GUI designers should look out for when designing apps (like `bitcoin-qt`). |
122 |
| - |
123 |
| -== Testing QT |
124 |
| - |
125 |
| -Currently, although several QT tests exist in _src/qt/test_, there is no good way to test QT changes except by hand. |
126 |
| -A good way to try and have QT code included in the test framework is to target having the RPC layer be a thin as possible, so more code can be re-used between RPC and GUI. |
| 13 | +include::testing-qt.adoc[] |
0 commit comments