VirtualBox

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

Last change on this file since 102493 was 98926, checked in by vboxsync, 18 months ago

FE/Qt: bugref:10322: A bit of cleanup and sanity for openSession and startMachine stuff.

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

© 2024 Oracle
ContactPrivacy/Do Not Sell My InfoTerms of Use