refactor: Make BitcoinUnits::Unit a scoped enum#60
refactor: Make BitcoinUnits::Unit a scoped enum#60hebasto wants to merge 5 commits intobitcoin-core:masterfrom
Conversation
|
bitcoin/bitcoin#17877 has Concept ACKs from: @promag @jonasschnelli Mind reviewing this PR? |
|
tACK b109ae6 I just noticed one practical downside of this separate repo; having to add another remote: |
|
@Sjors I only have |
|
I manually call |
|
Concept ACK |
|
|
||
| // Display | ||
| if (!settings.contains("nDisplayUnit")) | ||
| settings.setValue("nDisplayUnit", BitcoinUnits::BTC); |
There was a problem hiding this comment.
Maybe it should migrate the old setting key if it exists?
There was a problem hiding this comment.
Will it be dead code after a while?
There was a problem hiding this comment.
And? For instance bitcoin/bitcoin#20966 also tries to use old data.
There was a problem hiding this comment.
@promag
I was thinking about your suggestion, and I failed to find a safe and short (about 1..2 lines of code) solution.
OTOH, adjusting this option requires only two clicks.
Therefore, I'm going to leave it as is, leaving a room for improvements in follow ups.
|
Updated cb08a1c -> 68baad3 (pr60.04 -> pr60.05):
|
This change improves type safety.
Since BitcoinUnits::Unit became a scoped enum, BitcoinUnits::valid function is no longer needed.
Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
|
Code Review ACK 8eb1a34 looks like a reasonable cleanup note: I found this PR with a git script that emails you when someone touches a part of the codebase you've previously touched (via git-contacts and git-blame). I recommend using this trick to find potential reviewers: 😉 |
|
🐙 This pull request conflicts with the target branch and needs rebase. Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft". |
|
cc @hebasto, a rebase is needed :) |
There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
|
I have a rebased version here: master...jb55:units-scoped-enum I can submit a PR if you want me to take this over @hebasto |
Thank you! I'll appreciate if you do that. |
|
Closing in favor of #556. |
0e5dedb qt/wallettests: sort includes (William Casarin) 0554251 qt: Skip displayUnitChanged signal if unit is not actually changed (Hennadii Stepanov) ffbc2fe qt, refactor: Remove default cases for scoped enum (Hennadii Stepanov) 152d5ba qt, refactor: Remove BitcoinUnits::valid function (Hennadii Stepanov) aa23960 qt, refactor: Make BitcoinUnits::Unit a scoped enum (Hennadii Stepanov) 75832fd qt: Use QVariant instead of int for BitcoinUnit in QSettings (Hennadii Stepanov) Pull request description: This is a rebased version of #60 Since Qt 5.5 there are [means](https://doc.qt.io/qt-5/qobject.html#Q_ENUM) to register an enum type with the meta-object system (such enum still lacks an ability to interact with [QSettings::setValue()](https://doc.qt.io/qt-5/qsettings.html#setValue) and [QSettings::value()](https://doc.qt.io/qt-5/qsettings.html#value) without defined stream operators). In order to reduce global namespace polluting and to force strong type checking, this PR makes BitcoinUnits::Unit a scoped enum (typedef BitcoinUnits::Unit BitcoinUnit;). No behavior change. ACKs for top commit: jonatack: ACK 0e5dedb, review and debug build of each commit after rebase on current master, lightly tested running the GUI, changing units a few times, and verifying persistence after restarting promag: Code review ACK 0e5dedb Tree-SHA512: 39ec0d7e4f0b9b25be287888121a8db6b282339674e37ec3a3554da63a9e22d6fe079e8310ca289b2a0356a19b3c7e55afa17d09dd34e0f222177f603bb053a3
Ported from bitcoin/bitcoin#17877.
Since Qt 5.5 there are means to register an enum type with the meta-object system (such enum still lacks an ability to interact with
QSettings::setValue()andQSettings::value()without defined stream operators).In order to reduce global namespace polluting and to force strong type checking, this PR makes
BitcoinUnits::Unita scoped enum (typedef BitcoinUnits::Unit BitcoinUnit;).No behavior change.