Bitcoin-Qt: use statustips in addition to tooltips #1923

pull Diapolo wants to merge 1 commits into bitcoin:master from Diapolo:Qt_tooltips changing 2 files +45 −16
  1. Diapolo commented at 2:12 PM on October 12, 2012: none
    • add setStatusTip() in addition to setTooltip() where it makes sense
    • add only setStatusTip() if GUI element is only used in main- or tray menu
    • add an event filter on our BitcoinGUI object to prevent garbelled text on the status bar, which happens when we use it for e.g. displaying block-sync state and then a QEvent::StatusTip wants to write own text to it
    • remove a double translation of "Bitcoin client"

    This solves #1079.

  2. laanwj commented at 7:31 AM on October 13, 2012: member

    To be more precise you removed "all tooltips from QActions"?

  3. Diapolo commented at 8:30 AM on October 13, 2012: none

    No, not from all, just from the ones, which were only used for tray menus and in our main menu. The tooltips on toolbar buttons (e.g. QAction *overviewAction;) are still there. I verified which were safe to remove.

  4. laanwj commented at 9:02 AM on October 13, 2012: member

    ok.. "except from the tab buttons". I agree they are pointless at the moment.

    But it's a bit sad to throw these messages away, which have been translated into many languages. I wonder if there is another way to show a short help message for menu items?

    It appears that on the Qt documentation they recommend using status tips for menu items:

    openAct->setStatusTip(tr("Open an existing file"));
    

    I wonder if we can fit these in somehow, or use another way.

  5. Diapolo commented at 10:52 AM on October 13, 2012: none

    You are absolutely right, it even looks nice to use tooltips for these :). I'll change this pull.

    Edit: Well it doesn't look nice, when hovering a menu item which has a tooltip during block-sync as the statusbar text get's garbelled pretty ugly (2 different texts displayed at the same place -> unreadable).

    garbelled text

  6. laanwj commented at 11:05 AM on October 13, 2012: member

    Hm, indeed, as we use the status bar for different purposes, we'd need to find a solution for that. I think most straightforward would be to hide status tips when something else occupies the status bar?

  7. Diapolo commented at 11:13 AM on October 13, 2012: none

    I've currently no idea how to do this ... but I'll try via an event filter :).

  8. Diapolo commented at 11:45 AM on October 13, 2012: none

    I got it working, will update this pull later. I installed a global event filter on qApp and use this code to prevent the garbelled text:

    <pre> bool BitcoinGUI::eventFilter(QObject *object, QEvent *event) { // Catch status tip events if (event->type() == QEvent::StatusTip) { // Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff if (progressBarLabel->isVisible() && progressBar->isVisible()) return true; } return QMainWindow::eventFilter(object, event); } </pre>

    What do you think?

  9. laanwj commented at 1:33 PM on October 13, 2012: member

    I think it's a good solution!

  10. Diapolo commented at 9:27 AM on October 14, 2012: none

    Updated with event filter, would be nice if @laanwj could test it, too.

  11. BitcoinPullTester commented at 12:02 AM on October 20, 2012: none

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

  12. laanwj commented at 6:34 AM on October 20, 2012: member

    I can't get status tips to appear at all on Ubuntu. This is likely an Ubuntu problem :cry: (as it exports the menu), not a bug in the code.

    Edit: It works when disabling the "Native menubar":

    QT_X11_NO_NATIVE_MENUBAR=1 ./bitcoin-qt -testnet
    

    This proves that the problem is in https://launchpad.net/appmenu-qt and thus out of the scope of this issue. Even filed a upstream bug: https://bugs.launchpad.net/appmenu-qt/+bug/1068974

  13. laanwj commented at 6:43 AM on October 20, 2012: member

    It works in windows! That means it will also work in other Linux distributions that don't hijack everything.

    ACK

  14. Diapolo commented at 8:34 AM on October 20, 2012: none

    I think another pull should be made after this, to get a tooltip for every single item used in the main menu, which is currently not the case. It feels incomplete when we leave it that way IMO.

  15. laanwj commented at 8:56 AM on October 20, 2012: member

    I recommend setting the status tip equal to the tooltip for all QActions by default. This keeps the amount of messages relatively small, and they're never visible at once anyway (ie, tooltips show when the QAction is used for buttons and statustips when the same action is used for menu item).

  16. Diapolo commented at 6:59 AM on October 22, 2012: none

    @laanwj I updated this pull to now use statustips in addition to tooltips where it makes sense and added new descriptive texts for some elements that were missing these.

  17. laanwj commented at 7:21 AM on October 22, 2012: member

    Instead of repeating the message, why not do:

    widget->setStatusTip(widget->getToolTip())
    

    (or other way around) Otherwise they're bound to diverge over time.

  18. Diapolo commented at 7:27 AM on October 22, 2012: none

    Sure that is way better :).

  19. Diapolo commented at 7:43 AM on October 22, 2012: none

    Updated to reflect your suggestion.

  20. Diapolo commented at 8:17 AM on October 25, 2012: none

    @laanwj I guess this needs a rebase after your warning bar pull is in, but are you ok with it now?

    I have a question on our used eventFilter() functions. The Digia doc says:

    <pre> If all the event filters allow further processing of an event (by each returning false), the event is sent to the target object itself. If one of them stops processing (by returning true), the target and any later event filters do not get to see the event at all. </pre>

    Then why are we nearly everywhere doing something like return QObject::eventFilter(obj, evt); at the end of your eventFilter() instead of just false, to send the event to the target object?

  21. laanwj commented at 8:20 AM on October 25, 2012: member

    QObject is not the target object. It is the superclass, it's customary to call the superclass method when overriding a method in Qt. It might well be implemented as "return false", but that's an internal implementation detail.

    Edit: yes this is ok with me now

  22. Diapolo commented at 8:24 AM on October 25, 2012: none

    Alright, but we also have some that use QWidget or QDialog and one that uses just false. I just want to understand, if we should harmonize that and what are the resons we did it like it's now.

  23. laanwj commented at 8:32 AM on October 25, 2012: member

    Yes, if your superclass is QFoo you should use QFoo. QObject is used for classes that derive from QObject. Etc.

    Using just false could cause bugs in event propagation in some cases, at least theoretically.

  24. Bitcoin-Qt: use statustips in addition to tooltips
    - add setStatusTip() in addition to setTooltip() where it makes sense
    - add only setStatusTip() if GUI element is only used in main- or tray menu
    
    - add an event filter on our BitcoinGUI object to prevent garbelled text
      on the status bar, which happens when we use it for e.g. displaying
      block-sync state and then a QEvent::StatusTip wants to write own text to it
    
    - remove a double translation of "Bitcoin client"
    6f959c4cb3
  25. in src/qt/bitcoingui.cpp:None in 121e8e3403 outdated
     175 | @@ -176,6 +176,9 @@
     176 |      // Clicking on "Sign Message" in the receive coins page sends you to the sign message tab
     177 |      connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));
     178 |  
     179 | +    // Install global event filter to be able to catch status tip events (QEvent::StatusTip)
     180 | +    qApp->installEventFilter(this);
    


    Diapolo commented at 9:20 AM on October 25, 2012:

    @laanwj Shouldn't this be this instead of qApp? qApp is the QCoreApplication->Instance(), but we just need this filter for the QMainWindow (which is the object with the statusbar), which is our BitcoinGUI object.


    laanwj commented at 9:23 AM on October 25, 2012:

    You could try. It's good to make event listeners as local as possible (a global event listener will be called for all events throughout the application, which can impact performance), but I don't know if it would work.


    Diapolo commented at 9:42 AM on October 25, 2012:

    Compiles and works just fine, I'll update with this change!

  26. in src/qt/bitcoingui.cpp:None in 43aaf33c04 outdated
     175 | @@ -176,6 +176,9 @@
     176 |      // Clicking on "Sign Message" in the receive coins page sends you to the sign message tab
     177 |      connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));
     178 |  
     179 | +    // Install event filter to be able to catch status tip events (QEvent::StatusTip)
     180 | +    this->installEventFilter(this);
    


    laanwj commented at 10:20 AM on October 25, 2012:

    BTW, just for information (this implementation is fine), instead of installing an event filter on the object itself, you can also override one of the *event methods ( see https://qt-project.org/doc/qt-4.8/qwidget.html#event ).


    Diapolo commented at 1:54 PM on October 25, 2012:

    Good to know, thanks :).

  27. Diapolo commented at 7:24 AM on October 31, 2012: none

    Can I get an ACK?

  28. BitcoinPullTester commented at 7:35 AM on October 31, 2012: none

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

  29. laanwj commented at 8:04 AM on October 31, 2012: member

    ACK

  30. laanwj referenced this in commit a4f758b72c on Nov 1, 2012
  31. laanwj merged this on Nov 1, 2012
  32. laanwj closed this on Nov 1, 2012

  33. laudney referenced this in commit 2704dd0df3 on Mar 19, 2014
  34. KolbyML referenced this in commit 911a046859 on Dec 5, 2020
  35. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 18:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me