-
Notifications
You must be signed in to change notification settings - Fork 38.7k
GUI: init with correct display unit and update it, when user changes it via options dialog #1434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Updated - added |
|
@laanwj Can you take a look at the code, I think this is a rather "small" one, which could get in, if you don't want to add/change something. |
src/qt/overviewpage.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like special-casing 0. Either;
- Keep it as "txdelegate->unit = model->getOptionsModel()->getDisplayUnit();", and remove the parameter again
or
- Pass a valid parameter everywhere you use this function, and use
txdelegate->unit = nUnit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I understand you, nUnit is non-zero, when updateDisplayUnit() is called via the displayUnitChanged() SIGNAL and 0 when called to init. Do you want me to use updateDisplayUnit(0) and remove the default-init of 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to use 0 at all, the argument adds unneeded complexity. IMO I think it's best to remove the argument nUnit completely, and always use the unit from the optionsmodel (as it was before).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a SLOT and SIGNAL, which handles the unit, why should we not use this? It's used in the other 2 files, too. I really like the ?: operator and disagree here. Can we find a consensus which leads to similar solutions for all 3 files edited in this pull :)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the other alternative is to always pass in a valid unit value.
You may like it, but there is no real need to special-case 0, no need to use ?:. You only need one function signature for this, without special magic values which are bound to bite you some day.
If you look at how I've done it in the other files it's like this:
void MyClass::setModel(model)
{
if(model)
{
/* Set initial value */
fooChanged(model->getFoo());
/* Track changes */
connect(model, SIGNAL(fooChanged(int)), self, SLOT(fooChanged(int)))
}
}
void MyClass::fooChanged(value)
{
// Do something with value
}
So everywhere you call updateDisplayUnit() use updateDisplayUnit(model->getOptionsModel->getDisplayUnit()). Either that or the previous suggestion,
void MyClass::setModel(model)
{
if(model)
{
/* Set initial value */
blaChanged();
/* Track changes */
connect(model, SIGNAL(fooChanged(int)), self, SLOT(fooChanged()))
}
}
void MyClass::fooChanged()
{
if(model)
{
value = model->getFoo();
// Do something with value
}
}
which IMO in this particular case is most sensible as we're always taking the value from the options model anyway. Both are valid solutions, but don't try to do them both at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So simply not use the int passed from fooChanged() SIGNAL... it is cleaner yes, I just was sad we didn't use it.
I'm going to change it in all 3 files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's ton of places where the signal argument is not used, also in Qt itself, no need to be sad about it :)
|
Last commit implements 2 of your suggestions @laanwj , this will get squashed after we are "final" :). |
|
Removed the ?: and int usage from the SIGNAL. Anything left? |
|
ACK |
|
Merged all commits, no further changes, final then. |
|
BTW one unrelated comment regarding your commit messages. It's not very urgent, and there's no need to change it for current pulls. However, currently you try to trim everything into one line, this makes for very long "git log" lines when abbreviated. The general format that most people use for a commit message is: for example, see commit 1025440: |
…ndcoinsentry and connect it to displayUnitChanged() - this ensures all fields in the GUI, who use a display unit are imediately updated, when the user changes this setting in the optionsdialog / ensure used fields init with the current set display unit
|
@laanwj Can you merge this now, I'm working on further changes in some of the files and would like to avoid merge-conflicts :). |
GUI: init with correct display unit and update it, when user changes it via options dialog
GUI: init with correct display unit and update it, when user changes it via options dialog
…e-HD wallets 28d051f [QA] Add Travis job to run functional tests with --legacywallet (random-zebra) 9b94070 [Tests] Skip unrelated tests when --legacywallet (random-zebra) Pull request description: Follows the discussion in bitcoin#1410 . Defines a list of tests to be skipped by the `test_runner` when running with the `--legacywallet` flag (not directly related to the wallet / key management). Also adds a specific Travis job, to run the functional test suite on pre-HD wallets. Note: currently based on top of - [x] bitcoin#1411 to make legacy tests pass. ACKs for top commit: Fuzzbawls: ACK 28d051f Tree-SHA512: 4a8c896a3b8232221b8f86480d4b3e730297e1efb103cd61ac26fd104d6d90577a2fdab2a9002932c4d61d5a7404f7ef588e92958cdfb28249b018f58e74dd2a
This addresses / fixes #781 and #927.