VirtualBox

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


Ignore:
Timestamp:
Dec 11, 2024 5:06:46 PM (5 weeks ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10814: Cleanup for UIToolPaneMachine.

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

Legend:

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

    r106061 r107293  
    3232# include <QStyle>
    3333#endif
    34 #include <QUuid>
    3534
    3635/* GUI includes */
    37 #include "UIActionPoolManager.h"
    3836#include "UICommon.h"
    3937#include "UIDetails.h"
     
    4139#include "UIFileManager.h"
    4240#include "UIGlobalSession.h"
    43 #include "UIIconPool.h"
    4441#include "UISnapshotPane.h"
    4542#include "UIToolPaneMachine.h"
     
    4744#include "UIVMActivityToolWidget.h"
    4845#include "UIVMLogViewerWidget.h"
    49 
    5046
    5147/* Other VBox includes: */
     
    6561    , m_fActive(false)
    6662{
    67     /* Prepare: */
    6863    prepare();
    6964}
     
    7166UIToolPaneMachine::~UIToolPaneMachine()
    7267{
    73     /* Cleanup: */
    7468    cleanup();
    7569}
     
    9690bool UIToolPaneMachine::isToolOpened(UIToolType enmType) const
    9791{
    98     /* Search through the stacked widgets: */
    9992    for (int iIndex = 0; iIndex < m_pLayout->count(); ++iIndex)
    10093        if (m_pLayout->widget(iIndex)->property("ToolType").value<UIToolType>() == enmType)
     
    127120                /* Create Error pane: */
    128121                m_pPaneError = new UIErrorPane;
    129                 if (m_pPaneError)
    130                 {
     122                AssertPtrReturnVoid(m_pPaneError);
     123                {
     124                    /* Configure pane: */
     125                    m_pPaneError->setProperty("ToolType", QVariant::fromValue(UIToolType_Error));
    131126#ifndef VBOX_WS_MAC
    132127                    const int iMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 4;
    133128                    m_pPaneError->setContentsMargins(iMargin, 0, iMargin, 0);
    134129#endif
    135 
    136                     /* Configure pane: */
    137                     m_pPaneError->setProperty("ToolType", QVariant::fromValue(UIToolType_Error));
    138130
    139131                    /* Add into layout: */
     
    168160                AssertPtrReturnVoid(m_pPaneSnapshots);
    169161                {
    170 #ifndef VBOX_WS_MAC
    171                     const int iMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 4;
    172                     m_pPaneSnapshots->setContentsMargins(iMargin, 0, iMargin, 0);
    173 #endif
    174 
    175162                    /* Configure pane: */
    176163                    m_pPaneSnapshots->setProperty("ToolType", QVariant::fromValue(UIToolType_Snapshots));
     
    178165                            this, &UIToolPaneMachine::sigCurrentSnapshotItemChange);
    179166                    m_pPaneSnapshots->setMachineItems(m_items);
     167#ifndef VBOX_WS_MAC
     168                    const int iMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 4;
     169                    m_pPaneSnapshots->setContentsMargins(iMargin, 0, iMargin, 0);
     170#endif
    180171
    181172                    /* Add into layout: */
     
    187178            case UIToolType_Logs:
    188179            {
    189                 /* Create the Logviewer pane: */
     180                /* Create Logviewer pane: */
    190181                m_pPaneLogViewer = new UIVMLogViewerWidget(EmbedTo_Stack, m_pActionPool, false /* show toolbar */);
    191182                AssertPtrReturnVoid(m_pPaneLogViewer);
    192183                {
    193 #ifndef VBOX_WS_MAC
    194                     const int iMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 4;
    195                     m_pPaneLogViewer->setContentsMargins(iMargin, 0, iMargin, 0);
    196 #endif
    197 
    198184                    /* Configure pane: */
    199185                    m_pPaneLogViewer->setProperty("ToolType", QVariant::fromValue(UIToolType_Logs));
     
    201187                            this, &UIToolPaneMachine::sltDetachToolPane);
    202188                    m_pPaneLogViewer->setSelectedVMListItems(m_items);
     189#ifndef VBOX_WS_MAC
     190                    const int iMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 4;
     191                    m_pPaneLogViewer->setContentsMargins(iMargin, 0, iMargin, 0);
     192#endif
    203193
    204194                    /* Add into layout: */
     
    210200            case UIToolType_VMActivity:
    211201            {
     202                /* Create Activity pane: */
    212203                m_pPaneVMActivityMonitor = new UIVMActivityToolWidget(EmbedTo_Stack, m_pActionPool,
    213204                                                                      false /* Show toolbar */, 0 /* Parent */);
    214205                AssertPtrReturnVoid(m_pPaneVMActivityMonitor);
    215 #ifndef VBOX_WS_MAC
    216                 const int iMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 4;
    217                 m_pPaneVMActivityMonitor->setContentsMargins(iMargin, 0, iMargin, 0);
    218 #endif
    219 
    220                 /* Configure pane: */
    221                 m_pPaneVMActivityMonitor->setProperty("ToolType", QVariant::fromValue(UIToolType_VMActivity));
    222                 m_pPaneVMActivityMonitor->setSelectedVMListItems(m_items);
    223                 /* Add into layout: */
    224                 m_pLayout->addWidget(m_pPaneVMActivityMonitor);
    225                 m_pLayout->setCurrentWidget(m_pPaneVMActivityMonitor);
    226 
    227                 connect(m_pPaneVMActivityMonitor, &UIVMActivityToolWidget::sigSwitchToActivityOverviewPane,
    228                         this, &UIToolPaneMachine::sigSwitchToActivityOverviewPane);
     206                {
     207                    /* Configure pane: */
     208                    m_pPaneVMActivityMonitor->setProperty("ToolType", QVariant::fromValue(UIToolType_VMActivity));
     209                    m_pPaneVMActivityMonitor->setSelectedVMListItems(m_items);
     210                    connect(m_pPaneVMActivityMonitor, &UIVMActivityToolWidget::sigSwitchToActivityOverviewPane,
     211                            this, &UIToolPaneMachine::sigSwitchToActivityOverviewPane);
     212#ifndef VBOX_WS_MAC
     213                    const int iMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 4;
     214                    m_pPaneVMActivityMonitor->setContentsMargins(iMargin, 0, iMargin, 0);
     215#endif
     216
     217                    /* Add into layout: */
     218                    m_pLayout->addWidget(m_pPaneVMActivityMonitor);
     219                    m_pLayout->setCurrentWidget(m_pPaneVMActivityMonitor);
     220                }
    229221                break;
    230222            }
    231223            case UIToolType_FileManager:
    232224            {
     225                /* Create File Manager pane: */
    233226                if (!m_items.isEmpty())
    234227                    m_pPaneFileManager = new UIFileManager(EmbedTo_Stack, m_pActionPool,
     
    239232                                                           0, false /* fShowToolbar */);
    240233                AssertPtrReturnVoid(m_pPaneFileManager);
    241 #ifndef VBOX_WS_MAC
    242                 const int iMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 4;
    243                 m_pPaneFileManager->setContentsMargins(iMargin, 0, iMargin, 0);
    244 #endif
    245                 /* Configure pane: */
    246                 m_pPaneFileManager->setProperty("ToolType", QVariant::fromValue(UIToolType_FileManager));
    247                 m_pPaneFileManager->setSelectedVMListItems(m_items);
    248                 /* Add into layout: */
    249                 m_pLayout->addWidget(m_pPaneFileManager);
    250                 m_pLayout->setCurrentWidget(m_pPaneFileManager);
     234                {
     235                    /* Configure pane: */
     236                    m_pPaneFileManager->setProperty("ToolType", QVariant::fromValue(UIToolType_FileManager));
     237                    m_pPaneFileManager->setSelectedVMListItems(m_items);
     238#ifndef VBOX_WS_MAC
     239                    const int iMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 4;
     240                    m_pPaneFileManager->setContentsMargins(iMargin, 0, iMargin, 0);
     241#endif
     242
     243                    /* Add into layout: */
     244                    m_pLayout->addWidget(m_pPaneFileManager);
     245                    m_pLayout->setCurrentWidget(m_pPaneFileManager);
     246                }
    251247                break;
    252248            }
     
    279275            case UIToolType_Logs:        m_pPaneLogViewer = 0; break;
    280276            case UIToolType_VMActivity:  m_pPaneVMActivityMonitor = 0; break;
     277            case UIToolType_FileManager: m_pPaneFileManager = 0; break;
    281278            default: break;
    282279        }
     
    291288}
    292289
     290QString UIToolPaneMachine::currentHelpKeyword() const
     291{
     292    QWidget *pCurrentToolWidget = 0;
     293    switch (currentTool())
     294    {
     295        case UIToolType_Error:
     296            pCurrentToolWidget = m_pPaneError;
     297            break;
     298        case UIToolType_Details:
     299            pCurrentToolWidget = m_pPaneDetails;
     300            break;
     301        case UIToolType_Snapshots:
     302            pCurrentToolWidget = m_pPaneSnapshots;
     303            break;
     304        case UIToolType_Logs:
     305            pCurrentToolWidget = m_pPaneLogViewer;
     306            break;
     307        case UIToolType_VMActivity:
     308            pCurrentToolWidget = m_pPaneVMActivityMonitor;
     309            break;
     310        case UIToolType_FileManager:
     311            pCurrentToolWidget = m_pPaneFileManager;
     312            break;
     313        default:
     314            break;
     315    }
     316    return uiCommon().helpKeyword(pCurrentToolWidget);
     317}
     318
    293319void UIToolPaneMachine::setErrorDetails(const QString &strDetails)
    294320{
     
    344370{
    345371    return m_pPaneSnapshots ? m_pPaneSnapshots->currentSnapshotId() : QUuid();
    346 }
    347 
    348 QString UIToolPaneMachine::currentHelpKeyword() const
    349 {
    350     QWidget *pCurrentToolWidget = 0;
    351     switch (currentTool())
    352     {
    353         case UIToolType_Error:
    354             pCurrentToolWidget = m_pPaneError;
    355             break;
    356         case UIToolType_Details:
    357             pCurrentToolWidget = m_pPaneDetails;
    358             break;
    359         case UIToolType_Snapshots:
    360             pCurrentToolWidget = m_pPaneSnapshots;
    361             break;
    362         case UIToolType_Logs:
    363             pCurrentToolWidget = m_pPaneLogViewer;
    364             break;
    365         case UIToolType_VMActivity:
    366             pCurrentToolWidget = m_pPaneVMActivityMonitor;
    367             break;
    368         case UIToolType_FileManager:
    369             pCurrentToolWidget = m_pPaneFileManager;
    370             break;
    371         default:
    372             break;
    373     }
    374     return uiCommon().helpKeyword(pCurrentToolWidget);
    375 }
    376 
    377 void UIToolPaneMachine::prepare()
    378 {
    379     /* Create stacked-layout: */
    380     m_pLayout = new QStackedLayout(this);
    381 
    382     /* Create Details pane: */
    383     openTool(UIToolType_Details);
    384 }
    385 
    386 void UIToolPaneMachine::cleanup()
    387 {
    388     /* Remove all widgets prematurelly: */
    389     while (m_pLayout->count())
    390     {
    391         QWidget *pWidget = m_pLayout->widget(0);
    392         m_pLayout->removeWidget(pWidget);
    393         delete pWidget;
    394     }
    395 }
    396 
    397 void UIToolPaneMachine::handleTokenChange()
    398 {
    399     // printf("UIToolPaneMachine::handleTokenChange: Active = %d, current tool = %d\n", m_fActive, currentTool());
    400372}
    401373
     
    406378    if (sender() == m_pPaneLogViewer)
    407379        enmToolType = UIToolType_Logs;
    408 
    409380    if (enmToolType != UIToolType_Invalid)
    410381        emit sigDetachToolPane(enmToolType);
    411382}
     383
     384void UIToolPaneMachine::prepare()
     385{
     386    /* Create stacked-layout: */
     387    m_pLayout = new QStackedLayout(this);
     388
     389    /* Create Details pane: */
     390    openTool(UIToolType_Details);
     391}
     392
     393void UIToolPaneMachine::cleanup()
     394{
     395    /* Remove all widgets prematurelly: */
     396    while (m_pLayout->count())
     397    {
     398        QWidget *pWidget = m_pLayout->widget(0);
     399        m_pLayout->removeWidget(pWidget);
     400        delete pWidget;
     401    }
     402}
     403
     404void UIToolPaneMachine::handleTokenChange()
     405{
     406    // printf("UIToolPaneMachine::handleTokenChange: Active = %d, current tool = %d\n", m_fActive, currentTool());
     407}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolPaneMachine.h

    r106061 r107293  
    3939#include "UIExtraDataDefs.h"
    4040
    41 /* COM includes: */
    42 #include "CMachine.h"
    43 
    4441/* Forward declarations: */
    45 class QHBoxLayout;
    4642class QStackedLayout;
    47 class QVBoxLayout;
    4843class UIActionPool;
    4944class UIDetails;
     
    5550class UIFileManager;
    5651
    57 /** QWidget subclass representing container for tool panes. */
     52/** QWidget subclass representing container for Machine tool panes. */
    5853class UIToolPaneMachine : public QWidget
    5954{
     
    9994    void closeTool(UIToolType enmType);
    10095
     96    /** Returns the help keyword of the current tool's widget. */
     97    QString currentHelpKeyword() const;
     98
    10199    /** Defines error @a strDetails and switches to Error pane. */
    102100    void setErrorDetails(const QString &strDetails);
     
    110108    /** Returns currently selected snapshot ID if any. */
    111109    QUuid currentSnapshotId();
    112 
    113     /** Returns the help keyword of the current tool's widget. */
    114     QString currentHelpKeyword() const;
    115110
    116111private slots:
     
    135130
    136131    /** Holds the stacked-layout instance. */
    137     QStackedLayout      *m_pLayout;
     132    QStackedLayout         *m_pLayout;
    138133    /** Holds the Error pane instance. */
    139     UIErrorPane         *m_pPaneError;
     134    UIErrorPane            *m_pPaneError;
    140135    /** Holds the Details pane instance. */
    141     UIDetails           *m_pPaneDetails;
     136    UIDetails              *m_pPaneDetails;
    142137    /** Holds the Snapshots pane instance. */
    143     UISnapshotPane      *m_pPaneSnapshots;
     138    UISnapshotPane         *m_pPaneSnapshots;
    144139    /** Holds the Logviewer pane instance. */
    145     UIVMLogViewerWidget *m_pPaneLogViewer;
     140    UIVMLogViewerWidget    *m_pPaneLogViewer;
    146141    /** Holds the Performance Monitor pane instance. */
    147142    UIVMActivityToolWidget *m_pPaneVMActivityMonitor;
    148143    /** Holds the File Manager pane instance. */
    149     UIFileManager *m_pPaneFileManager;
     144    UIFileManager          *m_pPaneFileManager;
    150145
    151146    /** Holds whether this pane is active. */
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