VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineLogicScale.cpp@ 98849

Last change on this file since 98849 was 98849, checked in by vboxsync, 21 months ago

FE/Qt: bugref:10322: Runtime UI: Cleanup frame-buffer related signals and connections; They are unused now anyway.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.1 KB
Line 
1/* $Id: UIMachineLogicScale.cpp 98849 2023-03-07 08:27:57Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachineLogicScale class implementation.
4 */
5
6/*
7 * Copyright (C) 2010-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#ifndef VBOX_WS_MAC
30# include <QTimer>
31#endif
32
33/* GUI includes: */
34#include "UIActionPoolRuntime.h"
35#include "UICommon.h"
36#include "UIDesktopWidgetWatchdog.h"
37#include "UIMachine.h"
38#include "UIMachineLogicScale.h"
39#include "UIMachineWindow.h"
40#include "UIMessageCenter.h"
41#include "UIShortcutPool.h"
42#ifndef VBOX_WS_MAC
43# include "QIMenu.h"
44#else
45# include "VBoxUtils.h"
46#endif
47
48/* COM includes: */
49#include "CGraphicsAdapter.h"
50
51
52UIMachineLogicScale::UIMachineLogicScale(UIMachine *pMachine)
53 : UIMachineLogic(pMachine)
54#ifndef VBOX_WS_MAC
55 , m_pPopupMenu(0)
56#endif /* !VBOX_WS_MAC */
57{
58}
59
60bool UIMachineLogicScale::checkAvailability()
61{
62 /* Show the info message. */
63 const UIShortcut &shortcut =
64 gShortcutPool->shortcut(actionPool()->shortcutsExtraDataID(),
65 actionPool()->action(UIActionIndexRT_M_View_T_Scale)->shortcutExtraDataID());
66 const QString strHotKey = QString("Host+%1").arg(shortcut.primaryToPortableText());
67 if (!msgCenter().confirmGoingScale(strHotKey))
68 return false;
69
70 return true;
71}
72
73#ifndef VBOX_WS_MAC
74void UIMachineLogicScale::sltInvokePopupMenu()
75{
76 /* Popup main-menu if present: */
77 if (m_pPopupMenu && !m_pPopupMenu->isEmpty())
78 {
79 m_pPopupMenu->popup(activeMachineWindow()->geometry().center());
80 QTimer::singleShot(0, m_pPopupMenu, SLOT(sltHighlightFirstAction()));
81 }
82}
83#endif /* !VBOX_WS_MAC */
84
85void UIMachineLogicScale::sltHostScreenAvailableAreaChange()
86{
87#ifdef VBOX_WS_X11
88 /* Prevent handling if fake screen detected: */
89 if (UIDesktopWidgetWatchdog::isFakeScreenDetected())
90 return;
91
92 /* Make sure all machine-window(s) have previous but normalized geometry: */
93 foreach (UIMachineWindow *pMachineWindow, machineWindows())
94 pMachineWindow->restoreCachedGeometry();
95#endif /* VBOX_WS_X11 */
96
97 /* Call to base-class: */
98 UIMachineLogic::sltHostScreenAvailableAreaChange();
99}
100
101void UIMachineLogicScale::prepareActionGroups()
102{
103 /* Call to base-class: */
104 UIMachineLogic::prepareActionGroups();
105
106 /* Restrict 'Adjust Window', 'Guest Autoresize', 'Status Bar', 'Resize' and 'Rescale' actions for 'View' menu: */
107 actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Logic,
108 (UIExtraDataMetaDefs::RuntimeMenuViewActionType)
109 (UIExtraDataMetaDefs::RuntimeMenuViewActionType_AdjustWindow |
110 UIExtraDataMetaDefs::RuntimeMenuViewActionType_GuestAutoresize |
111 UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar |
112 UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar |
113 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize |
114 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Rescale));
115
116 /* Take care of view-action toggle state: */
117 UIAction *pActionScale = actionPool()->action(UIActionIndexRT_M_View_T_Scale);
118 if (!pActionScale->isChecked())
119 {
120 pActionScale->blockSignals(true);
121 pActionScale->setChecked(true);
122 pActionScale->blockSignals(false);
123 }
124}
125
126void UIMachineLogicScale::prepareActionConnections()
127{
128 /* Call to base-class: */
129 UIMachineLogic::prepareActionConnections();
130
131 /* Prepare 'View' actions connections: */
132 connect(actionPool()->action(UIActionIndexRT_M_View_T_Scale), &QAction::triggered,
133 this, &UIMachineLogicScale::sltChangeVisualStateToNormal);
134 connect(actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen), &QAction::triggered,
135 this, &UIMachineLogicScale::sltChangeVisualStateToFullscreen);
136 connect(actionPool()->action(UIActionIndexRT_M_View_T_Seamless), &QAction::triggered,
137 this, &UIMachineLogicScale::sltChangeVisualStateToSeamless);
138}
139
140void UIMachineLogicScale::prepareMachineWindows()
141{
142 /* Do not create machine-window(s) if they created already: */
143 if (isMachineWindowsCreated())
144 return;
145
146#ifdef VBOX_WS_MAC /// @todo Is that really need here?
147 /* We have to make sure that we are getting the front most process.
148 * This is necessary for Qt versions > 4.3.3: */
149 ::darwinSetFrontMostProcess();
150#endif /* VBOX_WS_MAC */
151
152 /* Acquire monitor count: */
153 ulong cMonitorCount = 0;
154 uimachine()->acquireMonitorCount(cMonitorCount);
155
156 /* Create machine window(s): */
157 for (ulong uScreenId = 0; uScreenId < cMonitorCount; ++ uScreenId)
158 addMachineWindow(UIMachineWindow::create(this, uScreenId));
159 /* Order machine window(s): */
160 for (ulong uScreenId = cMonitorCount; uScreenId > 0; -- uScreenId)
161 machineWindows()[uScreenId - 1]->raise();
162
163 /* Mark machine-window(s) created: */
164 setMachineWindowsCreated(true);
165}
166
167#ifndef VBOX_WS_MAC
168void UIMachineLogicScale::prepareMenu()
169{
170 /* Prepare popup-menu: */
171 m_pPopupMenu = new QIMenu;
172 AssertPtrReturnVoid(m_pPopupMenu);
173 {
174 /* Prepare popup-menu: */
175 foreach (QMenu *pMenu, actionPool()->menus())
176 m_pPopupMenu->addMenu(pMenu);
177 }
178}
179#endif /* !VBOX_WS_MAC */
180
181#ifndef VBOX_WS_MAC
182void UIMachineLogicScale::cleanupMenu()
183{
184 /* Cleanup popup-menu: */
185 delete m_pPopupMenu;
186 m_pPopupMenu = 0;
187}
188#endif /* !VBOX_WS_MAC */
189
190void UIMachineLogicScale::cleanupMachineWindows()
191{
192 /* Do not destroy machine-window(s) if they destroyed already: */
193 if (!isMachineWindowsCreated())
194 return;
195
196 /* Mark machine-window(s) destroyed: */
197 setMachineWindowsCreated(false);
198
199 /* Cleanup machine-window(s): */
200 foreach (UIMachineWindow *pMachineWindow, machineWindows())
201 UIMachineWindow::destroy(pMachineWindow);
202}
203
204void UIMachineLogicScale::cleanupActionConnections()
205{
206 /* "View" actions disconnections: */
207 disconnect(actionPool()->action(UIActionIndexRT_M_View_T_Scale), &QAction::triggered,
208 this, &UIMachineLogicScale::sltChangeVisualStateToNormal);
209 disconnect(actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen), &QAction::triggered,
210 this, &UIMachineLogicScale::sltChangeVisualStateToFullscreen);
211 disconnect(actionPool()->action(UIActionIndexRT_M_View_T_Seamless), &QAction::triggered,
212 this, &UIMachineLogicScale::sltChangeVisualStateToSeamless);
213
214 /* Call to base-class: */
215 UIMachineLogic::cleanupActionConnections();
216
217}
218
219void UIMachineLogicScale::cleanupActionGroups()
220{
221 /* Take care of view-action toggle state: */
222 UIAction *pActionScale = actionPool()->action(UIActionIndexRT_M_View_T_Scale);
223 if (pActionScale->isChecked())
224 {
225 pActionScale->blockSignals(true);
226 pActionScale->setChecked(false);
227 pActionScale->blockSignals(false);
228 }
229
230 /* Allow 'Adjust Window', 'Guest Autoresize', 'Status Bar' and 'Resize' actions for 'View' menu: */
231 actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Logic,
232 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid);
233
234 /* Call to base-class: */
235 UIMachineLogic::cleanupActionGroups();
236}
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