VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIStarter.cpp

Last change on this file was 106061, checked in by vboxsync, 7 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: UIStarter.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIStarter class implementation.
4 */
5
6/*
7 * Copyright (C) 2018-2024 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
31/* GUI includes: */
32#include "UICommon.h"
33#include "UIExtraDataManager.h"
34#include "UIGlobalSession.h"
35#include "UIMessageCenter.h"
36#include "UINotificationCenter.h"
37#include "UIStarter.h"
38#ifndef VBOX_RUNTIME_UI
39# include "UIVirtualBoxManager.h"
40#else
41# include "UIMachine.h"
42#endif
43
44
45UIStarter::UIStarter()
46{
47 /* Listen for UICommon signals: */
48 connect(&uiCommon(), &UICommon::sigAskToRestartUI,
49 this, &UIStarter::sltRestartUI);
50 connect(&uiCommon(), &UICommon::sigAskToCloseUI,
51 this, &UIStarter::sltCloseUI);
52}
53
54UIStarter::~UIStarter()
55{
56 /* Listen for UICommon signals no more: */
57 disconnect(&uiCommon(), &UICommon::sigAskToRestartUI,
58 this, &UIStarter::sltRestartUI);
59 disconnect(&uiCommon(), &UICommon::sigAskToCloseUI,
60 this, &UIStarter::sltCloseUI);
61}
62
63void UIStarter::sltStartUI()
64{
65 /* Exit if UICommon is not valid: */
66 if (!uiCommon().isValid())
67 return;
68
69#ifndef VBOX_RUNTIME_UI
70
71 /* Make sure Manager UI is permitted, quit if not: */
72 if (gEDataManager->guiFeatureEnabled(GUIFeatureType_NoSelector))
73 {
74 msgCenter().cannotStartSelector();
75 return QApplication::quit();
76 }
77
78 /* Create/show manager-window: */
79 UIVirtualBoxManager::create();
80
81# ifdef VBOX_BLEEDING_EDGE
82 /* Show EXPERIMENTAL BUILD warning: */
83 UINotificationMessage::remindAboutExperimentalBuild();
84# else /* !VBOX_BLEEDING_EDGE */
85# ifndef DEBUG
86 /* Show BETA warning if necessary: */
87 const QString vboxVersion(gpGlobalSession->virtualBox().GetVersion());
88 if ( vboxVersion.contains("BETA")
89 && gEDataManager->preventBetaBuildWarningForVersion() != vboxVersion)
90 UINotificationMessage::remindAboutBetaBuild();
91# endif /* !DEBUG */
92# endif /* !VBOX_BLEEDING_EDGE */
93
94#else /* VBOX_RUNTIME_UI */
95
96 /* Make sure Runtime UI is possible at all, quit if not: */
97 if (uiCommon().managedVMUuid().isNull())
98 {
99 msgCenter().cannotStartRuntime();
100 return QApplication::quit();
101 }
102
103 /* Try to start virtual machine, quit if failed: */
104 if (!UIMachine::startMachine())
105 return QApplication::quit();
106
107#endif /* VBOX_RUNTIME_UI */
108}
109
110void UIStarter::sltRestartUI()
111{
112#ifndef VBOX_RUNTIME_UI
113 /* Recreate/show manager-window: */
114 UIVirtualBoxManager::destroy();
115 UIVirtualBoxManager::create();
116#endif
117}
118
119void UIStarter::sltCloseUI()
120{
121#ifndef VBOX_RUNTIME_UI
122 /* Destroy Manager UI: */
123 UIVirtualBoxManager::destroy();
124#else
125 /* Destroy Runtime UI: */
126 UIMachine::destroy();
127#endif
128}
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