VirtualBox

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

Last change on this file was 105480, checked in by vboxsync, 8 weeks ago

FE/Qt: macOS: Update Dev Preview branding rules for ARM host.

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