VirtualBox

Changeset 72025 in vbox


Ignore:
Timestamp:
Apr 25, 2018 5:13:11 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
122288
Message:

FE/Qt: bugref:9049: Full and heavy cleanup for UIMenuBarEditorWindow and move it to VBoxGlobal library.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
1 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r72022 r72025  
    462462        src/runtime/UIMachineWindow.h \
    463463        src/runtime/UIMachineView.h \
    464         src/runtime/UIMenuBarEditorWindow.h \
    465464        src/runtime/UIMouseHandler.h \
    466465        src/runtime/UIMultiScreenLayout.h \
     
    677676        src/widgets/UIMediumSizeEditor.h \
    678677        src/widgets/UIMenuBar.h \
     678        src/widgets/UIMenuBarEditorWindow.h \
    679679        src/widgets/UINameAndSystemEditor.h \
    680680        src/widgets/UIPopupBox.h \
     
    784784        src/widgets/UIMediumSizeEditor.h \
    785785        src/widgets/UIMenuBar.h \
     786        src/widgets/UIMenuBarEditorWindow.h \
    786787        src/widgets/UINameAndSystemEditor.h \
    787788        src/widgets/UIPopupBox.h \
     
    969970        src/runtime/UIMachineView.cpp \
    970971        src/runtime/UIMachineWindow.cpp \
    971         src/runtime/UIMenuBarEditorWindow.cpp \
    972972        src/runtime/UIMouseHandler.cpp \
    973973        src/runtime/UIMultiScreenLayout.cpp \
     
    12231223        src/widgets/UIMediumSizeEditor.cpp \
    12241224        src/widgets/UIMenuBar.cpp \
     1225        src/widgets/UIMenuBarEditorWindow.cpp \
    12251226        src/widgets/UINameAndSystemEditor.cpp \
    12261227        src/widgets/UIPopupBox.cpp \
     
    13561357        src/widgets/UIMediumSizeEditor.cpp \
    13571358        src/widgets/UIMenuBar.cpp \
     1359        src/widgets/UIMenuBarEditorWindow.cpp \
    13581360        src/widgets/UINameAndSystemEditor.cpp \
    13591361        src/widgets/UIPopupBox.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMenuBarEditorWindow.cpp

    r72024 r72025  
    55
    66/*
    7  * Copyright (C) 2014-2017 Oracle Corporation
     7 * Copyright (C) 2014-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3131# ifndef VBOX_WS_MAC
    3232#  include <QCheckBox>
    33 # endif /* !VBOX_WS_MAC */
     33# endif
    3434
    3535/* 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"
    4336# include "QIToolButton.h"
    4437# 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"
    4545
    4646#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    4747
    4848/* Forward declarations: */
     49class QAccessibleInterface;
     50class QRect;
    4951class UIAccessibilityInterfaceForUIMenuBarEditorButton;
    5052
     
    104106    /** Holds the parent interface we are linked to. */
    105107    UIAccessibilityInterfaceForUIMenuBarEditorButton *m_pParent;
     108
    106109    /** Holds the index of segment we are referring to. */
    107     const UIMenuBarEditorSegment m_enmIndex;
     110    const UIMenuBarEditorSegment  m_enmIndex;
    108111};
    109112
     
    141144
    142145    /** Holds the map of instances of sub-element interfaces. */
    143     QMap<UIMenuBarEditorSegment, UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment*> m_elements;
     146    QMap<UIMenuBarEditorSegment, UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment*>  m_elements;
    144147};
    145148
     
    167170}
    168171
    169 QString UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment::text(QAccessible::Text /* enmTextRole */) const
     172QString UIAccessibilityInterfaceForUIMenuBarEditorButtonSegment::text(QAccessible::Text) const
    170173{
    171174    return m_pParent->subText(m_enmIndex);
     
    301304    /* Null string by default: */
    302305    return QString();
     306}
     307
     308
     309/*********************************************************************************************************************************
     310*   Class UIMenuBarEditorWindow implementation.                                                                                  *
     311*********************************************************************************************************************************/
     312
     313UIMenuBarEditorWindow::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{
    303320}
    304321
     
    322339#ifndef VBOX_WS_MAC
    323340    , m_pCheckBoxEnable(0)
    324 #endif /* !VBOX_WS_MAC */
     341#endif
    325342    , m_restrictionsOfMenuBar(UIExtraDataMetaDefs::MenuType_Invalid)
    326343    , m_restrictionsOfMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Invalid)
     
    645662}
    646663
     664void 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
     676void 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
    647749void UIMenuBarEditorWidget::sltHandleConfigurationChange(const QString &strMachineID)
    648750{
     
    660762#ifdef VBOX_WITH_DEBUGGER_GUI
    661763    setRestrictionsOfMenuDebug(gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(machineID()));
    662 #endif /* VBOX_WITH_DEBUGGER_GUI */
     764#endif
    663765#ifdef VBOX_WS_MAC
    664766    setRestrictionsOfMenuWindow(gEDataManager->restrictedRuntimeMenuWindowActionTypes(machineID()));
    665 #endif /* VBOX_WS_MAC */
     767#endif
    666768    setRestrictionsOfMenuHelp(gEDataManager->restrictedRuntimeMenuHelpActionTypes(machineID()));
    667769}
     
    679781        {
    680782            /* Get sender type: */
    681             const UIExtraDataMetaDefs::MenuType type =
     783            const UIExtraDataMetaDefs::MenuType enmType =
    682784                static_cast<UIExtraDataMetaDefs::MenuType>(pAction->property("type").toInt());
    683785            /* Invert restriction for sender type: */
    684             m_restrictionsOfMenuBar = (UIExtraDataMetaDefs::MenuType)(m_restrictionsOfMenuBar ^ type);
     786            m_restrictionsOfMenuBar = (UIExtraDataMetaDefs::MenuType)(m_restrictionsOfMenuBar ^ enmType);
    685787            if (m_fStartedFromVMSettings)
    686788            {
     
    698800        {
    699801            /* Get sender type: */
    700             const UIExtraDataMetaDefs::MenuApplicationActionType type =
     802            const UIExtraDataMetaDefs::MenuApplicationActionType enmType =
    701803                static_cast<UIExtraDataMetaDefs::MenuApplicationActionType>(pAction->property("type").toInt());
    702804            /* Invert restriction for sender type: */
    703             m_restrictionsOfMenuApplication = (UIExtraDataMetaDefs::MenuApplicationActionType)(m_restrictionsOfMenuApplication ^ type);
     805            m_restrictionsOfMenuApplication = (UIExtraDataMetaDefs::MenuApplicationActionType)(m_restrictionsOfMenuApplication ^ enmType);
    704806            if (m_fStartedFromVMSettings)
    705807            {
     
    717819        {
    718820            /* Get sender type: */
    719             const UIExtraDataMetaDefs::RuntimeMenuMachineActionType type =
     821            const UIExtraDataMetaDefs::RuntimeMenuMachineActionType enmType =
    720822                static_cast<UIExtraDataMetaDefs::RuntimeMenuMachineActionType>(pAction->property("type").toInt());
    721823            /* Invert restriction for sender type: */
    722             m_restrictionsOfMenuMachine = (UIExtraDataMetaDefs::RuntimeMenuMachineActionType)(m_restrictionsOfMenuMachine ^ type);
     824            m_restrictionsOfMenuMachine = (UIExtraDataMetaDefs::RuntimeMenuMachineActionType)(m_restrictionsOfMenuMachine ^ enmType);
    723825            if (m_fStartedFromVMSettings)
    724826            {
     
    736838        {
    737839            /* Get sender type: */
    738             const UIExtraDataMetaDefs::RuntimeMenuViewActionType type =
     840            const UIExtraDataMetaDefs::RuntimeMenuViewActionType enmType =
    739841                static_cast<UIExtraDataMetaDefs::RuntimeMenuViewActionType>(pAction->property("type").toInt());
    740842            /* Invert restriction for sender type: */
    741             m_restrictionsOfMenuView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)(m_restrictionsOfMenuView ^ type);
     843            m_restrictionsOfMenuView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)(m_restrictionsOfMenuView ^ enmType);
    742844            if (m_fStartedFromVMSettings)
    743845            {
     
    755857        {
    756858            /* Get sender type: */
    757             const UIExtraDataMetaDefs::RuntimeMenuInputActionType type =
     859            const UIExtraDataMetaDefs::RuntimeMenuInputActionType enmType =
    758860                static_cast<UIExtraDataMetaDefs::RuntimeMenuInputActionType>(pAction->property("type").toInt());
    759861            /* Invert restriction for sender type: */
    760             m_restrictionsOfMenuInput = (UIExtraDataMetaDefs::RuntimeMenuInputActionType)(m_restrictionsOfMenuInput ^ type);
     862            m_restrictionsOfMenuInput = (UIExtraDataMetaDefs::RuntimeMenuInputActionType)(m_restrictionsOfMenuInput ^ enmType);
    761863            if (m_fStartedFromVMSettings)
    762864            {
     
    774876        {
    775877            /* Get sender type: */
    776             const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType type =
     878            const UIExtraDataMetaDefs::RuntimeMenuDevicesActionType enmType =
    777879                static_cast<UIExtraDataMetaDefs::RuntimeMenuDevicesActionType>(pAction->property("type").toInt());
    778880            /* Invert restriction for sender type: */
    779             m_restrictionsOfMenuDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(m_restrictionsOfMenuDevices ^ type);
     881            m_restrictionsOfMenuDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(m_restrictionsOfMenuDevices ^ enmType);
    780882            if (m_fStartedFromVMSettings)
    781883            {
     
    794896        {
    795897            /* Get sender type: */
    796             const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType type =
     898            const UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType enmType =
    797899                static_cast<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>(pAction->property("type").toInt());
    798900            /* Invert restriction for sender type: */
    799             m_restrictionsOfMenuDebug = (UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType)(m_restrictionsOfMenuDebug ^ type);
     901            m_restrictionsOfMenuDebug = (UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType)(m_restrictionsOfMenuDebug ^ enmType);
    800902            if (m_fStartedFromVMSettings)
    801903            {
     
    815917        {
    816918            /* Get sender type: */
    817             const UIExtraDataMetaDefs::MenuWindowActionType type =
     919            const UIExtraDataMetaDefs::MenuWindowActionType enmType =
    818920                static_cast<UIExtraDataMetaDefs::MenuWindowActionType>(pAction->property("type").toInt());
    819921            /* Invert restriction for sender type: */
    820             m_restrictionsOfMenuWindow = (UIExtraDataMetaDefs::MenuWindowActionType)(m_restrictionsOfMenuWindow ^ type);
     922            m_restrictionsOfMenuWindow = (UIExtraDataMetaDefs::MenuWindowActionType)(m_restrictionsOfMenuWindow ^ enmType);
    821923            if (m_fStartedFromVMSettings)
    822924            {
     
    835937        {
    836938            /* Get sender type: */
    837             const UIExtraDataMetaDefs::MenuHelpActionType type =
     939            const UIExtraDataMetaDefs::MenuHelpActionType enmType =
    838940                static_cast<UIExtraDataMetaDefs::MenuHelpActionType>(pAction->property("type").toInt());
    839941            /* Invert restriction for sender type: */
    840             m_restrictionsOfMenuHelp = (UIExtraDataMetaDefs::MenuHelpActionType)(m_restrictionsOfMenuHelp ^ type);
     942            m_restrictionsOfMenuHelp = (UIExtraDataMetaDefs::MenuHelpActionType)(m_restrictionsOfMenuHelp ^ enmType);
    841943            if (m_fStartedFromVMSettings)
    842944            {
     
    9521054#ifdef VBOX_WITH_DEBUGGER_GUI
    9531055    prepareMenuDebug();
    954 #endif /* VBOX_WITH_DEBUGGER_GUI */
     1056#endif
    9551057#ifdef VBOX_WS_MAC
    9561058    prepareMenuWindow();
    957 #endif /* VBOX_WS_MAC */
     1059#endif
    9581060    prepareMenuHelp();
    9591061
     
    9691071#ifdef VBOX_WITH_DEBUGGER_GUI
    9701072        setRestrictionsOfMenuDebug(gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(machineID()));
    971 #endif /* VBOX_WITH_DEBUGGER_GUI */
     1073#endif
    9721074#ifdef VBOX_WS_MAC
    9731075        setRestrictionsOfMenuWindow(gEDataManager->restrictedRuntimeMenuWindowActionTypes(machineID()));
    974 #endif /* VBOX_WS_MAC */
     1076#endif
    9751077        setRestrictionsOfMenuHelp(gEDataManager->restrictedRuntimeMenuHelpActionTypes(machineID()));
    9761078        /* And listen for the menu-bar configuration changes after that: */
     
    9811083
    9821084#ifdef VBOX_WS_MAC
    983 QMenu* UIMenuBarEditorWidget::prepareNamedMenu(const QString &strName)
     1085QMenu *UIMenuBarEditorWidget::prepareNamedMenu(const QString &strName)
    9841086{
    9851087    /* Create named menu: */
     
    10271129#endif /* VBOX_WS_MAC */
    10281130
    1029 QMenu* UIMenuBarEditorWidget::prepareCopiedMenu(const UIAction *pAction)
     1131QMenu *UIMenuBarEditorWidget::prepareCopiedMenu(const UIAction *pAction)
    10301132{
    10311133    /* Create copied menu: */
     
    10791181
    10801182#if 0
    1081 QMenu* UIMenuBarEditorWidget::prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction)
     1183QMenu *UIMenuBarEditorWidget::prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction)
    10821184{
    10831185    /* Create copied sub-menu: */
     
    11041206#endif
    11051207
    1106 QAction* UIMenuBarEditorWidget::prepareNamedAction(QMenu *pMenu, const QString &strName,
     1208QAction *UIMenuBarEditorWidget::prepareNamedAction(QMenu *pMenu, const QString &strName,
    11071209                                                   int iExtraDataID, const QString &strExtraDataID)
    11081210{
     
    11221224}
    11231225
    1124 QAction* UIMenuBarEditorWidget::prepareCopiedAction(QMenu *pMenu, const UIAction *pAction)
     1226QAction *UIMenuBarEditorWidget::prepareCopiedAction(QMenu *pMenu, const UIAction *pAction)
    11251227{
    11261228    /* Create copied action: */
     
    12971399#ifndef VBOX_WS_MAC
    12981400        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  
    55
    66/*
    7  * Copyright (C) 2014-2017 Oracle Corporation
     7 * Copyright (C) 2014-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2323
    2424/* GUI includes: */
     25#include "QIWithRetranslateUI.h"
    2526#include "UIExtraDataDefs.h"
     27#include "UILibraryDefs.h"
    2628#include "UISlidingToolBar.h"
    27 #include "QIWithRetranslateUI.h"
    2829
    2930/* Forward declarations: */
    30 class UIMachineWindow;
     31class QAction;
     32class QHBoxLayout;
     33class QMenu;
     34#ifndef VBOX_WS_MAC
     35class QCheckBox;
     36#endif
     37class QString;
     38class QWidget;
     39class QIToolButton;
     40class UIAction;
    3141class UIActionPool;
    3242class 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
     43class UIMachineWindow;
     44
     45
     46/** UISlidingToolBar subclass
    4347  * providing user with possibility to edit menu-bar layout. */
    44 class UIMenuBarEditorWindow : public UISlidingToolBar
     48class SHARED_LIBRARY_STUFF UIMenuBarEditorWindow : public UISlidingToolBar
    4549{
    4650    Q_OBJECT;
     
    4852public:
    4953
    50     /** Constructor, 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. */
    5256    UIMenuBarEditorWindow(UIMachineWindow *pParent, UIActionPool *pActionPool);
    5357};
    5458
    55 /** QWidget reimplementation
     59
     60/** QWidget subclass
    5661  * used as menu-bar editor widget. */
    57 class UIMenuBarEditorWidget : public QIWithRetranslateUI2<QWidget>
     62class SHARED_LIBRARY_STUFF UIMenuBarEditorWidget : public QIWithRetranslateUI2<QWidget>
    5863{
    5964    Q_OBJECT;
     
    6671public:
    6772
    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. */
    7377    UIMenuBarEditorWidget(QWidget *pParent,
    7478                          bool fStartedFromVMSettings = true,
     
    7781
    7882    /** Returns the machine ID instance. */
    79     const QString& machineID() const { return m_strMachineID; }
     83    const QString &machineID() const { return m_strMachineID; }
    8084    /** Defines the @a strMachineID instance. */
    8185    void setMachineID(const QString &strMachineID);
    8286
    8387    /** Returns the action-pool reference. */
    84     const UIActionPool* actionPool() const { return m_pActionPool; }
     88    const UIActionPool *actionPool() const { return m_pActionPool; }
    8589    /** Defines the @a pActionPool reference. */
    8690    void setActionPool(UIActionPool *pActionPool);
     
    9195    /** Defines whether the menu-bar @a fEnabled. */
    9296    void setMenuBarEnabled(bool fEnabled);
    93 #endif /* !VBOX_WS_MAC */
     97#endif
    9498
    9599    /** Returns the cached restrictions of menu-bar. */
     
    108112    /** Returns the cached restrictions of menu 'Debug'. */
    109113    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'. */
    113117    UIExtraDataMetaDefs::MenuWindowActionType restrictionsOfMenuWindow() const { return m_restrictionsOfMenuWindow; }
    114 #endif /* VBOX_WS_MAC */
     118#endif
    115119    /** Returns the cached restrictions of menu 'Help'. */
    116120    UIExtraDataMetaDefs::MenuHelpActionType restrictionsOfMenuHelp() const { return m_restrictionsOfMenuHelp; }
     
    131135    /** Defines the cached @a restrictions of menu 'Debug'. */
    132136    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'. */
    136140    void setRestrictionsOfMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType restrictions);
    137 #endif /* VBOX_WS_MAC */
     141#endif
    138142    /** Defines the cached @a restrictions of menu 'Help'. */
    139143    void setRestrictionsOfMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType restrictions);
    140144
     145protected:
     146
     147    /** Handles translation event. */
     148    virtual void retranslateUi() /* override */;
     149
     150    /** Handles paint @a pEvent. */
     151    virtual void paintEvent(QPaintEvent *pEvent) /* override */;
     152
    141153private slots:
    142154
     
    154166#ifdef VBOX_WS_MAC
    155167    /** Prepare named menu routine. */
    156     QMenu* prepareNamedMenu(const QString &strName);
    157 #endif /* VBOX_WS_MAC */
     168    QMenu *prepareNamedMenu(const QString &strName);
     169#endif
    158170    /** Prepare copied menu routine. */
    159     QMenu* prepareCopiedMenu(const UIAction *pAction);
     171    QMenu *prepareCopiedMenu(const UIAction *pAction);
    160172#if 0
    161173    /** Prepare copied sub-menu routine. */
    162     QMenu* prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction);
     174    QMenu *prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction);
    163175#endif
    164176    /** Prepare named action routine. */
    165     QAction* prepareNamedAction(QMenu *pMenu, const QString &strName,
     177    QAction *prepareNamedAction(QMenu *pMenu, const QString &strName,
    166178                                int iExtraDataID, const QString &strExtraDataID);
    167179    /** Prepare copied action routine. */
    168     QAction* prepareCopiedAction(QMenu *pMenu, const UIAction *pAction);
     180    QAction *prepareCopiedAction(QMenu *pMenu, const UIAction *pAction);
    169181
    170182    /** Prepare menus routine. */
     
    183195    /** Prepare 'Debug' menu routine. */
    184196    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. */
    188200    void prepareMenuWindow();
    189 #endif /* VBOX_WS_MAC */
     201#endif
    190202    /** Prepare 'Help' menu routine. */
    191203    void prepareMenuHelp();
    192 
    193     /** Retranslation routine. */
    194     virtual void retranslateUi();
    195 
    196     /** Paint event handler. */
    197     virtual void paintEvent(QPaintEvent *pEvent);
    198204
    199205    /** @name General
    200206      * @{ */
    201207        /** Holds whether 'this' is prepared. */
    202         bool m_fPrepared;
     208        bool                m_fPrepared;
    203209        /** Holds whether 'this' is a part of VM settings. */
    204         bool m_fStartedFromVMSettings;
     210        bool                m_fStartedFromVMSettings;
    205211        /** Holds the machine ID instance. */
    206         QString m_strMachineID;
     212        QString             m_strMachineID;
    207213        /** Holds the action-pool reference. */
    208214        const UIActionPool *m_pActionPool;
     
    212218      * @{ */
    213219        /** Holds the main-layout instance. */
    214         QHBoxLayout *m_pMainLayout;
     220        QHBoxLayout             *m_pMainLayout;
    215221        /** Holds the tool-bar instance. */
    216         UIToolBar *m_pToolBar;
     222        UIToolBar               *m_pToolBar;
    217223        /** Holds the close-button instance. */
    218         QIToolButton *m_pButtonClose;
     224        QIToolButton            *m_pButtonClose;
    219225#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
    223229        /** Holds tool-bar action references. */
    224         QMap<QString, QAction*> m_actions;
     230        QMap<QString, QAction*>  m_actions;
    225231    /** @} */
    226232
     
    228234      * @{ */
    229235        /** Holds the cached restrictions of menu-bar. */
    230         UIExtraDataMetaDefs::MenuType m_restrictionsOfMenuBar;
     236        UIExtraDataMetaDefs::MenuType                       m_restrictionsOfMenuBar;
    231237        /** Holds the cached restrictions of menu 'Application'. */
    232         UIExtraDataMetaDefs::MenuApplicationActionType m_restrictionsOfMenuApplication;
     238        UIExtraDataMetaDefs::MenuApplicationActionType      m_restrictionsOfMenuApplication;
    233239        /** Holds the cached restrictions of menu 'Machine'. */
    234         UIExtraDataMetaDefs::RuntimeMenuMachineActionType m_restrictionsOfMenuMachine;
     240        UIExtraDataMetaDefs::RuntimeMenuMachineActionType   m_restrictionsOfMenuMachine;
    235241        /** Holds the cached restrictions of menu 'View'. */
    236         UIExtraDataMetaDefs::RuntimeMenuViewActionType m_restrictionsOfMenuView;
     242        UIExtraDataMetaDefs::RuntimeMenuViewActionType      m_restrictionsOfMenuView;
    237243        /** Holds the cached restrictions of menu 'Input'. */
    238         UIExtraDataMetaDefs::RuntimeMenuInputActionType m_restrictionsOfMenuInput;
     244        UIExtraDataMetaDefs::RuntimeMenuInputActionType     m_restrictionsOfMenuInput;
    239245        /** Holds the cached restrictions of menu 'Devices'. */
    240         UIExtraDataMetaDefs::RuntimeMenuDevicesActionType m_restrictionsOfMenuDevices;
     246        UIExtraDataMetaDefs::RuntimeMenuDevicesActionType   m_restrictionsOfMenuDevices;
    241247#ifdef VBOX_WITH_DEBUGGER_GUI
    242248        /** 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
    249255        /** Holds the cached restrictions of menu 'Help'. */
    250         UIExtraDataMetaDefs::MenuHelpActionType m_restrictionsOfMenuHelp;
     256        UIExtraDataMetaDefs::MenuHelpActionType             m_restrictionsOfMenuHelp;
    251257    /** @} */
    252258};
    253259
     260
    254261#endif /* !___UIMenuBarEditorWindow_h___ */
Note: See TracChangeset for help on using the changeset viewer.

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