-
Notifications
You must be signed in to change notification settings - Fork 35.7k
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
update CClientUIInterface and remove orphan Wx stuff #1988
Conversation
@laanwj I suppose ui_interface.h - MessageBoxFlags could be cleaned up or the GUI part needs some reworking to make this options available (which seems not needed, as we only use MessageBoxFlags for displaying warnings / errors currently). |
ACK! This needed to be done badly :) Indeed, the UI message interface has a lot of unused flags (inherited from Wx). Some of them could be implemented and used, others are completely useless and can be removed. Feel free to do so. |
If you are fine with the code please first merge this and I'll create another cleanup-pull afterwards? Edit: I also thought about changing the message box caption for InitError() and InitWarning() to |
I'll update this pull tomorrow :) did a litle more work here! |
Automatic sanity-testing: FAILED BUILD/TEST, see http://jenkins.bluematt.me/pull-tester/75ba0be11aef6bff3abebb667564a0671533cd81 for binaries and test log. This could happen for one of several reasons:
|
/** Notify the user of an error in the network or transaction handling code. */ | ||
void error(const QString &title, const QString &message, bool modal); | ||
/** Notify the user of an event from the core network or transaction handling code. */ | ||
void error(const QString &title, const QString &message, bool modal, int style); |
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.
@laanwj I would love to rename that function to coreEvent() or something as error() is not suitable IMHO. What do you think?
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.
Maybe just call it message() (event was dumb, I thought this referred to some other place in the source :-).
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.
Yeah, that makes sense :).
Updated to not only fix the bug with always having an error icon, but to also extend the CClientUIInterface. |
@@ -41,12 +40,17 @@ static void ThreadSafeMessageBox(const std::string& message, const std::string& | |||
if(guiref) | |||
{ | |||
bool modal = (style & CClientUIInterface::MODAL); | |||
// remove modal flag from style variable after we have the state | |||
if (modal) | |||
style -= CClientUIInterface::MODAL; |
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 really don't like using - on flags. Please use a mask with &
if you need a subset of the bits, instead of subtracting them one by one.
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.
This should work, or?
style ^= CClientUIInterface::MODAL;
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.
It certainly works (both with - and ^), my point was that removing the
flags one by one when set gives needlessly verbose code, when you can
simply select a subset of the flags with a mask.
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 was not aware of that mask stuff, update for the pull is on it's way now :).
@laanwj Updated to just use masks, can you please take another look. Thanks for your time :). |
@@ -84,7 +84,7 @@ void ClientModel::updateAlert(const QString &hash, int status) | |||
CAlert alert = CAlert::getAlertByHash(hash_256); | |||
if(!alert.IsNull()) | |||
{ | |||
emit error(tr("Network Alert"), QString::fromStdString(alert.strStatusBar), false); | |||
emit message(tr("Bitcoin - Network Alert"), QString::fromStdString(alert.strStatusBar), false, CClientUIInterface::ICON_ERROR); |
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.
If you really want to prefix tr("Bitcoin - ")
to all titles, why not do it in message or some other inner function? This prevents having to change all these messages, and translators from having to translate Bitcoin a zillion times :)
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.
Didn't see that low hanging fruit, but will update :).
Updated to make the MASKs part of the enums and now prepends "Bitcoin - " to the captions. |
@@ -209,16 +211,22 @@ int main(int argc, char* argv[]) | |||
|
|||
bool static InitError(const std::string &str) | |||
{ | |||
uiInterface.ThreadSafeMessageBox(str, _("Bitcoin"), CClientUIInterface::OK | CClientUIInterface::MODAL); | |||
uiInterface.ThreadSafeMessageBox(str, _("Error"), CClientUIInterface::ICON_ERROR | CClientUIInterface::MODAL); |
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 see another pattern here :-)
uiInterface.ThreadSafeMessageBox(str, _("Error"), CClientUIInterface::ICON_ERROR | CClientUIInterface::MODAL);
uiInterface.ThreadSafeMessageBox(str, _("Warning"), CClientUIInterface::ICON_WARNING | CClientUIInterface::MODAL);
....
Wonder if we can do anything with that :)
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 get it? Standing on the line I guess :-D.
Edit: Something like this in the enum?
/** Predefined combinations for certain usage cases */ MSG_INFORMATION = (ICON_INFORMATION | BTN_OK), MSG_WARNING = (ICON_WARNING | BTN_OK | MODAL), MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL)
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.
Messages with flag WARNING have "Warning" as title, same for error. If we
aren't using title to summarize the message we could leave it out entirely
and base it on the flags too. Another simplification of the interface.
Sorry for being picky here, but I'm trying to get this "perfect" in one go. |
@laanwj I'm the one who loves to do things perfect, so I'm really fine with getting constructive feedback! |
Updated to allow more efficient usage of ThreadSafeMessageBox with predefined MSG_ERROR, MSG_WARNING or MSG_INFORMATION, which don't need a string for title/caption anymore. Example before and after: |
@@ -1248,7 +1248,7 @@ void AddTimeData(const CNetAddr& ip, int64 nTime) | |||
string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Bitcoin will not work properly."); | |||
strMiscWarning = strMessage; | |||
printf("*** %s\n", strMessage.c_str()); | |||
uiInterface.ThreadSafeMessageBox(strMessage+" ", string("Bitcoin"), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION); | |||
uiInterface.ThreadSafeMessageBox(strMessage, _("Warning"), CClientUIInterface::ICON_WARNING); |
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.
Is this intended to be non-modal?
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 suppose you could make it modal.
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.
Done...
@laanwj Would it be better (typesafe) to directly use |
@laanwj I'll merge the last commit if you ACKed all changes and are fine with the pull as is now :). |
Code/design ack - still need to test |
Good, merged commits, no code changes. |
Had to fix the connect() calls in bitcoingui.cpp as they still were using int instead of unsigned int. |
@laanwj I would love to replace all direct Did you have the time try to test out this pull yet? |
Added a detailed comment for ::message() and added a missing unsigned ;). |
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/60e82f82e638b9059de82e8f093f3ab45a11ed94 for binaries and test log. |
@laanwj I need your help getting this in, any time-window :)? |
return true; | ||
} | ||
|
||
bool static InitInformation(const std::string &str) |
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.
It complains that this function is unused...
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.
Yes, because it IS unused ;). I thought it could be useful for others / later, that's why I added it.
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.
Ok, makes sense. I don't really like the idea of introducing dead code in
the core though just in case it is useful later (especially as it is just a
wrapper around the ui interface). We should try to at least use it
somewhere. Shouldn't be hard if there is a clear use case. I can't think of
one right now. Issues that arise during initialization are either:
- fatal: modal dialog and exit
- important warning that requires immediate attention: modal dialog and
proceed - warning affecting usage of the program, ie upgrade alerts: persistent
warning in status bar
Transient notifications are most useful for events that are signaled to the
user but do not require immediate attention. I don't see any of those
arising in init (but maybe you do?).
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.
No need to discuss in the end, I just removed if for now :).
- fix ThreadSafeMessageBox always displays error icon - allow to specify MSG_ERROR / MSG_WARNING or MSG_INFORMATION without a custom caption / title - allow to specify CClientUIInterface::ICON_ERROR / ICON_WARNING and ICON_INFORMATION (which is default) as message box icon - remove CClientUIInterface::OK from ThreadSafeMessageBox-calls, as the OK button will be set as default, if none is specified - prepend "Bitcoin - " to used captions - rename BitcoinGUI::error() -> BitcoinGUI::message() and add function documentation - change all style parameters and enum flags to unsigned - update code to use that new API - update Client- and WalletModel to use new BitcoinGUI::message() and rename the classes error() method into message() - include the possibility to supply the wanted icon for messages from Client- and WalletModel via "style" parameter
@laanwj I would like to use the new interface for other pulls, so it would be great if you could prioritize the testing of this pull :). |
I intended to merge it this morning but forgot. I'll try to do it in the |
That's fine, thanks. |
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/5350ea4171be69d16a94e6f40c5e7fa41e00ac13 for binaries and test log. |
update CClientUIInterface and remove orphan Wx stuff
update CClientUIInterface and remove orphan Wx stuff
…de info 4c6ad09 [Trivial] Fix v5_shield description and chainparams indentation (random-zebra) 88507d0 scripted-diff: Rename nu param v5_dummy --> v5_shield (random-zebra) Pull request description: Rename the NU param info/index removing the "dummy" label. ``` -BEGIN VERIFY SCRIPT- sed -i 's/v5_dummy/v5_shield/g' src/*.h src/*.cpp src/*/*.h src/*/*.cpp src/*/*/*.h src/*/*/*.cpp test/functional/*.py ; sed -i 's/v5 dummy/v5 shield/g' test/functional/*.py test/functional/*/*.py; sed -i 's/UPGRADE_V5_DUMMY/UPGRADE_V5_0/g' src/*.h src/*.cpp src/*/*.h src/*/*.cpp src/*/*/*.h src/*/*/*.cpp ; -END VERIFY SCRIPT- ``` ACKs for top commit: furszy: ACK 4c6ad09, straightforward scripted PR, merging.. Tree-SHA512: fd91f19166ecece4c3c1ad9deca8993ea04bfadacdd5f9ffccfdb475270cf50fcef762304df5375640ed690127e985b87f65d0f83c2a524a159189b61e94fb95
custom caption / title
ICON_INFORMATION (which is default) as message box icon
the OK button will be set as default, if none is specified
documentation
rename the classes error() method into message()
Client- and WalletModel via "style" parameter