VirtualBox

Changeset 74178 in vbox for trunk/src


Ignore:
Timestamp:
Sep 10, 2018 10:36:11 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager UI: Chooser view cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
2 edited

Legend:

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

    r74085 r74178  
    55
    66/*
    7  * Copyright (C) 2012-2017 Oracle Corporation
     7 * Copyright (C) 2012-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121
    2222/* Qt includes: */
     23# include <QAccessibleWidget>
    2324# include <QScrollBar>
    24 # include <QAccessibleWidget>
    2525
    2626/* GUI includes: */
    2727# include "UIChooser.h"
     28# include "UIChooserItem.h"
    2829# include "UIChooserModel.h"
    2930# include "UIChooserView.h"
    30 # include "UIChooserItem.h"
    3131
    3232/* Other VBox includes: */
     
    103103    , m_iMinimumHeightHint(0)
    104104{
     105    /* Prepare: */
     106    prepare();
     107}
     108
     109void UIChooserView::sltFocusChanged(UIChooserItem *pFocusItem)
     110{
     111    /* Make sure focus-item set: */
     112    if (!pFocusItem)
     113        return;
     114
     115    const QSize viewSize = viewport()->size();
     116    QRectF geo = pFocusItem->geometry();
     117    geo &= QRectF(geo.topLeft(), viewSize);
     118    ensureVisible(geo, 0, 0);
     119}
     120
     121void UIChooserView::sltMinimumWidthHintChanged(int iHint)
     122{
     123    /* Is there something changed? */
     124    if (m_iMinimumWidthHint == iHint)
     125        return;
     126
     127    /* Remember new value: */
     128    m_iMinimumWidthHint = iHint;
     129
     130    /* Set minimum view width according passed width-hint: */
     131    setMinimumWidth(2 * frameWidth() + m_iMinimumWidthHint + verticalScrollBar()->sizeHint().width());
     132
     133    /* Update scene-rect: */
     134    updateSceneRect();
     135}
     136
     137void UIChooserView::sltMinimumHeightHintChanged(int iHint)
     138{
     139    /* Is there something changed? */
     140    if (m_iMinimumHeightHint == iHint)
     141        return;
     142
     143    /* Remember new value: */
     144    m_iMinimumHeightHint = iHint;
     145
     146    /* Update scene-rect: */
     147    updateSceneRect();
     148}
     149
     150void UIChooserView::retranslateUi()
     151{
     152    /* Translate this: */
     153    setToolTip(tr("Contains a tree of Virtual Machines and their groups"));
     154}
     155
     156void UIChooserView::prepare()
     157{
    105158    /* Install Chooser-view accessibility interface factory: */
    106159    QAccessible::installFactory(UIAccessibilityInterfaceForUIChooserView::pFactory);
     
    120173    updateSceneRect();
    121174
    122     /* Translate finally: */
     175    /* Apply language settings: */
    123176    retranslateUi();
    124 }
    125 
    126 void UIChooserView::sltMinimumWidthHintChanged(int iMinimumWidthHint)
    127 {
    128     /* Is there something changed? */
    129     if (m_iMinimumWidthHint == iMinimumWidthHint)
    130         return;
    131 
    132     /* Remember new value: */
    133     m_iMinimumWidthHint = iMinimumWidthHint;
    134 
    135     /* Set minimum view width according passed width-hint: */
    136     setMinimumWidth(2 * frameWidth() + iMinimumWidthHint + verticalScrollBar()->sizeHint().width());
    137 
    138     /* Update scene-rect: */
    139     updateSceneRect();
    140 }
    141 
    142 void UIChooserView::sltMinimumHeightHintChanged(int iMinimumHeightHint)
    143 {
    144     /* Is there something changed? */
    145     if (m_iMinimumHeightHint == iMinimumHeightHint)
    146         return;
    147 
    148     /* Remember new value: */
    149     m_iMinimumHeightHint = iMinimumHeightHint;
    150 
    151     /* Update scene-rect: */
    152     updateSceneRect();
    153 }
    154 
    155 void UIChooserView::sltFocusChanged(UIChooserItem *pFocusItem)
    156 {
    157     /* Make sure focus-item set: */
    158     if (!pFocusItem)
    159         return;
    160 
    161     QSize viewSize = viewport()->size();
    162     QRectF geo = pFocusItem->geometry();
    163     geo &= QRectF(geo.topLeft(), viewSize);
    164     ensureVisible(geo, 0, 0);
    165 }
    166 
    167 void UIChooserView::retranslateUi()
    168 {
    169     /* Translate this: */
    170     setToolTip(tr("Contains a tree of Virtual Machines and their groups"));
    171177}
    172178
     
    192198    setSceneRect(0, 0, m_iMinimumWidthHint, m_iMinimumHeightHint);
    193199}
    194 
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.h

    r74177 r74178  
    55
    66/*
    7  * Copyright (C) 2012-2017 Oracle Corporation
     7 * Copyright (C) 2012-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef __UIChooserView_h__
    19 #define __UIChooserView_h__
     18#ifndef ___UIChooserView_h___
     19#define ___UIChooserView_h___
    2020
    2121/* GUI includes: */
     
    2727class UIChooserItem;
    2828
    29 /* Graphics chooser-view: */
     29/** QIGraphicsView extension used as VM chooser pane view. */
    3030class UIChooserView : public QIWithRetranslateUI<QIGraphicsView>
    3131{
     
    3434signals:
    3535
    36     /* Notifier: Resize stuff: */
     36    /** Notifies listeners about resize. */
    3737    void sigResized();
    3838
     
    4343    UIChooserView(UIChooser *pParent);
    4444
    45     /** Returns the chooser reference. */
    46     UIChooser *chooser() const { return m_pChooser; }
     45    /** @name General stuff.
     46      * @{ */
     47        /** Returns the chooser reference. */
     48        UIChooser *chooser() const { return m_pChooser; }
     49    /** @} */
    4750
    4851public slots:
    4952
    50     /* Handlers: Size-hint stuff: */
    51     void sltMinimumWidthHintChanged(int iMinimumWidthHint);
    52     void sltMinimumHeightHintChanged(int iMinimumHeightHint);
     53    /** @name General stuff.
     54      * @{ */
     55        /** Handles focus change to @a pFocusItem. */
     56        void sltFocusChanged(UIChooserItem *pFocusItem);
     57    /** @} */
    5358
    54     /* Handler: Focus-item stuff: */
    55     void sltFocusChanged(UIChooserItem *pFocusItem);
     59    /** @name Layout stuff.
     60      * @{ */
     61        /** Handles minimum width @a iHint change. */
     62        void sltMinimumWidthHintChanged(int iHint);
     63        /** Handles minimum height @a iHint change. */
     64        void sltMinimumHeightHintChanged(int iHint);
     65    /** @} */
     66
     67protected:
     68
     69    /** @name Event handling stuff.
     70      * @{ */
     71        /** Handles translation event. */
     72        virtual void retranslateUi() /* override */;
     73
     74        /** Handles resize @a pEvent. */
     75        virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
     76    /** @} */
    5677
    5778private:
    5879
    59     /** Handles translation event. */
    60     virtual void retranslateUi() /* override */;
     80    /** @name Prepare/Cleanup cascade.
     81      * @{ */
     82        /** Prepares all. */
     83        void prepare();
     84        /** Prepares palette. */
     85        void preparePalette();
     86    /** @} */
    6187
    62     /* Helper: Prepare stuff: */
    63     void preparePalette();
     88    /** @name General stuff.
     89      * @{ */
     90        /** Updates scene rectangle. */
     91        void updateSceneRect();
     92    /** @} */
    6493
    65     /* Handler: Resize-event stuff: */
    66     void resizeEvent(QResizeEvent *pEvent);
     94    /** @name General stuff.
     95      * @{ */
     96        /** Holds the chooser pane reference. */
     97        UIChooser *m_pChooser;
     98    /** @} */
    6799
    68     /* Helper: Update stuff: */
    69     void updateSceneRect();
    70 
    71     /** Holds the chooser reference. */
    72     UIChooser *m_pChooser;
    73 
    74     /* Variables: */
    75     int m_iMinimumWidthHint;
    76     int m_iMinimumHeightHint;
     100    /** @name Layout stuff.
     101      * @{ */
     102        /** Holds the minimum width hint. */
     103        int m_iMinimumWidthHint;
     104        /** Holds the minimum height hint. */
     105        int m_iMinimumHeightHint;
     106    /** @} */
    77107};
    78108
    79 #endif /* __UIChooserView_h__ */
    80 
     109#endif /* !___UIChooserView_h___ */
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