VirtualBox

Changeset 57670 in vbox


Ignore:
Timestamp:
Sep 9, 2015 3:06:32 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Selector UI: Details pane: Elements: Cleanup/rework (step 3).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp

    r57669 r57670  
    5555
    5656
    57 /* Constructor: */
    5857UIGDetailsUpdateThread::UIGDetailsUpdateThread(const CMachine &machine)
    5958    : m_machine(machine)
     
    115114        m_pThread = 0;
    116115    }
     116}
     117
     118
     119UIGDetailsElementPreview::UIGDetailsElementPreview(UIGDetailsSet *pParent, bool fOpened)
     120    : UIGDetailsElement(pParent, DetailsElementType_Preview, fOpened)
     121{
     122    /* Icon: */
     123    setIcon(UIIconPool::iconSet(":/machine_16px.png"));
     124
     125    /* Prepare variables: */
     126    int iMargin = data(ElementData_Margin).toInt();
     127    /* Prepare layout: */
     128    QGraphicsLinearLayout *pLayout = new QGraphicsLinearLayout;
     129    pLayout->setContentsMargins(iMargin, 2 * iMargin + minimumHeaderHeight(), iMargin, iMargin);
     130    setLayout(pLayout);
     131
     132    /* Create preview: */
     133    m_pPreview = new UIGMachinePreview(this);
     134    connect(m_pPreview, SIGNAL(sigSizeHintChanged()),
     135            this, SLOT(sltPreviewSizeHintChanged()));
     136    pLayout->addItem(m_pPreview);
     137    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     138
     139    /* Translate finally: */
     140    retranslateUi();
     141}
     142
     143void UIGDetailsElementPreview::sltPreviewSizeHintChanged()
     144{
     145    /* Recursively update size-hints: */
     146    updateGeometry();
     147    /* Update whole model layout: */
     148    model()->updateLayout();
     149}
     150
     151void UIGDetailsElementPreview::retranslateUi()
     152{
     153    /* Assign corresponding name: */
     154    setName(gpConverter->toString(elementType()));
     155}
     156
     157int UIGDetailsElementPreview::minimumWidthHint() const
     158{
     159    /* Prepare variables: */
     160    int iMargin = data(ElementData_Margin).toInt();
     161
     162    /* Calculating proposed width: */
     163    int iProposedWidth = 0;
     164
     165    /* Maximum between header width and preview width: */
     166    iProposedWidth += qMax(minimumHeaderWidth(), m_pPreview->minimumSizeHint().toSize().width());
     167
     168    /* Two margins: */
     169    iProposedWidth += 2 * iMargin;
     170
     171    /* Return result: */
     172    return iProposedWidth;
     173}
     174
     175int UIGDetailsElementPreview::minimumHeightHint(bool fClosed) const
     176{
     177    /* Prepare variables: */
     178    int iMargin = data(ElementData_Margin).toInt();
     179
     180    /* Calculating proposed height: */
     181    int iProposedHeight = 0;
     182
     183    /* Two margins: */
     184    iProposedHeight += 2 * iMargin;
     185
     186    /* Header height: */
     187    iProposedHeight += minimumHeaderHeight();
     188
     189    /* Element is opened? */
     190    if (!fClosed)
     191    {
     192        iProposedHeight += iMargin;
     193        iProposedHeight += m_pPreview->minimumSizeHint().toSize().height();
     194    }
     195    else
     196    {
     197        /* Additional height during animation: */
     198        if (button()->isAnimationRunning())
     199            iProposedHeight += additionalHeight();
     200    }
     201
     202    /* Return result: */
     203    return iProposedHeight;
     204}
     205
     206void UIGDetailsElementPreview::updateLayout()
     207{
     208    /* Call to base-class: */
     209    UIGDetailsElement::updateLayout();
     210
     211    /* Show/hide preview: */
     212    if (closed() && m_pPreview->isVisible())
     213        m_pPreview->hide();
     214    if (opened() && !m_pPreview->isVisible() && !isAnimationRunning())
     215        m_pPreview->show();
     216}
     217
     218void UIGDetailsElementPreview::updateAppearance()
     219{
     220    /* Call for base class: */
     221    UIGDetailsElement::updateAppearance();
     222
     223    /* Set new machine attribute: */
     224    m_pPreview->setMachine(machine());
     225    emit sigBuildDone();
    117226}
    118227
     
    164273
    165274    COMBase::CleanupCOM();
    166 }
    167 
    168 
    169 UIGDetailsElementPreview::UIGDetailsElementPreview(UIGDetailsSet *pParent, bool fOpened)
    170     : UIGDetailsElement(pParent, DetailsElementType_Preview, fOpened)
    171 {
    172     /* Icon: */
    173     setIcon(UIIconPool::iconSet(":/machine_16px.png"));
    174 
    175     /* Prepare variables: */
    176     int iMargin = data(ElementData_Margin).toInt();
    177     /* Prepare layout: */
    178     QGraphicsLinearLayout *pLayout = new QGraphicsLinearLayout;
    179     pLayout->setContentsMargins(iMargin, 2 * iMargin + minimumHeaderHeight(), iMargin, iMargin);
    180     setLayout(pLayout);
    181 
    182     /* Create preview: */
    183     m_pPreview = new UIGMachinePreview(this);
    184     connect(m_pPreview, SIGNAL(sigSizeHintChanged()),
    185             this, SLOT(sltPreviewSizeHintChanged()));
    186     pLayout->addItem(m_pPreview);
    187     setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    188 
    189     /* Translate finally: */
    190     retranslateUi();
    191 }
    192 
    193 void UIGDetailsElementPreview::sltPreviewSizeHintChanged()
    194 {
    195     /* Recursively update size-hints: */
    196     updateGeometry();
    197     /* Update whole model layout: */
    198     model()->updateLayout();
    199 }
    200 
    201 void UIGDetailsElementPreview::retranslateUi()
    202 {
    203     /* Assign corresponding name: */
    204     setName(gpConverter->toString(elementType()));
    205 }
    206 
    207 int UIGDetailsElementPreview::minimumWidthHint() const
    208 {
    209     /* Prepare variables: */
    210     int iMargin = data(ElementData_Margin).toInt();
    211 
    212     /* Calculating proposed width: */
    213     int iProposedWidth = 0;
    214 
    215     /* Maximum between header width and preview width: */
    216     iProposedWidth += qMax(minimumHeaderWidth(), m_pPreview->minimumSizeHint().toSize().width());
    217 
    218     /* Two margins: */
    219     iProposedWidth += 2 * iMargin;
    220 
    221     /* Return result: */
    222     return iProposedWidth;
    223 }
    224 
    225 int UIGDetailsElementPreview::minimumHeightHint(bool fClosed) const
    226 {
    227     /* Prepare variables: */
    228     int iMargin = data(ElementData_Margin).toInt();
    229 
    230     /* Calculating proposed height: */
    231     int iProposedHeight = 0;
    232 
    233     /* Two margins: */
    234     iProposedHeight += 2 * iMargin;
    235 
    236     /* Header height: */
    237     iProposedHeight += minimumHeaderHeight();
    238 
    239     /* Element is opened? */
    240     if (!fClosed)
    241     {
    242         iProposedHeight += iMargin;
    243         iProposedHeight += m_pPreview->minimumSizeHint().toSize().height();
    244     }
    245     else
    246     {
    247         /* Additional height during animation: */
    248         if (button()->isAnimationRunning())
    249             iProposedHeight += additionalHeight();
    250     }
    251 
    252     /* Return result: */
    253     return iProposedHeight;
    254 }
    255 
    256 void UIGDetailsElementPreview::updateLayout()
    257 {
    258     /* Call to base-class: */
    259     UIGDetailsElement::updateLayout();
    260 
    261     /* Show/hide preview: */
    262     if (closed() && m_pPreview->isVisible())
    263         m_pPreview->hide();
    264     if (opened() && !m_pPreview->isVisible() && !isAnimationRunning())
    265         m_pPreview->show();
    266 }
    267 
    268 void UIGDetailsElementPreview::updateAppearance()
    269 {
    270     /* Call for base class: */
    271     UIGDetailsElement::updateAppearance();
    272 
    273     /* Set new machine attribute: */
    274     m_pPreview->setMachine(machine());
    275     emit sigBuildDone();
    276275}
    277276
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.h

    r57669 r57670  
    3232class UIGMachinePreview;
    3333
     34
    3435/* Element update thread: */
    3536class UIGDetailsUpdateThread : public QThread
     
    9091    /* Variables: */
    9192    UIGDetailsUpdateThread *m_pThread;
    92 };
    93 
    94 
    95 /* Thread 'General': */
    96 class UIGDetailsUpdateThreadGeneral : public UIGDetailsUpdateThread
    97 {
    98     Q_OBJECT;
    99 
    100 public:
    101 
    102     /* Constructor: */
    103     UIGDetailsUpdateThreadGeneral(const CMachine &machine)
    104         : UIGDetailsUpdateThread(machine) {}
    105 
    106 private:
    107 
    108     /* Helpers: Prepare stuff: */
    109     void run();
    110 };
    111 
    112 /* Element 'General': */
    113 class UIGDetailsElementGeneral : public UIGDetailsElementInterface
    114 {
    115     Q_OBJECT;
    116 
    117 public:
    118 
    119     /* Constructor: */
    120     UIGDetailsElementGeneral(UIGDetailsSet *pParent, bool fOpened)
    121         : UIGDetailsElementInterface(pParent, DetailsElementType_General, fOpened) {}
    122 
    123 private:
    124 
    125     /* Helper: Update stuff: */
    126     UIGDetailsUpdateThread* createUpdateThread() { return new UIGDetailsUpdateThreadGeneral(machine()); }
    12793};
    12894
     
    161127
    162128
     129/* Thread 'General': */
     130class UIGDetailsUpdateThreadGeneral : public UIGDetailsUpdateThread
     131{
     132    Q_OBJECT;
     133
     134public:
     135
     136    /* Constructor: */
     137    UIGDetailsUpdateThreadGeneral(const CMachine &machine)
     138        : UIGDetailsUpdateThread(machine) {}
     139
     140private:
     141
     142    /* Helpers: Prepare stuff: */
     143    void run();
     144};
     145
     146/* Element 'General': */
     147class UIGDetailsElementGeneral : public UIGDetailsElementInterface
     148{
     149    Q_OBJECT;
     150
     151public:
     152
     153    /* Constructor: */
     154    UIGDetailsElementGeneral(UIGDetailsSet *pParent, bool fOpened)
     155        : UIGDetailsElementInterface(pParent, DetailsElementType_General, fOpened) {}
     156
     157private:
     158
     159    /* Helper: Update stuff: */
     160    UIGDetailsUpdateThread* createUpdateThread() { return new UIGDetailsUpdateThreadGeneral(machine()); }
     161};
     162
     163
    163164/* Thread 'System': */
    164165class UIGDetailsUpdateThreadSystem : public UIGDetailsUpdateThread
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