VirtualBox

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


Ignore:
Timestamp:
Aug 20, 2018 11:41:59 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: A bit of rework for prepare/cleanup cascades for known tools.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.cpp

    r73780 r73783  
    678678void UIHostNetworkManagerWidget::prepare()
    679679{
    680     /* Prepare this: */
    681     prepareThis();
     680    /* Prepare actions: */
     681    prepareActions();
     682    /* Prepare widgets: */
     683    prepareWidgets();
    682684
    683685    /* Load settings: */
     
    689691    /* Load host networks: */
    690692    loadHostNetworks();
    691 }
    692 
    693 void UIHostNetworkManagerWidget::prepareThis()
    694 {
    695     /* Prepare actions: */
    696     prepareActions();
    697     /* Prepare widget: */
    698     prepareWidgets();
    699693}
    700694
     
    726720#endif
    727721
    728         /* Prepare toolbar: */
     722        /* Prepare toolbar, if requested: */
    729723        if (m_fShowToolbar)
    730724            prepareToolBar();
     
    746740        m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric));
    747741        m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
     742
    748743        /* Add toolbar actions: */
    749744        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Create));
     
    753748//        m_pToolBar->addSeparator();
    754749//        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Network_S_Refresh));
     750
    755751#ifdef VBOX_WS_MAC
    756752        /* Check whether we are embedded into a stack: */
  • trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.h

    r73738 r73783  
    125125        /** Prepares all. */
    126126        void prepare();
    127         /** Prepares this. */
    128         void prepareThis();
    129127        /** Prepares actions. */
    130128        void prepareActions();
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r73780 r73783  
    418418void UIVMLogViewerWidget::prepare()
    419419{
    420     /* Create main layout: */
    421     m_pMainLayout = new QVBoxLayout(this);
    422 
    423420    /* Prepare stuff: */
    424421    prepareActions();
    425     if (m_fShowToolbar)
    426         prepareToolBar();
     422    /* Prepare widgets: */
    427423    prepareWidgets();
    428424    /* Load settings: */
    429425    loadSettings();
    430426
     427    /* Apply language settings: */
     428    retranslateUi();
     429
    431430    /* Reading log files: */
    432431    sltRefresh();
    433 
    434     /* Loading language constants: */
    435     retranslateUi();
    436 
     432    /* Setup escape shortcut: */
    437433    manageEscapeShortCut();
    438434}
     
    440436void UIVMLogViewerWidget::prepareActions()
    441437{
    442     /* Configure 'Find' action: */
     438    /* Connect actions: */
    443439    connect(m_pActionPool->action(UIActionIndex_M_LogViewer_T_Find), &QAction::toggled,
    444440            this, &UIVMLogViewerWidget::sltPanelActionToggled);
    445 
    446     /* Configure 'Filter' action: */
    447441    connect(m_pActionPool->action(UIActionIndex_M_LogViewer_T_Filter), &QAction::toggled,
    448442            this, &UIVMLogViewerWidget::sltPanelActionToggled);
    449 
    450     /* Configure 'Bookmark' action: */
    451443    connect(m_pActionPool->action(UIActionIndex_M_LogViewer_T_Bookmark), &QAction::toggled,
    452444            this, &UIVMLogViewerWidget::sltPanelActionToggled);
    453 
    454     /* Configure 'Settings' action: */
    455445    connect(m_pActionPool->action(UIActionIndex_M_LogViewer_T_Settings), &QAction::toggled,
    456446            this, &UIVMLogViewerWidget::sltPanelActionToggled);
    457 
    458     /* Configure 'Refresh' action: */
    459447    connect(m_pActionPool->action(UIActionIndex_M_LogViewer_S_Refresh), &QAction::triggered,
    460448            this, &UIVMLogViewerWidget::sltRefresh);
    461 
    462     /* Configure 'Save' action: */
    463449    connect(m_pActionPool->action(UIActionIndex_M_LogViewer_S_Save), &QAction::triggered,
    464450            this, &UIVMLogViewerWidget::sltSave);
     451}
     452
     453void UIVMLogViewerWidget::prepareWidgets()
     454{
     455    /* Create main layout: */
     456    m_pMainLayout = new QVBoxLayout(this);
     457    if (m_pMainLayout)
     458    {
     459        /* Configure layout: */
     460        m_pMainLayout->setContentsMargins(0, 0, 0, 0);
     461#ifdef VBOX_WS_MAC
     462        m_pMainLayout->setSpacing(10);
     463#else
     464        m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) / 2);
     465#endif
     466
     467        /* Prepare toolbar, if requested: */
     468        if (m_fShowToolbar)
     469            prepareToolBar();
     470
     471        /* Create VM Log-Viewer container: */
     472        m_pTabWidget = new QITabWidget;
     473        if (m_pTabWidget)
     474        {
     475            /* Add into layout: */
     476            m_pMainLayout->addWidget(m_pTabWidget);
     477        }
     478
     479        /* Create VM Log-Viewer search-panel: */
     480        m_pSearchPanel = new UIVMLogViewerSearchPanel(0, this);
     481        if (m_pSearchPanel)
     482        {
     483            /* Configure panel: */
     484            installEventFilter(m_pSearchPanel);
     485            m_pSearchPanel->hide();
     486            connect(m_pSearchPanel, &UIVMLogViewerSearchPanel::sigHighlightingUpdated,
     487                    this, &UIVMLogViewerWidget::sltSearchResultHighLigting);
     488            m_panelActionMap.insert(m_pSearchPanel, m_pActionPool->action(UIActionIndex_M_LogViewer_T_Find));
     489
     490            /* Add into layout: */
     491            m_pMainLayout->addWidget(m_pSearchPanel);
     492        }
     493
     494        /* Create VM Log-Viewer filter-panel: */
     495        m_pFilterPanel = new UIVMLogViewerFilterPanel(0, this);
     496        if (m_pFilterPanel)
     497        {
     498            /* Configure panel: */
     499            installEventFilter(m_pFilterPanel);
     500            m_pFilterPanel->hide();
     501            connect(m_pFilterPanel, &UIVMLogViewerFilterPanel::sigFilterApplied,
     502                    this, &UIVMLogViewerWidget::sltFilterApplied);
     503            m_panelActionMap.insert(m_pFilterPanel, m_pActionPool->action(UIActionIndex_M_LogViewer_T_Filter));
     504
     505            /* Add into layout: */
     506            m_pMainLayout->addWidget(m_pFilterPanel);
     507        }
     508
     509        /* Create VM Log-Viewer bookmarks-panel: */
     510        m_pBookmarksPanel = new UIVMLogViewerBookmarksPanel(0, this);
     511        if (m_pBookmarksPanel)
     512        {
     513            /* Configure panel: */
     514            m_pBookmarksPanel->hide();
     515            connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteBookmark,
     516                    this, &UIVMLogViewerWidget::sltDeleteBookmark);
     517            connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteAllBookmarks,
     518                    this, &UIVMLogViewerWidget::sltDeleteAllBookmarks);
     519            connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected,
     520                    this, &UIVMLogViewerWidget::gotoBookmark);
     521            m_panelActionMap.insert(m_pBookmarksPanel, m_pActionPool->action(UIActionIndex_M_LogViewer_T_Bookmark));
     522
     523            /* Add into layout: */
     524            m_pMainLayout->addWidget(m_pBookmarksPanel);
     525        }
     526
     527        /* Create VM Log-Viewer settings-panel: */
     528        m_pSettingsPanel = new UIVMLogViewerSettingsPanel(0, this);
     529        if (m_pSettingsPanel)
     530        {
     531            /* Configure panel: */
     532            m_pSettingsPanel->hide();
     533            m_pSettingsPanel->setShowLineNumbers(m_bShowLineNumbers);
     534            m_pSettingsPanel->setWrapLines(m_bWrapLines);
     535            m_pSettingsPanel->setFontSizeInPoints(m_font.pointSize());
     536            connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigShowLineNumbers, this, &UIVMLogViewerWidget::sltShowLineNumbers);
     537            connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigWrapLines, this, &UIVMLogViewerWidget::sltWrapLines);
     538            connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigChangeFontSizeInPoints, this, &UIVMLogViewerWidget::sltFontSizeChanged);
     539            connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigChangeFont, this, &UIVMLogViewerWidget::sltChangeFont);
     540            connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigResetToDefaults, this, &UIVMLogViewerWidget::sltResetSettingsToDefault);
     541            m_panelActionMap.insert(m_pSettingsPanel, m_pActionPool->action(UIActionIndex_M_LogViewer_T_Settings));
     542
     543            /* Add into layout: */
     544            m_pMainLayout->addWidget(m_pSettingsPanel);
     545        }
     546    }
    465547}
    466548
     
    491573        {
    492574            /* Add into layout: */
    493             layout()->addWidget(m_pToolBar);
     575            m_pMainLayout->addWidget(m_pToolBar);
    494576        }
    495577#else
     
    497579        m_pMainLayout->addWidget(m_pToolBar);
    498580#endif
    499     }
    500 }
    501 
    502 void UIVMLogViewerWidget::prepareWidgets()
    503 {
    504     /* Configure layout: */
    505     layout()->setContentsMargins(0, 0, 0, 0);
    506 #ifdef VBOX_WS_MAC
    507     layout()->setSpacing(10);
    508 #else
    509     layout()->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) / 2);
    510 #endif
    511 
    512     /* Create VM Log-Viewer container: */
    513     m_pTabWidget = new QITabWidget;
    514     if (m_pTabWidget)
    515     {
    516         /* Add into layout: */
    517         m_pMainLayout->addWidget(m_pTabWidget);
    518     }
    519 
    520     /* Create VM Log-Viewer search-panel: */
    521     m_pSearchPanel = new UIVMLogViewerSearchPanel(0, this);
    522     if (m_pSearchPanel)
    523     {
    524         /* Configure VM Log-Viewer search-panel: */
    525         installEventFilter(m_pSearchPanel);
    526         m_pSearchPanel->hide();
    527         connect(m_pSearchPanel, &UIVMLogViewerSearchPanel::sigHighlightingUpdated,
    528                 this, &UIVMLogViewerWidget::sltSearchResultHighLigting);
    529         m_panelActionMap.insert(m_pSearchPanel, m_pActionPool->action(UIActionIndex_M_LogViewer_T_Find));
    530 
    531         /* Add into layout: */
    532         m_pMainLayout->addWidget(m_pSearchPanel);
    533     }
    534 
    535     /* Create VM Log-Viewer filter-panel: */
    536     m_pFilterPanel = new UIVMLogViewerFilterPanel(0, this);
    537     if (m_pFilterPanel)
    538     {
    539         /* Configure VM Log-Viewer filter-panel: */
    540         installEventFilter(m_pFilterPanel);
    541         m_pFilterPanel->hide();
    542         connect(m_pFilterPanel, &UIVMLogViewerFilterPanel::sigFilterApplied,
    543                 this, &UIVMLogViewerWidget::sltFilterApplied);
    544         m_panelActionMap.insert(m_pFilterPanel, m_pActionPool->action(UIActionIndex_M_LogViewer_T_Filter));
    545 
    546         /* Add into layout: */
    547         m_pMainLayout->addWidget(m_pFilterPanel);
    548     }
    549 
    550     m_pBookmarksPanel = new UIVMLogViewerBookmarksPanel(0, this);
    551     if (m_pBookmarksPanel)
    552     {
    553         /* Configure VM Log-Viewer bookmarks-panel: */
    554         m_pBookmarksPanel->hide();
    555         connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteBookmark,
    556                 this, &UIVMLogViewerWidget::sltDeleteBookmark);
    557         connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteAllBookmarks,
    558                 this, &UIVMLogViewerWidget::sltDeleteAllBookmarks);
    559         connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected,
    560                 this, &UIVMLogViewerWidget::gotoBookmark);
    561         m_panelActionMap.insert(m_pBookmarksPanel, m_pActionPool->action(UIActionIndex_M_LogViewer_T_Bookmark));
    562 
    563         /* Add into layout: */
    564         m_pMainLayout->addWidget(m_pBookmarksPanel);
    565     }
    566 
    567     m_pSettingsPanel = new UIVMLogViewerSettingsPanel(0, this);
    568     if (m_pSettingsPanel)
    569     {
    570         /* Configure VM Log-Viewer settings-panel: */
    571         m_pSettingsPanel->hide();
    572         m_pSettingsPanel->setShowLineNumbers(m_bShowLineNumbers);
    573         m_pSettingsPanel->setWrapLines(m_bWrapLines);
    574         m_pSettingsPanel->setFontSizeInPoints(m_font.pointSize());
    575         connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigShowLineNumbers, this, &UIVMLogViewerWidget::sltShowLineNumbers);
    576         connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigWrapLines, this, &UIVMLogViewerWidget::sltWrapLines);
    577         connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigChangeFontSizeInPoints, this, &UIVMLogViewerWidget::sltFontSizeChanged);
    578         connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigChangeFont, this, &UIVMLogViewerWidget::sltChangeFont);
    579         connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigResetToDefaults, this, &UIVMLogViewerWidget::sltResetSettingsToDefault);
    580         m_panelActionMap.insert(m_pSettingsPanel, m_pActionPool->action(UIActionIndex_M_LogViewer_T_Settings));
    581 
    582         /* Add into layout: */
    583         m_pMainLayout->addWidget(m_pSettingsPanel);
    584581    }
    585582}
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h

    r73697 r73783  
    136136        /** Prepares actions. */
    137137        void prepareActions();
     138        /** Prepares widgets. */
     139        void prepareWidgets();
    138140        /** Prepares toolbar. */
    139141        void prepareToolBar();
    140         /** Prepares widgets. */
    141         void prepareWidgets();
    142142        /** Loads settings.  */
    143143        void loadSettings();
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r73780 r73783  
    675675void UIMediumManagerWidget::prepare()
    676676{
    677     /* Prepare this: */
    678     prepareThis();
     677    /* Prepare connections: */
     678    prepareConnections();
     679    /* Prepare actions: */
     680    prepareActions();
     681    /* Prepare widgets: */
     682    prepareWidgets();
    679683
    680684    /* Load settings: */
     
    697701            sltHandleMediumEnumerationFinish();
    698702    }
    699 }
    700 
    701 void UIMediumManagerWidget::prepareThis()
    702 {
    703     /* Prepare connections: */
    704     prepareConnections();
    705     /* Prepare actions: */
    706     prepareActions();
    707     /* Prepare central-widget: */
    708     prepareWidgets();
    709703}
    710704
     
    762756#endif
    763757
    764         /* Prepare toolbar: */
     758        /* Prepare toolbar, if requested: */
    765759        if (m_fShowToolbar)
    766760            prepareToolBar();
     
    782776        m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric));
    783777        m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
     778
    784779        /* Add toolbar actions: */
    785780        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Add));
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h

    r73734 r73783  
    203203        /** Prepares all. */
    204204        void prepare();
    205         /** Prepares this. */
    206         void prepareThis();
    207205        /** Prepares connections. */
    208206        void prepareConnections();
  • trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.cpp

    r73676 r73783  
    11651165void UISnapshotPane::prepare()
    11661166{
     1167    /* Create read-write locker: */
     1168    m_pLockReadWrite = new QReadWriteLock;
     1169
     1170    /* Create pixmaps: */
     1171    m_pIconSnapshotOffline = new QIcon(UIIconPool::iconSet(":/snapshot_offline_16px.png"));
     1172    m_pIconSnapshotOnline = new QIcon(UIIconPool::iconSet(":/snapshot_online_16px.png"));
     1173
     1174    /* Create timer: */
     1175    m_pTimerUpdateAge = new QTimer;
     1176    AssertPtrReturnVoid(m_pTimerUpdateAge);
     1177    {
     1178        /* Configure timer: */
     1179        m_pTimerUpdateAge->setSingleShot(true);
     1180        connect(m_pTimerUpdateAge, &QTimer::timeout, this, &UISnapshotPane::sltUpdateSnapshotsAge);
     1181    }
     1182
     1183    /* Prepare connections: */
     1184    prepareConnections();
     1185    /* Prepare actions: */
     1186    prepareActions();
     1187    /* Prepare widgets: */
     1188    prepareWidgets();
     1189
     1190    /* Load settings: */
     1191    loadSettings();
     1192
     1193    /* Apply language settings: */
     1194    retranslateUi();
     1195}
     1196
     1197void UISnapshotPane::prepareConnections()
     1198{
    11671199    /* Configure Main event connections: */
    11681200    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineDataChange,
     
    11801212    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotRestore,
    11811213            this, &UISnapshotPane::sltHandleSnapshotRestore);
    1182 
    1183     /* Create read-write locker: */
    1184     m_pLockReadWrite = new QReadWriteLock;
    1185 
    1186     /* Create pixmaps: */
    1187     m_pIconSnapshotOffline = new QIcon(UIIconPool::iconSet(":/snapshot_offline_16px.png"));
    1188     m_pIconSnapshotOnline = new QIcon(UIIconPool::iconSet(":/snapshot_online_16px.png"));
    1189 
    1190     /* Create timer: */
    1191     m_pTimerUpdateAge = new QTimer;
    1192     AssertPtrReturnVoid(m_pTimerUpdateAge);
    1193     {
    1194         /* Configure timer: */
    1195         m_pTimerUpdateAge->setSingleShot(true);
    1196         connect(m_pTimerUpdateAge, &QTimer::timeout, this, &UISnapshotPane::sltUpdateSnapshotsAge);
    1197     }
    1198 
    1199     /* Prepare widgets: */
    1200     prepareWidgets();
    1201 
    1202     /* Load settings: */
    1203     loadSettings();
    1204 
    1205     /* Apply language settings: */
    1206     retranslateUi();
     1214}
     1215
     1216void UISnapshotPane::prepareActions()
     1217{
     1218    /* Connect actions: */
     1219    connect(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Take), &UIAction::triggered,
     1220            this, &UISnapshotPane::sltTakeSnapshot);
     1221    connect(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Delete), &UIAction::triggered,
     1222            this, &UISnapshotPane::sltDeleteSnapshot);
     1223    connect(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Restore), &UIAction::triggered,
     1224            this, &UISnapshotPane::sltRestoreSnapshot);
     1225    connect(m_pActionPool->action(UIActionIndexST_M_Snapshot_T_Properties), &UIAction::toggled,
     1226            this, &UISnapshotPane::sltToggleSnapshotDetailsVisibility);
     1227    connect(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Clone), &UIAction::triggered,
     1228            this, &UISnapshotPane::sltCloneSnapshot);
    12071229}
    12081230
     
    12421264        m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    12431265
    1244         /* Add Take Snapshot action: */
     1266        /* Add toolbar actions: */
    12451267        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Take));
    1246         connect(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Take), &UIAction::triggered,
    1247                 this, &UISnapshotPane::sltTakeSnapshot);
    1248 
    1249         /* Add Delete Snapshot action: */
    12501268        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Delete));
    1251         connect(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Delete), &UIAction::triggered,
    1252                 this, &UISnapshotPane::sltDeleteSnapshot);
    1253 
    12541269        m_pToolBar->addSeparator();
    1255 
    1256         /* Add Restore Snapshot action: */
    12571270        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Restore));
    1258         connect(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Restore), &UIAction::triggered,
    1259                 this, &UISnapshotPane::sltRestoreSnapshot);
    1260 
    1261         /* Add Show Snapshot Details action: */
    12621271        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Snapshot_T_Properties));
    1263         connect(m_pActionPool->action(UIActionIndexST_M_Snapshot_T_Properties), &UIAction::toggled,
    1264                 this, &UISnapshotPane::sltToggleSnapshotDetailsVisibility);
    1265 
    12661272        m_pToolBar->addSeparator();
    1267 
    1268         /* Add Clone Snapshot action: */
    12691273        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Clone));
    1270         connect(m_pActionPool->action(UIActionIndexST_M_Snapshot_S_Clone), &UIAction::triggered,
    1271                 this, &UISnapshotPane::sltCloneSnapshot);
    12721274
    12731275        /* Add into layout: */
  • trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.h

    r73676 r73783  
    144144        /** Prepares all. */
    145145        void prepare();
     146        /** Prepares connections. */
     147        void prepareConnections();
     148        /** Prepares actions. */
     149        void prepareActions();
    146150        /** Prepares widgets. */
    147151        void prepareWidgets();
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