VirtualBox

Changeset 88508 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 14, 2021 2:00:09 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8161: A bit of refactoring for Tools pane; Mostly proper prepare/cleanup cascade; This is necessary for shutdown procedure.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UITools.cpp

    r88122 r88508  
    55
    66/*
    7  * Copyright (C) 2012-2020 Oracle Corporation
     7 * Copyright (C) 2012-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020
    2121/* GUI includes: */
     22#include "UICommon.h"
    2223#include "UITools.h"
    2324#include "UIToolsModel.h"
    2425#include "UIToolsView.h"
    2526#include "UIVirtualBoxManagerWidget.h"
    26 #include "UICommon.h"
    2727
    2828
    29 UITools::UITools(UIVirtualBoxManagerWidget *pParent)
     29UITools::UITools(UIVirtualBoxManagerWidget *pParent /* = 0 */)
    3030    : QWidget(pParent, Qt::Popup)
    3131    , m_pManagerWidget(pParent)
     
    3434    , m_pToolsView(0)
    3535{
    36     /* Prepare: */
    3736    prepare();
    38 }
    39 
    40 UITools::~UITools()
    41 {
    42     /* Cleanup: */
    43     cleanup();
    4437}
    4538
     
    10699void UITools::prepare()
    107100{
    108     /* Prepare palette: */
     101    /* Prepare everything: */
    109102    preparePalette();
    110     /* Prepare layout: */
    111     prepareLayout();
    112     /* Prepare model: */
    113     prepareModel();
    114     /* Prepare view: */
    115     prepareView();
    116     /* Prepare connections: */
     103    prepareContents();
    117104    prepareConnections();
    118105
    119     /* Load settings: */
    120     loadSettings();
     106    /* Init model finally: */
     107    initModel();
    121108}
    122109
    123110void UITools::preparePalette()
    124111{
    125     /* Setup palette: */
    126112    setAutoFillBackground(true);
    127113    QPalette pal = palette();
     
    131117}
    132118
    133 void UITools::prepareLayout()
     119void UITools::prepareContents()
    134120{
    135121    /* Setup own layout rules: */
    136122    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
    137123
    138     /* Create main-layout: */
     124    /* Prepare main-layout: */
    139125    m_pMainLayout = new QVBoxLayout(this);
    140126    if (m_pMainLayout)
    141127    {
    142         /* Configure main-layout: */
    143128        m_pMainLayout->setContentsMargins(1, 1, 1, 1);
    144129        m_pMainLayout->setSpacing(0);
     130
     131        /* Prepare model: */
     132        prepareModel();
    145133    }
    146134}
     
    148136void UITools::prepareModel()
    149137{
    150     /* Create Tools-model: */
     138    /* Prepare model: */
    151139    m_pToolsModel = new UIToolsModel(this);
     140    if (m_pToolsModel)
     141        prepareView();
    152142}
    153143
    154144void UITools::prepareView()
    155145{
    156     /* Setup Tools-view: */
     146    AssertPtrReturnVoid(m_pToolsModel);
     147    AssertPtrReturnVoid(m_pMainLayout);
     148
     149    /* Prepare view: */
    157150    m_pToolsView = new UIToolsView(this);
    158151    if (m_pToolsView)
    159152    {
    160         /* Configure Tools-view. */
    161153        m_pToolsView->setScene(m_pToolsModel->scene());
    162154        m_pToolsView->show();
     
    170162void UITools::prepareConnections()
    171163{
    172     /* Setup Tools-model connections: */
     164    /* Model connections: */
    173165    connect(m_pToolsModel, &UIToolsModel::sigItemMinimumWidthHintChanged,
    174166            m_pToolsView, &UIToolsView::sltMinimumWidthHintChanged);
     
    178170            m_pToolsView, &UIToolsView::sltFocusChanged);
    179171
    180     /* Setup Tools-view connections: */
     172    /* View connections: */
    181173    connect(m_pToolsView, &UIToolsView::sigResized,
    182174            m_pToolsModel, &UIToolsModel::sltHandleViewResized);
    183175}
    184176
    185 void UITools::loadSettings()
     177void UITools::initModel()
    186178{
    187     /* Init model: */
    188179    m_pToolsModel->init();
    189180}
    190 
    191 void UITools::saveSettings()
    192 {
    193     /* Deinit model: */
    194     m_pToolsModel->deinit();
    195 }
    196 
    197 void UITools::cleanup()
    198 {
    199     /* Save settings: */
    200     saveSettings();
    201 }
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UITools.h

    r88122 r88508  
    55
    66/*
    7  * Copyright (C) 2012-2020 Oracle Corporation
     7 * Copyright (C) 2012-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5757
    5858    /** Constructs Tools-pane passing @a pParent to the base-class. */
    59     UITools(UIVirtualBoxManagerWidget *pParent);
    60     /** Destructs Tools-pane. */
    61     virtual ~UITools() /* override */;
     59    UITools(UIVirtualBoxManagerWidget *pParent = 0);
    6260
    6361    /** @name General stuff.
     
    114112        /** Prepares palette. */
    115113        void preparePalette();
    116         /** Prepares layout. */
    117         void prepareLayout();
     114        /** Prepares contents. */
     115        void prepareContents();
    118116        /** Prepares model. */
    119117        void prepareModel();
     
    122120        /** Prepares connections. */
    123121        void prepareConnections();
    124         /** Loads settings. */
    125         void loadSettings();
    126 
    127         /** Saves settings. */
    128         void saveSettings();
    129         /** Cleanups all. */
    130         void cleanup();
     122        /** Inits model. */
     123        void initModel();
    131124    /** @} */
    132125
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.cpp

    r88252 r88508  
    8484}
    8585
    86 void UIToolsModel::deinit()
    87 {
    88     /* Save last selected item: */
    89     saveLastSelectedItems();
    90 }
    91 
    9286UITools *UIToolsModel::tools() const
    9387{
     
    629623void UIToolsModel::cleanup()
    630624{
     625    /* Save last selected item: */
     626    saveLastSelectedItems();
    631627    /* Cleanup connections: */
    632628    cleanupConnections();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.h

    r88122 r88508  
    8686        /** Inits model. */
    8787        void init();
    88         /** Deinits model. */
    89         void deinit();
    9088
    9189        /** Returns the Tools reference. */
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