VirtualBox

Changeset 74177 in vbox for trunk/src/VBox/Frontends


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

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

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

Legend:

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

    r74138 r74177  
    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 <QVBoxLayout>
    2423# include <QStatusBar>
    2524# include <QStyle>
     25# include <QVBoxLayout>
    2626
    2727/* GUI includes: */
     
    4242    , m_pChooserView(0)
    4343{
    44     /* Prepare palette: */
    45     preparePalette();
    46 
    47     /* Prepare layout: */
    48     prepareLayout();
    49 
    50     /* Prepare model: */
    51     prepareModel();
    52 
    53     /* Prepare view: */
    54     prepareView();
    55 
    56     /* Prepare connections: */
    57     prepareConnections();
    58 
    59     /* Load: */
    60     load();
     44    /* Prepare: */
     45    prepare();
    6146}
    6247
    6348UIChooser::~UIChooser()
    6449{
    65     /* Save: */
    66     save();
     50    /* Cleanup: */
     51    cleanup();
    6752}
    6853
    69 UIActionPool* UIChooser::actionPool() const
     54UIActionPool *UIChooser::actionPool() const
    7055{
    7156    return managerWidget()->actionPool();
     
    118103}
    119104
     105void UIChooser::prepare()
     106{
     107    /* Prepare palette: */
     108    preparePalette();
     109    /* Prepare layout: */
     110    prepareLayout();
     111    /* Prepare model: */
     112    prepareModel();
     113    /* Prepare view: */
     114    prepareView();
     115    /* Prepare connections: */
     116    prepareConnections();
     117
     118    /* Load settings: */
     119    loadSettings();
     120}
     121
    120122void UIChooser::preparePalette()
    121123{
     
    130132void UIChooser::prepareLayout()
    131133{
    132     /* Setup main-layout: */
     134    /* Create main-layout: */
    133135    m_pMainLayout = new QVBoxLayout(this);
    134     const int iR = qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) / 9;
    135     m_pMainLayout->setContentsMargins(0, 0, iR, 0);
    136     m_pMainLayout->setSpacing(0);
     136    if (m_pMainLayout)
     137    {
     138        /* Configure main-layout: */
     139        m_pMainLayout->setContentsMargins(0, 0, 0, 0);
     140        m_pMainLayout->setSpacing(0);
     141    }
    137142}
    138143
    139144void UIChooser::prepareModel()
    140145{
    141     /* Setup chooser-model: */
     146    /* Create chooser-model: */
    142147    m_pChooserModel = new UIChooserModel(this);
    143148}
     
    147152    /* Setup chooser-view: */
    148153    m_pChooserView = new UIChooserView(this);
    149     m_pChooserView->setScene(m_pChooserModel->scene());
    150     m_pChooserView->show();
    151     setFocusProxy(m_pChooserView);
    152     m_pMainLayout->addWidget(m_pChooserView);
     154    if (m_pChooserView)
     155    {
     156        /* Configure chooser-view. */
     157        m_pChooserView->setScene(m_pChooserModel->scene());
     158        m_pChooserView->show();
     159        setFocusProxy(m_pChooserView);
     160
     161        /* Add into layout: */
     162        m_pMainLayout->addWidget(m_pChooserView);
     163    }
    153164}
    154165
     
    156167{
    157168    /* Setup chooser-model connections: */
    158     connect(m_pChooserModel, SIGNAL(sigRootItemMinimumWidthHintChanged(int)),
    159             m_pChooserView, SLOT(sltMinimumWidthHintChanged(int)));
    160     connect(m_pChooserModel, SIGNAL(sigRootItemMinimumHeightHintChanged(int)),
    161             m_pChooserView, SLOT(sltMinimumHeightHintChanged(int)));
    162     connect(m_pChooserModel, SIGNAL(sigFocusChanged(UIChooserItem*)),
    163             m_pChooserView, SLOT(sltFocusChanged(UIChooserItem*)));
     169    connect(m_pChooserModel, &UIChooserModel::sigRootItemMinimumWidthHintChanged,
     170            m_pChooserView, &UIChooserView::sltMinimumWidthHintChanged);
     171    connect(m_pChooserModel, &UIChooserModel::sigRootItemMinimumHeightHintChanged,
     172            m_pChooserView, &UIChooserView::sltMinimumHeightHintChanged);
     173    connect(m_pChooserModel, &UIChooserModel::sigFocusChanged,
     174            m_pChooserView, &UIChooserView::sltFocusChanged);
    164175
    165176    /* Setup chooser-view connections: */
    166     connect(m_pChooserView, SIGNAL(sigResized()),
    167             m_pChooserModel, SLOT(sltHandleViewResized()));
     177    connect(m_pChooserView, &UIChooserView::sigResized,
     178            m_pChooserModel, &UIChooserModel::sltHandleViewResized);
    168179}
    169180
    170 void UIChooser::load()
     181void UIChooser::loadSettings()
    171182{
    172183    /* Prepare model: */
     
    174185}
    175186
    176 void UIChooser::save()
     187void UIChooser::saveSettings()
    177188{
    178189    /* Cleanup model: */
     
    180191}
    181192
     193void UIChooser::cleanup()
     194{
     195    /* Save settings: */
     196    saveSettings();
     197}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h

    r74138 r74177  
    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 __UIChooser_h__
    19 #define __UIChooser_h__
     18#ifndef ___UIChooser_h___
     19#define ___UIChooser_h___
    2020
    2121/* Qt includes: */
     
    2525#include "UIChooserItem.h"
    2626
    27 /* Forward declartions: */
    28 class UIVirtualMachineItem;
     27/* Forward declarations: */
    2928class QVBoxLayout;
    30 class UIVirtualBoxManagerWidget;
    3129class UIActionPool;
    3230class UIChooserModel;
    3331class UIChooserView;
    34 class QStatusBar;
     32class UIVirtualBoxManagerWidget;
     33class UIVirtualMachineItem;
    3534
    36 /* Graphics selector widget: */
     35/** QWidget extension used as VM chooser pane. */
    3736class UIChooser : public QWidget
    3837{
     
    4140signals:
    4241
    43     /* Notifier: Selection change: */
    44     void sigSelectionChanged();
     42    /** @name General stuff.
     43      * @{ */
     44        /** Notifies listeners about selection changed. */
     45        void sigSelectionChanged();
    4546
    46     /* Notifier: Sliding stuff: */
    47     void sigSlidingStarted();
     47        /** Notifies listeners about sliding started. */
     48        void sigSlidingStarted();
    4849
    49     /* Notifiers: Toggle stuff: */
    50     void sigToggleStarted();
    51     void sigToggleFinished();
     50        /** Notifies listeners about toggling started. */
     51        void sigToggleStarted();
     52        /** Notifies listeners about toggling finished. */
     53        void sigToggleFinished();
     54    /** @} */
    5255
    53     /* Notifier: Group-saving stuff: */
    54     void sigGroupSavingStateChanged();
     56    /** @name Group saving stuff.
     57      * @{ */
     58        /** Notifies listeners about group saving state change. */
     59        void sigGroupSavingStateChanged();
     60    /** @} */
    5561
    5662public:
    5763
    58     /* Constructor/destructor: */
     64    /** Constructs chooser pane passing @a pParent to the base-class. */
    5965    UIChooser(UIVirtualBoxManagerWidget *pParent);
    60     ~UIChooser();
     66    /** Destructs chooser pane. */
     67    virtual ~UIChooser() /* override */;
    6168
    62     /** Returns the manager-widget reference. */
    63     UIVirtualBoxManagerWidget *managerWidget() const { return m_pManagerWidget; }
    64     /** Returns the action-pool reference. */
    65     UIActionPool* actionPool() const;
     69    /** @name General stuff.
     70      * @{ */
     71        /** Returns the manager-widget reference. */
     72        UIVirtualBoxManagerWidget *managerWidget() const { return m_pManagerWidget; }
    6673
    67     /** Return the Chooser-model instance. */
    68     UIChooserModel *model() const { return m_pChooserModel; }
    69     /** Return the Chooser-view instance. */
    70     UIChooserView *view() const { return m_pChooserView; }
     74        /** Returns the action-pool reference. */
     75        UIActionPool *actionPool() const;
    7176
    72     /* API: Current-item stuff: */
    73     bool isGroupItemSelected() const;
    74     bool isGlobalItemSelected() const;
    75     bool isMachineItemSelected() const;
    76     UIVirtualMachineItem *currentItem() const;
    77     QList<UIVirtualMachineItem*> currentItems() const;
    78     bool isSingleGroupSelected() const;
    79     bool isAllItemsOfOneGroupSelected() const;
     77        /** Return the Chooser-model instance. */
     78        UIChooserModel *model() const { return m_pChooserModel; }
     79        /** Return the Chooser-view instance. */
     80        UIChooserView *view() const { return m_pChooserView; }
     81    /** @} */
    8082
    81     /* API: Group-saving stuff: */
    82     bool isGroupSavingInProgress() const;
     83    /** @name Current item stuff.
     84      * @{ */
     85        /** Returns whether group item is selected. */
     86        bool isGroupItemSelected() const;
     87        /** Returns whether global item is selected. */
     88        bool isGlobalItemSelected() const;
     89        /** Returns whether machine item is selected. */
     90        bool isMachineItemSelected() const;
     91        /** Returns current item. */
     92        UIVirtualMachineItem *currentItem() const;
     93        /** Returns current items. */
     94        QList<UIVirtualMachineItem*> currentItems() const;
     95        /** Returns whether single group is selected. */
     96        bool isSingleGroupSelected() const;
     97        /** Returns whether all machine items of one group is selected. */
     98        bool isAllItemsOfOneGroupSelected() const;
     99    /** @} */
     100
     101    /** @name Group saving stuff.
     102      * @{ */
     103        /** Returns whether group saving is in progress. */
     104        bool isGroupSavingInProgress() const;
     105    /** @} */
    83106
    84107public slots:
    85108
    86     /** Handles toolbar resize to @a newSize. */
    87     void sltHandleToolbarResize(const QSize &newSize);
     109    /** @name General stuff.
     110      * @{ */
     111        /** Handles toolbar resize to @a newSize. */
     112        void sltHandleToolbarResize(const QSize &newSize);
     113    /** @} */
    88114
    89115private:
    90116
    91     /* Helpers: Prepare stuff: */
    92     void preparePalette();
    93     void prepareLayout();
    94     void prepareModel();
    95     void prepareView();
    96     void prepareConnections();
    97     void load();
     117    /** @name Prepare/Cleanup cascade.
     118      * @{ */
     119        /** Prepares all. */
     120        void prepare();
     121        /** Prepares palette. */
     122        void preparePalette();
     123        /** Prepares layout. */
     124        void prepareLayout();
     125        /** Prepares model. */
     126        void prepareModel();
     127        /** Prepares view. */
     128        void prepareView();
     129        /** Prepares connections. */
     130        void prepareConnections();
     131        /** Loads settings. */
     132        void loadSettings();
    98133
    99     /* Helper: Cleanup stuff: */
    100     void save();
     134        /** Saves settings. */
     135        void saveSettings();
     136        /** Cleanups all. */
     137        void cleanup();
     138    /** @} */
    101139
    102     /** Holds the manager-widget reference. */
    103     UIVirtualBoxManagerWidget *m_pManagerWidget;
     140    /** @name General stuff.
     141      * @{ */
     142        /** Holds the manager-widget reference. */
     143        UIVirtualBoxManagerWidget *m_pManagerWidget;
    104144
    105     /* Variables: */
    106     QVBoxLayout *m_pMainLayout;
    107     UIChooserModel *m_pChooserModel;
    108     UIChooserView *m_pChooserView;
     145        /** Holds the main layout instane. */
     146        QVBoxLayout    *m_pMainLayout;
     147        /** Holds the chooser model instane. */
     148        UIChooserModel *m_pChooserModel;
     149        /** Holds the chooser view instane. */
     150        UIChooserView  *m_pChooserView;
     151    /** @} */
    109152};
    110153
    111 #endif /* __UIChooser_h__ */
    112 
     154#endif /* !___UIChooser_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r74138 r74177  
    712712}
    713713
     714void UIChooserModel::sltHandleViewResized()
     715{
     716    /* Relayout: */
     717    updateLayout();
     718}
     719
    714720void UIChooserModel::sltMachineStateChanged(QString strId, KMachineState)
    715721{
     
    778784    /* Update machine-items with passed id: */
    779785    mainRoot()->updateAllItems(strId);
    780 }
    781 
    782 void UIChooserModel::sltHandleViewResized()
    783 {
    784     /* Relayout: */
    785     updateLayout();
    786786}
    787787
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r74138 r74177  
    161161    bool isGroupSavingInProgress() const;
    162162
     163public slots:
     164
     165    /* Handler: Chooser-view stuff: */
     166    void sltHandleViewResized();
     167
    163168private slots:
    164169
     
    169174    void sltSessionStateChanged(QString strId, KSessionState state);
    170175    void sltSnapshotChanged(QString strId, QString strSnapshotId);
    171 
    172     /* Handler: Chooser-view stuff: */
    173     void sltHandleViewResized();
    174176
    175177    /* Handler: Focus-item stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.h

    r74085 r74177  
    4646    UIChooser *chooser() const { return m_pChooser; }
    4747
    48 private slots:
     48public slots:
    4949
    5050    /* Handlers: Size-hint stuff: */
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