Changeset 72025 in vbox
- Timestamp:
- Apr 25, 2018 5:13:11 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 122288
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r72022 r72025 462 462 src/runtime/UIMachineWindow.h \ 463 463 src/runtime/UIMachineView.h \ 464 src/runtime/UIMenuBarEditorWindow.h \465 464 src/runtime/UIMouseHandler.h \ 466 465 src/runtime/UIMultiScreenLayout.h \ … … 677 676 src/widgets/UIMediumSizeEditor.h \ 678 677 src/widgets/UIMenuBar.h \ 678 src/widgets/UIMenuBarEditorWindow.h \ 679 679 src/widgets/UINameAndSystemEditor.h \ 680 680 src/widgets/UIPopupBox.h \ … … 784 784 src/widgets/UIMediumSizeEditor.h \ 785 785 src/widgets/UIMenuBar.h \ 786 src/widgets/UIMenuBarEditorWindow.h \ 786 787 src/widgets/UINameAndSystemEditor.h \ 787 788 src/widgets/UIPopupBox.h \ … … 969 970 src/runtime/UIMachineView.cpp \ 970 971 src/runtime/UIMachineWindow.cpp \ 971 src/runtime/UIMenuBarEditorWindow.cpp \972 972 src/runtime/UIMouseHandler.cpp \ 973 973 src/runtime/UIMultiScreenLayout.cpp \ … … 1223 1223 src/widgets/UIMediumSizeEditor.cpp \ 1224 1224 src/widgets/UIMenuBar.cpp \ 1225 src/widgets/UIMenuBarEditorWindow.cpp \ 1225 1226 src/widgets/UINameAndSystemEditor.cpp \ 1226 1227 src/widgets/UIPopupBox.cpp \ … … 1356 1357 src/widgets/UIMediumSizeEditor.cpp \ 1357 1358 src/widgets/UIMenuBar.cpp \ 1359 src/widgets/UIMenuBarEditorWindow.cpp \ 1358 1360 src/widgets/UINameAndSystemEditor.cpp \ 1359 1361 src/widgets/UIPopupBox.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMenuBarEditorWindow.cpp
r72024 r72025 5 5 6 6 /* 7 * Copyright (C) 2014-201 7Oracle Corporation7 * Copyright (C) 2014-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 31 31 # ifndef VBOX_WS_MAC 32 32 # include <QCheckBox> 33 # endif /* !VBOX_WS_MAC */33 # endif 34 34 35 35 /* GUI includes: */ 36 # include "UIMenuBarEditorWindow.h"37 # include "UIActionPoolRuntime.h"38 # include "UIExtraDataManager.h"39 # include "UIMachineWindow.h"40 # include "UIConverter.h"41 # include "UIIconPool.h"42 # include "UIToolBar.h"43 36 # include "QIToolButton.h" 44 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 45 46 46 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 47 47 48 48 /* Forward declarations: */ 49 class QAccessibleInterface; 50 class QRect; 49 51 class UIAccessibilityInterfaceForUIMenuBarEditorButton; 50 52 … … 104 106 /** Holds the parent interface we are linked to. */ 105 107 UIAccessibilityInterfaceForUIMenuBarEditorButton *m_pParent; 108 106 109 /** Holds the index of segment we are referring to. */ 107 const UIMenuBarEditorSegment m_enmIndex;110 const UIMenuBarEditorSegment m_enmIndex; 108 111 }; 109 112 … … 141 144 142 145 /** Holds the map of instances of sub-element interfaces. */ 143 QMap<UIMenuBarEditorSegment, UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment*> m_elements;146 QMap<UIMenuBarEditorSegment, UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment*> m_elements; 144 147 }; 145 148 … … 167 170 } 168 171 169 QString UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment::text(QAccessible::Text /* enmTextRole */) const172 QString UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment::text(QAccessible::Text) const 170 173 { 171 174 return m_pParent->subText(m_enmIndex); … … 301 304 /* Null string by default: */ 302 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 { 303 320 } 304 321 … … 322 339 #ifndef VBOX_WS_MAC 323 340 , m_pCheckBoxEnable(0) 324 #endif /* !VBOX_WS_MAC */341 #endif 325 342 , m_restrictionsOfMenuBar(UIExtraDataMetaDefs::MenuType_Invalid) 326 343 , m_restrictionsOfMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Invalid) … … 645 662 } 646 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 647 749 void UIMenuBarEditorWidget::sltHandleConfigurationChange(const QString &strMachineID) 648 750 { … … 660 762 #ifdef VBOX_WITH_DEBUGGER_GUI 661 763 setRestrictionsOfMenuDebug(gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(machineID())); 662 #endif /* VBOX_WITH_DEBUGGER_GUI */764 #endif 663 765 #ifdef VBOX_WS_MAC 664 766 setRestrictionsOfMenuWindow(gEDataManager->restrictedRuntimeMenuWindowActionTypes(machineID())); 665 #endif /* VBOX_WS_MAC */767 #endif 666 768 setRestrictionsOfMenuHelp(gEDataManager->restrictedRuntimeMenuHelpActionTypes(machineID())); 667 769 } … … 679 781 { 680 782 /* Get sender type: */ 681 const UIExtraDataMetaDefs::MenuType type =783 const UIExtraDataMetaDefs::MenuType enmType = 682 784 static_cast<UIExtraDataMetaDefs::MenuType>(pAction->property("type").toInt()); 683 785 /* Invert restriction for sender type: */ 684 m_restrictionsOfMenuBar = (UIExtraDataMetaDefs::MenuType)(m_restrictionsOfMenuBar ^ type);786 m_restrictionsOfMenuBar = (UIExtraDataMetaDefs::MenuType)(m_restrictionsOfMenuBar ^ enmType); 685 787 if (m_fStartedFromVMSettings) 686 788 { … … 698 800 { 699 801 /* Get sender type: */ 700 const UIExtraDataMetaDefs::MenuApplicationActionType type =802 const UIExtraDataMetaDefs::MenuApplicationActionType enmType = 701 803 static_cast<UIExtraDataMetaDefs::MenuApplicationActionType>(pAction->property("type").toInt()); 702 804 /* Invert restriction for sender type: */ 703 m_restrictionsOfMenuApplication = (UIExtraDataMetaDefs::MenuApplicationActionType)(m_restrictionsOfMenuApplication ^ type);805 m_restrictionsOfMenuApplication = (UIExtraDataMetaDefs::MenuApplicationActionType)(m_restrictionsOfMenuApplication ^ enmType); 704 806 if (m_fStartedFromVMSettings) 705 807 { … … 717 819 { 718 820 /* Get sender type: */ 719 const UIExtraDataMetaDefs::RuntimeMenuMachineActionType type =821 const UIExtraDataMetaDefs::RuntimeMenuMachineActionType enmType = 720 822 static_cast<UIExtraDataMetaDefs::RuntimeMenuMachineActionType>(pAction->property("type").toInt()); 721 823 /* Invert restriction for sender type: */ 722 m_restrictionsOfMenuMachine = (UIExtraDataMetaDefs::RuntimeMenuMachineActionType)(m_restrictionsOfMenuMachine ^ type);824 m_restrictionsOfMenuMachine = (UIExtraDataMetaDefs::RuntimeMenuMachineActionType)(m_restrictionsOfMenuMachine ^ enmType); 723 825 if (m_fStartedFromVMSettings) 724 826 { … … 736 838 { 737 839 /* Get sender type: */ 738 const UIExtraDataMetaDefs::RuntimeMenuViewActionType type =840 const UIExtraDataMetaDefs::RuntimeMenuViewActionType enmType = 739 841 static_cast<UIExtraDataMetaDefs::RuntimeMenuViewActionType>(pAction->property("type").toInt()); 740 842 /* Invert restriction for sender type: */ 741 m_restrictionsOfMenuView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)(m_restrictionsOfMenuView ^ type);843 m_restrictionsOfMenuView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)(m_restrictionsOfMenuView ^ enmType); 742 844 if (m_fStartedFromVMSettings) 743 845 { … … 755 857 { 756 858 /* Get sender type: */ 757 const UIExtraDataMetaDefs::RuntimeMenuInputActionType type =859 const UIExtraDataMetaDefs::RuntimeMenuInputActionType enmType = 758 860 static_cast<UIExtraDataMetaDefs::RuntimeMenuInputActionType>(pAction->property("type").toInt()); 759 861 /* Invert restriction for sender type: */ 760 m_restrictionsOfMenuInput = (UIExtraDataMetaDefs::RuntimeMenuInputActionType)(m_restrictionsOfMenuInput ^ type);862 m_restrictionsOfMenuInput = (UIExtraDataMetaDefs::RuntimeMenuInputActionType)(m_restrictionsOfMenuInput ^ enmType); 761 863 if (m_fStartedFromVMSettings) 762 864 { … … 774 876 { 775 877 /* Get sender type: */ 776 const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType type =878 const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType enmType = 777 879 static_cast<UIExtraDataMetaDefs::RuntimeMenuDevicesActionType>(pAction->property("type").toInt()); 778 880 /* Invert restriction for sender type: */ 779 m_restrictionsOfMenuDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(m_restrictionsOfMenuDevices ^ type);881 m_restrictionsOfMenuDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(m_restrictionsOfMenuDevices ^ enmType); 780 882 if (m_fStartedFromVMSettings) 781 883 { … … 794 896 { 795 897 /* Get sender type: */ 796 const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType type =898 const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType enmType = 797 899 static_cast<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>(pAction->property("type").toInt()); 798 900 /* Invert restriction for sender type: */ 799 m_restrictionsOfMenuDebug = (UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType)(m_restrictionsOfMenuDebug ^ type);901 m_restrictionsOfMenuDebug = (UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType)(m_restrictionsOfMenuDebug ^ enmType); 800 902 if (m_fStartedFromVMSettings) 801 903 { … … 815 917 { 816 918 /* Get sender type: */ 817 const UIExtraDataMetaDefs::MenuWindowActionType type =919 const UIExtraDataMetaDefs::MenuWindowActionType enmType = 818 920 static_cast<UIExtraDataMetaDefs::MenuWindowActionType>(pAction->property("type").toInt()); 819 921 /* Invert restriction for sender type: */ 820 m_restrictionsOfMenuWindow = (UIExtraDataMetaDefs::MenuWindowActionType)(m_restrictionsOfMenuWindow ^ type);922 m_restrictionsOfMenuWindow = (UIExtraDataMetaDefs::MenuWindowActionType)(m_restrictionsOfMenuWindow ^ enmType); 821 923 if (m_fStartedFromVMSettings) 822 924 { … … 835 937 { 836 938 /* Get sender type: */ 837 const UIExtraDataMetaDefs::MenuHelpActionType type =939 const UIExtraDataMetaDefs::MenuHelpActionType enmType = 838 940 static_cast<UIExtraDataMetaDefs::MenuHelpActionType>(pAction->property("type").toInt()); 839 941 /* Invert restriction for sender type: */ 840 m_restrictionsOfMenuHelp = (UIExtraDataMetaDefs::MenuHelpActionType)(m_restrictionsOfMenuHelp ^ type);942 m_restrictionsOfMenuHelp = (UIExtraDataMetaDefs::MenuHelpActionType)(m_restrictionsOfMenuHelp ^ enmType); 841 943 if (m_fStartedFromVMSettings) 842 944 { … … 952 1054 #ifdef VBOX_WITH_DEBUGGER_GUI 953 1055 prepareMenuDebug(); 954 #endif /* VBOX_WITH_DEBUGGER_GUI */1056 #endif 955 1057 #ifdef VBOX_WS_MAC 956 1058 prepareMenuWindow(); 957 #endif /* VBOX_WS_MAC */1059 #endif 958 1060 prepareMenuHelp(); 959 1061 … … 969 1071 #ifdef VBOX_WITH_DEBUGGER_GUI 970 1072 setRestrictionsOfMenuDebug(gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(machineID())); 971 #endif /* VBOX_WITH_DEBUGGER_GUI */1073 #endif 972 1074 #ifdef VBOX_WS_MAC 973 1075 setRestrictionsOfMenuWindow(gEDataManager->restrictedRuntimeMenuWindowActionTypes(machineID())); 974 #endif /* VBOX_WS_MAC */1076 #endif 975 1077 setRestrictionsOfMenuHelp(gEDataManager->restrictedRuntimeMenuHelpActionTypes(machineID())); 976 1078 /* And listen for the menu-bar configuration changes after that: */ … … 981 1083 982 1084 #ifdef VBOX_WS_MAC 983 QMenu *UIMenuBarEditorWidget::prepareNamedMenu(const QString &strName)1085 QMenu *UIMenuBarEditorWidget::prepareNamedMenu(const QString &strName) 984 1086 { 985 1087 /* Create named menu: */ … … 1027 1129 #endif /* VBOX_WS_MAC */ 1028 1130 1029 QMenu *UIMenuBarEditorWidget::prepareCopiedMenu(const UIAction *pAction)1131 QMenu *UIMenuBarEditorWidget::prepareCopiedMenu(const UIAction *pAction) 1030 1132 { 1031 1133 /* Create copied menu: */ … … 1079 1181 1080 1182 #if 0 1081 QMenu *UIMenuBarEditorWidget::prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction)1183 QMenu *UIMenuBarEditorWidget::prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction) 1082 1184 { 1083 1185 /* Create copied sub-menu: */ … … 1104 1206 #endif 1105 1207 1106 QAction *UIMenuBarEditorWidget::prepareNamedAction(QMenu *pMenu, const QString &strName,1208 QAction *UIMenuBarEditorWidget::prepareNamedAction(QMenu *pMenu, const QString &strName, 1107 1209 int iExtraDataID, const QString &strExtraDataID) 1108 1210 { … … 1122 1224 } 1123 1225 1124 QAction *UIMenuBarEditorWidget::prepareCopiedAction(QMenu *pMenu, const UIAction *pAction)1226 QAction *UIMenuBarEditorWidget::prepareCopiedAction(QMenu *pMenu, const UIAction *pAction) 1125 1227 { 1126 1228 /* Create copied action: */ … … 1297 1399 #ifndef VBOX_WS_MAC 1298 1400 prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_Simple_About)); 1299 #endif /* !VBOX_WS_MAC */ 1300 } 1301 } 1302 1303 void UIMenuBarEditorWidget::retranslateUi() 1304 { 1305 /* Translate close-button if necessary: */ 1306 if (!m_fStartedFromVMSettings && m_pButtonClose) 1307 m_pButtonClose->setToolTip(tr("Close")); 1308 #ifndef VBOX_WS_MAC 1309 /* Translate enable-checkbox if necessary: */ 1310 if (m_fStartedFromVMSettings && m_pCheckBoxEnable) 1311 m_pCheckBoxEnable->setToolTip(tr("Enable Menu Bar")); 1312 #endif /* !VBOX_WS_MAC */ 1313 } 1314 1315 void UIMenuBarEditorWidget::paintEvent(QPaintEvent*) 1316 { 1317 /* Prepare painter: */ 1318 QPainter painter(this); 1319 1320 /* Prepare palette colors: */ 1321 const QPalette pal = palette(); 1322 QColor color0 = pal.color(QPalette::Window); 1323 QColor color1 = pal.color(QPalette::Window).lighter(110); 1324 color1.setAlpha(0); 1325 QColor color2 = pal.color(QPalette::Window).darker(200); 1326 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11) 1327 QColor color3 = pal.color(QPalette::Window).darker(120); 1328 #endif /* VBOX_WS_WIN || VBOX_WS_X11 */ 1329 1330 /* Acquire metric: */ 1331 const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4; 1332 1333 /* Left corner: */ 1334 QRadialGradient grad1(QPointF(iMetric, height() - iMetric), iMetric); 1335 { 1336 grad1.setColorAt(0, color2); 1337 grad1.setColorAt(1, color1); 1338 } 1339 /* Right corner: */ 1340 QRadialGradient grad2(QPointF(width() - iMetric, height() - iMetric), iMetric); 1341 { 1342 grad2.setColorAt(0, color2); 1343 grad2.setColorAt(1, color1); 1344 } 1345 /* Bottom line: */ 1346 QLinearGradient grad3(QPointF(iMetric, height()), QPointF(iMetric, height() - iMetric)); 1347 { 1348 grad3.setColorAt(0, color1); 1349 grad3.setColorAt(1, color2); 1350 } 1351 /* Left line: */ 1352 QLinearGradient grad4(QPointF(0, height() - iMetric), QPointF(iMetric, height() - iMetric)); 1353 { 1354 grad4.setColorAt(0, color1); 1355 grad4.setColorAt(1, color2); 1356 } 1357 /* Right line: */ 1358 QLinearGradient grad5(QPointF(width(), height() - iMetric), QPointF(width() - iMetric, height() - iMetric)); 1359 { 1360 grad5.setColorAt(0, color1); 1361 grad5.setColorAt(1, color2); 1362 } 1363 1364 /* Paint shape/shadow: */ 1365 painter.fillRect(QRect(iMetric, 0, width() - iMetric * 2, height() - iMetric), color0); // background 1366 painter.fillRect(QRect(0, height() - iMetric, iMetric, iMetric), grad1); // left corner 1367 painter.fillRect(QRect(width() - iMetric, height() - iMetric, iMetric, iMetric), grad2); // right corner 1368 painter.fillRect(QRect(iMetric, height() - iMetric, width() - iMetric * 2, iMetric), grad3); // bottom line 1369 painter.fillRect(QRect(0, 0, iMetric, height() - iMetric), grad4); // left line 1370 painter.fillRect(QRect(width() - iMetric, 0, iMetric, height() - iMetric), grad5); // right line 1371 1372 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11) 1373 /* Paint frames: */ 1374 painter.save(); 1375 painter.setPen(color3); 1376 painter.drawLine(QLine(QPoint(iMetric + 1, 0), 1377 QPoint(iMetric + 1, height() - 1 - iMetric - 1))); 1378 painter.drawLine(QLine(QPoint(iMetric + 1, height() - 1 - iMetric - 1), 1379 QPoint(width() - 1 - iMetric - 1, height() - 1 - iMetric - 1))); 1380 painter.drawLine(QLine(QPoint(width() - 1 - iMetric - 1, height() - 1 - iMetric - 1), 1381 QPoint(width() - 1 - iMetric - 1, 0))); 1382 if (m_fStartedFromVMSettings) 1383 painter.drawLine(QLine(QPoint(width() - 1 - iMetric - 1, 0), QPoint(iMetric + 1, 0))); 1384 painter.restore(); 1385 #endif /* VBOX_WS_WIN || VBOX_WS_X11 */ 1386 } 1387 1388 1389 UIMenuBarEditorWindow::UIMenuBarEditorWindow(UIMachineWindow *pParent, UIActionPool *pActionPool) 1390 #ifndef VBOX_WS_MAC 1391 : UISlidingToolBar(pParent, pParent->menuBar(), new UIMenuBarEditorWidget(0, false, vboxGlobal().managedVMUuid(), pActionPool), UISlidingToolBar::Position_Top) 1392 #else /* VBOX_WS_MAC */ 1393 : UISlidingToolBar(pParent, 0, new UIMenuBarEditorWidget(0, false, vboxGlobal().managedVMUuid(), pActionPool), UISlidingToolBar::Position_Top) 1394 #endif /* VBOX_WS_MAC */ 1395 { 1396 } 1397 1401 #endif 1402 } 1403 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMenuBarEditorWindow.h
r72024 r72025 5 5 6 6 /* 7 * Copyright (C) 2014-201 7Oracle Corporation7 * Copyright (C) 2014-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 23 23 24 24 /* GUI includes: */ 25 #include "QIWithRetranslateUI.h" 25 26 #include "UIExtraDataDefs.h" 27 #include "UILibraryDefs.h" 26 28 #include "UISlidingToolBar.h" 27 #include "QIWithRetranslateUI.h"28 29 29 30 /* Forward declarations: */ 30 class UIMachineWindow; 31 class QAction; 32 class QHBoxLayout; 33 class QMenu; 34 #ifndef VBOX_WS_MAC 35 class QCheckBox; 36 #endif 37 class QString; 38 class QWidget; 39 class QIToolButton; 40 class UIAction; 31 41 class UIActionPool; 32 42 class UIToolBar; 33 class UIAction; 34 class QIToolButton; 35 #ifndef VBOX_WS_MAC 36 class QCheckBox; 37 #endif /* !VBOX_WS_MAC */ 38 class QHBoxLayout; 39 class QAction; 40 class QMenu; 41 42 /** UISlidingToolBar wrapper 43 class UIMachineWindow; 44 45 46 /** UISlidingToolBar subclass 43 47 * providing user with possibility to edit menu-bar layout. */ 44 class UIMenuBarEditorWindow : public UISlidingToolBar48 class SHARED_LIBRARY_STUFF UIMenuBarEditorWindow : public UISlidingToolBar 45 49 { 46 50 Q_OBJECT; … … 48 52 public: 49 53 50 /** Construct or, passes @a pParent to the UISlidingToolBar constructor.51 * @param pActionPool brings the action-pool reference for internal use. */54 /** Constructs sliding toolbar passing @a pParent to the base-class. 55 * @param pActionPool Brings the action-pool reference for internal use. */ 52 56 UIMenuBarEditorWindow(UIMachineWindow *pParent, UIActionPool *pActionPool); 53 57 }; 54 58 55 /** QWidget reimplementation 59 60 /** QWidget subclass 56 61 * used as menu-bar editor widget. */ 57 class UIMenuBarEditorWidget : public QIWithRetranslateUI2<QWidget>62 class SHARED_LIBRARY_STUFF UIMenuBarEditorWidget : public QIWithRetranslateUI2<QWidget> 58 63 { 59 64 Q_OBJECT; … … 66 71 public: 67 72 68 /** Constructor. 69 * @param pParent is passed to QWidget constructor, 70 * @param fStartedFromVMSettings determines whether 'this' is a part of VM settings, 71 * @param strMachineID brings the machine ID to be used by the editor, 72 * @param pActionPool brings the action-pool to be used by the editor. */ 73 /** Constructs menu-bar editor widget passing @a pParent to the base-class. 74 * @param fStartedFromVMSettings Brings whether 'this' is a part of VM settings. 75 * @param strMachineID Brings the machine ID to be used by the editor. 76 * @param pActionPool Brings the action-pool to be used by the editor. */ 73 77 UIMenuBarEditorWidget(QWidget *pParent, 74 78 bool fStartedFromVMSettings = true, … … 77 81 78 82 /** Returns the machine ID instance. */ 79 const QString &machineID() const { return m_strMachineID; }83 const QString &machineID() const { return m_strMachineID; } 80 84 /** Defines the @a strMachineID instance. */ 81 85 void setMachineID(const QString &strMachineID); 82 86 83 87 /** Returns the action-pool reference. */ 84 const UIActionPool *actionPool() const { return m_pActionPool; }88 const UIActionPool *actionPool() const { return m_pActionPool; } 85 89 /** Defines the @a pActionPool reference. */ 86 90 void setActionPool(UIActionPool *pActionPool); … … 91 95 /** Defines whether the menu-bar @a fEnabled. */ 92 96 void setMenuBarEnabled(bool fEnabled); 93 #endif /* !VBOX_WS_MAC */97 #endif 94 98 95 99 /** Returns the cached restrictions of menu-bar. */ … … 108 112 /** Returns the cached restrictions of menu 'Debug'. */ 109 113 UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType restrictionsOfMenuDebug() const { return m_restrictionsOfMenuDebug; } 110 #endif /* VBOX_WITH_DEBUGGER_GUI */111 #ifdef VBOX_WS_MAC 112 /** Mac OS X:Returns the cached restrictions of menu 'Window'. */114 #endif 115 #ifdef VBOX_WS_MAC 116 /** Returns the cached restrictions of menu 'Window'. */ 113 117 UIExtraDataMetaDefs::MenuWindowActionType restrictionsOfMenuWindow() const { return m_restrictionsOfMenuWindow; } 114 #endif /* VBOX_WS_MAC */118 #endif 115 119 /** Returns the cached restrictions of menu 'Help'. */ 116 120 UIExtraDataMetaDefs::MenuHelpActionType restrictionsOfMenuHelp() const { return m_restrictionsOfMenuHelp; } … … 131 135 /** Defines the cached @a restrictions of menu 'Debug'. */ 132 136 void setRestrictionsOfMenuDebug(UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType restrictions); 133 #endif /* VBOX_WITH_DEBUGGER_GUI */134 #ifdef VBOX_WS_MAC 135 /** Mac OS X:Defines the cached @a restrictions of menu 'Window'. */137 #endif 138 #ifdef VBOX_WS_MAC 139 /** Defines the cached @a restrictions of menu 'Window'. */ 136 140 void setRestrictionsOfMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType restrictions); 137 #endif /* VBOX_WS_MAC */141 #endif 138 142 /** Defines the cached @a restrictions of menu 'Help'. */ 139 143 void setRestrictionsOfMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType restrictions); 140 144 145 protected: 146 147 /** Handles translation event. */ 148 virtual void retranslateUi() /* override */; 149 150 /** Handles paint @a pEvent. */ 151 virtual void paintEvent(QPaintEvent *pEvent) /* override */; 152 141 153 private slots: 142 154 … … 154 166 #ifdef VBOX_WS_MAC 155 167 /** Prepare named menu routine. */ 156 QMenu *prepareNamedMenu(const QString &strName);157 #endif /* VBOX_WS_MAC */168 QMenu *prepareNamedMenu(const QString &strName); 169 #endif 158 170 /** Prepare copied menu routine. */ 159 QMenu *prepareCopiedMenu(const UIAction *pAction);171 QMenu *prepareCopiedMenu(const UIAction *pAction); 160 172 #if 0 161 173 /** Prepare copied sub-menu routine. */ 162 QMenu *prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction);174 QMenu *prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction); 163 175 #endif 164 176 /** Prepare named action routine. */ 165 QAction *prepareNamedAction(QMenu *pMenu, const QString &strName,177 QAction *prepareNamedAction(QMenu *pMenu, const QString &strName, 166 178 int iExtraDataID, const QString &strExtraDataID); 167 179 /** Prepare copied action routine. */ 168 QAction *prepareCopiedAction(QMenu *pMenu, const UIAction *pAction);180 QAction *prepareCopiedAction(QMenu *pMenu, const UIAction *pAction); 169 181 170 182 /** Prepare menus routine. */ … … 183 195 /** Prepare 'Debug' menu routine. */ 184 196 void prepareMenuDebug(); 185 #endif /* VBOX_WITH_DEBUGGER_GUI */186 #ifdef VBOX_WS_MAC 187 /** Mac OS X:Prepare 'Window' menu routine. */197 #endif 198 #ifdef VBOX_WS_MAC 199 /** Prepare 'Window' menu routine. */ 188 200 void prepareMenuWindow(); 189 #endif /* VBOX_WS_MAC */201 #endif 190 202 /** Prepare 'Help' menu routine. */ 191 203 void prepareMenuHelp(); 192 193 /** Retranslation routine. */194 virtual void retranslateUi();195 196 /** Paint event handler. */197 virtual void paintEvent(QPaintEvent *pEvent);198 204 199 205 /** @name General 200 206 * @{ */ 201 207 /** Holds whether 'this' is prepared. */ 202 bool m_fPrepared;208 bool m_fPrepared; 203 209 /** Holds whether 'this' is a part of VM settings. */ 204 bool m_fStartedFromVMSettings;210 bool m_fStartedFromVMSettings; 205 211 /** Holds the machine ID instance. */ 206 QString m_strMachineID;212 QString m_strMachineID; 207 213 /** Holds the action-pool reference. */ 208 214 const UIActionPool *m_pActionPool; … … 212 218 * @{ */ 213 219 /** Holds the main-layout instance. */ 214 QHBoxLayout *m_pMainLayout;220 QHBoxLayout *m_pMainLayout; 215 221 /** Holds the tool-bar instance. */ 216 UIToolBar *m_pToolBar;222 UIToolBar *m_pToolBar; 217 223 /** Holds the close-button instance. */ 218 QIToolButton *m_pButtonClose;224 QIToolButton *m_pButtonClose; 219 225 #ifndef VBOX_WS_MAC 220 /** Non Mac OS X:Holds the enable-checkbox instance. */221 QCheckBox *m_pCheckBoxEnable;222 #endif /* !VBOX_WS_MAC */226 /** Holds the enable-checkbox instance. */ 227 QCheckBox *m_pCheckBoxEnable; 228 #endif 223 229 /** Holds tool-bar action references. */ 224 QMap<QString, QAction*> m_actions;230 QMap<QString, QAction*> m_actions; 225 231 /** @} */ 226 232 … … 228 234 * @{ */ 229 235 /** Holds the cached restrictions of menu-bar. */ 230 UIExtraDataMetaDefs::MenuType m_restrictionsOfMenuBar;236 UIExtraDataMetaDefs::MenuType m_restrictionsOfMenuBar; 231 237 /** Holds the cached restrictions of menu 'Application'. */ 232 UIExtraDataMetaDefs::MenuApplicationActionType m_restrictionsOfMenuApplication;238 UIExtraDataMetaDefs::MenuApplicationActionType m_restrictionsOfMenuApplication; 233 239 /** Holds the cached restrictions of menu 'Machine'. */ 234 UIExtraDataMetaDefs::RuntimeMenuMachineActionType m_restrictionsOfMenuMachine;240 UIExtraDataMetaDefs::RuntimeMenuMachineActionType m_restrictionsOfMenuMachine; 235 241 /** Holds the cached restrictions of menu 'View'. */ 236 UIExtraDataMetaDefs::RuntimeMenuViewActionType m_restrictionsOfMenuView;242 UIExtraDataMetaDefs::RuntimeMenuViewActionType m_restrictionsOfMenuView; 237 243 /** Holds the cached restrictions of menu 'Input'. */ 238 UIExtraDataMetaDefs::RuntimeMenuInputActionType m_restrictionsOfMenuInput;244 UIExtraDataMetaDefs::RuntimeMenuInputActionType m_restrictionsOfMenuInput; 239 245 /** Holds the cached restrictions of menu 'Devices'. */ 240 UIExtraDataMetaDefs::RuntimeMenuDevicesActionType m_restrictionsOfMenuDevices;246 UIExtraDataMetaDefs::RuntimeMenuDevicesActionType m_restrictionsOfMenuDevices; 241 247 #ifdef VBOX_WITH_DEBUGGER_GUI 242 248 /** Holds the cached restrictions of menu 'Debug'. */ 243 UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType m_restrictionsOfMenuDebug;244 #endif /* VBOX_WITH_DEBUGGER_GUI */245 #ifdef VBOX_WS_MAC 246 /** Mac OS X:Holds the cached restrictions of menu 'Window'. */247 UIExtraDataMetaDefs::MenuWindowActionType m_restrictionsOfMenuWindow;248 #endif /* VBOX_WS_MAC */249 UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType m_restrictionsOfMenuDebug; 250 #endif 251 #ifdef VBOX_WS_MAC 252 /** Holds the cached restrictions of menu 'Window'. */ 253 UIExtraDataMetaDefs::MenuWindowActionType m_restrictionsOfMenuWindow; 254 #endif 249 255 /** Holds the cached restrictions of menu 'Help'. */ 250 UIExtraDataMetaDefs::MenuHelpActionType m_restrictionsOfMenuHelp;256 UIExtraDataMetaDefs::MenuHelpActionType m_restrictionsOfMenuHelp; 251 257 /** @} */ 252 258 }; 253 259 260 254 261 #endif /* !___UIMenuBarEditorWindow_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.