1 | /* $Id: UIMenuBarEditorWindow.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIMenuBarEditorWindow class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2014-2019 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 | # include <QAccessibleWidget>
|
---|
24 | # include <QHBoxLayout>
|
---|
25 | # include <QMenu>
|
---|
26 | # include <QMenuBar>
|
---|
27 | # include <QMetaEnum>
|
---|
28 | # include <QPainter>
|
---|
29 | # include <QPaintEvent>
|
---|
30 | # include <QStyleOptionToolButton>
|
---|
31 | # ifndef VBOX_WS_MAC
|
---|
32 | # include <QCheckBox>
|
---|
33 | # endif
|
---|
34 |
|
---|
35 | /* GUI includes: */
|
---|
36 | # include "QIToolButton.h"
|
---|
37 | # include "VBoxGlobal.h"
|
---|
38 | # include "UIActionPoolRuntime.h"
|
---|
39 | # include "UIConverter.h"
|
---|
40 | # include "UIExtraDataManager.h"
|
---|
41 | # include "UIIconPool.h"
|
---|
42 | # include "UIMachineWindow.h"
|
---|
43 | # include "UIMenuBarEditorWindow.h"
|
---|
44 | # include "UIToolBar.h"
|
---|
45 |
|
---|
46 | #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
47 |
|
---|
48 | /* Forward declarations: */
|
---|
49 | class QAccessibleInterface;
|
---|
50 | class QRect;
|
---|
51 | class UIAccessibilityInterfaceForUIMenuBarEditorButton;
|
---|
52 |
|
---|
53 |
|
---|
54 | /** Menu-bar editor button segment types. */
|
---|
55 | enum UIMenuBarEditorSegment
|
---|
56 | {
|
---|
57 | UIMenuBarEditorSegment_Button,
|
---|
58 | UIMenuBarEditorSegment_Menu,
|
---|
59 | UIMenuBarEditorSegment_Max,
|
---|
60 | };
|
---|
61 |
|
---|
62 |
|
---|
63 | /** QAccessibleWidget extension used as an accessibility interface for UIMenuBarEditor button segments. */
|
---|
64 | class UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment : public QAccessibleInterface
|
---|
65 | {
|
---|
66 | public:
|
---|
67 |
|
---|
68 | /** Constructs an accessibility interface.
|
---|
69 | * @param pParent Brings the parent interface we are linked to.
|
---|
70 | * @param enmIndex Brings the index of segment we are referring to. */
|
---|
71 | UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment(UIAccessibilityInterfaceForUIMenuBarEditorButton *pParent,
|
---|
72 | UIMenuBarEditorSegment enmIndex);
|
---|
73 |
|
---|
74 | /** Returns whether the interface is valid. */
|
---|
75 | virtual bool isValid() const /* override */ { return true; }
|
---|
76 |
|
---|
77 | /** Returns the wrapped object. */
|
---|
78 | virtual QObject *object() const /* override */ { return 0; }
|
---|
79 | /** Returns the parent. */
|
---|
80 | virtual QAccessibleInterface *parent() const /* override */;
|
---|
81 |
|
---|
82 | /** Returns the number of children. */
|
---|
83 | virtual int childCount() const /* override */ { return 0; }
|
---|
84 | /** Returns the child with the passed @a iIndex. */
|
---|
85 | virtual QAccessibleInterface *child(int /* iIndex */) const /* override */ { return 0; }
|
---|
86 | /** Returns the child at position QPoint(@a x, @a y). */
|
---|
87 | virtual QAccessibleInterface *childAt(int /* x */, int /* y */) const /* override */ { return 0; }
|
---|
88 | /** Returns the index of the passed @a pChild. */
|
---|
89 | virtual int indexOfChild(const QAccessibleInterface * /* pChild */) const /* override */ { return -1; }
|
---|
90 |
|
---|
91 | /** Returns the rect. */
|
---|
92 | virtual QRect rect() const /* override */;
|
---|
93 |
|
---|
94 | /** Defines a @a strText for the passed @a enmTextRole. */
|
---|
95 | virtual void setText(QAccessible::Text /* enmTextRole */, const QString & /* strText */) /* override */ {}
|
---|
96 | /** Returns a text for the passed @a enmTextRole. */
|
---|
97 | virtual QString text(QAccessible::Text /* enmTextRole */) const /* override */;
|
---|
98 |
|
---|
99 | /** Returns the role. */
|
---|
100 | virtual QAccessible::Role role() const /* override */ { return QAccessible::Button; }
|
---|
101 | /** Returns the state. */
|
---|
102 | virtual QAccessible::State state() const /* override */ { return QAccessible::State(); }
|
---|
103 |
|
---|
104 | private:
|
---|
105 |
|
---|
106 | /** Holds the parent interface we are linked to. */
|
---|
107 | UIAccessibilityInterfaceForUIMenuBarEditorButton *m_pParent;
|
---|
108 |
|
---|
109 | /** Holds the index of segment we are referring to. */
|
---|
110 | const UIMenuBarEditorSegment m_enmIndex;
|
---|
111 | };
|
---|
112 |
|
---|
113 |
|
---|
114 | /** QAccessibleWidget extension used as an accessibility interface for UIMenuBarEditor buttons. */
|
---|
115 | class UIAccessibilityInterfaceForUIMenuBarEditorButton : public QAccessibleWidget
|
---|
116 | {
|
---|
117 | public:
|
---|
118 |
|
---|
119 | /** Returns an accessibility interface for passed @a strClassname and @a pObject. */
|
---|
120 | static QAccessibleInterface *pFactory(const QString &strClassname, QObject *pObject);
|
---|
121 |
|
---|
122 | /** Constructs an accessibility interface passing @a pWidget to the base-class. */
|
---|
123 | UIAccessibilityInterfaceForUIMenuBarEditorButton(QWidget *pWidget);
|
---|
124 | /** Destructs an accessibility interface. */
|
---|
125 | ~UIAccessibilityInterfaceForUIMenuBarEditorButton();
|
---|
126 |
|
---|
127 | /** Returns the number of children. */
|
---|
128 | virtual int childCount() const /* override */;
|
---|
129 | /** Returns the child with the passed @a iIndex. */
|
---|
130 | virtual QAccessibleInterface *child(int iIndex) const /* override */;
|
---|
131 |
|
---|
132 | /** Returns the role. */
|
---|
133 | virtual QAccessible::Role role() const /* override */;
|
---|
134 |
|
---|
135 | /** Returns the rect of sub-element @a enmSegment. */
|
---|
136 | QRect subRect(UIMenuBarEditorSegment enmSegment) const;
|
---|
137 | /** Returns the text of sub-element @a enmSegment. */
|
---|
138 | QString subText(UIMenuBarEditorSegment enmSegment) const;
|
---|
139 |
|
---|
140 | private:
|
---|
141 |
|
---|
142 | /** Returns corresponding toolbar button. */
|
---|
143 | QToolButton *button() const { return qobject_cast<QToolButton*>(widget()); }
|
---|
144 |
|
---|
145 | /** Holds the map of instances of sub-element interfaces. */
|
---|
146 | QMap<UIMenuBarEditorSegment, UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment*> m_elements;
|
---|
147 | };
|
---|
148 |
|
---|
149 |
|
---|
150 | /*********************************************************************************************************************************
|
---|
151 | * Class UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment implementation. *
|
---|
152 | *********************************************************************************************************************************/
|
---|
153 |
|
---|
154 | UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment::UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment(
|
---|
155 | UIAccessibilityInterfaceForUIMenuBarEditorButton *pParent,
|
---|
156 | UIMenuBarEditorSegment enmIndex)
|
---|
157 | : m_pParent(pParent)
|
---|
158 | , m_enmIndex(enmIndex)
|
---|
159 | {
|
---|
160 | }
|
---|
161 |
|
---|
162 | QAccessibleInterface *UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment::parent() const
|
---|
163 | {
|
---|
164 | return m_pParent;
|
---|
165 | }
|
---|
166 |
|
---|
167 | QRect UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment::rect() const
|
---|
168 | {
|
---|
169 | return m_pParent->subRect(m_enmIndex);
|
---|
170 | }
|
---|
171 |
|
---|
172 | QString UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment::text(QAccessible::Text) const
|
---|
173 | {
|
---|
174 | return m_pParent->subText(m_enmIndex);
|
---|
175 | }
|
---|
176 |
|
---|
177 |
|
---|
178 | /*********************************************************************************************************************************
|
---|
179 | * Class UIAccessibilityInterfaceForUIMenuBarEditorButton implementation. *
|
---|
180 | *********************************************************************************************************************************/
|
---|
181 |
|
---|
182 | /* static */
|
---|
183 | QAccessibleInterface *UIAccessibilityInterfaceForUIMenuBarEditorButton::pFactory(const QString &strClassname, QObject *pObject)
|
---|
184 | {
|
---|
185 | /* Creating toolbar button accessibility interface: */
|
---|
186 | if ( pObject
|
---|
187 | && strClassname == QLatin1String("QToolButton")
|
---|
188 | && pObject->property("Belongs to") == "UIMenuBarEditorWidget")
|
---|
189 | return new UIAccessibilityInterfaceForUIMenuBarEditorButton(qobject_cast<QWidget*>(pObject));
|
---|
190 |
|
---|
191 | /* Null by default: */
|
---|
192 | return 0;
|
---|
193 | }
|
---|
194 |
|
---|
195 | UIAccessibilityInterfaceForUIMenuBarEditorButton::UIAccessibilityInterfaceForUIMenuBarEditorButton(QWidget *pWidget)
|
---|
196 | : QAccessibleWidget(pWidget, QAccessible::Button)
|
---|
197 | {
|
---|
198 | /* Prepare button with popup menu: */
|
---|
199 | if (button()->popupMode() == QToolButton::MenuButtonPopup)
|
---|
200 | {
|
---|
201 | for (int iIndex = 0; iIndex < (int)UIMenuBarEditorSegment_Max; ++iIndex)
|
---|
202 | m_elements[(UIMenuBarEditorSegment)iIndex] =
|
---|
203 | new UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment(this, (UIMenuBarEditorSegment)iIndex);
|
---|
204 | }
|
---|
205 | }
|
---|
206 |
|
---|
207 | UIAccessibilityInterfaceForUIMenuBarEditorButton::~UIAccessibilityInterfaceForUIMenuBarEditorButton()
|
---|
208 | {
|
---|
209 | /* Cleanup button with popup menu: */
|
---|
210 | qDeleteAll(m_elements);
|
---|
211 | m_elements.clear();
|
---|
212 | }
|
---|
213 |
|
---|
214 | int UIAccessibilityInterfaceForUIMenuBarEditorButton::childCount() const
|
---|
215 | {
|
---|
216 | /* Sanity check: */
|
---|
217 | AssertPtrReturn(button(), 0);
|
---|
218 |
|
---|
219 | /* Return child count for a button with popup menu: */
|
---|
220 | if (button()->popupMode() == QToolButton::MenuButtonPopup)
|
---|
221 | return UIMenuBarEditorSegment_Max;
|
---|
222 |
|
---|
223 | /* Call to base-class: */
|
---|
224 | return QAccessibleWidget::childCount();
|
---|
225 | }
|
---|
226 |
|
---|
227 | QAccessibleInterface *UIAccessibilityInterfaceForUIMenuBarEditorButton::child(int iIndex) const
|
---|
228 | {
|
---|
229 | /* Sanity check: */
|
---|
230 | AssertPtrReturn(button(), 0);
|
---|
231 | AssertReturn(iIndex >= 0 && iIndex < childCount(), 0);
|
---|
232 |
|
---|
233 | /* Return the child with the passed iIndex for a button with popup menu: */
|
---|
234 | if (button()->popupMode() == QToolButton::MenuButtonPopup)
|
---|
235 | return m_elements.value((UIMenuBarEditorSegment)iIndex);
|
---|
236 |
|
---|
237 | /* Call to base-class: */
|
---|
238 | return QAccessibleWidget::child(iIndex);
|
---|
239 | }
|
---|
240 |
|
---|
241 | QAccessible::Role UIAccessibilityInterfaceForUIMenuBarEditorButton::role() const
|
---|
242 | {
|
---|
243 | /* Sanity check: */
|
---|
244 | AssertPtrReturn(button(), QAccessibleWidget::role());
|
---|
245 |
|
---|
246 | /* Return role for button with popup menu: */
|
---|
247 | if (button()->popupMode() == QToolButton::MenuButtonPopup)
|
---|
248 | return QAccessible::ToolBar;
|
---|
249 |
|
---|
250 | /* Call to base-class: */
|
---|
251 | return QAccessibleWidget::role();
|
---|
252 | }
|
---|
253 |
|
---|
254 | QRect UIAccessibilityInterfaceForUIMenuBarEditorButton::subRect(UIMenuBarEditorSegment enmSegment) const
|
---|
255 | {
|
---|
256 | /* Sanity check: */
|
---|
257 | AssertReturn(button()->popupMode() == QToolButton::MenuButtonPopup, QRect());
|
---|
258 |
|
---|
259 | /* Return the rect of segment with the passed enmIndex for a button with popup menu: */
|
---|
260 | switch (enmSegment)
|
---|
261 | {
|
---|
262 | case UIMenuBarEditorSegment_Button:
|
---|
263 | {
|
---|
264 | QStyleOptionToolButton options;
|
---|
265 | options.initFrom(button());
|
---|
266 | options.features |= QStyleOptionToolButton::MenuButtonPopup;
|
---|
267 | QRect rect = button()->style()->subControlRect(QStyle::CC_ToolButton, &options, QStyle::SC_ToolButton);
|
---|
268 | rect.moveTo(button()->mapToGlobal(rect.topLeft()));
|
---|
269 | return rect;
|
---|
270 | }
|
---|
271 | case UIMenuBarEditorSegment_Menu:
|
---|
272 | {
|
---|
273 | QStyleOptionToolButton options;
|
---|
274 | options.initFrom(button());
|
---|
275 | options.features |= QStyleOptionToolButton::MenuButtonPopup;
|
---|
276 | QRect rect = button()->style()->subControlRect(QStyle::CC_ToolButton, &options, QStyle::SC_ToolButtonMenu);
|
---|
277 | rect.moveTo(button()->mapToGlobal(rect.topLeft()));
|
---|
278 | return rect;
|
---|
279 | }
|
---|
280 | default:
|
---|
281 | break;
|
---|
282 | }
|
---|
283 |
|
---|
284 | /* Null rect by default: */
|
---|
285 | return QRect();
|
---|
286 | }
|
---|
287 |
|
---|
288 | QString UIAccessibilityInterfaceForUIMenuBarEditorButton::subText(UIMenuBarEditorSegment enmSegment) const
|
---|
289 | {
|
---|
290 | /* Sanity check: */
|
---|
291 | AssertReturn(button()->popupMode() == QToolButton::MenuButtonPopup, QString());
|
---|
292 |
|
---|
293 | /* Return the text of segment with the passed enmIndex for a button with popup menu: */
|
---|
294 | switch (enmSegment)
|
---|
295 | {
|
---|
296 | case UIMenuBarEditorSegment_Button:
|
---|
297 | return UIMenuBarEditorWidget::tr("Toggle menu %1").arg(QAccessibleWidget::text(QAccessible::Description));
|
---|
298 | case UIMenuBarEditorSegment_Menu:
|
---|
299 | return UIMenuBarEditorWidget::tr("Popup menu %1").arg(QAccessibleWidget::text(QAccessible::Description));
|
---|
300 | default:
|
---|
301 | break;
|
---|
302 | }
|
---|
303 |
|
---|
304 | /* Null string by default: */
|
---|
305 | return QString();
|
---|
306 | }
|
---|
307 |
|
---|
308 |
|
---|
309 | /*********************************************************************************************************************************
|
---|
310 | * Class UIMenuBarEditorWindow implementation. *
|
---|
311 | *********************************************************************************************************************************/
|
---|
312 |
|
---|
313 | UIMenuBarEditorWindow::UIMenuBarEditorWindow(UIMachineWindow *pParent, UIActionPool *pActionPool)
|
---|
314 | #ifndef VBOX_WS_MAC
|
---|
315 | : UISlidingToolBar(pParent, pParent->menuBar(), new UIMenuBarEditorWidget(0, false, vboxGlobal().managedVMUuid(), pActionPool), UISlidingToolBar::Position_Top)
|
---|
316 | #else
|
---|
317 | : UISlidingToolBar(pParent, 0, new UIMenuBarEditorWidget(0, false, vboxGlobal().managedVMUuid(), pActionPool), UISlidingToolBar::Position_Top)
|
---|
318 | #endif
|
---|
319 | {
|
---|
320 | }
|
---|
321 |
|
---|
322 |
|
---|
323 | /*********************************************************************************************************************************
|
---|
324 | * Class UIMenuBarEditorWidget implementation. *
|
---|
325 | *********************************************************************************************************************************/
|
---|
326 |
|
---|
327 | UIMenuBarEditorWidget::UIMenuBarEditorWidget(QWidget *pParent,
|
---|
328 | bool fStartedFromVMSettings /* = true */,
|
---|
329 | const QUuid &uMachineID /* = QUuid() */,
|
---|
330 | UIActionPool *pActionPool /* = 0 */)
|
---|
331 | : QIWithRetranslateUI2<QWidget>(pParent)
|
---|
332 | , m_fPrepared(false)
|
---|
333 | , m_fStartedFromVMSettings(fStartedFromVMSettings)
|
---|
334 | , m_uMachineID(uMachineID)
|
---|
335 | , m_pActionPool(pActionPool)
|
---|
336 | , m_pMainLayout(0)
|
---|
337 | , m_pToolBar(0)
|
---|
338 | , m_pButtonClose(0)
|
---|
339 | #ifndef VBOX_WS_MAC
|
---|
340 | , m_pCheckBoxEnable(0)
|
---|
341 | #endif
|
---|
342 | , m_restrictionsOfMenuBar(UIExtraDataMetaDefs::MenuType_Invalid)
|
---|
343 | , m_restrictionsOfMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Invalid)
|
---|
344 | , m_restrictionsOfMenuMachine(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid)
|
---|
345 | , m_restrictionsOfMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid)
|
---|
346 | , m_restrictionsOfMenuInput(UIExtraDataMetaDefs::RuntimeMenuInputActionType_Invalid)
|
---|
347 | , m_restrictionsOfMenuDevices(UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid)
|
---|
348 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
349 | , m_restrictionsOfMenuDebug(UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Invalid)
|
---|
350 | #endif
|
---|
351 | #ifdef VBOX_WS_MAC
|
---|
352 | , m_restrictionsOfMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Invalid)
|
---|
353 | #endif
|
---|
354 | , m_restrictionsOfMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Invalid)
|
---|
355 |
|
---|
356 | {
|
---|
357 | /* Prepare: */
|
---|
358 | prepare();
|
---|
359 | }
|
---|
360 |
|
---|
361 | void UIMenuBarEditorWidget::setMachineID(const QUuid &uMachineID)
|
---|
362 | {
|
---|
363 | /* Remember new machine ID: */
|
---|
364 | m_uMachineID = uMachineID;
|
---|
365 | /* Prepare: */
|
---|
366 | prepare();
|
---|
367 | }
|
---|
368 |
|
---|
369 | void UIMenuBarEditorWidget::setActionPool(UIActionPool *pActionPool)
|
---|
370 | {
|
---|
371 | /* Remember new action-pool: */
|
---|
372 | m_pActionPool = pActionPool;
|
---|
373 | /* Prepare: */
|
---|
374 | prepare();
|
---|
375 | }
|
---|
376 |
|
---|
377 | #ifndef VBOX_WS_MAC
|
---|
378 | bool UIMenuBarEditorWidget::isMenuBarEnabled() const
|
---|
379 | {
|
---|
380 | /* For VM settings only: */
|
---|
381 | AssertReturn(m_fStartedFromVMSettings, false);
|
---|
382 |
|
---|
383 | /* Acquire enable-checkbox if possible: */
|
---|
384 | AssertPtrReturn(m_pCheckBoxEnable, false);
|
---|
385 | return m_pCheckBoxEnable->isChecked();
|
---|
386 | }
|
---|
387 |
|
---|
388 | void UIMenuBarEditorWidget::setMenuBarEnabled(bool fEnabled)
|
---|
389 | {
|
---|
390 | /* For VM settings only: */
|
---|
391 | AssertReturnVoid(m_fStartedFromVMSettings);
|
---|
392 |
|
---|
393 | /* Update enable-checkbox if possible: */
|
---|
394 | AssertPtrReturnVoid(m_pCheckBoxEnable);
|
---|
395 | m_pCheckBoxEnable->setChecked(fEnabled);
|
---|
396 | }
|
---|
397 | #endif /* !VBOX_WS_MAC */
|
---|
398 |
|
---|
399 | void UIMenuBarEditorWidget::setRestrictionsOfMenuBar(UIExtraDataMetaDefs::MenuType restrictions)
|
---|
400 | {
|
---|
401 | /* Cache passed restrictions: */
|
---|
402 | m_restrictionsOfMenuBar = restrictions;
|
---|
403 | /* Get static meta-object: */
|
---|
404 | const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
|
---|
405 |
|
---|
406 | /* We have UIExtraDataMetaDefs::MenuType enum registered, so we can enumerate it: */
|
---|
407 | const int iEnumIndex = smo.indexOfEnumerator("MenuType");
|
---|
408 | const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
|
---|
409 | /* Handle other enum-values: */
|
---|
410 | for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
|
---|
411 | {
|
---|
412 | /* Get iterated enum-value: */
|
---|
413 | const UIExtraDataMetaDefs::MenuType enumValue =
|
---|
414 | static_cast<UIExtraDataMetaDefs::MenuType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
|
---|
415 | /* Skip MenuType_Invalid & MenuType_All enum-value: */
|
---|
416 | if (enumValue == UIExtraDataMetaDefs::MenuType_Invalid ||
|
---|
417 | enumValue == UIExtraDataMetaDefs::MenuType_All)
|
---|
418 | continue;
|
---|
419 | /* Which key required action registered under? */
|
---|
420 | const QString strKey = gpConverter->toInternalString(enumValue);
|
---|
421 | if (!m_actions.contains(strKey))
|
---|
422 | continue;
|
---|
423 | /* Update action 'checked' state: */
|
---|
424 | m_actions.value(strKey)->setChecked(!(m_restrictionsOfMenuBar & enumValue));
|
---|
425 | }
|
---|
426 | }
|
---|
427 |
|
---|
428 | void UIMenuBarEditorWidget::setRestrictionsOfMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType restrictions)
|
---|
429 | {
|
---|
430 | /* Cache passed restrictions: */
|
---|
431 | m_restrictionsOfMenuApplication = restrictions;
|
---|
432 | /* Get static meta-object: */
|
---|
433 | const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
|
---|
434 |
|
---|
435 | /* We have UIExtraDataMetaDefs::MenuApplicationActionType enum registered, so we can enumerate it: */
|
---|
436 | const int iEnumIndex = smo.indexOfEnumerator("MenuApplicationActionType");
|
---|
437 | QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
|
---|
438 | /* Handle other enum-values: */
|
---|
439 | for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
|
---|
440 | {
|
---|
441 | /* Get iterated enum-value: */
|
---|
442 | const UIExtraDataMetaDefs::MenuApplicationActionType enumValue =
|
---|
443 | static_cast<UIExtraDataMetaDefs::MenuApplicationActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
|
---|
444 | /* Skip MenuApplicationActionType_Invalid & MenuApplicationActionType_All enum-value: */
|
---|
445 | if (enumValue == UIExtraDataMetaDefs::MenuApplicationActionType_Invalid ||
|
---|
446 | enumValue == UIExtraDataMetaDefs::MenuApplicationActionType_All)
|
---|
447 | continue;
|
---|
448 | /* Which key required action registered under? */
|
---|
449 | const QString strKey = gpConverter->toInternalString(enumValue);
|
---|
450 | if (!m_actions.contains(strKey))
|
---|
451 | continue;
|
---|
452 | /* Update action 'checked' state: */
|
---|
453 | m_actions.value(strKey)->setChecked(!(m_restrictionsOfMenuApplication & enumValue));
|
---|
454 | }
|
---|
455 | }
|
---|
456 |
|
---|
457 | void UIMenuBarEditorWidget::setRestrictionsOfMenuMachine(UIExtraDataMetaDefs::RuntimeMenuMachineActionType restrictions)
|
---|
458 | {
|
---|
459 | /* Cache passed restrictions: */
|
---|
460 | m_restrictionsOfMenuMachine = restrictions;
|
---|
461 | /* Get static meta-object: */
|
---|
462 | const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
|
---|
463 |
|
---|
464 | /* We have UIExtraDataMetaDefs::RuntimeMenuMachineActionType enum registered, so we can enumerate it: */
|
---|
465 | const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuMachineActionType");
|
---|
466 | QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
|
---|
467 | /* Handle other enum-values: */
|
---|
468 | for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
|
---|
469 | {
|
---|
470 | /* Get iterated enum-value: */
|
---|
471 | const UIExtraDataMetaDefs::RuntimeMenuMachineActionType enumValue =
|
---|
472 | static_cast<UIExtraDataMetaDefs::RuntimeMenuMachineActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
|
---|
473 | /* Skip RuntimeMenuMachineActionType_Invalid & RuntimeMenuMachineActionType_All enum-value: */
|
---|
474 | if (enumValue == UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid ||
|
---|
475 | enumValue == UIExtraDataMetaDefs::RuntimeMenuMachineActionType_All)
|
---|
476 | continue;
|
---|
477 | /* Which key required action registered under? */
|
---|
478 | const QString strKey = gpConverter->toInternalString(enumValue);
|
---|
479 | if (!m_actions.contains(strKey))
|
---|
480 | continue;
|
---|
481 | /* Update action 'checked' state: */
|
---|
482 | m_actions.value(strKey)->setChecked(!(m_restrictionsOfMenuMachine & enumValue));
|
---|
483 | }
|
---|
484 | }
|
---|
485 |
|
---|
486 | void UIMenuBarEditorWidget::setRestrictionsOfMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictions)
|
---|
487 | {
|
---|
488 | /* Cache passed restrictions: */
|
---|
489 | m_restrictionsOfMenuView = restrictions;
|
---|
490 | /* Get static meta-object: */
|
---|
491 | const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
|
---|
492 |
|
---|
493 | /* We have UIExtraDataMetaDefs::RuntimeMenuViewActionType enum registered, so we can enumerate it: */
|
---|
494 | const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuViewActionType");
|
---|
495 | QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
|
---|
496 | /* Handle other enum-values: */
|
---|
497 | for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
|
---|
498 | {
|
---|
499 | /* Get iterated enum-value: */
|
---|
500 | const UIExtraDataMetaDefs::RuntimeMenuViewActionType enumValue =
|
---|
501 | static_cast<UIExtraDataMetaDefs::RuntimeMenuViewActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
|
---|
502 | /* Skip RuntimeMenuViewActionType_Invalid & RuntimeMenuViewActionType_All enum-value: */
|
---|
503 | if (enumValue == UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid ||
|
---|
504 | enumValue == UIExtraDataMetaDefs::RuntimeMenuViewActionType_All)
|
---|
505 | continue;
|
---|
506 | /* Which key required action registered under? */
|
---|
507 | const QString strKey = gpConverter->toInternalString(enumValue);
|
---|
508 | if (!m_actions.contains(strKey))
|
---|
509 | continue;
|
---|
510 | /* Update action 'checked' state: */
|
---|
511 | m_actions.value(strKey)->setChecked(!(m_restrictionsOfMenuView & enumValue));
|
---|
512 | }
|
---|
513 | }
|
---|
514 |
|
---|
515 | void UIMenuBarEditorWidget::setRestrictionsOfMenuInput(UIExtraDataMetaDefs::RuntimeMenuInputActionType restrictions)
|
---|
516 | {
|
---|
517 | /* Cache passed restrictions: */
|
---|
518 | m_restrictionsOfMenuInput = restrictions;
|
---|
519 | /* Get static meta-object: */
|
---|
520 | const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
|
---|
521 |
|
---|
522 | /* We have UIExtraDataMetaDefs::RuntimeMenuInputActionType enum registered, so we can enumerate it: */
|
---|
523 | const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuInputActionType");
|
---|
524 | QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
|
---|
525 | /* Handle other enum-values: */
|
---|
526 | for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
|
---|
527 | {
|
---|
528 | /* Get iterated enum-value: */
|
---|
529 | const UIExtraDataMetaDefs::RuntimeMenuInputActionType enumValue =
|
---|
530 | static_cast<UIExtraDataMetaDefs::RuntimeMenuInputActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
|
---|
531 | /* Skip RuntimeMenuInputActionType_Invalid & RuntimeMenuInputActionType_All enum-value: */
|
---|
532 | if (enumValue == UIExtraDataMetaDefs::RuntimeMenuInputActionType_Invalid ||
|
---|
533 | enumValue == UIExtraDataMetaDefs::RuntimeMenuInputActionType_All)
|
---|
534 | continue;
|
---|
535 | /* Which key required action registered under? */
|
---|
536 | const QString strKey = gpConverter->toInternalString(enumValue);
|
---|
537 | if (!m_actions.contains(strKey))
|
---|
538 | continue;
|
---|
539 | /* Update action 'checked' state: */
|
---|
540 | m_actions.value(strKey)->setChecked(!(m_restrictionsOfMenuInput & enumValue));
|
---|
541 | }
|
---|
542 | }
|
---|
543 |
|
---|
544 | void UIMenuBarEditorWidget::setRestrictionsOfMenuDevices(UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictions)
|
---|
545 | {
|
---|
546 | /* Cache passed restrictions: */
|
---|
547 | m_restrictionsOfMenuDevices = restrictions;
|
---|
548 | /* Get static meta-object: */
|
---|
549 | const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
|
---|
550 |
|
---|
551 | /* We have UIExtraDataMetaDefs::RuntimeMenuDevicesActionType enum registered, so we can enumerate it: */
|
---|
552 | const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuDevicesActionType");
|
---|
553 | QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
|
---|
554 | /* Handle other enum-values: */
|
---|
555 | for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
|
---|
556 | {
|
---|
557 | /* Get iterated enum-value: */
|
---|
558 | const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType enumValue =
|
---|
559 | static_cast<UIExtraDataMetaDefs::RuntimeMenuDevicesActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
|
---|
560 | /* Skip RuntimeMenuDevicesActionType_Invalid & RuntimeMenuDevicesActionType_All enum-value: */
|
---|
561 | if (enumValue == UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid ||
|
---|
562 | enumValue == UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_All)
|
---|
563 | continue;
|
---|
564 | /* Which key required action registered under? */
|
---|
565 | const QString strKey = gpConverter->toInternalString(enumValue);
|
---|
566 | if (!m_actions.contains(strKey))
|
---|
567 | continue;
|
---|
568 | /* Update action 'checked' state: */
|
---|
569 | m_actions.value(strKey)->setChecked(!(m_restrictionsOfMenuDevices & enumValue));
|
---|
570 | }
|
---|
571 | }
|
---|
572 |
|
---|
573 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
574 | void UIMenuBarEditorWidget::setRestrictionsOfMenuDebug(UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType restrictions)
|
---|
575 | {
|
---|
576 | /* Cache passed restrictions: */
|
---|
577 | m_restrictionsOfMenuDebug = restrictions;
|
---|
578 | /* Get static meta-object: */
|
---|
579 | const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
|
---|
580 |
|
---|
581 | /* We have UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType enum registered, so we can enumerate it: */
|
---|
582 | const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuDebuggerActionType");
|
---|
583 | QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
|
---|
584 | /* Handle other enum-values: */
|
---|
585 | for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
|
---|
586 | {
|
---|
587 | /* Get iterated enum-value: */
|
---|
588 | const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType enumValue =
|
---|
589 | static_cast<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
|
---|
590 | /* Skip RuntimeMenuDebuggerActionType_Invalid & RuntimeMenuDebuggerActionType_All enum-value: */
|
---|
591 | if (enumValue == UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Invalid ||
|
---|
592 | enumValue == UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_All)
|
---|
593 | continue;
|
---|
594 | /* Which key required action registered under? */
|
---|
595 | const QString strKey = gpConverter->toInternalString(enumValue);
|
---|
596 | if (!m_actions.contains(strKey))
|
---|
597 | continue;
|
---|
598 | /* Update action 'checked' state: */
|
---|
599 | m_actions.value(strKey)->setChecked(!(m_restrictionsOfMenuDebug & enumValue));
|
---|
600 | }
|
---|
601 | }
|
---|
602 | #endif /* VBOX_WITH_DEBUGGER_GUI */
|
---|
603 |
|
---|
604 | #ifdef VBOX_WS_MAC
|
---|
605 | void UIMenuBarEditorWidget::setRestrictionsOfMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType restrictions)
|
---|
606 | {
|
---|
607 | /* Cache passed restrictions: */
|
---|
608 | m_restrictionsOfMenuWindow = restrictions;
|
---|
609 | /* Get static meta-object: */
|
---|
610 | const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
|
---|
611 |
|
---|
612 | /* We have UIExtraDataMetaDefs::MenuWindowActionType enum registered, so we can enumerate it: */
|
---|
613 | const int iEnumIndex = smo.indexOfEnumerator("MenuWindowActionType");
|
---|
614 | QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
|
---|
615 | /* Handle other enum-values: */
|
---|
616 | for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
|
---|
617 | {
|
---|
618 | /* Get iterated enum-value: */
|
---|
619 | const UIExtraDataMetaDefs::MenuWindowActionType enumValue =
|
---|
620 | static_cast<const UIExtraDataMetaDefs::MenuWindowActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
|
---|
621 | /* Skip MenuWindowActionType_Invalid & MenuWindowActionType_All enum-value: */
|
---|
622 | if (enumValue == UIExtraDataMetaDefs::MenuWindowActionType_Invalid ||
|
---|
623 | enumValue == UIExtraDataMetaDefs::MenuWindowActionType_All)
|
---|
624 | continue;
|
---|
625 | /* Which key required action registered under? */
|
---|
626 | const QString strKey = gpConverter->toInternalString(enumValue);
|
---|
627 | if (!m_actions.contains(strKey))
|
---|
628 | continue;
|
---|
629 | /* Update action 'checked' state: */
|
---|
630 | m_actions.value(strKey)->setChecked(!(m_restrictionsOfMenuWindow & enumValue));
|
---|
631 | }
|
---|
632 | }
|
---|
633 | #endif /* VBOX_WS_MAC */
|
---|
634 |
|
---|
635 | void UIMenuBarEditorWidget::setRestrictionsOfMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType restrictions)
|
---|
636 | {
|
---|
637 | /* Cache passed restrictions: */
|
---|
638 | m_restrictionsOfMenuHelp = restrictions;
|
---|
639 | /* Get static meta-object: */
|
---|
640 | const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
|
---|
641 |
|
---|
642 | /* We have UIExtraDataMetaDefs::MenuHelpActionType enum registered, so we can enumerate it: */
|
---|
643 | const int iEnumIndex = smo.indexOfEnumerator("MenuHelpActionType");
|
---|
644 | QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
|
---|
645 | /* Handle other enum-values: */
|
---|
646 | for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
|
---|
647 | {
|
---|
648 | /* Get iterated enum-value: */
|
---|
649 | const UIExtraDataMetaDefs::MenuHelpActionType enumValue =
|
---|
650 | static_cast<UIExtraDataMetaDefs::MenuHelpActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
|
---|
651 | /* Skip MenuHelpActionType_Invalid & MenuHelpActionType_All enum-value: */
|
---|
652 | if (enumValue == UIExtraDataMetaDefs::MenuHelpActionType_Invalid ||
|
---|
653 | enumValue == UIExtraDataMetaDefs::MenuHelpActionType_All)
|
---|
654 | continue;
|
---|
655 | /* Which key required action registered under? */
|
---|
656 | const QString strKey = gpConverter->toInternalString(enumValue);
|
---|
657 | if (!m_actions.contains(strKey))
|
---|
658 | continue;
|
---|
659 | /* Update action 'checked' state: */
|
---|
660 | m_actions.value(strKey)->setChecked(!(m_restrictionsOfMenuHelp & enumValue));
|
---|
661 | }
|
---|
662 | }
|
---|
663 |
|
---|
664 | void UIMenuBarEditorWidget::retranslateUi()
|
---|
665 | {
|
---|
666 | /* Translate close-button if necessary: */
|
---|
667 | if (!m_fStartedFromVMSettings && m_pButtonClose)
|
---|
668 | m_pButtonClose->setToolTip(tr("Close"));
|
---|
669 | #ifndef VBOX_WS_MAC
|
---|
670 | /* Translate enable-checkbox if necessary: */
|
---|
671 | if (m_fStartedFromVMSettings && m_pCheckBoxEnable)
|
---|
672 | m_pCheckBoxEnable->setToolTip(tr("Enable Menu Bar"));
|
---|
673 | #endif
|
---|
674 | }
|
---|
675 |
|
---|
676 | void UIMenuBarEditorWidget::paintEvent(QPaintEvent *)
|
---|
677 | {
|
---|
678 | /* Prepare painter: */
|
---|
679 | QPainter painter(this);
|
---|
680 |
|
---|
681 | /* Prepare palette colors: */
|
---|
682 | const QPalette pal = palette();
|
---|
683 | QColor color0 = pal.color(QPalette::Window);
|
---|
684 | QColor color1 = pal.color(QPalette::Window).lighter(110);
|
---|
685 | color1.setAlpha(0);
|
---|
686 | QColor color2 = pal.color(QPalette::Window).darker(200);
|
---|
687 | #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
|
---|
688 | QColor color3 = pal.color(QPalette::Window).darker(120);
|
---|
689 | #endif /* VBOX_WS_WIN || VBOX_WS_X11 */
|
---|
690 |
|
---|
691 | /* Acquire metric: */
|
---|
692 | const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4;
|
---|
693 |
|
---|
694 | /* Left corner: */
|
---|
695 | QRadialGradient grad1(QPointF(iMetric, height() - iMetric), iMetric);
|
---|
696 | {
|
---|
697 | grad1.setColorAt(0, color2);
|
---|
698 | grad1.setColorAt(1, color1);
|
---|
699 | }
|
---|
700 | /* Right corner: */
|
---|
701 | QRadialGradient grad2(QPointF(width() - iMetric, height() - iMetric), iMetric);
|
---|
702 | {
|
---|
703 | grad2.setColorAt(0, color2);
|
---|
704 | grad2.setColorAt(1, color1);
|
---|
705 | }
|
---|
706 | /* Bottom line: */
|
---|
707 | QLinearGradient grad3(QPointF(iMetric, height()), QPointF(iMetric, height() - iMetric));
|
---|
708 | {
|
---|
709 | grad3.setColorAt(0, color1);
|
---|
710 | grad3.setColorAt(1, color2);
|
---|
711 | }
|
---|
712 | /* Left line: */
|
---|
713 | QLinearGradient grad4(QPointF(0, height() - iMetric), QPointF(iMetric, height() - iMetric));
|
---|
714 | {
|
---|
715 | grad4.setColorAt(0, color1);
|
---|
716 | grad4.setColorAt(1, color2);
|
---|
717 | }
|
---|
718 | /* Right line: */
|
---|
719 | QLinearGradient grad5(QPointF(width(), height() - iMetric), QPointF(width() - iMetric, height() - iMetric));
|
---|
720 | {
|
---|
721 | grad5.setColorAt(0, color1);
|
---|
722 | grad5.setColorAt(1, color2);
|
---|
723 | }
|
---|
724 |
|
---|
725 | /* Paint shape/shadow: */
|
---|
726 | painter.fillRect(QRect(iMetric, 0, width() - iMetric * 2, height() - iMetric), color0); // background
|
---|
727 | painter.fillRect(QRect(0, height() - iMetric, iMetric, iMetric), grad1); // left corner
|
---|
728 | painter.fillRect(QRect(width() - iMetric, height() - iMetric, iMetric, iMetric), grad2); // right corner
|
---|
729 | painter.fillRect(QRect(iMetric, height() - iMetric, width() - iMetric * 2, iMetric), grad3); // bottom line
|
---|
730 | painter.fillRect(QRect(0, 0, iMetric, height() - iMetric), grad4); // left line
|
---|
731 | painter.fillRect(QRect(width() - iMetric, 0, iMetric, height() - iMetric), grad5); // right line
|
---|
732 |
|
---|
733 | #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
|
---|
734 | /* Paint frames: */
|
---|
735 | painter.save();
|
---|
736 | painter.setPen(color3);
|
---|
737 | painter.drawLine(QLine(QPoint(iMetric + 1, 0),
|
---|
738 | QPoint(iMetric + 1, height() - 1 - iMetric - 1)));
|
---|
739 | painter.drawLine(QLine(QPoint(iMetric + 1, height() - 1 - iMetric - 1),
|
---|
740 | QPoint(width() - 1 - iMetric - 1, height() - 1 - iMetric - 1)));
|
---|
741 | painter.drawLine(QLine(QPoint(width() - 1 - iMetric - 1, height() - 1 - iMetric - 1),
|
---|
742 | QPoint(width() - 1 - iMetric - 1, 0)));
|
---|
743 | if (m_fStartedFromVMSettings)
|
---|
744 | painter.drawLine(QLine(QPoint(width() - 1 - iMetric - 1, 0), QPoint(iMetric + 1, 0)));
|
---|
745 | painter.restore();
|
---|
746 | #endif /* VBOX_WS_WIN || VBOX_WS_X11 */
|
---|
747 | }
|
---|
748 |
|
---|
749 | void UIMenuBarEditorWidget::sltHandleConfigurationChange(const QUuid &uMachineID)
|
---|
750 | {
|
---|
751 | /* Skip unrelated machine IDs: */
|
---|
752 | if (machineID() != uMachineID)
|
---|
753 | return;
|
---|
754 |
|
---|
755 | /* Recache menu-bar configuration: */
|
---|
756 | setRestrictionsOfMenuBar(gEDataManager->restrictedRuntimeMenuTypes(machineID()));
|
---|
757 | setRestrictionsOfMenuApplication(gEDataManager->restrictedRuntimeMenuApplicationActionTypes(machineID()));
|
---|
758 | setRestrictionsOfMenuMachine(gEDataManager->restrictedRuntimeMenuMachineActionTypes(machineID()));
|
---|
759 | setRestrictionsOfMenuView(gEDataManager->restrictedRuntimeMenuViewActionTypes(machineID()));
|
---|
760 | setRestrictionsOfMenuInput(gEDataManager->restrictedRuntimeMenuInputActionTypes(machineID()));
|
---|
761 | setRestrictionsOfMenuDevices(gEDataManager->restrictedRuntimeMenuDevicesActionTypes(machineID()));
|
---|
762 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
763 | setRestrictionsOfMenuDebug(gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(machineID()));
|
---|
764 | #endif
|
---|
765 | #ifdef VBOX_WS_MAC
|
---|
766 | setRestrictionsOfMenuWindow(gEDataManager->restrictedRuntimeMenuWindowActionTypes(machineID()));
|
---|
767 | #endif
|
---|
768 | setRestrictionsOfMenuHelp(gEDataManager->restrictedRuntimeMenuHelpActionTypes(machineID()));
|
---|
769 | }
|
---|
770 |
|
---|
771 | void UIMenuBarEditorWidget::sltHandleMenuBarMenuClick()
|
---|
772 | {
|
---|
773 | /* Make sure sender is valid: */
|
---|
774 | QAction *pAction = qobject_cast<QAction*>(sender());
|
---|
775 | AssertPtrReturnVoid(pAction);
|
---|
776 |
|
---|
777 | /* Depending on triggered action class: */
|
---|
778 | switch (pAction->property("class").toInt())
|
---|
779 | {
|
---|
780 | case UIExtraDataMetaDefs::MenuType_All:
|
---|
781 | {
|
---|
782 | /* Get sender type: */
|
---|
783 | const UIExtraDataMetaDefs::MenuType enmType =
|
---|
784 | static_cast<UIExtraDataMetaDefs::MenuType>(pAction->property("type").toInt());
|
---|
785 | /* Invert restriction for sender type: */
|
---|
786 | m_restrictionsOfMenuBar = (UIExtraDataMetaDefs::MenuType)(m_restrictionsOfMenuBar ^ enmType);
|
---|
787 | if (m_fStartedFromVMSettings)
|
---|
788 | {
|
---|
789 | /* Reapply menu-bar restrictions from cache: */
|
---|
790 | setRestrictionsOfMenuBar(m_restrictionsOfMenuBar);
|
---|
791 | }
|
---|
792 | else
|
---|
793 | {
|
---|
794 | /* Save updated menu-bar restrictions: */
|
---|
795 | gEDataManager->setRestrictedRuntimeMenuTypes(m_restrictionsOfMenuBar, machineID());
|
---|
796 | }
|
---|
797 | break;
|
---|
798 | }
|
---|
799 | case UIExtraDataMetaDefs::MenuType_Application:
|
---|
800 | {
|
---|
801 | /* Get sender type: */
|
---|
802 | const UIExtraDataMetaDefs::MenuApplicationActionType enmType =
|
---|
803 | static_cast<UIExtraDataMetaDefs::MenuApplicationActionType>(pAction->property("type").toInt());
|
---|
804 | /* Invert restriction for sender type: */
|
---|
805 | m_restrictionsOfMenuApplication = (UIExtraDataMetaDefs::MenuApplicationActionType)(m_restrictionsOfMenuApplication ^ enmType);
|
---|
806 | if (m_fStartedFromVMSettings)
|
---|
807 | {
|
---|
808 | /* Reapply menu-bar restrictions from cache: */
|
---|
809 | setRestrictionsOfMenuApplication(m_restrictionsOfMenuApplication);
|
---|
810 | }
|
---|
811 | else
|
---|
812 | {
|
---|
813 | /* Save updated menu-bar restrictions: */
|
---|
814 | gEDataManager->setRestrictedRuntimeMenuApplicationActionTypes(m_restrictionsOfMenuApplication, machineID());
|
---|
815 | }
|
---|
816 | break;
|
---|
817 | }
|
---|
818 | case UIExtraDataMetaDefs::MenuType_Machine:
|
---|
819 | {
|
---|
820 | /* Get sender type: */
|
---|
821 | const UIExtraDataMetaDefs::RuntimeMenuMachineActionType enmType =
|
---|
822 | static_cast<UIExtraDataMetaDefs::RuntimeMenuMachineActionType>(pAction->property("type").toInt());
|
---|
823 | /* Invert restriction for sender type: */
|
---|
824 | m_restrictionsOfMenuMachine = (UIExtraDataMetaDefs::RuntimeMenuMachineActionType)(m_restrictionsOfMenuMachine ^ enmType);
|
---|
825 | if (m_fStartedFromVMSettings)
|
---|
826 | {
|
---|
827 | /* Reapply menu-bar restrictions from cache: */
|
---|
828 | setRestrictionsOfMenuMachine(m_restrictionsOfMenuMachine);
|
---|
829 | }
|
---|
830 | else
|
---|
831 | {
|
---|
832 | /* Save updated menu-bar restrictions: */
|
---|
833 | gEDataManager->setRestrictedRuntimeMenuMachineActionTypes(m_restrictionsOfMenuMachine, machineID());
|
---|
834 | }
|
---|
835 | break;
|
---|
836 | }
|
---|
837 | case UIExtraDataMetaDefs::MenuType_View:
|
---|
838 | {
|
---|
839 | /* Get sender type: */
|
---|
840 | const UIExtraDataMetaDefs::RuntimeMenuViewActionType enmType =
|
---|
841 | static_cast<UIExtraDataMetaDefs::RuntimeMenuViewActionType>(pAction->property("type").toInt());
|
---|
842 | /* Invert restriction for sender type: */
|
---|
843 | m_restrictionsOfMenuView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)(m_restrictionsOfMenuView ^ enmType);
|
---|
844 | if (m_fStartedFromVMSettings)
|
---|
845 | {
|
---|
846 | /* Reapply menu-bar restrictions from cache: */
|
---|
847 | setRestrictionsOfMenuView(m_restrictionsOfMenuView);
|
---|
848 | }
|
---|
849 | else
|
---|
850 | {
|
---|
851 | /* Save updated menu-bar restrictions: */
|
---|
852 | gEDataManager->setRestrictedRuntimeMenuViewActionTypes(m_restrictionsOfMenuView, machineID());
|
---|
853 | }
|
---|
854 | break;
|
---|
855 | }
|
---|
856 | case UIExtraDataMetaDefs::MenuType_Input:
|
---|
857 | {
|
---|
858 | /* Get sender type: */
|
---|
859 | const UIExtraDataMetaDefs::RuntimeMenuInputActionType enmType =
|
---|
860 | static_cast<UIExtraDataMetaDefs::RuntimeMenuInputActionType>(pAction->property("type").toInt());
|
---|
861 | /* Invert restriction for sender type: */
|
---|
862 | m_restrictionsOfMenuInput = (UIExtraDataMetaDefs::RuntimeMenuInputActionType)(m_restrictionsOfMenuInput ^ enmType);
|
---|
863 | if (m_fStartedFromVMSettings)
|
---|
864 | {
|
---|
865 | /* Reapply menu-bar restrictions from cache: */
|
---|
866 | setRestrictionsOfMenuInput(m_restrictionsOfMenuInput);
|
---|
867 | }
|
---|
868 | else
|
---|
869 | {
|
---|
870 | /* Save updated menu-bar restrictions: */
|
---|
871 | gEDataManager->setRestrictedRuntimeMenuInputActionTypes(m_restrictionsOfMenuInput, machineID());
|
---|
872 | }
|
---|
873 | break;
|
---|
874 | }
|
---|
875 | case UIExtraDataMetaDefs::MenuType_Devices:
|
---|
876 | {
|
---|
877 | /* Get sender type: */
|
---|
878 | const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType enmType =
|
---|
879 | static_cast<UIExtraDataMetaDefs::RuntimeMenuDevicesActionType>(pAction->property("type").toInt());
|
---|
880 | /* Invert restriction for sender type: */
|
---|
881 | m_restrictionsOfMenuDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(m_restrictionsOfMenuDevices ^ enmType);
|
---|
882 | if (m_fStartedFromVMSettings)
|
---|
883 | {
|
---|
884 | /* Reapply menu-bar restrictions from cache: */
|
---|
885 | setRestrictionsOfMenuDevices(m_restrictionsOfMenuDevices);
|
---|
886 | }
|
---|
887 | else
|
---|
888 | {
|
---|
889 | /* Save updated menu-bar restrictions: */
|
---|
890 | gEDataManager->setRestrictedRuntimeMenuDevicesActionTypes(m_restrictionsOfMenuDevices, machineID());
|
---|
891 | }
|
---|
892 | break;
|
---|
893 | }
|
---|
894 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
895 | case UIExtraDataMetaDefs::MenuType_Debug:
|
---|
896 | {
|
---|
897 | /* Get sender type: */
|
---|
898 | const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType enmType =
|
---|
899 | static_cast<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>(pAction->property("type").toInt());
|
---|
900 | /* Invert restriction for sender type: */
|
---|
901 | m_restrictionsOfMenuDebug = (UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType)(m_restrictionsOfMenuDebug ^ enmType);
|
---|
902 | if (m_fStartedFromVMSettings)
|
---|
903 | {
|
---|
904 | /* Reapply menu-bar restrictions from cache: */
|
---|
905 | setRestrictionsOfMenuDebug(m_restrictionsOfMenuDebug);
|
---|
906 | }
|
---|
907 | else
|
---|
908 | {
|
---|
909 | /* Save updated menu-bar restrictions: */
|
---|
910 | gEDataManager->setRestrictedRuntimeMenuDebuggerActionTypes(m_restrictionsOfMenuDebug, machineID());
|
---|
911 | }
|
---|
912 | break;
|
---|
913 | }
|
---|
914 | #endif /* VBOX_WITH_DEBUGGER_GUI */
|
---|
915 | #ifdef VBOX_WS_MAC
|
---|
916 | case UIExtraDataMetaDefs::MenuType_Window:
|
---|
917 | {
|
---|
918 | /* Get sender type: */
|
---|
919 | const UIExtraDataMetaDefs::MenuWindowActionType enmType =
|
---|
920 | static_cast<UIExtraDataMetaDefs::MenuWindowActionType>(pAction->property("type").toInt());
|
---|
921 | /* Invert restriction for sender type: */
|
---|
922 | m_restrictionsOfMenuWindow = (UIExtraDataMetaDefs::MenuWindowActionType)(m_restrictionsOfMenuWindow ^ enmType);
|
---|
923 | if (m_fStartedFromVMSettings)
|
---|
924 | {
|
---|
925 | /* Reapply menu-bar restrictions from cache: */
|
---|
926 | setRestrictionsOfMenuWindow(m_restrictionsOfMenuWindow);
|
---|
927 | }
|
---|
928 | else
|
---|
929 | {
|
---|
930 | /* Save updated menu-bar restrictions: */
|
---|
931 | gEDataManager->setRestrictedRuntimeMenuWindowActionTypes(m_restrictionsOfMenuWindow, machineID());
|
---|
932 | }
|
---|
933 | break;
|
---|
934 | }
|
---|
935 | #endif /* VBOX_WS_MAC */
|
---|
936 | case UIExtraDataMetaDefs::MenuType_Help:
|
---|
937 | {
|
---|
938 | /* Get sender type: */
|
---|
939 | const UIExtraDataMetaDefs::MenuHelpActionType enmType =
|
---|
940 | static_cast<UIExtraDataMetaDefs::MenuHelpActionType>(pAction->property("type").toInt());
|
---|
941 | /* Invert restriction for sender type: */
|
---|
942 | m_restrictionsOfMenuHelp = (UIExtraDataMetaDefs::MenuHelpActionType)(m_restrictionsOfMenuHelp ^ enmType);
|
---|
943 | if (m_fStartedFromVMSettings)
|
---|
944 | {
|
---|
945 | /* Reapply menu-bar restrictions from cache: */
|
---|
946 | setRestrictionsOfMenuHelp(m_restrictionsOfMenuHelp);
|
---|
947 | }
|
---|
948 | else
|
---|
949 | {
|
---|
950 | /* Save updated menu-bar restrictions: */
|
---|
951 | gEDataManager->setRestrictedRuntimeMenuHelpActionTypes(m_restrictionsOfMenuHelp, machineID());
|
---|
952 | } break;
|
---|
953 | }
|
---|
954 | default: break;
|
---|
955 | }
|
---|
956 | }
|
---|
957 |
|
---|
958 | void UIMenuBarEditorWidget::prepare()
|
---|
959 | {
|
---|
960 | /* Do nothing if already prepared: */
|
---|
961 | if (m_fPrepared)
|
---|
962 | return;
|
---|
963 |
|
---|
964 | /* Do not prepare if machine ID or action-pool is not set: */
|
---|
965 | if (m_uMachineID.isNull() || !m_pActionPool)
|
---|
966 | return;
|
---|
967 |
|
---|
968 | /* Install tool-bar button accessibility interface factory: */
|
---|
969 | QAccessible::installFactory(UIAccessibilityInterfaceForUIMenuBarEditorButton::pFactory);
|
---|
970 |
|
---|
971 | /* Create main-layout: */
|
---|
972 | m_pMainLayout = new QHBoxLayout(this);
|
---|
973 | AssertPtrReturnVoid(m_pMainLayout);
|
---|
974 | {
|
---|
975 | /* Configure main-layout: */
|
---|
976 | int iLeft, iTop, iRight, iBottom;
|
---|
977 | m_pMainLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
|
---|
978 | /* Acquire metric: */
|
---|
979 | const int iStandardMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 2;
|
---|
980 | const int iMinimumMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4;
|
---|
981 | /* Standard margins should not be too small/large: */
|
---|
982 | iLeft = iStandardMetric;
|
---|
983 | iTop = iStandardMetric;
|
---|
984 | iRight = iStandardMetric;
|
---|
985 | iBottom = iStandardMetric;
|
---|
986 | /* Top margin should be smaller for the common case: */
|
---|
987 | if (iTop >= iMinimumMetric)
|
---|
988 | iTop -= iMinimumMetric;
|
---|
989 | #ifndef VBOX_WS_MAC
|
---|
990 | /* Right margin should be bigger for the settings case: */
|
---|
991 | if (m_fStartedFromVMSettings)
|
---|
992 | iRight += iMinimumMetric;
|
---|
993 | #endif /* !VBOX_WS_MAC */
|
---|
994 | /* Apply margins/spacing finally: */
|
---|
995 | m_pMainLayout->setContentsMargins(iLeft, iTop, iRight, iBottom);
|
---|
996 | m_pMainLayout->setSpacing(0);
|
---|
997 | /* Create tool-bar: */
|
---|
998 | m_pToolBar = new UIToolBar;
|
---|
999 | AssertPtrReturnVoid(m_pToolBar);
|
---|
1000 | {
|
---|
1001 | /* Prepare menus: */
|
---|
1002 | prepareMenus();
|
---|
1003 | /* Add tool-bar into main-layout: */
|
---|
1004 | m_pMainLayout->addWidget(m_pToolBar);
|
---|
1005 | }
|
---|
1006 | /* Insert stretch: */
|
---|
1007 | m_pMainLayout->addStretch();
|
---|
1008 | /* Create close-button if necessary: */
|
---|
1009 | if (!m_fStartedFromVMSettings)
|
---|
1010 | {
|
---|
1011 | m_pButtonClose = new QIToolButton;
|
---|
1012 | AssertPtrReturnVoid(m_pButtonClose);
|
---|
1013 | {
|
---|
1014 | /* Configure close-button: */
|
---|
1015 | m_pButtonClose->setFocusPolicy(Qt::StrongFocus);
|
---|
1016 | m_pButtonClose->setShortcut(Qt::Key_Escape);
|
---|
1017 | m_pButtonClose->setIcon(UIIconPool::iconSet(":/ok_16px.png"));
|
---|
1018 | connect(m_pButtonClose, SIGNAL(clicked(bool)), this, SIGNAL(sigCancelClicked()));
|
---|
1019 | /* Add close-button into main-layout: */
|
---|
1020 | m_pMainLayout->addWidget(m_pButtonClose);
|
---|
1021 | }
|
---|
1022 | }
|
---|
1023 | #ifndef VBOX_WS_MAC
|
---|
1024 | /* Create enable-checkbox if necessary: */
|
---|
1025 | else
|
---|
1026 | {
|
---|
1027 | m_pCheckBoxEnable = new QCheckBox;
|
---|
1028 | AssertPtrReturnVoid(m_pCheckBoxEnable);
|
---|
1029 | {
|
---|
1030 | /* Configure enable-checkbox: */
|
---|
1031 | m_pCheckBoxEnable->setFocusPolicy(Qt::StrongFocus);
|
---|
1032 | /* Add enable-checkbox into main-layout: */
|
---|
1033 | m_pMainLayout->addWidget(m_pCheckBoxEnable);
|
---|
1034 | }
|
---|
1035 | }
|
---|
1036 | #endif /* !VBOX_WS_MAC */
|
---|
1037 | }
|
---|
1038 |
|
---|
1039 | /* Mark as prepared: */
|
---|
1040 | m_fPrepared = true;
|
---|
1041 |
|
---|
1042 | /* Translate contents: */
|
---|
1043 | retranslateUi();
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 | void UIMenuBarEditorWidget::prepareMenus()
|
---|
1047 | {
|
---|
1048 | /* Create menus: */
|
---|
1049 | prepareMenuApplication();
|
---|
1050 | prepareMenuMachine();
|
---|
1051 | prepareMenuView();
|
---|
1052 | prepareMenuInput();
|
---|
1053 | prepareMenuDevices();
|
---|
1054 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
1055 | prepareMenuDebug();
|
---|
1056 | #endif
|
---|
1057 | #ifdef VBOX_WS_MAC
|
---|
1058 | prepareMenuWindow();
|
---|
1059 | #endif
|
---|
1060 | prepareMenuHelp();
|
---|
1061 |
|
---|
1062 | if (!m_fStartedFromVMSettings)
|
---|
1063 | {
|
---|
1064 | /* Cache menu-bar configuration: */
|
---|
1065 | setRestrictionsOfMenuBar(gEDataManager->restrictedRuntimeMenuTypes(machineID()));
|
---|
1066 | setRestrictionsOfMenuApplication(gEDataManager->restrictedRuntimeMenuApplicationActionTypes(machineID()));
|
---|
1067 | setRestrictionsOfMenuMachine(gEDataManager->restrictedRuntimeMenuMachineActionTypes(machineID()));
|
---|
1068 | setRestrictionsOfMenuView(gEDataManager->restrictedRuntimeMenuViewActionTypes(machineID()));
|
---|
1069 | setRestrictionsOfMenuInput(gEDataManager->restrictedRuntimeMenuInputActionTypes(machineID()));
|
---|
1070 | setRestrictionsOfMenuDevices(gEDataManager->restrictedRuntimeMenuDevicesActionTypes(machineID()));
|
---|
1071 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
1072 | setRestrictionsOfMenuDebug(gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(machineID()));
|
---|
1073 | #endif
|
---|
1074 | #ifdef VBOX_WS_MAC
|
---|
1075 | setRestrictionsOfMenuWindow(gEDataManager->restrictedRuntimeMenuWindowActionTypes(machineID()));
|
---|
1076 | #endif
|
---|
1077 | setRestrictionsOfMenuHelp(gEDataManager->restrictedRuntimeMenuHelpActionTypes(machineID()));
|
---|
1078 | /* And listen for the menu-bar configuration changes after that: */
|
---|
1079 | connect(gEDataManager, SIGNAL(sigMenuBarConfigurationChange(const QString&)),
|
---|
1080 | this, SLOT(sltHandleConfigurationChange(const QString&)));
|
---|
1081 | }
|
---|
1082 | }
|
---|
1083 |
|
---|
1084 | #ifdef VBOX_WS_MAC
|
---|
1085 | QMenu *UIMenuBarEditorWidget::prepareNamedMenu(const QString &strName)
|
---|
1086 | {
|
---|
1087 | /* Create named menu: */
|
---|
1088 | QMenu *pNamedMenu = new QMenu(strName, m_pToolBar);
|
---|
1089 | AssertPtrReturn(pNamedMenu, 0);
|
---|
1090 | {
|
---|
1091 | /* Configure named menu: */
|
---|
1092 | pNamedMenu->setProperty("class", UIExtraDataMetaDefs::MenuType_Application);
|
---|
1093 | /* Get named menu action: */
|
---|
1094 | QAction *pNamedMenuAction = pNamedMenu->menuAction();
|
---|
1095 | AssertPtrReturn(pNamedMenuAction, 0);
|
---|
1096 | {
|
---|
1097 | /* Add menu action into tool-bar: */
|
---|
1098 | m_pToolBar->addAction(pNamedMenuAction);
|
---|
1099 | /* Get named menu tool-button: */
|
---|
1100 | QToolButton *pNamedMenuToolButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(pNamedMenuAction));
|
---|
1101 | AssertPtrReturn(pNamedMenuToolButton, 0);
|
---|
1102 | {
|
---|
1103 | /* Configure named menu tool-button: */
|
---|
1104 | pNamedMenuToolButton->setProperty("Belongs to", "UIMenuBarEditorWidget");
|
---|
1105 | pNamedMenuToolButton->setPopupMode(QToolButton::MenuButtonPopup);
|
---|
1106 | pNamedMenuToolButton->setAutoRaise(true);
|
---|
1107 | /* Update the accessibility interface to take "Belongs to" into account: */
|
---|
1108 | QAccessibleInterface *pInterface = QAccessible::queryAccessibleInterface(pNamedMenuToolButton);
|
---|
1109 | if (pInterface)
|
---|
1110 | {
|
---|
1111 | QAccessible::deleteAccessibleInterface(QAccessible::uniqueId(pInterface));
|
---|
1112 | QAccessible::queryAccessibleInterface(pNamedMenuToolButton); // <= new one, proper..
|
---|
1113 | }
|
---|
1114 | /* Create spacing after named menu tool-button: */
|
---|
1115 | QWidget *pSpacing = new QWidget;
|
---|
1116 | AssertPtrReturn(pSpacing, 0);
|
---|
1117 | {
|
---|
1118 | /* Configure spacing: */
|
---|
1119 | pSpacing->setFixedSize(5, 1);
|
---|
1120 | /* Add spacing into tool-bar: */
|
---|
1121 | m_pToolBar->addWidget(pSpacing);
|
---|
1122 | }
|
---|
1123 | }
|
---|
1124 | }
|
---|
1125 | }
|
---|
1126 | /* Return named menu: */
|
---|
1127 | return pNamedMenu;
|
---|
1128 | }
|
---|
1129 | #endif /* VBOX_WS_MAC */
|
---|
1130 |
|
---|
1131 | QMenu *UIMenuBarEditorWidget::prepareCopiedMenu(const UIAction *pAction)
|
---|
1132 | {
|
---|
1133 | /* Create copied menu: */
|
---|
1134 | QMenu *pCopiedMenu = new QMenu(pAction->name(), m_pToolBar);
|
---|
1135 | AssertPtrReturn(pCopiedMenu, 0);
|
---|
1136 | {
|
---|
1137 | /* Configure copied menu: */
|
---|
1138 | pCopiedMenu->setProperty("class", pAction->extraDataID());
|
---|
1139 | /* Get copied menu action: */
|
---|
1140 | QAction *pCopiedMenuAction = pCopiedMenu->menuAction();
|
---|
1141 | AssertPtrReturn(pCopiedMenuAction, 0);
|
---|
1142 | {
|
---|
1143 | /* Configure copied menu action: */
|
---|
1144 | pCopiedMenuAction->setCheckable(true);
|
---|
1145 | pCopiedMenuAction->setProperty("class", UIExtraDataMetaDefs::MenuType_All);
|
---|
1146 | pCopiedMenuAction->setProperty("type", pAction->extraDataID());
|
---|
1147 | connect(pCopiedMenuAction, SIGNAL(triggered(bool)), this, SLOT(sltHandleMenuBarMenuClick()));
|
---|
1148 | m_actions.insert(pAction->extraDataKey(), pCopiedMenuAction);
|
---|
1149 | /* Add menu action into tool-bar: */
|
---|
1150 | m_pToolBar->addAction(pCopiedMenuAction);
|
---|
1151 | /* Get copied menu tool-button: */
|
---|
1152 | QToolButton *pCopiedMenuToolButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(pCopiedMenuAction));
|
---|
1153 | AssertPtrReturn(pCopiedMenuToolButton, 0);
|
---|
1154 | {
|
---|
1155 | /* Configure copied menu tool-button: */
|
---|
1156 | pCopiedMenuToolButton->setProperty("Belongs to", "UIMenuBarEditorWidget");
|
---|
1157 | pCopiedMenuToolButton->setPopupMode(QToolButton::MenuButtonPopup);
|
---|
1158 | pCopiedMenuToolButton->setAutoRaise(true);
|
---|
1159 | /* Update the accessibility interface to take "Belongs to" into account: */
|
---|
1160 | QAccessibleInterface *pInterface = QAccessible::queryAccessibleInterface(pCopiedMenuToolButton);
|
---|
1161 | if (pInterface)
|
---|
1162 | {
|
---|
1163 | QAccessible::deleteAccessibleInterface(QAccessible::uniqueId(pInterface));
|
---|
1164 | QAccessible::queryAccessibleInterface(pCopiedMenuToolButton); // <= new one, proper..
|
---|
1165 | }
|
---|
1166 | /* Create spacing after copied menu tool-button: */
|
---|
1167 | QWidget *pSpacing = new QWidget;
|
---|
1168 | AssertPtrReturn(pSpacing, 0);
|
---|
1169 | {
|
---|
1170 | /* Configure spacing: */
|
---|
1171 | pSpacing->setFixedSize(5, 1);
|
---|
1172 | /* Add spacing into tool-bar: */
|
---|
1173 | m_pToolBar->addWidget(pSpacing);
|
---|
1174 | }
|
---|
1175 | }
|
---|
1176 | }
|
---|
1177 | }
|
---|
1178 | /* Return copied menu: */
|
---|
1179 | return pCopiedMenu;
|
---|
1180 | }
|
---|
1181 |
|
---|
1182 | #if 0
|
---|
1183 | QMenu *UIMenuBarEditorWidget::prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction)
|
---|
1184 | {
|
---|
1185 | /* Create copied sub-menu: */
|
---|
1186 | QMenu *pCopiedMenu = pMenu->addMenu(pAction->name());
|
---|
1187 | AssertPtrReturn(pCopiedMenu, 0);
|
---|
1188 | {
|
---|
1189 | /* Configure copied sub-menu: */
|
---|
1190 | pCopiedMenu->setProperty("class", pMenu->property("class"));
|
---|
1191 | /* Get copied sub-menu action: */
|
---|
1192 | QAction *pCopiedMenuAction = pCopiedMenu->menuAction();
|
---|
1193 | AssertPtrReturn(pCopiedMenuAction, 0);
|
---|
1194 | {
|
---|
1195 | /* Configure copied sub-menu: */
|
---|
1196 | pCopiedMenuAction->setCheckable(true);
|
---|
1197 | pCopiedMenuAction->setProperty("class", pCopiedMenu->property("class"));
|
---|
1198 | pCopiedMenuAction->setProperty("type", pAction->extraDataID());
|
---|
1199 | connect(pCopiedMenuAction, SIGNAL(triggered(bool)), this, SLOT(sltHandleMenuBarMenuClick()));
|
---|
1200 | m_actions.insert(pAction->extraDataKey(), pCopiedMenuAction);
|
---|
1201 | }
|
---|
1202 | }
|
---|
1203 | /* Return copied sub-menu: */
|
---|
1204 | return pCopiedMenu;
|
---|
1205 | }
|
---|
1206 | #endif
|
---|
1207 |
|
---|
1208 | QAction *UIMenuBarEditorWidget::prepareNamedAction(QMenu *pMenu, const QString &strName,
|
---|
1209 | int iExtraDataID, const QString &strExtraDataID)
|
---|
1210 | {
|
---|
1211 | /* Create copied action: */
|
---|
1212 | QAction *pCopiedAction = pMenu->addAction(strName);
|
---|
1213 | AssertPtrReturn(pCopiedAction, 0);
|
---|
1214 | {
|
---|
1215 | /* Configure copied action: */
|
---|
1216 | pCopiedAction->setCheckable(true);
|
---|
1217 | pCopiedAction->setProperty("class", pMenu->property("class"));
|
---|
1218 | pCopiedAction->setProperty("type", iExtraDataID);
|
---|
1219 | connect(pCopiedAction, SIGNAL(triggered(bool)), this, SLOT(sltHandleMenuBarMenuClick()));
|
---|
1220 | m_actions.insert(strExtraDataID, pCopiedAction);
|
---|
1221 | }
|
---|
1222 | /* Return copied action: */
|
---|
1223 | return pCopiedAction;
|
---|
1224 | }
|
---|
1225 |
|
---|
1226 | QAction *UIMenuBarEditorWidget::prepareCopiedAction(QMenu *pMenu, const UIAction *pAction)
|
---|
1227 | {
|
---|
1228 | /* Create copied action: */
|
---|
1229 | QAction *pCopiedAction = pMenu->addAction(pAction->name());
|
---|
1230 | AssertPtrReturn(pCopiedAction, 0);
|
---|
1231 | {
|
---|
1232 | /* Configure copied action: */
|
---|
1233 | pCopiedAction->setCheckable(true);
|
---|
1234 | pCopiedAction->setProperty("class", pMenu->property("class"));
|
---|
1235 | pCopiedAction->setProperty("type", pAction->extraDataID());
|
---|
1236 | connect(pCopiedAction, SIGNAL(triggered(bool)), this, SLOT(sltHandleMenuBarMenuClick()));
|
---|
1237 | m_actions.insert(pAction->extraDataKey(), pCopiedAction);
|
---|
1238 | }
|
---|
1239 | /* Return copied action: */
|
---|
1240 | return pCopiedAction;
|
---|
1241 | }
|
---|
1242 |
|
---|
1243 | void UIMenuBarEditorWidget::prepareMenuApplication()
|
---|
1244 | {
|
---|
1245 | /* Copy menu: */
|
---|
1246 | #ifdef VBOX_WS_MAC
|
---|
1247 | QMenu *pMenu = prepareNamedMenu("Application");
|
---|
1248 | #else /* !VBOX_WS_MAC */
|
---|
1249 | QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndex_M_Application));
|
---|
1250 | #endif /* !VBOX_WS_MAC */
|
---|
1251 | AssertPtrReturnVoid(pMenu);
|
---|
1252 | {
|
---|
1253 | #ifdef VBOX_WS_MAC
|
---|
1254 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Application_S_About));
|
---|
1255 | # ifdef VBOX_GUI_WITH_NETWORK_MANAGER
|
---|
1256 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Application_S_NetworkAccessManager));
|
---|
1257 | # endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
|
---|
1258 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Application_S_ResetWarnings));
|
---|
1259 | pMenu->addSeparator();
|
---|
1260 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Application_S_Preferences));
|
---|
1261 | #else /* !VBOX_WS_MAC */
|
---|
1262 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Application_S_Preferences));
|
---|
1263 | pMenu->addSeparator();
|
---|
1264 | # ifdef VBOX_GUI_WITH_NETWORK_MANAGER
|
---|
1265 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Application_S_NetworkAccessManager));
|
---|
1266 | # endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
|
---|
1267 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Application_S_ResetWarnings));
|
---|
1268 | #endif /* !VBOX_WS_MAC */
|
---|
1269 | }
|
---|
1270 | }
|
---|
1271 |
|
---|
1272 | void UIMenuBarEditorWidget::prepareMenuMachine()
|
---|
1273 | {
|
---|
1274 | /* Copy menu: */
|
---|
1275 | QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndexRT_M_Machine));
|
---|
1276 | AssertPtrReturnVoid(pMenu);
|
---|
1277 | {
|
---|
1278 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_Settings));
|
---|
1279 | pMenu->addSeparator();
|
---|
1280 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_TakeSnapshot));
|
---|
1281 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_ShowInformation));
|
---|
1282 | pMenu->addSeparator();
|
---|
1283 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_T_Pause));
|
---|
1284 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_Reset));
|
---|
1285 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_Detach));
|
---|
1286 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_SaveState));
|
---|
1287 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_Shutdown));
|
---|
1288 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_PowerOff));
|
---|
1289 | }
|
---|
1290 | }
|
---|
1291 |
|
---|
1292 | void UIMenuBarEditorWidget::prepareMenuView()
|
---|
1293 | {
|
---|
1294 | /* Copy menu: */
|
---|
1295 | QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndexRT_M_View));
|
---|
1296 | AssertPtrReturnVoid(pMenu);
|
---|
1297 | {
|
---|
1298 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen));
|
---|
1299 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_T_Seamless));
|
---|
1300 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_T_Scale));
|
---|
1301 | pMenu->addSeparator();
|
---|
1302 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_S_AdjustWindow));
|
---|
1303 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize));
|
---|
1304 | pMenu->addSeparator();
|
---|
1305 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_S_TakeScreenshot));
|
---|
1306 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_M_Recording_T_Start));
|
---|
1307 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer));
|
---|
1308 | pMenu->addSeparator();
|
---|
1309 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_M_MenuBar));
|
---|
1310 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_View_M_StatusBar));
|
---|
1311 | pMenu->addSeparator();
|
---|
1312 | prepareNamedAction(pMenu, tr("Virtual Screen Resize"),
|
---|
1313 | UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize,
|
---|
1314 | gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize));
|
---|
1315 | prepareNamedAction(pMenu, tr("Virtual Screen Remap"),
|
---|
1316 | UIExtraDataMetaDefs::RuntimeMenuViewActionType_Remap,
|
---|
1317 | gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Remap));
|
---|
1318 | prepareNamedAction(pMenu, tr("Virtual Screen Rescale"),
|
---|
1319 | UIExtraDataMetaDefs::RuntimeMenuViewActionType_Rescale,
|
---|
1320 | gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Rescale));
|
---|
1321 | }
|
---|
1322 | }
|
---|
1323 |
|
---|
1324 | void UIMenuBarEditorWidget::prepareMenuInput()
|
---|
1325 | {
|
---|
1326 | /* Copy menu: */
|
---|
1327 | QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndexRT_M_Input));
|
---|
1328 | AssertPtrReturnVoid(pMenu);
|
---|
1329 | {
|
---|
1330 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Input_M_Keyboard));
|
---|
1331 | pMenu->addSeparator();
|
---|
1332 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Input_M_Mouse_T_Integration));
|
---|
1333 | }
|
---|
1334 | }
|
---|
1335 |
|
---|
1336 | void UIMenuBarEditorWidget::prepareMenuDevices()
|
---|
1337 | {
|
---|
1338 | /* Copy menu: */
|
---|
1339 | QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndexRT_M_Devices));
|
---|
1340 | AssertPtrReturnVoid(pMenu);
|
---|
1341 | {
|
---|
1342 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_HardDrives));
|
---|
1343 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_OpticalDevices));
|
---|
1344 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_FloppyDevices));
|
---|
1345 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_Audio));
|
---|
1346 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_Network));
|
---|
1347 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_USBDevices));
|
---|
1348 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_WebCams));
|
---|
1349 | pMenu->addSeparator();
|
---|
1350 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_SharedFolders));
|
---|
1351 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_SharedClipboard));
|
---|
1352 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_M_DragAndDrop));
|
---|
1353 | pMenu->addSeparator();
|
---|
1354 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Devices_S_InstallGuestTools));
|
---|
1355 | }
|
---|
1356 | }
|
---|
1357 |
|
---|
1358 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
1359 | void UIMenuBarEditorWidget::prepareMenuDebug()
|
---|
1360 | {
|
---|
1361 | /* Copy menu: */
|
---|
1362 | QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndexRT_M_Debug));
|
---|
1363 | AssertPtrReturnVoid(pMenu);
|
---|
1364 | {
|
---|
1365 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Debug_S_ShowStatistics));
|
---|
1366 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Debug_S_ShowCommandLine));
|
---|
1367 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Debug_T_Logging));
|
---|
1368 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Debug_S_ShowLogDialog));
|
---|
1369 | }
|
---|
1370 | }
|
---|
1371 | #endif /* VBOX_WITH_DEBUGGER_GUI */
|
---|
1372 |
|
---|
1373 | #ifdef VBOX_WS_MAC
|
---|
1374 | void UIMenuBarEditorWidget::prepareMenuWindow()
|
---|
1375 | {
|
---|
1376 | /* Copy menu: */
|
---|
1377 | QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndex_M_Window));
|
---|
1378 | AssertPtrReturnVoid(pMenu);
|
---|
1379 | {
|
---|
1380 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Window_S_Minimize));
|
---|
1381 | pMenu->addSeparator();
|
---|
1382 | prepareNamedAction(pMenu, tr("Switch"),
|
---|
1383 | UIExtraDataMetaDefs::MenuWindowActionType_Switch,
|
---|
1384 | gpConverter->toInternalString(UIExtraDataMetaDefs::MenuWindowActionType_Switch));
|
---|
1385 | }
|
---|
1386 | }
|
---|
1387 | #endif /* VBOX_WS_MAC */
|
---|
1388 |
|
---|
1389 | void UIMenuBarEditorWidget::prepareMenuHelp()
|
---|
1390 | {
|
---|
1391 | /* Copy menu: */
|
---|
1392 | QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndex_Menu_Help));
|
---|
1393 | AssertPtrReturnVoid(pMenu);
|
---|
1394 | {
|
---|
1395 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_Contents));
|
---|
1396 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_WebSite));
|
---|
1397 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_BugTracker));
|
---|
1398 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_Forums));
|
---|
1399 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_Oracle));
|
---|
1400 | pMenu->addSeparator();
|
---|
1401 | #ifndef VBOX_WS_MAC
|
---|
1402 | prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_About));
|
---|
1403 | #endif
|
---|
1404 | }
|
---|
1405 | }
|
---|