VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsInterface.cpp@ 104158

Last change on this file since 104158 was 103552, checked in by vboxsync, 12 months ago

FE/Qt: Rework UIActionPool to use global UIType instead of own cloned enum.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.9 KB
Line 
1/* $Id: UIMachineSettingsInterface.cpp 103552 2024-02-23 16:31:29Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachineSettingsInterface class implementation.
4 */
5
6/*
7 * Copyright (C) 2008-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 <QVBoxLayout>
30
31/* GUI includes: */
32#include "UIActionPool.h"
33#include "UIExtraDataManager.h"
34#include "UIMachineSettingsInterface.h"
35#include "UIStatusBarEditor.h"
36#include "UIMenuBarEditor.h"
37#include "UIMiniToolbarSettingsEditor.h"
38#include "UIVisualStateEditor.h"
39
40/** Machine settings: User Interface page data structure. */
41struct UIDataSettingsMachineInterface
42{
43 /** Constructs data. */
44 UIDataSettingsMachineInterface()
45 : m_fStatusBarEnabled(false)
46#ifndef VBOX_WS_MAC
47 , m_fMenuBarEnabled(false)
48#endif /* !VBOX_WS_MAC */
49 , m_restrictionsOfMenuBar(UIExtraDataMetaDefs::MenuType_Invalid)
50 , m_restrictionsOfMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Invalid)
51 , m_restrictionsOfMenuMachine(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid)
52 , m_restrictionsOfMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid)
53 , m_restrictionsOfMenuInput(UIExtraDataMetaDefs::RuntimeMenuInputActionType_Invalid)
54 , m_restrictionsOfMenuDevices(UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid)
55#ifdef VBOX_WITH_DEBUGGER_GUI
56 , m_restrictionsOfMenuDebug(UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Invalid)
57#endif /* VBOX_WITH_DEBUGGER_GUI */
58#ifdef VBOX_WS_MAC
59 , m_restrictionsOfMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Invalid)
60#endif /* VBOX_WS_MAC */
61 , m_restrictionsOfMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Invalid)
62#ifndef VBOX_WS_MAC
63 , m_fShowMiniToolbar(false)
64 , m_fMiniToolbarAtTop(false)
65#endif /* !VBOX_WS_MAC */
66 , m_enmVisualState(UIVisualStateType_Invalid)
67 {}
68
69 /** Returns whether the @a other passed data is equal to this one. */
70 bool equal(const UIDataSettingsMachineInterface &other) const
71 {
72 return true
73 && (m_fStatusBarEnabled == other.m_fStatusBarEnabled)
74 && (m_statusBarRestrictions == other.m_statusBarRestrictions)
75 && (m_statusBarOrder == other.m_statusBarOrder)
76#ifndef VBOX_WS_MAC
77 && (m_fMenuBarEnabled == other.m_fMenuBarEnabled)
78#endif /* !VBOX_WS_MAC */
79 && (m_restrictionsOfMenuBar == other.m_restrictionsOfMenuBar)
80 && (m_restrictionsOfMenuApplication == other.m_restrictionsOfMenuApplication)
81 && (m_restrictionsOfMenuMachine == other.m_restrictionsOfMenuMachine)
82 && (m_restrictionsOfMenuView == other.m_restrictionsOfMenuView)
83 && (m_restrictionsOfMenuInput == other.m_restrictionsOfMenuInput)
84 && (m_restrictionsOfMenuDevices == other.m_restrictionsOfMenuDevices)
85#ifdef VBOX_WITH_DEBUGGER_GUI
86 && (m_restrictionsOfMenuDebug == other.m_restrictionsOfMenuDebug)
87#endif /* VBOX_WITH_DEBUGGER_GUI */
88#ifdef VBOX_WS_MAC
89 && (m_restrictionsOfMenuWindow == other.m_restrictionsOfMenuWindow)
90#endif /* VBOX_WS_MAC */
91 && (m_restrictionsOfMenuHelp == other.m_restrictionsOfMenuHelp)
92#ifndef VBOX_WS_MAC
93 && (m_fShowMiniToolbar == other.m_fShowMiniToolbar)
94 && (m_fMiniToolbarAtTop == other.m_fMiniToolbarAtTop)
95#endif /* !VBOX_WS_MAC */
96 && (m_enmVisualState == other.m_enmVisualState)
97 ;
98 }
99
100 /** Returns whether the @a other passed data is equal to this one. */
101 bool operator==(const UIDataSettingsMachineInterface &other) const { return equal(other); }
102 /** Returns whether the @a other passed data is different from this one. */
103 bool operator!=(const UIDataSettingsMachineInterface &other) const { return !equal(other); }
104
105 /** Holds whether the status-bar is enabled. */
106 bool m_fStatusBarEnabled;
107 /** Holds the status-bar indicator restrictions. */
108 QList<IndicatorType> m_statusBarRestrictions;
109 /** Holds the status-bar indicator order. */
110 QList<IndicatorType> m_statusBarOrder;
111
112#ifndef VBOX_WS_MAC
113 /** Holds whether the menu-bar is enabled. */
114 bool m_fMenuBarEnabled;
115#endif /* !VBOX_WS_MAC */
116 /** Holds the menu-bar menu restrictions. */
117 UIExtraDataMetaDefs::MenuType m_restrictionsOfMenuBar;
118 /** Holds the Application menu restrictions. */
119 UIExtraDataMetaDefs::MenuApplicationActionType m_restrictionsOfMenuApplication;
120 /** Holds the Machine menu restrictions. */
121 UIExtraDataMetaDefs::RuntimeMenuMachineActionType m_restrictionsOfMenuMachine;
122 /** Holds the View menu restrictions. */
123 UIExtraDataMetaDefs::RuntimeMenuViewActionType m_restrictionsOfMenuView;
124 /** Holds the Input menu restrictions. */
125 UIExtraDataMetaDefs::RuntimeMenuInputActionType m_restrictionsOfMenuInput;
126 /** Holds the Devices menu restrictions. */
127 UIExtraDataMetaDefs::RuntimeMenuDevicesActionType m_restrictionsOfMenuDevices;
128#ifdef VBOX_WITH_DEBUGGER_GUI
129 /** Holds the Debug menu restrictions. */
130 UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType m_restrictionsOfMenuDebug;
131#endif /* VBOX_WITH_DEBUGGER_GUI */
132#ifdef VBOX_WS_MAC
133 /** Holds the Window menu restrictions. */
134 UIExtraDataMetaDefs::MenuWindowActionType m_restrictionsOfMenuWindow;
135#endif /* VBOX_WS_MAC */
136 /** Holds the Help menu restrictions. */
137 UIExtraDataMetaDefs::MenuHelpActionType m_restrictionsOfMenuHelp;
138
139#ifndef VBOX_WS_MAC
140 /** Holds whether the mini-toolbar is enabled. */
141 bool m_fShowMiniToolbar;
142 /** Holds whether the mini-toolbar should be aligned at top of screen. */
143 bool m_fMiniToolbarAtTop;
144#endif /* !VBOX_WS_MAC */
145
146 /** Holds the visual state. */
147 UIVisualStateType m_enmVisualState;
148};
149
150
151UIMachineSettingsInterface::UIMachineSettingsInterface(const QUuid &uMachineId)
152 : m_uMachineId(uMachineId)
153 , m_pActionPool(0)
154 , m_pCache(0)
155 , m_pEditorMenuBar(0)
156 , m_pEditorVisualState(0)
157 , m_pEditorMiniToolabSettings(0)
158 , m_pEditorStatusBar(0)
159{
160 prepare();
161}
162
163UIMachineSettingsInterface::~UIMachineSettingsInterface()
164{
165 cleanup();
166}
167
168bool UIMachineSettingsInterface::changed() const
169{
170 return m_pCache ? m_pCache->wasChanged() : false;
171}
172
173void UIMachineSettingsInterface::loadToCacheFrom(QVariant &data)
174{
175 /* Sanity check: */
176 if (!m_pCache)
177 return;
178
179 /* Fetch data to machine: */
180 UISettingsPageMachine::fetchData(data);
181
182 /* Clear cache initially: */
183 m_pCache->clear();
184
185 /* Prepare old data: */
186 UIDataSettingsMachineInterface oldInterfaceData;
187
188 /* Gather old data: */
189 oldInterfaceData.m_fStatusBarEnabled = gEDataManager->statusBarEnabled(m_machine.GetId());
190 oldInterfaceData.m_statusBarRestrictions = gEDataManager->restrictedStatusBarIndicators(m_machine.GetId());
191 oldInterfaceData.m_statusBarOrder = gEDataManager->statusBarIndicatorOrder(m_machine.GetId());
192#ifndef VBOX_WS_MAC
193 oldInterfaceData.m_fMenuBarEnabled = gEDataManager->menuBarEnabled(m_machine.GetId());
194#endif
195 oldInterfaceData.m_restrictionsOfMenuBar = gEDataManager->restrictedRuntimeMenuTypes(m_machine.GetId());
196 oldInterfaceData.m_restrictionsOfMenuApplication = gEDataManager->restrictedRuntimeMenuApplicationActionTypes(m_machine.GetId());
197 oldInterfaceData.m_restrictionsOfMenuMachine = gEDataManager->restrictedRuntimeMenuMachineActionTypes(m_machine.GetId());
198 oldInterfaceData.m_restrictionsOfMenuView = gEDataManager->restrictedRuntimeMenuViewActionTypes(m_machine.GetId());
199 oldInterfaceData.m_restrictionsOfMenuInput = gEDataManager->restrictedRuntimeMenuInputActionTypes(m_machine.GetId());
200 oldInterfaceData.m_restrictionsOfMenuDevices = gEDataManager->restrictedRuntimeMenuDevicesActionTypes(m_machine.GetId());
201#ifdef VBOX_WITH_DEBUGGER_GUI
202 oldInterfaceData.m_restrictionsOfMenuDebug = gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(m_machine.GetId());
203#endif
204#ifdef VBOX_WS_MAC
205 oldInterfaceData.m_restrictionsOfMenuWindow = gEDataManager->restrictedRuntimeMenuWindowActionTypes(m_machine.GetId());
206#endif
207 oldInterfaceData.m_restrictionsOfMenuHelp = gEDataManager->restrictedRuntimeMenuHelpActionTypes(m_machine.GetId());
208#ifndef VBOX_WS_MAC
209 oldInterfaceData.m_fShowMiniToolbar = gEDataManager->miniToolbarEnabled(m_machine.GetId());
210 oldInterfaceData.m_fMiniToolbarAtTop = gEDataManager->miniToolbarAlignment(m_machine.GetId()) == Qt::AlignTop;
211#endif
212 oldInterfaceData.m_enmVisualState = gEDataManager->requestedVisualState(m_machine.GetId());
213
214 /* Cache old data: */
215 m_pCache->cacheInitialData(oldInterfaceData);
216
217 /* Upload machine to data: */
218 UISettingsPageMachine::uploadData(data);
219}
220
221void UIMachineSettingsInterface::getFromCache()
222{
223 /* Sanity check: */
224 if (!m_pCache)
225 return;
226
227 /* Get old data from cache: */
228 const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
229
230 /* Load old data from cache: */
231 if (m_pEditorStatusBar)
232 {
233 m_pEditorStatusBar->setStatusBarEnabled(oldInterfaceData.m_fStatusBarEnabled);
234 m_pEditorStatusBar->setStatusBarConfiguration(oldInterfaceData.m_statusBarRestrictions,
235 oldInterfaceData.m_statusBarOrder);
236 }
237 if (m_pEditorMenuBar)
238 {
239#ifndef VBOX_WS_MAC
240 m_pEditorMenuBar->setMenuBarEnabled(oldInterfaceData.m_fMenuBarEnabled);
241#endif
242 m_pEditorMenuBar->setRestrictionsOfMenuBar(oldInterfaceData.m_restrictionsOfMenuBar);
243 m_pEditorMenuBar->setRestrictionsOfMenuApplication(oldInterfaceData.m_restrictionsOfMenuApplication);
244 m_pEditorMenuBar->setRestrictionsOfMenuMachine(oldInterfaceData.m_restrictionsOfMenuMachine);
245 m_pEditorMenuBar->setRestrictionsOfMenuView(oldInterfaceData.m_restrictionsOfMenuView);
246 m_pEditorMenuBar->setRestrictionsOfMenuInput(oldInterfaceData.m_restrictionsOfMenuInput);
247 m_pEditorMenuBar->setRestrictionsOfMenuDevices(oldInterfaceData.m_restrictionsOfMenuDevices);
248#ifdef VBOX_WITH_DEBUGGER_GUI
249 m_pEditorMenuBar->setRestrictionsOfMenuDebug(oldInterfaceData.m_restrictionsOfMenuDebug);
250#endif
251#ifdef VBOX_WS_MAC
252 m_pEditorMenuBar->setRestrictionsOfMenuWindow(oldInterfaceData.m_restrictionsOfMenuWindow);
253#endif
254 m_pEditorMenuBar->setRestrictionsOfMenuHelp(oldInterfaceData.m_restrictionsOfMenuHelp);
255 }
256#ifndef VBOX_WS_MAC
257 if (m_pEditorMiniToolabSettings)
258 {
259 m_pEditorMiniToolabSettings->setShowMiniToolbar(oldInterfaceData.m_fShowMiniToolbar);
260 m_pEditorMiniToolabSettings->setMiniToolbarAtTop(oldInterfaceData.m_fMiniToolbarAtTop);
261 }
262#endif
263 if (m_pEditorVisualState)
264 {
265 m_pEditorVisualState->setMachineId(m_machine.GetId());
266 m_pEditorVisualState->setValue(oldInterfaceData.m_enmVisualState);
267 }
268
269 /* Polish page finally: */
270 polishPage();
271
272 /* Revalidate: */
273 revalidate();
274}
275
276void UIMachineSettingsInterface::putToCache()
277{
278 /* Sanity check: */
279 if (!m_pCache)
280 return;
281
282 /* Prepare new data: */
283 UIDataSettingsMachineInterface newInterfaceData;
284
285 /* Cache new data: */
286 if (m_pEditorStatusBar)
287 {
288 newInterfaceData.m_fStatusBarEnabled = m_pEditorStatusBar->isStatusBarEnabled();
289 newInterfaceData.m_statusBarRestrictions = m_pEditorStatusBar->statusBarIndicatorRestrictions();
290 newInterfaceData.m_statusBarOrder = m_pEditorStatusBar->statusBarIndicatorOrder();
291 }
292 if (m_pEditorMenuBar)
293 {
294#ifndef VBOX_WS_MAC
295 newInterfaceData.m_fMenuBarEnabled = m_pEditorMenuBar->isMenuBarEnabled();
296#endif
297 newInterfaceData.m_restrictionsOfMenuBar = m_pEditorMenuBar->restrictionsOfMenuBar();
298 newInterfaceData.m_restrictionsOfMenuApplication = m_pEditorMenuBar->restrictionsOfMenuApplication();
299 newInterfaceData.m_restrictionsOfMenuMachine = m_pEditorMenuBar->restrictionsOfMenuMachine();
300 newInterfaceData.m_restrictionsOfMenuView = m_pEditorMenuBar->restrictionsOfMenuView();
301 newInterfaceData.m_restrictionsOfMenuInput = m_pEditorMenuBar->restrictionsOfMenuInput();
302 newInterfaceData.m_restrictionsOfMenuDevices = m_pEditorMenuBar->restrictionsOfMenuDevices();
303#ifdef VBOX_WITH_DEBUGGER_GUI
304 newInterfaceData.m_restrictionsOfMenuDebug = m_pEditorMenuBar->restrictionsOfMenuDebug();
305#endif
306#ifdef VBOX_WS_MAC
307 newInterfaceData.m_restrictionsOfMenuWindow = m_pEditorMenuBar->restrictionsOfMenuWindow();
308#endif
309 newInterfaceData.m_restrictionsOfMenuHelp = m_pEditorMenuBar->restrictionsOfMenuHelp();
310 }
311#ifndef VBOX_WS_MAC
312 if (m_pEditorMiniToolabSettings)
313 {
314 newInterfaceData.m_fShowMiniToolbar = m_pEditorMiniToolabSettings->showMiniToolbar();
315 newInterfaceData.m_fMiniToolbarAtTop = m_pEditorMiniToolabSettings->miniToolbarAtTop();
316 }
317#endif
318 if (m_pEditorVisualState)
319 newInterfaceData.m_enmVisualState = m_pEditorVisualState->value();
320 m_pCache->cacheCurrentData(newInterfaceData);
321}
322
323void UIMachineSettingsInterface::saveFromCacheTo(QVariant &data)
324{
325 /* Fetch data to machine: */
326 UISettingsPageMachine::fetchData(data);
327
328 /* Update data and failing state: */
329 setFailed(!saveData());
330
331 /* Upload machine to data: */
332 UISettingsPageMachine::uploadData(data);
333}
334
335void UIMachineSettingsInterface::retranslateUi()
336{
337 updateMinimumLayoutHint();
338}
339
340void UIMachineSettingsInterface::handleFilterChange()
341{
342 updateMinimumLayoutHint();
343}
344
345void UIMachineSettingsInterface::polishPage()
346{
347 /* Polish interface page availability: */
348 m_pEditorMenuBar->setEnabled(isMachineInValidMode());
349#ifdef VBOX_WS_MAC
350 m_pEditorMiniToolabSettings->hide();
351#else
352 m_pEditorMiniToolabSettings->setEnabled(isMachineInValidMode());
353#endif
354 m_pEditorStatusBar->setEnabled(isMachineInValidMode());
355}
356
357void UIMachineSettingsInterface::prepare()
358{
359 /* Prepare action-pool: */
360 m_pActionPool = UIActionPool::create(UIType_RuntimeUI);
361
362 /* Prepare cache: */
363 m_pCache = new UISettingsCacheMachineInterface;
364 AssertPtrReturnVoid(m_pCache);
365
366 /* Prepare everything: */
367 prepareWidgets();
368 prepareConnections();
369
370 /* Apply language settings: */
371 retranslateUi();
372}
373
374void UIMachineSettingsInterface::prepareWidgets()
375{
376 /* Prepare main layout: */
377 QVBoxLayout *pLayout = new QVBoxLayout(this);
378 if (pLayout)
379 {
380 /* Prepare menu-bar editor: */
381 m_pEditorMenuBar = new UIMenuBarEditorWidget(this);
382 if (m_pEditorMenuBar)
383 {
384 addEditor(m_pEditorMenuBar);
385 m_pEditorMenuBar->setActionPool(m_pActionPool);
386 m_pEditorMenuBar->setMachineID(m_uMachineId);
387
388 pLayout->addWidget(m_pEditorMenuBar);
389 }
390
391 /* Prepare visual-state editor: */
392 m_pEditorVisualState = new UIVisualStateEditor(this);
393 if (m_pEditorVisualState)
394 {
395 addEditor(m_pEditorVisualState);
396 pLayout->addWidget(m_pEditorVisualState);
397 }
398
399 /* Prepare mini-toolbar settings editor: */
400 m_pEditorMiniToolabSettings = new UIMiniToolbarSettingsEditor(this);
401 if (m_pEditorMiniToolabSettings)
402 {
403 addEditor(m_pEditorMiniToolabSettings);
404 pLayout->addWidget(m_pEditorMiniToolabSettings);
405 }
406
407 pLayout->addStretch();
408
409 /* Prepare status-bar editor: */
410 m_pEditorStatusBar = new UIStatusBarEditorWidget(this);
411 if (m_pEditorStatusBar)
412 {
413 addEditor(m_pEditorStatusBar);
414 m_pEditorStatusBar->setMachineID(m_uMachineId);
415 pLayout->addWidget(m_pEditorStatusBar);
416 }
417 }
418}
419
420void UIMachineSettingsInterface::prepareConnections()
421{
422}
423
424void UIMachineSettingsInterface::cleanup()
425{
426 /* Cleanup action-pool: */
427 UIActionPool::destroy(m_pActionPool);
428
429 /* Cleanup cache: */
430 delete m_pCache;
431 m_pCache = 0;
432}
433
434bool UIMachineSettingsInterface::saveData()
435{
436 /* Sanity check: */
437 if (!m_pCache)
438 return false;
439
440 /* Prepare result: */
441 bool fSuccess = true;
442 /* Save display settings from cache: */
443 if (fSuccess && isMachineInValidMode() && m_pCache->wasChanged())
444 {
445 /* Save 'Menu-bar' data from cache: */
446 if (fSuccess)
447 fSuccess = saveMenuBarData();
448 /* Save 'Status-bar' data from cache: */
449 if (fSuccess)
450 fSuccess = saveStatusBarData();
451 /* Save 'Mini-toolbar' data from cache: */
452 if (fSuccess)
453 fSuccess = saveMiniToolbarData();
454 /* Save 'Visual State' data from cache: */
455 if (fSuccess)
456 fSuccess = saveVisualStateData();
457 }
458 /* Return result: */
459 return fSuccess;
460}
461
462bool UIMachineSettingsInterface::saveMenuBarData()
463{
464 /* Sanity check: */
465 if (!m_pCache)
466 return false;
467
468 /* Prepare result: */
469 bool fSuccess = true;
470 /* Save 'Menu-bar' data from cache: */
471 if (fSuccess)
472 {
473 /* Get old data from cache: */
474 const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
475 /* Get new data from cache: */
476 const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data();
477
478#ifndef VBOX_WS_MAC
479 /* Save whether menu-bar is enabled: */
480 if (fSuccess && newInterfaceData.m_fMenuBarEnabled != oldInterfaceData.m_fMenuBarEnabled)
481 /* fSuccess = */ gEDataManager->setMenuBarEnabled(newInterfaceData.m_fMenuBarEnabled, m_machine.GetId());
482#endif
483 /* Save menu-bar restrictions: */
484 if (fSuccess && newInterfaceData.m_restrictionsOfMenuBar != oldInterfaceData.m_restrictionsOfMenuBar)
485 /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuTypes(newInterfaceData.m_restrictionsOfMenuBar, m_machine.GetId());
486 /* Save menu-bar Application menu restrictions: */
487 if (fSuccess && newInterfaceData.m_restrictionsOfMenuApplication != oldInterfaceData.m_restrictionsOfMenuApplication)
488 /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuApplicationActionTypes(newInterfaceData.m_restrictionsOfMenuApplication, m_machine.GetId());
489 /* Save menu-bar Machine menu restrictions: */
490 if (fSuccess && newInterfaceData.m_restrictionsOfMenuMachine != oldInterfaceData.m_restrictionsOfMenuMachine)
491 /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuMachineActionTypes(newInterfaceData.m_restrictionsOfMenuMachine, m_machine.GetId());
492 /* Save menu-bar View menu restrictions: */
493 if (fSuccess && newInterfaceData.m_restrictionsOfMenuView != oldInterfaceData.m_restrictionsOfMenuView)
494 /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuViewActionTypes(newInterfaceData.m_restrictionsOfMenuView, m_machine.GetId());
495 /* Save menu-bar Input menu restrictions: */
496 if (fSuccess && newInterfaceData.m_restrictionsOfMenuInput != oldInterfaceData.m_restrictionsOfMenuInput)
497 /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuInputActionTypes(newInterfaceData.m_restrictionsOfMenuInput, m_machine.GetId());
498 /* Save menu-bar Devices menu restrictions: */
499 if (fSuccess && newInterfaceData.m_restrictionsOfMenuDevices != oldInterfaceData.m_restrictionsOfMenuDevices)
500 /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuDevicesActionTypes(newInterfaceData.m_restrictionsOfMenuDevices, m_machine.GetId());
501#ifdef VBOX_WITH_DEBUGGER_GUI
502 /* Save menu-bar Debug menu restrictions: */
503 if (fSuccess && newInterfaceData.m_restrictionsOfMenuDebug != oldInterfaceData.m_restrictionsOfMenuDebug)
504 /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuDebuggerActionTypes(newInterfaceData.m_restrictionsOfMenuDebug, m_machine.GetId());
505#endif
506#ifdef VBOX_WS_MAC
507 /* Save menu-bar Window menu restrictions: */
508 if (fSuccess && newInterfaceData.m_restrictionsOfMenuWindow != oldInterfaceData.m_restrictionsOfMenuWindow)
509 /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuWindowActionTypes(newInterfaceData.m_restrictionsOfMenuWindow, m_machine.GetId());
510#endif
511 /* Save menu-bar Help menu restrictions: */
512 if (fSuccess && newInterfaceData.m_restrictionsOfMenuHelp != oldInterfaceData.m_restrictionsOfMenuHelp)
513 /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuHelpActionTypes(newInterfaceData.m_restrictionsOfMenuHelp, m_machine.GetId());
514 }
515 /* Return result: */
516 return fSuccess;
517}
518
519bool UIMachineSettingsInterface::saveStatusBarData()
520{
521 /* Sanity check: */
522 if (!m_pCache)
523 return false;
524
525 /* Prepare result: */
526 bool fSuccess = true;
527 /* Save 'Status-bar' data from cache: */
528 if (fSuccess)
529 {
530 /* Get old data from cache: */
531 const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
532 /* Get new data from cache: */
533 const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data();
534
535 /* Save whether status-bar is enabled: */
536 if (fSuccess && newInterfaceData.m_fStatusBarEnabled != oldInterfaceData.m_fStatusBarEnabled)
537 /* fSuccess = */ gEDataManager->setStatusBarEnabled(newInterfaceData.m_fStatusBarEnabled, m_machine.GetId());
538 /* Save status-bar restrictions: */
539 if (fSuccess && newInterfaceData.m_statusBarRestrictions != oldInterfaceData.m_statusBarRestrictions)
540 /* fSuccess = */ gEDataManager->setRestrictedStatusBarIndicators(newInterfaceData.m_statusBarRestrictions, m_machine.GetId());
541 /* Save status-bar order: */
542 if (fSuccess && newInterfaceData.m_statusBarOrder != oldInterfaceData.m_statusBarOrder)
543 /* fSuccess = */ gEDataManager->setStatusBarIndicatorOrder(newInterfaceData.m_statusBarOrder, m_machine.GetId());
544 }
545 /* Return result: */
546 return fSuccess;
547}
548
549bool UIMachineSettingsInterface::saveMiniToolbarData()
550{
551 /* Sanity check: */
552 if (!m_pCache)
553 return false;
554
555 /* Prepare result: */
556 bool fSuccess = true;
557 /* Save 'Mini-toolbar' data from cache: */
558 if (fSuccess)
559 {
560 /* Get old data from cache: */
561 const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base(); Q_UNUSED(oldInterfaceData);
562 /* Get new data from cache: */
563 const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data(); Q_UNUSED(newInterfaceData);
564
565#ifndef VBOX_WS_MAC
566 /* Save whether mini-toolbar is enabled: */
567 if (fSuccess && newInterfaceData.m_fShowMiniToolbar != oldInterfaceData.m_fShowMiniToolbar)
568 /* fSuccess = */ gEDataManager->setMiniToolbarEnabled(newInterfaceData.m_fShowMiniToolbar, m_machine.GetId());
569 /* Save whether mini-toolbar should be location at top of screen: */
570 if (fSuccess && newInterfaceData.m_fMiniToolbarAtTop != oldInterfaceData.m_fMiniToolbarAtTop)
571 /* fSuccess = */ gEDataManager->setMiniToolbarAlignment(newInterfaceData.m_fMiniToolbarAtTop ? Qt::AlignTop : Qt::AlignBottom, m_machine.GetId());
572#endif
573 }
574 /* Return result: */
575 return fSuccess;
576}
577
578bool UIMachineSettingsInterface::saveVisualStateData()
579{
580 /* Sanity check: */
581 if (!m_pCache)
582 return false;
583
584 /* Prepare result: */
585 bool fSuccess = true;
586 /* Save 'Visual State' data from cache: */
587 if (fSuccess)
588 {
589 /* Get old data from cache: */
590 const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
591 /* Get new data from cache: */
592 const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data();
593
594 /* Save desired visual state: */
595 if (fSuccess && newInterfaceData.m_enmVisualState != oldInterfaceData.m_enmVisualState)
596 /* fSuccess = */ gEDataManager->setRequestedVisualState(newInterfaceData.m_enmVisualState, m_machine.GetId());
597 }
598 /* Return result: */
599 return fSuccess;
600}
601
602void UIMachineSettingsInterface::updateMinimumLayoutHint()
603{
604 /* These editors have own labels, but we want them to be properly layouted according to each other: */
605 int iMinimumLayoutHint = 0;
606 if (m_pEditorVisualState && !m_pEditorVisualState->isHidden())
607 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorVisualState->minimumLabelHorizontalHint());
608 if (m_pEditorMiniToolabSettings && !m_pEditorMiniToolabSettings->isHidden())
609 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorMiniToolabSettings->minimumLabelHorizontalHint());
610 if (m_pEditorVisualState)
611 m_pEditorVisualState->setMinimumLayoutIndent(iMinimumLayoutHint);
612 if (m_pEditorMiniToolabSettings)
613 m_pEditorMiniToolabSettings->setMinimumLayoutIndent(iMinimumLayoutHint);
614}
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