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

update CClientUIInterface and remove orphan Wx stuff #1988

Merged
merged 1 commit into from
Nov 27, 2012
Merged

update CClientUIInterface and remove orphan Wx stuff #1988

merged 1 commit into from
Nov 27, 2012

Conversation

Diapolo
Copy link

@Diapolo Diapolo commented Nov 5, 2012

  • 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

@Diapolo
Copy link
Author

Diapolo commented Nov 5, 2012

@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).

@laanwj
Copy link
Member

laanwj commented Nov 5, 2012

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.

@Diapolo
Copy link
Author

Diapolo commented Nov 5, 2012

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 Bitcoin - Error and Bitcoin - Warning.

@Diapolo
Copy link
Author

Diapolo commented Nov 5, 2012

I'll update this pull tomorrow :) did a litle more work here!

@BitcoinPullTester
Copy link

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:

  1. It chanages paths in makefile.linux-mingw or otherwise changes build scripts in a way that made them incompatible with the automated testing scripts
  2. It does not build on either Linux i386 or Win32 (via MinGW cross compile)
  3. The test suite fails on either Linux i386 or Win32
  4. The block test-cases failed (lookup the first bNN identifier which failed in https://github.com/TheBlueMatt/test-scripts/blob/master/FullBlockTestGenerator.java)

/** 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);
Copy link
Author

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?

Copy link
Member

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 :-).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense :).

@Diapolo
Copy link
Author

Diapolo commented Nov 6, 2012

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;
Copy link
Member

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.

Copy link
Author

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;

Copy link
Member

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.

Copy link
Author

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 :).

@Diapolo
Copy link
Author

Diapolo commented Nov 9, 2012

@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);
Copy link
Member

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 :)

Copy link
Author

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 :).

@Diapolo
Copy link
Author

Diapolo commented Nov 13, 2012

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);
Copy link
Member

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 :)

Copy link
Author

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)

Copy link
Member

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.

@laanwj
Copy link
Member

laanwj commented Nov 13, 2012

Sorry for being picky here, but I'm trying to get this "perfect" in one go.

@Diapolo
Copy link
Author

Diapolo commented Nov 13, 2012

@laanwj I'm the one who loves to do things perfect, so I'm really fine with getting constructive feedback!

@Diapolo
Copy link
Author

Diapolo commented Nov 13, 2012

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:
uiInterface.ThreadSafeMessageBox(strerr, _("Error"), CClientUIInterface::ICON_ERROR | CClientUIInterface::BTN_OK | CClientUIInterface::MODAL);
uiInterface.ThreadSafeMessageBox(strerr, "", CClientUIInterface::MSG_ERROR);

@@ -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);
Copy link
Author

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?

Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done...

@Diapolo
Copy link
Author

Diapolo commented Nov 14, 2012

@laanwj Would it be better (typesafe) to directly use CClientUIInterface::MessageBoxFlags style instead of int style in the modified functions? Seems like a not well thought idea, as (ICON_ERROR | BTN_OK) are not recognized as enum but as integer...

@Diapolo
Copy link
Author

Diapolo commented Nov 14, 2012

@laanwj I'll merge the last commit if you ACKed all changes and are fine with the pull as is now :).

@laanwj
Copy link
Member

laanwj commented Nov 14, 2012

Code/design ack - still need to test

@Diapolo
Copy link
Author

Diapolo commented Nov 14, 2012

Good, merged commits, no code changes.

@Diapolo
Copy link
Author

Diapolo commented Nov 14, 2012

Had to fix the connect() calls in bitcoingui.cpp as they still were using int instead of unsigned int.

@Diapolo
Copy link
Author

Diapolo commented Nov 19, 2012

@laanwj I would love to replace all direct notificator->notify() with message() in another pull. Are you fine with using message(tr("foo"), tr("foo"), false, CClientUIInterface::ICON_WARNING); to achieve this :)?

Did you have the time try to test out this pull yet?

@Diapolo
Copy link
Author

Diapolo commented Nov 20, 2012

Added a detailed comment for ::message() and added a missing unsigned ;).

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/60e82f82e638b9059de82e8f093f3ab45a11ed94 for binaries and test log.

@Diapolo
Copy link
Author

Diapolo commented Nov 25, 2012

@laanwj I need your help getting this in, any time-window :)?

return true;
}

bool static InitInformation(const std::string &str)
Copy link
Member

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...

Copy link
Author

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.

Copy link
Member

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?).

Copy link
Author

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
@Diapolo
Copy link
Author

Diapolo commented Nov 27, 2012

@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 :).

@laanwj
Copy link
Member

laanwj commented Nov 27, 2012

I intended to merge it this morning but forgot. I'll try to do it in the
evening today.

@Diapolo
Copy link
Author

Diapolo commented Nov 27, 2012

That's fine, thanks.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/5350ea4171be69d16a94e6f40c5e7fa41e00ac13 for binaries and test log.

laanwj added a commit that referenced this pull request Nov 27, 2012
update CClientUIInterface and remove orphan Wx stuff
@laanwj laanwj merged commit 97c8e63 into bitcoin:master Nov 27, 2012
laudney pushed a commit to reddcoin-project/reddcoin-3.10 that referenced this pull request Mar 19, 2014
update CClientUIInterface and remove orphan Wx stuff
KolbyML pushed a commit to KolbyML/bitcoin that referenced this pull request Dec 5, 2020
…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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants