VirtualBox

Changeset 37610 in vbox


Ignore:
Timestamp:
Jun 23, 2011 12:26:14 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: 5748: Fixing GUI on KDE issue: Disappearing of page selector list in Global/Machine settings while opening for the first time.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeWidget.cpp

    r28800 r37610  
    2828    : QTreeWidget (aParent)
    2929{
     30}
     31
     32void QITreeWidget::setSizeHintForItems(const QSize &sizeHint)
     33{
     34    for (int i = 0; i < topLevelItemCount(); ++i)
     35        topLevelItem(i)->setSizeHint(0, sizeHint);
    3036}
    3137
     
    6066}
    6167
    62 void QITreeWidget::addTopBottomMarginToItems (int aMargin)
    63 {
    64     for (int i = 0; i < topLevelItemCount(); ++ i)
    65     {
    66         QTreeWidgetItem *item = topLevelItem (i);
    67         QSize s = item->sizeHint (0);
    68         item->setSizeHint (0, QSize (s.width(), s.height() + 2 * aMargin));
    69     }
    70 }
    71 
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeWidget.h

    r28800 r37610  
    3434    QITreeWidget (QWidget *aParent = 0);
    3535
    36     void addTopBottomMarginToItems (int aMargin);
     36    void setSizeHintForItems(const QSize &sizeHint);
    3737
    3838signals:
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/VBoxSettingsSelector.cpp

    r32814 r37610  
    285285void VBoxSettingsTreeViewSelector::polish()
    286286{
    287     mTwSelector->setFixedWidth (static_cast<QAbstractItemView*> (mTwSelector)
    288         ->sizeHintForColumn (treeWidget_Category) + 2 * mTwSelector->frameWidth());
    289 
    290     /* Sort selector by the id column */
    291     mTwSelector->sortItems (treeWidget_Id, Qt::AscendingOrder);
    292     mTwSelector->resizeColumnToContents (treeWidget_Category);
    293 
    294     /* Add some margin to every item in the tree */
    295     mTwSelector->addTopBottomMarginToItems (12);
     287    /* Get recommended size hint: */
     288    int iItemWidth = static_cast<QAbstractItemView*>(mTwSelector)->sizeHintForColumn(treeWidget_Category);
     289    int iItemHeight = qMax(16 /* icon height */, mTwSelector->fontMetrics().height() /* text height */);
     290    /* Add some margin to every item in the tree: */
     291    iItemHeight += 4 /* margin itself */ * 2 /* margin count */;
     292    /* Set final size hint for items: */
     293    mTwSelector->setSizeHintForItems(QSize(iItemWidth , iItemHeight));
     294
     295    /* Fix selector width to minimum possible: */
     296    mTwSelector->setFixedWidth(iItemWidth + 2 * mTwSelector->frameWidth());
     297
     298    /* Sort selector by the id column: */
     299    mTwSelector->sortItems(treeWidget_Id, Qt::AscendingOrder);
     300
     301    /* Resize column(s) to content: */
     302    mTwSelector->resizeColumnToContents(treeWidget_Category);
    296303}
    297304
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