Title: Where can I find a code for BC 0.8 GUI? Post by: Many Coins on May 08, 2018, 11:21:31 AM Hello!
Where is the code responsible for the autocomplete form fields in Bitcoin Core 0.8? For example: https://i.imgur.com/rFSWg9n.png Here, the "Amount" field is auto-completed with zeros after the number is entered. I want to find the code that does this. Where do I need to look? Thank you! Title: Re: Where can I find a code for BC 0.8 GUI? Post by: Xynerise on May 08, 2018, 12:16:16 PM Bitcoin Core uses the Qt GUI, and everything pertaining to it can be found in
Code: master/src/qt Title: Re: Where can I find a code for BC 0.8 GUI? Post by: starmyc on May 08, 2018, 12:34:50 PM Hello! Where is the code responsible for the autocomplete form fields in Bitcoin Core 0.8? Not 100% sure, but it is most likely filed by validator in the widget there (https://github.com/bitcoin/bitcoin/blob/v0.8.6/src/qt/guiutil.cpp#L71): Code: void setupAmountWidget(QLineEdit *widget, QWidget *parent) Title: Re: Where can I find a code for BC 0.8 GUI? Post by: shahzadafzal on May 08, 2018, 12:35:43 PM Check below source code at location Code: \bitcoin-master\src\qt\bitcoingui.cpp This is the code responsible for formatting the amounts: Code: QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators) Title: Re: Where can I find a code for BC 0.8 GUI? Post by: Many Coins on May 08, 2018, 03:33:23 PM shahzadafzal, starmyc, Xynerise
Thank you! but I try change Code: amount->setDecimals(8); to "5" in src\qt\bitcoinamountfield.cpp and Code: amountValidator->setDecimals(8); in guiutil.cpp and Code: case real_type: os_ << std::showpoint << std::fixed << std::setprecision(8) in src\json\json_spirit_writer_template.h No way. The number of zeros after the comma is still 8 and not 5. How to change it in src\qt\bitcoingui.cpp - I do not understand. Can you tell me please? Title: Re: Where can I find a code for BC 0.8 GUI? Post by: starmyc on May 08, 2018, 04:39:29 PM shahzadafzal, starmyc, Xynerise Thank you! but I try change Code: amount->setDecimals(8); to "5" in src\qt\bitcoinamountfield.cpp and Code: amountValidator->setDecimals(8); No way. The number of zeros after the comma is still 8 and not 5. How to change it in src\qt\bitcoingui.cpp - I do not understand. Can you tell me please? Okay, I was wrong. Your widget is created in bitcoinamountfield.cpp like this: Code: BitcoinAmountField::BitcoinAmountField(QWidget *parent): But, the function (also a qt "slot") will also change it: Code: void BitcoinAmountField::unitChanged(int idx) If you want to change the number of decimals to 5, you need to change it in the UI constructor and in the BitcoinUnits::decimals function as well (or put 5 instead of modifying the function - at least, it worked for me on your coin source tree) Title: Re: Where can I find a code for BC 0.8 GUI? Post by: Many Coins on May 08, 2018, 04:52:46 PM or put 5 instead of modifying the function Yes, its working :) Thank you. I'll try to change the function. Title: Re: Where can I find a code for BC 0.8 GUI? Post by: Many Coins on May 08, 2018, 04:56:47 PM Wow! So simply! ))
in src/qt/bitcoinunits.cpp Code: int BitcoinUnits::decimals(int unit) :) Thank you! Title: Re: Where can I find a code for BC 0.8 GUI? Post by: shahzadafzal on May 09, 2018, 07:02:23 AM Wow! So simply! )) in src/qt/bitcoinunits.cpp Well I thought you want to change on that particular screen. Here bitcoinunits.cpp you will change the bitcoin decimals for the whole system? Btw why want to do this? Title: Re: Where can I find a code for BC 0.8 GUI? Post by: Many Coins on May 09, 2018, 09:07:34 AM Well I thought you want to change on that particular screen. Here bitcoinunits.cpp you will change the bitcoin decimals for the whole system? Btw why want to do this? I'll show you later :) By the way, do you happen to know why these values are necessary: Code: amount->setDecimals(8); in src/qt/bitcoinamountfield.cpp Code: amountValidator->setDecimals(8); in src/qt/guiutil.cpp Code: case real_type: os_ << std::showpoint << std::fixed << std::setprecision(8) in src/json/json_spirit_writer_template.h ??? What do they influence? |