VirtualBox

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

Last change on this file since 57027 was 54217, checked in by vboxsync, 10 years ago

FE/Qt: 3635: Hide the Scale-factor sub-menu from the Scale mode.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/* $Id: UIMachineLogicScale.cpp 54217 2015-02-16 15:02:35Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachineLogicScale class implementation.
4 */
5
6/*
7 * Copyright (C) 2010-2013 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifdef VBOX_WITH_PRECOMPILED_HEADERS
19# include <precomp.h>
20#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
21
22/* Qt includes: */
23# ifndef Q_WS_MAC
24# include <QTimer>
25# endif /* !Q_WS_MAC */
26
27/* GUI includes: */
28# include "VBoxGlobal.h"
29# include "UIMessageCenter.h"
30# include "UISession.h"
31# include "UIActionPoolRuntime.h"
32# include "UIMachineLogicScale.h"
33# include "UIMachineWindow.h"
34# include "UIShortcutPool.h"
35# ifndef Q_WS_MAC
36# include "QIMenu.h"
37# else /* Q_WS_MAC */
38# include "VBoxUtils.h"
39# endif /* Q_WS_MAC */
40
41#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
42
43
44UIMachineLogicScale::UIMachineLogicScale(QObject *pParent, UISession *pSession)
45 : UIMachineLogic(pParent, pSession, UIVisualStateType_Scale)
46#ifndef Q_WS_MAC
47 , m_pPopupMenu(0)
48#endif /* !Q_WS_MAC */
49{
50}
51
52bool UIMachineLogicScale::checkAvailability()
53{
54 /* Show the info message. */
55 const UIShortcut &shortcut =
56 gShortcutPool->shortcut(actionPool()->shortcutsExtraDataID(),
57 actionPool()->action(UIActionIndexRT_M_View_T_Scale)->shortcutExtraDataID());
58 const QString strHotKey = QString("Host+%1").arg(shortcut.toString());
59 if (!msgCenter().confirmGoingScale(strHotKey))
60 return false;
61
62 return true;
63}
64
65#ifndef Q_WS_MAC
66void UIMachineLogicScale::sltInvokePopupMenu()
67{
68 /* Popup main-menu if present: */
69 if (m_pPopupMenu && !m_pPopupMenu->isEmpty())
70 {
71 m_pPopupMenu->popup(activeMachineWindow()->geometry().center());
72 QTimer::singleShot(0, m_pPopupMenu, SLOT(sltHighlightFirstAction()));
73 }
74}
75#endif /* !Q_WS_MAC */
76
77void UIMachineLogicScale::prepareActionGroups()
78{
79 /* Call to base-class: */
80 UIMachineLogic::prepareActionGroups();
81
82 /* Restrict 'Adjust Window', 'Guest Autoresize', 'Status Bar' and 'Resize' actions for 'View' menu: */
83 actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Logic,
84 (UIExtraDataMetaDefs::RuntimeMenuViewActionType)
85 (UIExtraDataMetaDefs::RuntimeMenuViewActionType_AdjustWindow |
86 UIExtraDataMetaDefs::RuntimeMenuViewActionType_GuestAutoresize |
87 UIExtraDataMetaDefs::RuntimeMenuViewActionType_MenuBar |
88 UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar |
89 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize |
90 UIExtraDataMetaDefs::RuntimeMenuViewActionType_ScaleFactor));
91
92 /* Take care of view-action toggle state: */
93 UIAction *pActionScale = actionPool()->action(UIActionIndexRT_M_View_T_Scale);
94 if (!pActionScale->isChecked())
95 {
96 pActionScale->blockSignals(true);
97 pActionScale->setChecked(true);
98 pActionScale->blockSignals(false);
99 }
100}
101
102void UIMachineLogicScale::prepareActionConnections()
103{
104 /* Call to base-class: */
105 UIMachineLogic::prepareActionConnections();
106
107 /* Prepare 'View' actions connections: */
108 connect(actionPool()->action(UIActionIndexRT_M_View_T_Scale), SIGNAL(triggered(bool)),
109 this, SLOT(sltChangeVisualStateToNormal()));
110 connect(actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen), SIGNAL(triggered(bool)),
111 this, SLOT(sltChangeVisualStateToFullscreen()));
112 connect(actionPool()->action(UIActionIndexRT_M_View_T_Seamless), SIGNAL(triggered(bool)),
113 this, SLOT(sltChangeVisualStateToSeamless()));
114}
115
116void UIMachineLogicScale::prepareMachineWindows()
117{
118 /* Do not create machine-window(s) if they created already: */
119 if (isMachineWindowsCreated())
120 return;
121
122#ifdef Q_WS_MAC // TODO: Is that really need here?
123 /* We have to make sure that we are getting the front most process.
124 * This is necessary for Qt versions > 4.3.3: */
125 ::darwinSetFrontMostProcess();
126#endif /* Q_WS_MAC */
127
128 /* Get monitors count: */
129 ulong uMonitorCount = machine().GetMonitorCount();
130 /* Create machine window(s): */
131 for (ulong uScreenId = 0; uScreenId < uMonitorCount; ++ uScreenId)
132 addMachineWindow(UIMachineWindow::create(this, uScreenId));
133 /* Order machine window(s): */
134 for (ulong uScreenId = uMonitorCount; uScreenId > 0; -- uScreenId)
135 machineWindows()[uScreenId - 1]->raise();
136
137 /* Listen for frame-buffer resize: */
138 foreach (UIMachineWindow *pMachineWindow, machineWindows())
139 connect(pMachineWindow, SIGNAL(sigFrameBufferResize()),
140 this, SIGNAL(sigFrameBufferResize()));
141 emit sigFrameBufferResize();
142
143 /* Mark machine-window(s) created: */
144 setMachineWindowsCreated(true);
145}
146
147#ifndef Q_WS_MAC
148void UIMachineLogicScale::prepareMenu()
149{
150 /* Prepare popup-menu: */
151 m_pPopupMenu = new QIMenu;
152 AssertPtrReturnVoid(m_pPopupMenu);
153 {
154 /* Prepare popup-menu: */
155 foreach (QMenu *pMenu, actionPool()->menus())
156 m_pPopupMenu->addMenu(pMenu);
157 }
158}
159#endif /* !Q_WS_MAC */
160
161#ifndef Q_WS_MAC
162void UIMachineLogicScale::cleanupMenu()
163{
164 /* Cleanup popup-menu: */
165 delete m_pPopupMenu;
166 m_pPopupMenu = 0;
167}
168#endif /* !Q_WS_MAC */
169
170void UIMachineLogicScale::cleanupMachineWindows()
171{
172 /* Do not destroy machine-window(s) if they destroyed already: */
173 if (!isMachineWindowsCreated())
174 return;
175
176 /* Mark machine-window(s) destroyed: */
177 setMachineWindowsCreated(false);
178
179 /* Cleanup machine-window(s): */
180 foreach (UIMachineWindow *pMachineWindow, machineWindows())
181 UIMachineWindow::destroy(pMachineWindow);
182}
183
184void UIMachineLogicScale::cleanupActionConnections()
185{
186 /* "View" actions disconnections: */
187 disconnect(actionPool()->action(UIActionIndexRT_M_View_T_Scale), SIGNAL(triggered(bool)),
188 this, SLOT(sltChangeVisualStateToNormal()));
189 disconnect(actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen), SIGNAL(triggered(bool)),
190 this, SLOT(sltChangeVisualStateToFullscreen()));
191 disconnect(actionPool()->action(UIActionIndexRT_M_View_T_Seamless), SIGNAL(triggered(bool)),
192 this, SLOT(sltChangeVisualStateToSeamless()));
193
194 /* Call to base-class: */
195 UIMachineLogic::cleanupActionConnections();
196
197}
198
199void UIMachineLogicScale::cleanupActionGroups()
200{
201 /* Take care of view-action toggle state: */
202 UIAction *pActionScale = actionPool()->action(UIActionIndexRT_M_View_T_Scale);
203 if (pActionScale->isChecked())
204 {
205 pActionScale->blockSignals(true);
206 pActionScale->setChecked(false);
207 pActionScale->blockSignals(false);
208 }
209
210 /* Allow 'Adjust Window', 'Guest Autoresize', 'Status Bar' and 'Resize' actions for 'View' menu: */
211 actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Logic,
212 UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid);
213
214 /* Call to base-class: */
215 UIMachineLogic::cleanupActionGroups();
216}
217
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette