VirtualBox

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

Last change on this file was 104445, checked in by vboxsync, 3 weeks ago

FE/Qt. bugref:9510. Adding a new pane container to activity monitor widget to host setting controls.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use