Add tooltip offset to top right

Qt stock tooltip position can be blocked by cursor (user could have large cursor size).

Current Seamly2D tooltip:

With tooltip offset to top right:

Guessing cursor size is difficult, better just offset it to top right.

Can be done by QWidget::eventFilter(QObject *, QEvent *)

bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
    if (event->type() == QEvent::ToolTip) {
        // Cast to a help event to get the coordinates
        QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);

        // Cast the object to a widget so we can get its tooltip text
        QWidget *widget = qobject_cast<QWidget *>(obj);

        if (widget && !widget->toolTip().isEmpty()) {
            // Show the tooltip with an offset
            // This bypasses the default blocking behavior
            QToolTip::showText(helpEvent->globalPos() + QPoint(20, -50),
                               widget->toolTip(),
                               widget);

            return true;
        }
    }
    // Pass everything else through to the original widget
    return MainWindowsNoGUI::eventFilter(obj, event);
}
1 polubienie

Good idea… but some issues.

You’ve only addressed Seamly2D’s MainWindow… there is also SeamlyMe’s MainWindow. I also found it knd of annoying to have it A) In the upper right corner which is not where one expects to see the tooltips. Lower right would be more in keeping with what everyone is accustom to. B) When it’s so far away (20 & 50 px) with a normal size cursor.

It’s also forcing users to adapt to the change. Maybe giving them a preference choice to toggle it off or set the position and distance would be a better solution. And yes… I do care about the user’s experience.

2 polubienia

Yes, with a reset to default button.

:unicorn:

2 polubienia

I built using 10, 20 and it was accpetable for a pointer size of 1 to 3. In my opinion any pointer larger than that is just useless unless you have a huge monitor, and even then the cursor won’t fit any Seamly text edit boxes. IMO it’s ahem.. pointless. :face_with_hand_over_mouth:

Maybe a better solution would be to provide a “View” menu item Cursor Offset with subitem pointer sizes of 1, 2, 3, 4 and 5 that sets the offset to suit that of the pointer size. It would allow a user to set a preference without having to access the Preferences to make a change.

2 polubienia