VirtualBox

Changeset 102711 in vbox for trunk/src


Ignore:
Timestamp:
Dec 27, 2023 11:07:54 AM (13 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10513: macOS: UIAdvancedSettingsDialog: Improvement for UIFilterEditor; Emulate cocoa focus ring around focused search field.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.cpp

    r102710 r102711  
    428428            m_fFocused = true;
    429429            emit sigFocused();
     430            update();
    430431            break;
    431432        /* Backward animation on focus-out: */
     
    433434            m_fFocused = false;
    434435            emit sigUnfocused();
     436            update();
    435437            break;
    436438        default:
     
    463465    const bool fActive = window() && window()->isActiveWindow();
    464466    const QPalette::ColorGroup enmColorGroup = fActive ? QPalette::Active : QPalette::Inactive;
     467#ifdef VBOX_WS_MAC
     468    const QColor colorHighlight = uiCommon().isInDarkMode()
     469                                ? qApp->palette().color(enmColorGroup, QPalette::Highlight).lighter(110)
     470                                : qApp->palette().color(enmColorGroup, QPalette::Highlight).darker(110);
     471#endif
    465472    const QColor colorBase = qApp->palette().color(enmColorGroup, QPalette::Base);
    466473    const QColor colorFrame = uiCommon().isInDarkMode()
     
    471478    const QRegion totalRegion = QRegion(m_pLineEdit->geometry()) + QRegion(m_pToolButton->geometry());
    472479    QRect widgetRect = totalRegion.boundingRect();
     480#ifdef VBOX_WS_MAC
     481    const QRect focusRect = widgetRect;
     482    widgetRect.adjust(3, 3, -3, -3);
     483    const QPainterPath focusPath = cookPainterPath(focusRect, m_iRadius + 2);
     484#endif
    473485    const QPainterPath widgetPath = cookPainterPath(widgetRect, m_iRadius);
    474486
    475487    /* Draw base/frame: */
     488#ifdef VBOX_WS_MAC
     489    if (m_pLineEdit->hasFocus())
     490        painter.fillPath(focusPath, colorHighlight);
     491#endif
    476492    painter.fillPath(widgetPath, colorBase);
    477493    painter.strokePath(widgetPath, colorFrame);
     
    498514    if (m_pLineEdit)
    499515    {
     516#ifdef VBOX_WS_MAC
     517        /* A bit of magic to be able to replace the frame.
     518         * Disable border, adjust margins and make background transparent.
     519                 * Left and right margins also take focus ring into account. */
     520        m_pLineEdit->setStyleSheet("QLineEdit {\
     521                                    background-color: rgba(255, 255, 255, 0%);\
     522                                    border: 0px none black;\
     523                                    margin: 6px 0px 6px 10px;\
     524                                    }");
     525#else
    500526        /* A bit of magic to be able to replace the frame.
    501527         * Disable border, adjust margins and make background transparent. */
     
    505531                                    margin: 3px 0px 3px 10px;\
    506532                                    }");
     533#endif
    507534        m_pLineEdit->installEventFilter(this);
    508535        connect(m_pLineEdit, &QILineEdit::textChanged,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette