Skip to content
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

qt: Set C locale for amountWidget #14177

Merged
merged 1 commit into from Oct 18, 2018
Merged

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Sep 9, 2018

Fix #13873

@fanquake fanquake added the GUI label Sep 9, 2018
Copy link
Member

@luke-jr luke-jr left a comment

Not sure if this is a good idea. What is the practical effect of setting the locale here?

Can a correct/point-based number still be entered and work properly?

src/qt/transactionview.h Outdated
@@ -70,6 +70,7 @@ class TransactionView : public QWidget
QComboBox *watchOnlyWidget;
QLineEdit *search_widget;
QLineEdit *amountWidget;
QDoubleValidator *amountValidator;

This comment has been minimized.

@luke-jr

luke-jr Sep 9, 2018
Member

This isn't used anywhere. Probably we either need to delete it in cleanup, or don't need to store it at all.

This comment has been minimized.

@hebasto

hebasto Sep 9, 2018
Author Member

@luke-jr QDoubleValidator uses system locale if its own one is not set. If system decimal separator is , then QDoubleValidator will not accept . at all. I've used the same approach as BitcoinAmountField class does:

amount->setLocale(QLocale::c());

amountValidator member is declared in the same place where amountWidget is.

This comment has been minimized.

@laanwj

laanwj Sep 13, 2018
Member

it is used: it's used to validate what is entered in the amount field

This comment has been minimized.

@laanwj

laanwj Sep 13, 2018
Member

Oh I agree with @luke-jr actually; there's no need to store this in the object, just store it temporarily in a local variable in TransactionView::TransactionView while you need to manipulate it.

@laanwj
Copy link
Member

@laanwj laanwj commented Sep 13, 2018

we don't use the system locale for bitcoin amount entry, so this seems right

utACK bd5107055d393e14269faca84741c8167500e7b5

src/qt/transactionview.cpp Outdated
@@ -106,7 +106,9 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
} else {
amountWidget->setFixedWidth(100);
}
amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this));
amountValidator = new QDoubleValidator(0, 1e20, 8, this);

This comment has been minimized.

@laanwj

laanwj Sep 13, 2018
Member

e.g. do

QDoubleValidator *amountValidator = new QDoubleValidator(0, 1e20, 8, this);
@hebasto hebasto force-pushed the hebasto:fix-amount-locale branch Sep 13, 2018
@hebasto
Copy link
Member Author

@hebasto hebasto commented Sep 13, 2018

@luke-jr @laanwj
Thank you for your reviews.
Fixed.

@hebasto
Copy link
Member Author

@hebasto hebasto commented Sep 23, 2018

I just found out that there is another PR addressed this issue: #13278
@MarcoFalke the @DrahtBot did not report about a PR conflict. Is it ok?

@MarcoFalke
Copy link
Member

@MarcoFalke MarcoFalke commented Sep 24, 2018

@hebasto The bot can't check against PRs that conflict with master.

@jonasschnelli
Copy link
Member

@jonasschnelli jonasschnelli commented Sep 25, 2018

Unsure.
Current master won't let me enter a comma (,)... it forces me to use "." for the dec. separator.
While in this PR, I can enter a comma (gets ignored) which may confuse users.
Thoughts?

Fix #13873
@hebasto hebasto force-pushed the hebasto:fix-amount-locale branch to b0510d7 Sep 26, 2018
@hebasto
Copy link
Member Author

@hebasto hebasto commented Sep 26, 2018

@jonasschnelli
Thank you for your review.

While in this PR, I can enter a comma (gets ignored) which may confuse users.

The comma , is a group separator in the C locale.

Thoughts?

Fixed. Please re-review.

@hebasto hebasto changed the title Qt: Set locale for amountWidget qt: Set C locale for amountWidget Sep 26, 2018
@Sjors
Copy link
Member

@Sjors Sjors commented Oct 8, 2018

On a macOS machine with Dutch locale (, decimal separator) When I enter an amount with a comma in the Send screen it's automatically converted to a dot, which is nice.

When I enter a comma in the search screen it's ignored, as @jonasschnelli noticed. That's annoying, but at least it fixes the bug. The user will see a list of amounts with . separators so they'll probably figure it out.

tACK b0510d7

@laanwj laanwj merged commit b0510d7 into bitcoin:master Oct 18, 2018
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
laanwj added a commit that referenced this pull request Oct 18, 2018
b0510d7 Set C locale for amountWidget (Hennadii Stepanov)

Pull request description:

  Fix #13873

Tree-SHA512: ef26b35ef83c3a87ebd90650f6d833b00a24f6c114b68fe01acd4a14d1f5bdec066f438eb7781c1e55c32640838c54e00b8f082c390639ade8d9a58830833d4a
@hebasto hebasto deleted the hebasto:fix-amount-locale branch Oct 18, 2018
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 28, 2020
Summary:
b0510d78aedde864756199fe71ca98f8e95dd44f Set C locale for amountWidget (Hennadii Stepanov)

Pull request description:

  Fix #13873

---

Backport of Core [[bitcoin/bitcoin#14177 | PR14177]]

Test Plan:
  ninja all
  ./qt/bitcoin-qt -testnet

move to transactions tab, try set an amount filter using comma instead of point and make sure I fail to do so.

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8545
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.