Index: trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp	(revision 43983)
+++ trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp	(revision 43984)
@@ -19,5 +19,4 @@
 
 /* Qt includes: */
-#include <QApplication>
 #include <QGraphicsView>
 #include <QStateMachine>
@@ -41,4 +40,6 @@
     , m_type(type)
     , m_iCornerRadius(10)
+    , m_iMinimumHeaderWidth(0)
+    , m_iMinimumHeaderHeight(0)
     , m_fClosed(!fOpened)
     , m_pButton(0)
@@ -93,12 +94,9 @@
     /* Prepare variables: */
     int iMargin = data(ElementData_Margin).toInt();
-    int iHeaderWidth = data(ElementData_HeaderSize).toSize().width();
     int iTextWidth = data(ElementData_TextWidth).toInt();
-
-    /* Calculating proposed width: */
     int iProposedWidth = 0;
 
     /* Maximum width: */
-    iProposedWidth = qMax(iHeaderWidth, iTextWidth);
+    iProposedWidth = qMax(m_iMinimumHeaderWidth, iTextWidth);
 
     /* And 4 margins: 2 left and 2 right: */
@@ -161,44 +159,4 @@
         case ElementData_Margin: return 5;
         case ElementData_Spacing: return 10;
-        /* Pixmaps: */
-        case ElementData_Pixmap: return m_icon;
-        /* Fonts: */
-        case ElementData_NameFont:
-        {
-            QFont nameFont = qApp->font();
-            nameFont.setWeight(QFont::Bold);
-            return nameFont;
-        }
-        case ElementData_TextFont:
-        {
-            QFont textFont = qApp->font();
-            return textFont;
-        }
-        /* Sizes: */
-        case ElementData_PixmapSize:
-            return m_icon.isNull() ? QSize(0, 0) : m_icon.availableSizes().at(0);
-        case ElementData_NameSize:
-        {
-            QFontMetrics fm(data(ElementData_NameFont).value<QFont>(), model()->paintDevice());
-            return QSize(fm.width(m_strName), fm.height());
-        }
-        case ElementData_ButtonSize: return m_pButton->minimumSizeHint();
-        case ElementData_HeaderSize:
-        {
-            /* Prepare variables: */
-            int iMargin = data(ElementData_Margin).toInt();
-            int iSpacing = data(ElementData_Spacing).toInt();
-            QSize pixmapSize = data(ElementData_PixmapSize).toSize();
-            QSize nameSize = data(ElementData_NameSize).toSize();
-            QSize buttonSize = data(ElementData_ButtonSize).toSize();
-            /* Header width: */
-            int iHeaderWidth = iMargin + pixmapSize.width() + iSpacing +
-                               nameSize.width() + iSpacing + buttonSize.width();
-            /* Header height: */
-            int iHeaderHeight = qMax(pixmapSize.height(), nameSize.height());
-            iHeaderHeight = qMax(iHeaderHeight, buttonSize.height());
-            /* Return value: */
-            return QSize(iHeaderWidth, iHeaderHeight);
-        }
         case ElementData_TextWidth:
         {
@@ -206,5 +164,5 @@
             int iSpacing = data(ElementData_Spacing).toInt();
             int iMinimumTextColumnWidth = data(ElementData_MinimumTextColumnWidth).toInt();
-            QFontMetrics fm(data(ElementData_TextFont).value<QFont>(), model()->paintDevice());
+            QFontMetrics fm(m_textFont, model()->paintDevice());
 
             /* Search for the maximum line widths: */
@@ -251,7 +209,6 @@
             int iMinimumTextColumnWidth = data(ElementData_MinimumTextColumnWidth).toInt();
             int iMaximumTextWidth = (int)geometry().width() - 3 * iMargin - iSpacing;
-            QFont textFont = data(ElementData_TextFont).value<QFont>();
             QPaintDevice *pPaintDevice = model()->paintDevice();
-            QFontMetrics fm(textFont, pPaintDevice);
+            QFontMetrics fm(m_textFont, pPaintDevice);
 
             /* Search for the maximum line widths: */
@@ -296,5 +253,5 @@
                 {
                     bool fRightColumnPresent = !line.second.isEmpty();
-                    QTextLayout *pTextLayout = prepareTextLayout(textFont, pPaintDevice,
+                    QTextLayout *pTextLayout = prepareTextLayout(m_textFont, pPaintDevice,
                                                                  fRightColumnPresent ? line.first + ":" : line.first,
                                                                  iLeftColumnWidth, iLeftColumnHeight);
@@ -306,5 +263,5 @@
                 if (!line.second.isEmpty())
                 {
-                    QTextLayout *pTextLayout = prepareTextLayout(textFont, pPaintDevice, line.second,
+                    QTextLayout *pTextLayout = prepareTextLayout(m_textFont, pPaintDevice, line.second,
                                                                  iRightColumnWidth, iRightColumnHeight);
                     delete pTextLayout;
@@ -325,12 +282,43 @@
 }
 
+void UIGDetailsElement::updateMinimumHeaderWidth()
+{
+    /* Prepare variables: */
+    int iSpacing = data(ElementData_Spacing).toInt();
+
+    /* Update minimum-header-width: */
+    m_iMinimumHeaderWidth = m_pixmapSize.width() +
+                            iSpacing + m_nameSize.width() +
+                            iSpacing + m_buttonSize.width();
+}
+
+void UIGDetailsElement::updateMinimumHeaderHeight()
+{
+    /* Update minimum-header-height: */
+    m_iMinimumHeaderHeight = qMax(m_pixmapSize.height(), m_nameSize.height());
+    m_iMinimumHeaderHeight = qMax(m_iMinimumHeaderHeight, m_buttonSize.height());
+}
+
 void UIGDetailsElement::setIcon(const QIcon &icon)
 {
-    m_icon = icon;
+    /* Cache icon: */
+    m_pixmapSize = icon.isNull() ? QSize(0, 0) : icon.availableSizes().first();
+    m_pixmap = icon.pixmap(m_pixmapSize);
+
+    /* Update linked values: */
+    updateMinimumHeaderWidth();
+    updateMinimumHeaderHeight();
 }
 
 void UIGDetailsElement::setName(const QString &strName)
 {
+    /* Cache name: */
     m_strName = strName;
+    QFontMetrics fm(m_nameFont, model()->paintDevice());
+    m_nameSize = QSize(fm.width(m_strName), fm.height());
+
+    /* Update linked values: */
+    updateMinimumHeaderWidth();
+    updateMinimumHeaderHeight();
 }
 
@@ -392,4 +380,9 @@
 void UIGDetailsElement::prepareElement()
 {
+    /* Initialization: */
+    m_nameFont = font();
+    m_nameFont.setWeight(QFont::Bold);
+    m_textFont = font();
+
     /* Create highlight machine: */
     m_pHighlightMachine = new QStateMachine(this);
@@ -435,4 +428,5 @@
     connect(m_pButton, SIGNAL(sigRotationStart()), this, SLOT(sltElementToggleStart()));
     connect(m_pButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltElementToggleFinish(bool)));
+    m_buttonSize = m_pButton->minimumSizeHint().toSize();
 }
 
@@ -445,13 +439,11 @@
     QSize size = geometry().size().toSize();
     int iMargin = data(ElementData_Margin).toInt();
-    QSize buttonSize = data(ElementData_ButtonSize).toSize();
-    int iButtonWidth = buttonSize.width();
-    int iButtonHeight = buttonSize.height();
-    int iFullHeaderHeight = data(ElementData_HeaderSize).toSize().height();
+    int iButtonWidth = m_buttonSize.width();
+    int iButtonHeight = m_buttonSize.height();
 
     /* Layout button: */
     int iButtonX = size.width() - 2 * iMargin - iButtonWidth;
-    int iButtonY = iButtonHeight == iFullHeaderHeight ? iMargin :
-                   iMargin + (iFullHeaderHeight - iButtonHeight) / 2;
+    int iButtonY = iButtonHeight == m_iMinimumHeaderHeight ? iMargin :
+                   iMargin + (m_iMinimumHeaderHeight - iButtonHeight) / 2;
     m_pButton->setPos(iButtonX, iButtonY);
 }
@@ -471,8 +463,5 @@
     /* Prepare variables: */
     int iMargin = data(ElementData_Margin).toInt();
-    int iHeaderHeight = data(ElementData_HeaderSize).toSize().height();
     int iTextHeight = data(ElementData_TextHeight).toInt();
-
-    /* Calculating proposed height: */
     int iProposedHeight = 0;
 
@@ -481,5 +470,5 @@
 
     /* Header height: */
-    iProposedHeight += iHeaderHeight;
+    iProposedHeight += m_iMinimumHeaderHeight;
 
     /* Element is opened? */
@@ -495,5 +484,5 @@
         iProposedHeight += m_iAdditionalHeight;
 
-    /* Return result: */
+    /* Return value: */
     return iProposedHeight;
 }
@@ -538,11 +527,8 @@
     int iMargin = data(ElementData_Margin).toInt();
     int iSpacing = data(ElementData_Spacing).toInt();
-    QSize pixmapSize = data(ElementData_PixmapSize).toSize();
-    QSize nameSize = data(ElementData_NameSize).toSize();
-    int iHeaderHeight = data(ElementData_HeaderSize).toSize().height();
 
     /* Calculate attributes: */
-    int iPixmapHeight = pixmapSize.height();
-    int iNameHeight = nameSize.height();
+    int iPixmapHeight = m_pixmapSize.height();
+    int iNameHeight = m_nameSize.height();
     int iMaximumHeight = qMax(iPixmapHeight, iNameHeight);
 
@@ -560,11 +546,11 @@
                 pPainter,
                 /* Rectangle to paint in: */
-                QRect(QPoint(iMachinePixmapX, iMachinePixmapY), pixmapSize),
+                QRect(QPoint(iMachinePixmapX, iMachinePixmapY), m_pixmapSize),
                 /* Pixmap to paint: */
-                data(ElementData_Pixmap).value<QIcon>().pixmap(pixmapSize));
+                m_pixmap);
 
     /* Paint name: */
     int iMachineNameX = iMachinePixmapX +
-                        pixmapSize.width() +
+                        m_pixmapSize.width() +
                         iSpacing;
     int iMachineNameY = iNameHeight == iMaximumHeight ?
@@ -573,7 +559,7 @@
               pPainter,
               /* Rectangle to paint in: */
-              QRect(QPoint(iMachineNameX, iMachineNameY), nameSize),
+              QRect(QPoint(iMachineNameX, iMachineNameY), m_nameSize),
               /* Font to paint text: */
-              data(ElementData_NameFont).value<QFont>(),
+              m_nameFont,
               /* Text to paint: */
               m_strName,
@@ -591,7 +577,6 @@
         int iMinimumTextColumnWidth = data(ElementData_MinimumTextColumnWidth).toInt();
         int iMaximumTextWidth = geometry().width() - 3 * iMargin - iSpacing;
-        QFont textFont = data(ElementData_TextFont).value<QFont>();
         QPaintDevice *pPaintDevice = model()->paintDevice();
-        QFontMetrics fm(textFont, pPaintDevice);
+        QFontMetrics fm(m_textFont, pPaintDevice);
 
         /* Search for the maximum line widths: */
@@ -629,5 +614,5 @@
         /* Where to paint? */
         int iMachineTextX = iMachinePixmapX;
-        int iMachineTextY = iMargin + iHeaderHeight + 2 * iMargin;
+        int iMachineTextY = iMargin + m_iMinimumHeaderHeight + 2 * iMargin;
 
         /* For each the line: */
@@ -639,5 +624,5 @@
             {
                 bool fRightColumnPresent = !line.second.isEmpty();
-                QTextLayout *pTextLayout = prepareTextLayout(textFont, pPaintDevice,
+                QTextLayout *pTextLayout = prepareTextLayout(m_textFont, pPaintDevice,
                                                              fRightColumnPresent ? line.first + ":" : line.first,
                                                              iLeftColumnWidth, iLeftColumnHeight);
@@ -650,5 +635,5 @@
             if (!line.second.isEmpty())
             {
-                QTextLayout *pTextLayout = prepareTextLayout(textFont, pPaintDevice,
+                QTextLayout *pTextLayout = prepareTextLayout(m_textFont, pPaintDevice,
                                                              line.second, iRightColumnWidth, iRightColumnHeight);
                 pTextLayout->draw(pPainter, QPointF(iMachineTextX + iLeftColumnWidth + iSpacing, iMachineTextY));
@@ -672,6 +657,5 @@
     /* Prepare variables: */
     int iMargin = data(ElementData_Margin).toInt();
-    int iHeaderContentHeight = data(ElementData_HeaderSize).toSize().height();
-    int iHeaderHeight = 2 * iMargin + iHeaderContentHeight;
+    int iHeaderHeight = 2 * iMargin + m_iMinimumHeaderHeight;
     QRect optionRect = pOption->rect;
     QRect fullRect = !m_fAnimationRunning ? optionRect :
@@ -792,15 +776,12 @@
     int iMargin = data(ElementData_Margin).toInt();
     int iSpacing = data(ElementData_Spacing).toInt();
-    int iPixmapWidth = data(ElementData_PixmapSize).toSize().width();
-    QSize nameSize = data(ElementData_NameSize).toSize();
-    int iNameHeight = nameSize.height();
-    int iHeaderHeight = data(ElementData_HeaderSize).toSize().height();
-    int iMachineNameX = 2 * iMargin + iPixmapWidth + iSpacing;
-    int iMachineNameY = iNameHeight == iHeaderHeight ?
-                        iMargin : iMargin + (iHeaderHeight - iNameHeight) / 2;
+    int iNameHeight = m_nameSize.height();
+    int iMachineNameX = 2 * iMargin + m_pixmapSize.width() + iSpacing;
+    int iMachineNameY = iNameHeight == m_iMinimumHeaderHeight ?
+                        iMargin : iMargin + (m_iMinimumHeaderHeight - iNameHeight) / 2;
 
     /* Simulate hyperlink hovering: */
     QPoint point = pEvent->pos().toPoint();
-    bool fNameHovered = QRect(QPoint(iMachineNameX, iMachineNameY), nameSize).contains(point);
+    bool fNameHovered = QRect(QPoint(iMachineNameX, iMachineNameY), m_nameSize).contains(point);
     if (m_fNameHoveringAccessible && m_fNameHovered != fNameHovered)
     {
Index: trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h	(revision 43983)
+++ trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h	(revision 43984)
@@ -109,14 +109,5 @@
         ElementData_Margin,
         ElementData_Spacing,
-        /* Pixmaps: */
-        ElementData_Pixmap,
-        /* Fonts: */
-        ElementData_NameFont,
-        ElementData_TextFont,
         /* Sizes: */
-        ElementData_PixmapSize,
-        ElementData_NameSize,
-        ElementData_ButtonSize,
-        ElementData_HeaderSize,
         ElementData_TextWidth,
         ElementData_TextHeight,
@@ -127,4 +118,8 @@
     QVariant data(int iKey) const;
 
+    /* Helpers: Update stuff: */
+    void updateMinimumHeaderWidth();
+    void updateMinimumHeaderHeight();
+
     /* API: Icon stuff: */
     void setIcon(const QIcon &icon);
@@ -141,4 +136,6 @@
 
     /* Helpers: Layout stuff: */
+    int minimumHeaderWidth() const { return m_iMinimumHeaderWidth; }
+    int minimumHeaderHeight() const { return m_iMinimumHeaderHeight; }
     void updateLayout();
 
@@ -196,8 +193,15 @@
     UIGDetailsSet *m_pSet;
     DetailsElementType m_type;
-    QIcon m_icon;
+    QPixmap m_pixmap;
     QString m_strName;
     UITextTable m_text;
     int m_iCornerRadius;
+    QFont m_nameFont;
+    QFont m_textFont;
+    QSize m_pixmapSize;
+    QSize m_nameSize;
+    QSize m_buttonSize;
+    int m_iMinimumHeaderWidth;
+    int m_iMinimumHeaderHeight;
 
     /* Variables: Toggle stuff: */
Index: trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp	(revision 43983)
+++ trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp	(revision 43984)
@@ -169,8 +169,7 @@
     /* Prepare variables: */
     int iMargin = data(ElementData_Margin).toInt();
-    int iHeaderHeight = data(ElementData_HeaderSize).toSize().height();
     /* Prepare layout: */
     QGraphicsLinearLayout *pLayout = new QGraphicsLinearLayout;
-    pLayout->setContentsMargins(iMargin, 2 * iMargin + iHeaderHeight, iMargin, iMargin);
+    pLayout->setContentsMargins(iMargin, 2 * iMargin + minimumHeaderHeight(), iMargin, iMargin);
     setLayout(pLayout);
 
@@ -185,5 +184,4 @@
     /* Prepare variables: */
     int iMargin = data(ElementData_Margin).toInt();
-    int iHeaderWidth = data(ElementData_HeaderSize).toSize().width();
 
     /* Calculating proposed width: */
@@ -191,5 +189,5 @@
 
     /* Maximum between header width and preview width: */
-    iProposedWidth += qMax(iHeaderWidth, m_pPreview->minimumSizeHint().toSize().width());
+    iProposedWidth += qMax(minimumHeaderWidth(), m_pPreview->minimumSizeHint().toSize().width());
 
     /* Two margins: */
@@ -204,5 +202,4 @@
     /* Prepare variables: */
     int iMargin = data(ElementData_Margin).toInt();
-    int iHeaderHeight = data(ElementData_HeaderSize).toSize().height();
 
     /* Calculating proposed height: */
@@ -213,5 +210,5 @@
 
     /* Header height: */
-    iProposedHeight += iHeaderHeight;
+    iProposedHeight += minimumHeaderHeight();
 
     /* Element is opened? */
