VirtualBox

Changeset 89138 in vbox


Ignore:
Timestamp:
May 18, 2021 12:48:07 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144479
Message:

FE/Qt: bugref:10003: Reworking Chooser pane; Fixing quirks painting group item frame and gathering suitable foreground color.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp

    r88862 r89138  
    16561656        return;
    16571657
     1658    /* Only selected item should have a frame: */
     1659    if (!model()->selectedItems().contains(this))
     1660        return;
     1661
    16581662    /* Save painter: */
    16591663    pPainter->save();
     
    16801684
    16811685    /* Draw borders: */
     1686    pPainter->drawLine(rectangle.topLeft(), rectangle.topRight());
    16821687    if (node()->hasNodes() && nodeToGroupType()->isOpened())
    16831688        pPainter->drawLine(topRect.bottomLeft() + QPoint(iParentIndent, 0), topRect.bottomRight() + QPoint(1, 0));
     
    17031708    const int iFullHeaderHeight = m_minimumHeaderSize.height();
    17041709
    1705     /* Configure painter color: */
    1706     pPainter->setPen(QApplication::palette().color(QPalette::Active,
    1707                                                    model()->selectedItems().contains(this) ?
    1708                                                    QPalette::HighlightedText : QPalette::ButtonText));
     1710    /* Selected item foreground: */
     1711    if (model()->selectedItems().contains(this))
     1712    {
     1713        /* Prepare palette: */
     1714        const QPalette pal = QApplication::palette();
     1715
     1716        /* Get background color: */
     1717        const QColor background = pal.color(QPalette::Active, QPalette::Highlight).darker(headerDarkness());
     1718
     1719        /* Get foreground color: */
     1720        const QColor simpleText = pal.color(QPalette::Active, QPalette::Text);
     1721        const QColor highlightText = pal.color(QPalette::Active, QPalette::HighlightedText);
     1722        const QColor lightText = simpleText.black() < highlightText.black() ? simpleText : highlightText;
     1723        const QColor darkText = simpleText.black() > highlightText.black() ? simpleText : highlightText;
     1724
     1725        /* Gather foreground color for background one: */
     1726        double dLuminance = (0.299 * background.red() + 0.587 * background.green() + 0.114 * background.blue()) / 255;
     1727        //printf("luminance = %f\n", dLuminance);
     1728        if (dLuminance > 0.5)
     1729            pPainter->setPen(darkText);
     1730        else
     1731            pPainter->setPen(lightText);
     1732    }
    17091733
    17101734    /* Paint name: */
Note: See TracChangeset for help on using the changeset viewer.

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