VirtualBox

Ignore:
Timestamp:
May 19, 2015 9:40:09 AM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: 6278: Settings dialog: Selector: Enable use of the HiDPI icons, adjust size-hint accordingly.

File:
1 edited

Legend:

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

    r52730 r55924  
    191191    sizePolicy.setVerticalStretch (0);
    192192    sizePolicy.setHeightForWidth (mTwSelector->sizePolicy().hasHeightForWidth());
     193    const QStyle *pStyle = QApplication::style();
     194    const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize);
    193195    mTwSelector->setSizePolicy (sizePolicy);
    194196    mTwSelector->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
     
    196198    mTwSelector->setRootIsDecorated (false);
    197199    mTwSelector->setUniformRowHeights (true);
    198     mTwSelector->setIconSize(QSize(24, 24));
     200    mTwSelector->setIconSize(QSize(1.5 * iIconMetric, 1.5 * iIconMetric));
    199201    /* Add the columns */
    200202    mTwSelector->headerItem()->setText (treeWidget_Category, "Category");
     
    291293{
    292294    /* Get recommended size hint: */
     295    const QStyle *pStyle = QApplication::style();
     296    const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize);
    293297    int iItemWidth = static_cast<QAbstractItemView*>(mTwSelector)->sizeHintForColumn(treeWidget_Category);
    294     int iItemHeight = qMax(24 /* icon height */, mTwSelector->fontMetrics().height() /* text height */);
     298    int iItemHeight = qMax((int)(iIconMetric * 1.5) /* icon height */,
     299                           mTwSelector->fontMetrics().height() /* text height */);
    295300    /* Add some margin to every item in the tree: */
    296301    iItemHeight += 4 /* margin itself */ * 2 /* margin count */;
     
    298303    mTwSelector->setSizeHintForItems(QSize(iItemWidth , iItemHeight));
    299304
    300     /* Fix selector width to minimum possible: */
     305    /* Adjust selector width/height: */
    301306    mTwSelector->setFixedWidth(iItemWidth + 2 * mTwSelector->frameWidth());
     307    mTwSelector->setMinimumHeight(mTwSelector->topLevelItemCount() * iItemHeight +
     308                                  1 /* margin itself */ * 2 /* margin count */);
    302309
    303310    /* Sort selector by the id column: */
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