VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp@ 103977

Last change on this file since 103977 was 103793, checked in by vboxsync, 9 months ago

FE/Qt: UICommon: Move versioning related functionality to UIVersion / UIVersionInfo; Rework user cases accordingly.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 48.2 KB
Line 
1/* $Id: UIVirtualBoxManagerWidget.cpp 103793 2024-03-11 19:17:31Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIVirtualBoxManagerWidget class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QHBoxLayout>
30#include <QStackedWidget>
31#include <QStyle>
32#include <QTimer>
33#include <QToolButton>
34#include <QVBoxLayout>
35
36/* GUI includes: */
37#include "QISplitter.h"
38#include "UIActionPoolManager.h"
39#include "UIDesktopWidgetWatchdog.h"
40#include "UIExtraDataManager.h"
41#include "UIChooser.h"
42#include "UICommon.h"
43#include "UIGlobalSession.h"
44#include "UILoggingDefs.h"
45#include "UIMessageCenter.h"
46#include "UINotificationCenter.h"
47#include "UIVirtualBoxManager.h"
48#include "UIVirtualBoxManagerWidget.h"
49#include "UITabBar.h"
50#include "QIToolBar.h"
51#include "UIVirtualBoxEventHandler.h"
52#include "UIVirtualMachineItemCloud.h"
53#include "UIVirtualMachineItemLocal.h"
54#include "UITools.h"
55#ifdef VBOX_WS_MAC
56# include "UIIconPool.h"
57# include "UIVersion.h"
58#endif
59#ifndef VBOX_WS_MAC
60# include "UIMenuBar.h"
61#endif
62
63
64UIVirtualBoxManagerWidget::UIVirtualBoxManagerWidget(UIVirtualBoxManager *pParent)
65 : m_pActionPool(pParent->actionPool())
66 , m_pSplitter(0)
67 , m_pToolBar(0)
68 , m_pPaneChooser(0)
69 , m_pStackedWidget(0)
70 , m_pPaneToolsGlobal(0)
71 , m_pPaneToolsMachine(0)
72 , m_pSlidingAnimation(0)
73 , m_pMenuToolsGlobal(0)
74 , m_pMenuToolsMachine(0)
75 , m_enmSelectionType(SelectionType_Invalid)
76 , m_fSelectedMachineItemAccessible(false)
77 , m_pSplitterSettingsSaveTimer(0)
78{
79 prepare();
80}
81
82UIVirtualBoxManagerWidget::~UIVirtualBoxManagerWidget()
83{
84 cleanup();
85}
86
87UIVirtualMachineItem *UIVirtualBoxManagerWidget::currentItem() const
88{
89 return m_pPaneChooser->currentItem();
90}
91
92QList<UIVirtualMachineItem*> UIVirtualBoxManagerWidget::currentItems() const
93{
94 return m_pPaneChooser->currentItems();
95}
96
97bool UIVirtualBoxManagerWidget::isGroupItemSelected() const
98{
99 return m_pPaneChooser->isGroupItemSelected();
100}
101
102bool UIVirtualBoxManagerWidget::isGlobalItemSelected() const
103{
104 return m_pPaneChooser->isGlobalItemSelected();
105}
106
107bool UIVirtualBoxManagerWidget::isMachineItemSelected() const
108{
109 return m_pPaneChooser->isMachineItemSelected();
110}
111
112bool UIVirtualBoxManagerWidget::isLocalMachineItemSelected() const
113{
114 return m_pPaneChooser->isLocalMachineItemSelected();
115}
116
117bool UIVirtualBoxManagerWidget::isCloudMachineItemSelected() const
118{
119 return m_pPaneChooser->isCloudMachineItemSelected();
120}
121
122bool UIVirtualBoxManagerWidget::isSingleGroupSelected() const
123{
124 return m_pPaneChooser->isSingleGroupSelected();
125}
126
127bool UIVirtualBoxManagerWidget::isSingleLocalGroupSelected() const
128{
129 return m_pPaneChooser->isSingleLocalGroupSelected();
130}
131
132bool UIVirtualBoxManagerWidget::isSingleCloudProviderGroupSelected() const
133{
134 return m_pPaneChooser->isSingleCloudProviderGroupSelected();
135}
136
137bool UIVirtualBoxManagerWidget::isSingleCloudProfileGroupSelected() const
138{
139 return m_pPaneChooser->isSingleCloudProfileGroupSelected();
140}
141
142bool UIVirtualBoxManagerWidget::isAllItemsOfOneGroupSelected() const
143{
144 return m_pPaneChooser->isAllItemsOfOneGroupSelected();
145}
146
147QString UIVirtualBoxManagerWidget::fullGroupName() const
148{
149 return m_pPaneChooser->fullGroupName();
150}
151
152bool UIVirtualBoxManagerWidget::isGroupSavingInProgress() const
153{
154 return m_pPaneChooser->isGroupSavingInProgress();
155}
156
157bool UIVirtualBoxManagerWidget::isCloudProfileUpdateInProgress() const
158{
159 return m_pPaneChooser->isCloudProfileUpdateInProgress();
160}
161
162void UIVirtualBoxManagerWidget::switchToGlobalItem()
163{
164 AssertPtrReturnVoid(m_pPaneChooser);
165 m_pPaneChooser->setCurrentGlobal();
166}
167
168void UIVirtualBoxManagerWidget::openGroupNameEditor()
169{
170 m_pPaneChooser->openGroupNameEditor();
171}
172
173void UIVirtualBoxManagerWidget::disbandGroup()
174{
175 m_pPaneChooser->disbandGroup();
176}
177
178void UIVirtualBoxManagerWidget::removeMachine()
179{
180 m_pPaneChooser->removeMachine();
181}
182
183void UIVirtualBoxManagerWidget::moveMachineToGroup(const QString &strName /* = QString() */)
184{
185 m_pPaneChooser->moveMachineToGroup(strName);
186}
187
188QStringList UIVirtualBoxManagerWidget::possibleGroupsForMachineToMove(const QUuid &uId)
189{
190 return m_pPaneChooser->possibleGroupsForMachineToMove(uId);
191}
192
193QStringList UIVirtualBoxManagerWidget::possibleGroupsForGroupToMove(const QString &strFullName)
194{
195 return m_pPaneChooser->possibleGroupsForGroupToMove(strFullName);
196}
197
198void UIVirtualBoxManagerWidget::refreshMachine()
199{
200 m_pPaneChooser->refreshMachine();
201}
202
203void UIVirtualBoxManagerWidget::sortGroup()
204{
205 m_pPaneChooser->sortGroup();
206}
207
208void UIVirtualBoxManagerWidget::setMachineSearchWidgetVisibility(bool fVisible)
209{
210 m_pPaneChooser->setMachineSearchWidgetVisibility(fVisible);
211}
212
213void UIVirtualBoxManagerWidget::setToolsTypeGlobal(UIToolType enmType)
214{
215 m_pMenuToolsGlobal->setToolsType(enmType);
216}
217
218UIToolType UIVirtualBoxManagerWidget::toolsTypeGlobal() const
219{
220 return m_pMenuToolsGlobal ? m_pMenuToolsGlobal->toolsType() : UIToolType_Invalid;
221}
222
223void UIVirtualBoxManagerWidget::setToolsTypeMachine(UIToolType enmType)
224{
225 m_pMenuToolsMachine->setToolsType(enmType);
226}
227
228UIToolType UIVirtualBoxManagerWidget::toolsTypeMachine() const
229{
230 return m_pMenuToolsMachine ? m_pMenuToolsMachine->toolsType() : UIToolType_Invalid;
231}
232
233UIToolType UIVirtualBoxManagerWidget::currentGlobalTool() const
234{
235 return m_pPaneToolsGlobal ? m_pPaneToolsGlobal->currentTool() : UIToolType_Invalid;
236}
237
238UIToolType UIVirtualBoxManagerWidget::currentMachineTool() const
239{
240 return m_pPaneToolsMachine ? m_pPaneToolsMachine->currentTool() : UIToolType_Invalid;
241}
242
243bool UIVirtualBoxManagerWidget::isGlobalToolOpened(UIToolType enmType) const
244{
245 return m_pPaneToolsGlobal ? m_pPaneToolsGlobal->isToolOpened(enmType) : false;
246}
247
248bool UIVirtualBoxManagerWidget::isMachineToolOpened(UIToolType enmType) const
249{
250 return m_pPaneToolsMachine ? m_pPaneToolsMachine->isToolOpened(enmType) : false;
251}
252
253void UIVirtualBoxManagerWidget::switchGlobalToolTo(UIToolType enmType)
254{
255 /* Open corresponding tool: */
256 m_pPaneToolsGlobal->openTool(enmType);
257
258 /* Let the parent know: */
259 emit sigToolTypeChangeGlobal();
260
261 /* Update toolbar: */
262 updateToolbar();
263
264 /* Handle current tool type change: */
265 handleCurrentToolTypeChange(enmType);
266}
267
268void UIVirtualBoxManagerWidget::switchMachineToolTo(UIToolType enmType)
269{
270 /* Open corresponding tool: */
271 m_pPaneToolsMachine->openTool(enmType);
272
273 /* Let the parent know: */
274 emit sigToolTypeChangeMachine();
275
276 /* Update toolbar: */
277 updateToolbar();
278
279 /* Handle current tool type change: */
280 handleCurrentToolTypeChange(enmType);
281}
282
283void UIVirtualBoxManagerWidget::closeGlobalTool(UIToolType enmType)
284{
285 m_pPaneToolsGlobal->closeTool(enmType);
286}
287
288void UIVirtualBoxManagerWidget::closeMachineTool(UIToolType enmType)
289{
290 m_pPaneToolsMachine->closeTool(enmType);
291}
292
293bool UIVirtualBoxManagerWidget::isCurrentStateItemSelected() const
294{
295 return m_pPaneToolsMachine->isCurrentStateItemSelected();
296}
297
298QUuid UIVirtualBoxManagerWidget::currentSnapshotId()
299{
300 return m_pPaneToolsMachine->currentSnapshotId();
301}
302
303void UIVirtualBoxManagerWidget::updateToolBarMenuButtons(bool fSeparateMenuSection)
304{
305 QToolButton *pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)));
306 if (pButton)
307 pButton->setPopupMode(fSeparateMenuSection ? QToolButton::MenuButtonPopup : QToolButton::DelayedPopup);
308}
309
310QString UIVirtualBoxManagerWidget::currentHelpKeyword() const
311{
312 QString strHelpKeyword;
313 if (isGlobalItemSelected())
314 strHelpKeyword = m_pPaneToolsGlobal->currentHelpKeyword();
315 else if (isMachineItemSelected())
316 strHelpKeyword = m_pPaneToolsMachine->currentHelpKeyword();
317 return strHelpKeyword;
318}
319
320void UIVirtualBoxManagerWidget::sltHandleToolBarContextMenuRequest(const QPoint &position)
321{
322 /* Populate toolbar actions: */
323 QList<QAction*> actions;
324 /* Add 'Show Toolbar Text' action: */
325 QAction *pShowToolBarText = new QAction(UIVirtualBoxManager::tr("Show Toolbar Text"), 0);
326 if (pShowToolBarText)
327 {
328 pShowToolBarText->setCheckable(true);
329 pShowToolBarText->setChecked(m_pToolBar->toolButtonStyle() == Qt::ToolButtonTextUnderIcon);
330 actions << pShowToolBarText;
331 }
332
333 /* Prepare the menu position: */
334 QPoint globalPosition = position;
335 QWidget *pSender = qobject_cast<QWidget*>(sender());
336 if (pSender)
337 globalPosition = pSender->mapToGlobal(position);
338
339 /* Execute the menu: */
340 QAction *pResult = QMenu::exec(actions, globalPosition);
341
342 /* Handle the menu execution result: */
343 if (pResult == pShowToolBarText)
344 {
345 m_pToolBar->setUseTextLabels(pResult->isChecked());
346 gEDataManager->setSelectorWindowToolBarTextVisible(pResult->isChecked());
347 }
348}
349
350void UIVirtualBoxManagerWidget::retranslateUi()
351{
352 /* Make sure chosen item fetched: */
353 sltHandleChooserPaneIndexChange();
354}
355
356void UIVirtualBoxManagerWidget::sltHandleCommitData()
357{
358 // WORKAROUND:
359 // This will be fixed proper way during session management cleanup for Qt6.
360 // But for now we will just cleanup connections which is Ok anyway.
361 cleanupConnections();
362}
363
364void UIVirtualBoxManagerWidget::sltHandleStateChange(const QUuid &uId)
365{
366 // WORKAROUND:
367 // In certain intermediate states VM info can be NULL which
368 // causing annoying assertions, such updates can be ignored?
369 CVirtualBox comVBox = gpGlobalSession->virtualBox();
370 CMachine comMachine = comVBox.FindMachine(uId.toString());
371 if (comVBox.isOk() && comMachine.isNotNull())
372 {
373 switch (comMachine.GetState())
374 {
375 case KMachineState_DeletingSnapshot:
376 return;
377 default:
378 break;
379 }
380 }
381
382 /* Recache current machine item information: */
383 recacheCurrentMachineItemInformation();
384}
385
386void UIVirtualBoxManagerWidget::sltHandleSettingsExpertModeChange()
387{
388 /* Update toolbar to show/hide corresponding actions: */
389 updateToolbar();
390
391 /* Update tools restrictions for currently selected item: */
392 if (currentItem())
393 updateToolsMenuMachine(currentItem());
394 else
395 updateToolsMenuGlobal();
396}
397
398void UIVirtualBoxManagerWidget::sltHandleSplitterMove()
399{
400 /* Create timer if isn't exist already: */
401 if (!m_pSplitterSettingsSaveTimer)
402 {
403 m_pSplitterSettingsSaveTimer = new QTimer(this);
404 if (m_pSplitterSettingsSaveTimer)
405 {
406 m_pSplitterSettingsSaveTimer->setInterval(300);
407 m_pSplitterSettingsSaveTimer->setSingleShot(true);
408 connect(m_pSplitterSettingsSaveTimer, &QTimer::timeout,
409 this, &UIVirtualBoxManagerWidget::sltSaveSplitterSettings);
410 }
411 }
412 /* [Re]start timer finally: */
413 m_pSplitterSettingsSaveTimer->start();
414}
415
416void UIVirtualBoxManagerWidget::sltSaveSplitterSettings()
417{
418 const QList<int> splitterSizes = m_pSplitter->sizes();
419 LogRel2(("GUI: UIVirtualBoxManagerWidget: Saving splitter as: Size=%d,%d\n",
420 splitterSizes.at(0), splitterSizes.at(1)));
421 gEDataManager->setSelectorWindowSplitterHints(splitterSizes);
422}
423
424void UIVirtualBoxManagerWidget::sltHandleToolBarResize(const QSize &newSize)
425{
426 emit sigToolBarHeightChange(newSize.height());
427}
428
429void UIVirtualBoxManagerWidget::sltHandleChooserPaneIndexChange()
430{
431 /* Let the parent know: */
432 emit sigChooserPaneIndexChange();
433
434 /* If global item is selected and we are on machine tools pane => switch to global tools pane: */
435 if ( isGlobalItemSelected()
436 && m_pStackedWidget->currentWidget() != m_pPaneToolsGlobal)
437 {
438 /* Just start animation and return, do nothing else.. */
439 m_pStackedWidget->setCurrentWidget(m_pPaneToolsGlobal); // rendering w/a
440 m_pStackedWidget->setCurrentWidget(m_pSlidingAnimation);
441 m_pSlidingAnimation->animate(SlidingDirection_Reverse);
442 return;
443 }
444
445 else
446
447 /* If machine or group item is selected and we are on global tools pane => switch to machine tools pane: */
448 if ( (isMachineItemSelected() || isGroupItemSelected())
449 && m_pStackedWidget->currentWidget() != m_pPaneToolsMachine)
450 {
451 /* Just start animation and return, do nothing else.. */
452 m_pStackedWidget->setCurrentWidget(m_pPaneToolsMachine); // rendering w/a
453 m_pStackedWidget->setCurrentWidget(m_pSlidingAnimation);
454 m_pSlidingAnimation->animate(SlidingDirection_Forward);
455 return;
456 }
457
458 /* Update tools restrictions for currently selected item: */
459 UIVirtualMachineItem *pItem = currentItem();
460 if (pItem)
461 updateToolsMenuMachine(pItem);
462 else
463 updateToolsMenuGlobal();
464
465 /* Recache current machine item information: */
466 recacheCurrentMachineItemInformation();
467
468 /* Calculate selection type: */
469 const SelectionType enmSelectedItemType = isSingleLocalGroupSelected()
470 ? SelectionType_SingleLocalGroupItem
471 : isSingleCloudProviderGroupSelected() || isSingleCloudProfileGroupSelected()
472 ? SelectionType_SingleCloudGroupItem
473 : isGlobalItemSelected()
474 ? SelectionType_FirstIsGlobalItem
475 : isLocalMachineItemSelected()
476 ? SelectionType_FirstIsLocalMachineItem
477 : isCloudMachineItemSelected()
478 ? SelectionType_FirstIsCloudMachineItem
479 : SelectionType_Invalid;
480
481 /* Update toolbar if selection type or item accessibility got changed: */
482 const bool fCurrentItemIsOk = pItem && pItem->accessible();
483 if ( m_enmSelectionType != enmSelectedItemType
484 || m_fSelectedMachineItemAccessible != fCurrentItemIsOk)
485 updateToolbar();
486
487 /* Remember the last selection type: */
488 m_enmSelectionType = enmSelectedItemType;
489 /* Remember whether the last selected item was accessible: */
490 m_fSelectedMachineItemAccessible = fCurrentItemIsOk;
491}
492
493void UIVirtualBoxManagerWidget::sltHandleSlidingAnimationComplete(SlidingDirection enmDirection)
494{
495 /* First switch the panes: */
496 switch (enmDirection)
497 {
498 case SlidingDirection_Forward:
499 {
500 /* Switch stacked widget to machine tool pane: */
501 m_pStackedWidget->setCurrentWidget(m_pPaneToolsMachine);
502 m_pPaneToolsGlobal->setActive(false);
503 m_pPaneToolsMachine->setActive(true);
504 /* Handle current tool type change: */
505 handleCurrentToolTypeChange(m_pMenuToolsMachine->toolsType());
506 break;
507 }
508 case SlidingDirection_Reverse:
509 {
510 /* Switch stacked widget to global tool pane: */
511 m_pStackedWidget->setCurrentWidget(m_pPaneToolsGlobal);
512 m_pPaneToolsMachine->setActive(false);
513 m_pPaneToolsGlobal->setActive(true);
514 /* Handle current tool type change: */
515 handleCurrentToolTypeChange(m_pMenuToolsGlobal->toolsType());
516 break;
517 }
518 }
519 /* Then handle current item change (again!): */
520 sltHandleChooserPaneIndexChange();
521}
522
523void UIVirtualBoxManagerWidget::sltHandleCloudProfileStateChange(const QString &strProviderShortName,
524 const QString &strProfileName)
525{
526 RT_NOREF(strProviderShortName, strProfileName);
527
528 /* If Global Activity Overview tool is currently chosen: */
529 if ( m_pStackedWidget->currentWidget() == m_pPaneToolsGlobal
530 && m_pPaneToolsGlobal->currentTool() == UIToolType_VMActivityOverview)
531 m_pPaneToolsGlobal->setCloudMachineItems(m_pPaneChooser->cloudMachineItems());
532}
533
534void UIVirtualBoxManagerWidget::sltHandleCloudMachineStateChange(const QUuid &uId)
535{
536 /* Not for global items: */
537 if (!isGlobalItemSelected())
538 {
539 /* Acquire current item: */
540 UIVirtualMachineItem *pItem = currentItem();
541 const bool fCurrentItemIsOk = pItem && pItem->accessible();
542
543 /* If current item is Ok: */
544 if (fCurrentItemIsOk)
545 {
546 /* If Error-pane is chosen currently => switch to tool currently chosen in Tools-menu: */
547 if (m_pPaneToolsMachine->currentTool() == UIToolType_Error)
548 switchMachineToolTo(m_pMenuToolsMachine->toolsType());
549
550 /* If we still have same item selected: */
551 if (pItem && pItem->id() == uId)
552 {
553 /* Propagate current items to update the Details-pane: */
554 m_pPaneToolsMachine->setItems(currentItems());
555 }
556 }
557 else
558 {
559 /* Make sure Error pane raised: */
560 if (m_pPaneToolsMachine->currentTool() != UIToolType_Error)
561 m_pPaneToolsMachine->openTool(UIToolType_Error);
562
563 /* If we still have same item selected: */
564 if (pItem && pItem->id() == uId)
565 {
566 /* Propagate current items to update the Details-pane (in any case): */
567 m_pPaneToolsMachine->setItems(currentItems());
568 /* Propagate last access error to update the Error-pane (if machine selected but inaccessible): */
569 m_pPaneToolsMachine->setErrorDetails(pItem->accessError());
570 }
571 }
572
573 /* Pass the signal further: */
574 emit sigCloudMachineStateChange(uId);
575 }
576}
577
578void UIVirtualBoxManagerWidget::sltHandleToolMenuRequested(const QPoint &position, UIVirtualMachineItem *pItem)
579{
580 /* Update tools menu beforehand: */
581 UITools *pMenu = pItem ? m_pMenuToolsMachine : m_pMenuToolsGlobal;
582 AssertPtrReturnVoid(pMenu);
583 if (pItem)
584 updateToolsMenuMachine(pItem);
585 else
586 updateToolsMenuGlobal();
587
588 /* Compose popup-menu geometry first of all: */
589 QRect ourGeo = QRect(position, pMenu->minimumSizeHint());
590 /* Adjust location only to properly fit into available geometry space: */
591 const QRect availableGeo = gpDesktop->availableGeometry(position);
592 ourGeo = gpDesktop->normalizeGeometry(ourGeo, availableGeo, false /* resize? */);
593
594 /* Move, resize and show: */
595 pMenu->move(ourGeo.topLeft());
596 pMenu->show();
597 // WORKAROUND:
598 // Don't want even to think why, but for Qt::Popup resize to
599 // smaller size often being ignored until it is actually shown.
600 pMenu->resize(ourGeo.size());
601}
602
603void UIVirtualBoxManagerWidget::sltSwitchToMachineActivityPane(const QUuid &uMachineId)
604{
605 AssertPtrReturnVoid(m_pPaneChooser);
606 AssertPtrReturnVoid(m_pMenuToolsMachine);
607 m_pPaneChooser->setCurrentMachine(uMachineId);
608 m_pMenuToolsMachine->setToolsType(UIToolType_VMActivity);
609}
610
611void UIVirtualBoxManagerWidget::sltSwitchToActivityOverviewPane()
612{
613 AssertPtrReturnVoid(m_pPaneChooser);
614 AssertPtrReturnVoid(m_pMenuToolsGlobal);
615 m_pMenuToolsGlobal->setToolsType(UIToolType_VMActivityOverview);
616 m_pPaneChooser->setCurrentGlobal();
617}
618
619void UIVirtualBoxManagerWidget::prepare()
620{
621 /* Prepare everything: */
622 prepareWidgets();
623 prepareConnections();
624
625 /* Load settings: */
626 loadSettings();
627
628 /* Translate UI: */
629 retranslateUi();
630
631 /* Make sure current Chooser-pane index fetched: */
632 sltHandleChooserPaneIndexChange();
633}
634
635void UIVirtualBoxManagerWidget::prepareWidgets()
636{
637 /* Create main-layout: */
638 QHBoxLayout *pLayoutMain = new QHBoxLayout(this);
639 if (pLayoutMain)
640 {
641 /* Configure layout: */
642 pLayoutMain->setSpacing(0);
643 pLayoutMain->setContentsMargins(0, 0, 0, 0);
644
645 /* Create splitter: */
646 m_pSplitter = new QISplitter;
647 if (m_pSplitter)
648 {
649 /* Create Chooser-pane: */
650 m_pPaneChooser = new UIChooser(this, actionPool());
651 if (m_pPaneChooser)
652 {
653 /* Add into splitter: */
654 m_pSplitter->addWidget(m_pPaneChooser);
655 }
656
657 /* Create right widget: */
658 QWidget *pWidgetRight = new QWidget;
659 if (pWidgetRight)
660 {
661 /* Create right-layout: */
662 QVBoxLayout *pLayoutRight = new QVBoxLayout(pWidgetRight);
663 if(pLayoutRight)
664 {
665 /* Configure layout: */
666 pLayoutRight->setSpacing(0);
667 pLayoutRight->setContentsMargins(0, 0, 0, 0);
668
669 /* Create Main toolbar: */
670 m_pToolBar = new QIToolBar;
671 if (m_pToolBar)
672 {
673 /* Configure toolbar: */
674 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize);
675 m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric));
676 m_pToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
677 m_pToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
678 m_pToolBar->setUseTextLabels(true);
679#ifdef VBOX_WS_MAC
680 m_pToolBar->emulateMacToolbar();
681 /* Branding stuff for Qt6 beta: */
682 if (UIVersionInfo::showBetaLabel())
683 m_pToolBar->enableBranding(UIIconPool::iconSet(":/explosion_hazard_32px.png"),
684 "Dev Preview", // do we need to make it NLS?
685 QColor(246, 179, 0),
686 74 /* width of BETA label */);
687#endif /* VBOX_WS_MAC */
688
689 /* Add toolbar into layout: */
690 pLayoutRight->addWidget(m_pToolBar);
691 }
692
693 /* Create stacked-widget: */
694 m_pStackedWidget = new QStackedWidget;
695 if (m_pStackedWidget)
696 {
697 /* Create Global Tools-pane: */
698 m_pPaneToolsGlobal = new UIToolPaneGlobal(actionPool());
699 if (m_pPaneToolsGlobal)
700 {
701 if (m_pPaneChooser->isGlobalItemSelected())
702 m_pPaneToolsGlobal->setActive(true);
703 connect(m_pPaneToolsGlobal, &UIToolPaneGlobal::sigCreateMedium,
704 this, &UIVirtualBoxManagerWidget::sigCreateMedium);
705 connect(m_pPaneToolsGlobal, &UIToolPaneGlobal::sigCopyMedium,
706 this, &UIVirtualBoxManagerWidget::sigCopyMedium);
707 connect(m_pPaneToolsGlobal, &UIToolPaneGlobal::sigSwitchToMachineActivityPane,
708 this, &UIVirtualBoxManagerWidget::sltSwitchToMachineActivityPane);
709
710 /* Add into stack: */
711 m_pStackedWidget->addWidget(m_pPaneToolsGlobal);
712 }
713
714 /* Create Machine Tools-pane: */
715 m_pPaneToolsMachine = new UIToolPaneMachine(actionPool());
716 if (m_pPaneToolsMachine)
717 {
718 if (!m_pPaneChooser->isGlobalItemSelected())
719 m_pPaneToolsMachine->setActive(true);
720 connect(m_pPaneToolsMachine, &UIToolPaneMachine::sigCurrentSnapshotItemChange,
721 this, &UIVirtualBoxManagerWidget::sigCurrentSnapshotItemChange);
722 connect(m_pPaneToolsMachine, &UIToolPaneMachine::sigSwitchToActivityOverviewPane,
723 this, &UIVirtualBoxManagerWidget::sltSwitchToActivityOverviewPane);
724 connect(m_pPaneToolsMachine, &UIToolPaneMachine::sigDetachToolPane,
725 this, &UIVirtualBoxManagerWidget::sigDetachToolPane);
726
727 /* Add into stack: */
728 m_pStackedWidget->addWidget(m_pPaneToolsMachine);
729 }
730
731 /* Create sliding-widget: */
732 // Reverse initial animation direction if group or machine selected!
733 const bool fReverse = !m_pPaneChooser->isGlobalItemSelected();
734 m_pSlidingAnimation = new UISlidingAnimation(Qt::Vertical, fReverse);
735 if (m_pSlidingAnimation)
736 {
737 /* Add first/second widgets into sliding animation: */
738 m_pSlidingAnimation->setWidgets(m_pPaneToolsGlobal, m_pPaneToolsMachine);
739 connect(m_pSlidingAnimation, &UISlidingAnimation::sigAnimationComplete,
740 this, &UIVirtualBoxManagerWidget::sltHandleSlidingAnimationComplete);
741
742 /* Add into stack: */
743 m_pStackedWidget->addWidget(m_pSlidingAnimation);
744 }
745
746 /* Choose which pane should be active initially: */
747 if (m_pPaneChooser->isGlobalItemSelected())
748 m_pStackedWidget->setCurrentWidget(m_pPaneToolsGlobal);
749 else
750 m_pStackedWidget->setCurrentWidget(m_pPaneToolsMachine);
751
752 /* Add into layout: */
753 pLayoutRight->addWidget(m_pStackedWidget, 1);
754 }
755 }
756
757 /* Add into splitter: */
758 m_pSplitter->addWidget(pWidgetRight);
759 }
760
761 /* Set the initial distribution. The right site is bigger. */
762 m_pSplitter->setStretchFactor(0, 2);
763 m_pSplitter->setStretchFactor(1, 3);
764
765 /* Add into layout: */
766 pLayoutMain->addWidget(m_pSplitter);
767 }
768
769 /* Create Global Tools-menu: */
770 m_pMenuToolsGlobal = new UITools(UIToolClass_Global, this);
771 /* Create Machine Tools-menu: */
772 m_pMenuToolsMachine = new UITools(UIToolClass_Machine, this);
773 }
774
775 /* Create notification-center: */
776 UINotificationCenter::create(this);
777
778 /* Update toolbar finally: */
779 updateToolbar();
780
781 /* Bring the VM list to the focus: */
782 m_pPaneChooser->setFocus();
783}
784
785void UIVirtualBoxManagerWidget::prepareConnections()
786{
787 /* UICommon connections: */
788 connect(&uiCommon(), &UICommon::sigAskToCommitData,
789 this, &UIVirtualBoxManagerWidget::sltHandleCommitData);
790
791 /* Global VBox event handlers: */
792 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange,
793 this, &UIVirtualBoxManagerWidget::sltHandleStateChange);
794
795 /* Global VBox extra-data event handlers: */
796 connect(gEDataManager, &UIExtraDataManager::sigSettingsExpertModeChange,
797 this, &UIVirtualBoxManagerWidget::sltHandleSettingsExpertModeChange);
798
799 /* Splitter connections: */
800 connect(m_pSplitter, &QISplitter::splitterMoved,
801 this, &UIVirtualBoxManagerWidget::sltHandleSplitterMove);
802
803 /* Tool-bar connections: */
804 connect(m_pToolBar, &QIToolBar::customContextMenuRequested,
805 this, &UIVirtualBoxManagerWidget::sltHandleToolBarContextMenuRequest);
806 connect(m_pToolBar, &QIToolBar::sigResized,
807 this, &UIVirtualBoxManagerWidget::sltHandleToolBarResize);
808
809 /* Chooser-pane connections: */
810 connect(this, &UIVirtualBoxManagerWidget::sigToolBarHeightChange,
811 m_pPaneChooser, &UIChooser::setGlobalItemHeightHint);
812 connect(m_pPaneChooser, &UIChooser::sigSelectionChanged,
813 this, &UIVirtualBoxManagerWidget::sltHandleChooserPaneIndexChange);
814 connect(m_pPaneChooser, &UIChooser::sigSelectionInvalidated,
815 this, &UIVirtualBoxManagerWidget::sltHandleChooserPaneSelectionInvalidated);
816 connect(m_pPaneChooser, &UIChooser::sigToggleStarted,
817 m_pPaneToolsMachine, &UIToolPaneMachine::sigToggleStarted);
818 connect(m_pPaneChooser, &UIChooser::sigToggleFinished,
819 m_pPaneToolsMachine, &UIToolPaneMachine::sigToggleFinished);
820 connect(m_pPaneChooser, &UIChooser::sigGroupSavingStateChanged,
821 this, &UIVirtualBoxManagerWidget::sigGroupSavingStateChanged);
822 connect(m_pPaneChooser, &UIChooser::sigCloudUpdateStateChanged,
823 this, &UIVirtualBoxManagerWidget::sigCloudUpdateStateChanged);
824 connect(m_pPaneChooser, &UIChooser::sigToolMenuRequested,
825 this, &UIVirtualBoxManagerWidget::sltHandleToolMenuRequested);
826 connect(m_pPaneChooser, &UIChooser::sigCloudProfileStateChange,
827 this, &UIVirtualBoxManagerWidget::sltHandleCloudProfileStateChange);
828 connect(m_pPaneChooser, &UIChooser::sigCloudMachineStateChange,
829 this, &UIVirtualBoxManagerWidget::sltHandleCloudMachineStateChange);
830 connect(m_pPaneChooser, &UIChooser::sigStartOrShowRequest,
831 this, &UIVirtualBoxManagerWidget::sigStartOrShowRequest);
832 connect(m_pPaneChooser, &UIChooser::sigMachineSearchWidgetVisibilityChanged,
833 this, &UIVirtualBoxManagerWidget::sigMachineSearchWidgetVisibilityChanged);
834
835 /* Details-pane connections: */
836 connect(m_pPaneToolsMachine, &UIToolPaneMachine::sigLinkClicked,
837 this, &UIVirtualBoxManagerWidget::sigMachineSettingsLinkClicked);
838
839 /* Tools-pane connections: */
840 connect(m_pMenuToolsGlobal, &UITools::sigSelectionChanged,
841 this, &UIVirtualBoxManagerWidget::sltHandleGlobalToolsMenuIndexChange);
842 connect(m_pMenuToolsMachine, &UITools::sigSelectionChanged,
843 this, &UIVirtualBoxManagerWidget::sltHandleMachineToolsMenuIndexChange);
844}
845
846void UIVirtualBoxManagerWidget::loadSettings()
847{
848 /* Restore splitter handle position: */
849 {
850 QList<int> sizes = gEDataManager->selectorWindowSplitterHints();
851 /* If both hints are zero, we have the 'default' case: */
852 if (sizes.at(0) == 0 && sizes.at(1) == 0)
853 {
854 sizes[0] = (int)(width() * .9 * (1.0 / 3));
855 sizes[1] = (int)(width() * .9 * (2.0 / 3));
856 }
857 LogRel2(("GUI: UIVirtualBoxManagerWidget: Restoring splitter to: Size=%d,%d\n",
858 sizes.at(0), sizes.at(1)));
859 m_pSplitter->setSizes(sizes);
860 }
861
862 /* Restore toolbar settings: */
863 {
864 m_pToolBar->setUseTextLabels(gEDataManager->selectorWindowToolBarTextVisible());
865 }
866
867 /* Open tools last chosen in Tools-menu: */
868 switchGlobalToolTo(m_pMenuToolsGlobal->toolsType());
869 switchMachineToolTo(m_pMenuToolsMachine->toolsType());
870}
871
872void UIVirtualBoxManagerWidget::updateToolbar()
873{
874 /* Make sure toolbar exists: */
875 AssertPtrReturnVoid(m_pToolBar);
876
877 /* Clear initially: */
878 m_pToolBar->clear();
879
880 /* If global item selected: */
881 if (isGlobalItemSelected())
882 {
883 switch (currentGlobalTool())
884 {
885 case UIToolType_Welcome:
886 {
887 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Application_S_Preferences));
888 m_pToolBar->addSeparator();
889 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_File_S_ImportAppliance));
890 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_File_S_ExportAppliance));
891 m_pToolBar->addSeparator();
892 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Welcome_S_New));
893 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Welcome_S_Add));
894 break;
895 }
896 case UIToolType_Extensions:
897 {
898 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Extension_S_Install));
899 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Extension_S_Uninstall));
900 break;
901 }
902 case UIToolType_Media:
903 {
904 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Add));
905 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Create));
906 m_pToolBar->addSeparator();
907 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Copy));
908 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Move));
909 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Remove));
910 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Release));
911 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Clear));
912 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_T_Search));
913 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_T_Details));
914 m_pToolBar->addSeparator();
915 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Refresh));
916 break;
917 }
918 case UIToolType_Network:
919 {
920 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_S_Create));
921 m_pToolBar->addSeparator();
922 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_S_Remove));
923 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_T_Details));
924 //m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_S_Refresh));
925 break;
926 }
927 case UIToolType_Cloud:
928 {
929 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Add));
930 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Import));
931 m_pToolBar->addSeparator();
932 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Remove));
933 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_T_Details));
934 m_pToolBar->addSeparator();
935 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_TryPage));
936 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Help));
937 break;
938 }
939 case UIToolType_VMActivityOverview:
940 {
941 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_VMActivityOverview_M_Columns));
942 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_VMActivityOverview_S_SwitchToMachineActivity));
943 QToolButton *pButton =
944 qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexMN_M_VMActivityOverview_M_Columns)));
945 if (pButton)
946 {
947 pButton->setPopupMode(QToolButton::InstantPopup);
948 pButton->setAutoRaise(true);
949 }
950 break;
951 }
952
953 default:
954 break;
955 }
956 }
957
958 else
959
960 /* If machine or group item selected: */
961 if (isMachineItemSelected() || isGroupItemSelected())
962 {
963 switch (currentMachineTool())
964 {
965 case UIToolType_Details:
966 {
967 if (isSingleGroupSelected())
968 {
969 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_New));
970 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Add));
971 m_pToolBar->addSeparator();
972 if (isSingleLocalGroupSelected())
973 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Discard));
974 else if ( isSingleCloudProviderGroupSelected()
975 || isSingleCloudProfileGroupSelected())
976 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Stop_S_Terminate));
977 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_StartOrShow));
978 }
979 else
980 {
981 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_New));
982 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Add));
983 m_pToolBar->addSeparator();
984 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings));
985 if (isLocalMachineItemSelected())
986 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard));
987 else if (isCloudMachineItemSelected())
988 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Stop_S_Terminate));
989 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow));
990 }
991 break;
992 }
993 case UIToolType_Snapshots:
994 {
995 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Take));
996 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Delete));
997 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Restore));
998 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_T_Properties));
999 if (gEDataManager->isSettingsInExpertMode())
1000 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Clone));
1001 m_pToolBar->addSeparator();
1002 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings));
1003 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard));
1004 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow));
1005 break;
1006 }
1007 case UIToolType_Logs:
1008 {
1009 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_S_Save));
1010 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Find));
1011 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Filter));
1012 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Bookmark));
1013 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Preferences));
1014 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_S_Refresh));
1015 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_S_Reload));
1016 m_pToolBar->addSeparator();
1017 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings));
1018 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard));
1019 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow));
1020 break;
1021 }
1022 case UIToolType_VMActivity:
1023 {
1024 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Activity_S_Export));
1025 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Activity_S_ToVMActivityOverview));
1026 m_pToolBar->addSeparator();
1027 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings));
1028 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard));
1029 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow));
1030 break;
1031 }
1032 case UIToolType_FileManager:
1033 {
1034 m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_T_Preferences));
1035 m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_T_Operations));
1036 m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_T_Log));
1037 m_pToolBar->addSeparator();
1038 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings));
1039 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard));
1040 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow));
1041 break;
1042 }
1043 case UIToolType_Error:
1044 {
1045 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_New));
1046 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Add));
1047 m_pToolBar->addSeparator();
1048 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Refresh));
1049 break;
1050 }
1051 default:
1052 break;
1053 }
1054 }
1055}
1056
1057void UIVirtualBoxManagerWidget::cleanupConnections()
1058{
1059 /* Tool-bar connections: */
1060 disconnect(m_pToolBar, &QIToolBar::customContextMenuRequested,
1061 this, &UIVirtualBoxManagerWidget::sltHandleToolBarContextMenuRequest);
1062 disconnect(m_pToolBar, &QIToolBar::sigResized,
1063 this, &UIVirtualBoxManagerWidget::sltHandleToolBarResize);
1064
1065 /* Chooser-pane connections: */
1066 disconnect(this, &UIVirtualBoxManagerWidget::sigToolBarHeightChange,
1067 m_pPaneChooser, &UIChooser::setGlobalItemHeightHint);
1068 disconnect(m_pPaneChooser, &UIChooser::sigSelectionChanged,
1069 this, &UIVirtualBoxManagerWidget::sltHandleChooserPaneIndexChange);
1070 disconnect(m_pPaneChooser, &UIChooser::sigSelectionInvalidated,
1071 this, &UIVirtualBoxManagerWidget::sltHandleChooserPaneSelectionInvalidated);
1072 disconnect(m_pPaneChooser, &UIChooser::sigToggleStarted,
1073 m_pPaneToolsMachine, &UIToolPaneMachine::sigToggleStarted);
1074 disconnect(m_pPaneChooser, &UIChooser::sigToggleFinished,
1075 m_pPaneToolsMachine, &UIToolPaneMachine::sigToggleFinished);
1076 disconnect(m_pPaneChooser, &UIChooser::sigGroupSavingStateChanged,
1077 this, &UIVirtualBoxManagerWidget::sigGroupSavingStateChanged);
1078 disconnect(m_pPaneChooser, &UIChooser::sigCloudUpdateStateChanged,
1079 this, &UIVirtualBoxManagerWidget::sigCloudUpdateStateChanged);
1080 disconnect(m_pPaneChooser, &UIChooser::sigToolMenuRequested,
1081 this, &UIVirtualBoxManagerWidget::sltHandleToolMenuRequested);
1082 disconnect(m_pPaneChooser, &UIChooser::sigCloudProfileStateChange,
1083 this, &UIVirtualBoxManagerWidget::sltHandleCloudProfileStateChange);
1084 disconnect(m_pPaneChooser, &UIChooser::sigCloudMachineStateChange,
1085 this, &UIVirtualBoxManagerWidget::sltHandleCloudMachineStateChange);
1086 disconnect(m_pPaneChooser, &UIChooser::sigStartOrShowRequest,
1087 this, &UIVirtualBoxManagerWidget::sigStartOrShowRequest);
1088 disconnect(m_pPaneChooser, &UIChooser::sigMachineSearchWidgetVisibilityChanged,
1089 this, &UIVirtualBoxManagerWidget::sigMachineSearchWidgetVisibilityChanged);
1090
1091 /* Details-pane connections: */
1092 disconnect(m_pPaneToolsMachine, &UIToolPaneMachine::sigLinkClicked,
1093 this, &UIVirtualBoxManagerWidget::sigMachineSettingsLinkClicked);
1094
1095 /* Tools-pane connections: */
1096 disconnect(m_pMenuToolsGlobal, &UITools::sigSelectionChanged,
1097 this, &UIVirtualBoxManagerWidget::sltHandleGlobalToolsMenuIndexChange);
1098 disconnect(m_pMenuToolsMachine, &UITools::sigSelectionChanged,
1099 this, &UIVirtualBoxManagerWidget::sltHandleMachineToolsMenuIndexChange);
1100}
1101
1102void UIVirtualBoxManagerWidget::cleanupWidgets()
1103{
1104 UINotificationCenter::destroy();
1105}
1106
1107void UIVirtualBoxManagerWidget::cleanup()
1108{
1109 /* Ask sub-dialogs to commit data: */
1110 sltHandleCommitData();
1111
1112 /* Cleanup everything: */
1113 cleanupWidgets();
1114}
1115
1116void UIVirtualBoxManagerWidget::recacheCurrentMachineItemInformation(bool fDontRaiseErrorPane /* = false */)
1117{
1118 /* Sanity check, this method is for machine or group of machine items: */
1119 if (!isMachineItemSelected() && !isGroupItemSelected())
1120 return;
1121
1122 /* Get current item: */
1123 UIVirtualMachineItem *pItem = currentItem();
1124 const bool fCurrentItemIsOk = pItem && pItem->accessible();
1125
1126 /* If current item is Ok: */
1127 if (fCurrentItemIsOk)
1128 {
1129 /* If Error-pane is chosen currently => switch to tool currently chosen in Tools-menu: */
1130 if (m_pPaneToolsMachine->currentTool() == UIToolType_Error)
1131 switchMachineToolTo(m_pMenuToolsMachine->toolsType());
1132
1133 /* Propagate current items to the Tools pane: */
1134 m_pPaneToolsMachine->setItems(currentItems());
1135 }
1136 /* Otherwise if we were not asked separately to calm down: */
1137 else if (!fDontRaiseErrorPane)
1138 {
1139 /* Make sure Error pane raised: */
1140 if (m_pPaneToolsMachine->currentTool() != UIToolType_Error)
1141 m_pPaneToolsMachine->openTool(UIToolType_Error);
1142
1143 /* Propagate last access error to the Error-pane: */
1144 if (pItem)
1145 m_pPaneToolsMachine->setErrorDetails(pItem->accessError());
1146 }
1147}
1148
1149void UIVirtualBoxManagerWidget::updateToolsMenuGlobal()
1150{
1151 /* Update global tools restrictions: */
1152 QSet<UIToolType> restrictedTypes;
1153 const bool fExpertMode = gEDataManager->isSettingsInExpertMode();
1154 if (!fExpertMode)
1155 restrictedTypes << UIToolType_Media
1156 << UIToolType_Network;
1157 if (restrictedTypes.contains(m_pMenuToolsGlobal->toolsType()))
1158 m_pMenuToolsGlobal->setToolsType(UIToolType_Welcome);
1159 const QList restrictions(restrictedTypes.begin(), restrictedTypes.end());
1160 m_pMenuToolsGlobal->setRestrictedToolTypes(restrictions);
1161
1162 /* Take restrictions into account, closing all restricted tools: */
1163 foreach (const UIToolType &enmRestrictedType, restrictedTypes)
1164 m_pPaneToolsGlobal->closeTool(enmRestrictedType);
1165}
1166
1167void UIVirtualBoxManagerWidget::updateToolsMenuMachine(UIVirtualMachineItem *pItem)
1168{
1169 /* Get current item state: */
1170 const bool fCurrentItemIsOk = pItem && pItem->accessible();
1171
1172 /* Update machine tools restrictions: */
1173 QSet<UIToolType> restrictedTypes;
1174 const bool fExpertMode = gEDataManager->isSettingsInExpertMode();
1175 if (!fExpertMode)
1176 restrictedTypes << UIToolType_FileManager;
1177 if (pItem && pItem->itemType() != UIVirtualMachineItemType_Local)
1178 restrictedTypes << UIToolType_Snapshots
1179 << UIToolType_Logs
1180 << UIToolType_FileManager;
1181 if (restrictedTypes.contains(m_pMenuToolsMachine->toolsType()))
1182 m_pMenuToolsMachine->setToolsType(UIToolType_Details);
1183 const QList restrictions(restrictedTypes.begin(), restrictedTypes.end());
1184 m_pMenuToolsMachine->setRestrictedToolTypes(restrictions);
1185 /* Update machine menu items availability: */
1186 m_pMenuToolsMachine->setItemsEnabled(fCurrentItemIsOk);
1187
1188 /* Take restrictions into account, closing all restricted tools: */
1189 foreach (const UIToolType &enmRestrictedType, restrictedTypes)
1190 m_pPaneToolsMachine->closeTool(enmRestrictedType);
1191}
1192
1193void UIVirtualBoxManagerWidget::handleCurrentToolTypeChange(UIToolType enmType)
1194{
1195 /* This method's behavior depends first of all of currently selected tool class.
1196 * But keep in mind, it is called for both Global and Machine type changes. */
1197
1198 /* If Global tools currently chosen: */
1199 if (m_pStackedWidget->currentWidget() == m_pPaneToolsGlobal)
1200 {
1201 /* For the Global tool type changes,
1202 * start unconditionally updating all cloud VMs,
1203 * if Activity Overview tool currently chosen (even if VMs are not selected): */
1204 if (UIToolStuff::isTypeOfClass(enmType, UIToolClass_Global))
1205 {
1206 bool fActivityOverviewActive = enmType == UIToolType_VMActivityOverview;
1207 m_pPaneChooser->setKeepCloudNodesUpdated(fActivityOverviewActive);
1208 if (fActivityOverviewActive)
1209 m_pPaneToolsGlobal->setCloudMachineItems(m_pPaneChooser->cloudMachineItems());
1210 }
1211 }
1212 /* If Machine tools currently chosen: */
1213 else
1214 {
1215 /* Stop unconditionally updating all cloud VMs,
1216 * (tho they will still be updated if selected): */
1217 m_pPaneChooser->setKeepCloudNodesUpdated(false);
1218 }
1219}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette