VirtualBox

Changeset 76008 in vbox


Ignore:
Timestamp:
Dec 6, 2018 10:03:50 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8694: UIActionPoolRuntime: And now a bit of cleanup for resize/remap/rescale actions code (s.a. r127226 and r127228).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolRuntime.cpp

    r76006 r76008  
    38513851{
    38523852    AssertPtrReturnVoid(pMenu);
    3853     /* Prepare new contents: */
     3853
     3854    /* Prepare content: */
    38543855    const QList<QSize> sizes = QList<QSize>()
    38553856                               << QSize(640, 480)
     
    38773878        QAction *pToggleAction = pMenu->addAction(QApplication::translate("UIActionPool", "Enable", "Virtual Screen"),
    38783879                                                  this, SLOT(sltHandleActionTriggerViewScreenToggle()));
    3879         AssertPtrReturnVoid(pToggleAction);
     3880        if (pToggleAction)
    38803881        {
    38813882            /* Configure 'toggle' action: */
     
    38913892    /* Create exclusive 'resize' action-group: */
    38923893    QActionGroup *pActionGroup = new QActionGroup(pMenu);
    3893     AssertPtrReturnVoid(pActionGroup);
     3894    if (pActionGroup)
    38943895    {
    38953896        /* Configure exclusive 'resize' action-group: */
    38963897        pActionGroup->setExclusive(true);
     3898
    38973899        /* For every available size: */
    38983900        foreach (const QSize &size, sizes)
     
    39013903            QAction *pAction = pActionGroup->addAction(QApplication::translate("UIActionPool", "Resize to %1x%2", "Virtual Screen")
    39023904                                                                               .arg(size.width()).arg(size.height()));
    3903             AssertPtrReturnVoid(pAction);
     3905            if (pAction)
    39043906            {
    39053907                /* Configure exclusive 'resize' action: */
     
    39083910                pAction->setProperty("Requested Size", size);
    39093911                pAction->setCheckable(true);
    3910                 if (screenSize.width() == size.width() &&
    3911                     screenSize.height() == size.height())
     3912                if (   screenSize.width() == size.width()
     3913                    && screenSize.height() == size.height())
    39123914                    pAction->setChecked(true);
    39133915            }
    39143916        }
     3917
    39153918        /* Insert group actions into menu: */
    39163919        pMenu->addActions(pActionGroup->actions());
    39173920        /* Install listener for exclusive action-group: */
    3918         connect(pActionGroup, SIGNAL(triggered(QAction*)),
    3919                 this, SLOT(sltHandleActionTriggerViewScreenResize(QAction*)));
     3921        connect(pActionGroup, &QActionGroup::triggered,
     3922                this, &UIActionPoolRuntime::sltHandleActionTriggerViewScreenResize);
    39203923    }
    39213924}
     
    39243927{
    39253928    AssertPtrReturnVoid(pMenu);
    3926     /* Get corresponding screen index and size: */
     3929
     3930    /* Get corresponding screen index: */
    39273931    const int iGuestScreenIndex = pMenu->property("Guest Screen Index").toInt();
    39283932
    3929     /* Create exclusive action-group: */
     3933    /* Create exclusive 'remap' action-group: */
    39303934    QActionGroup *pActionGroup = new QActionGroup(pMenu);
    3931     AssertPtrReturnVoid(pActionGroup);
    3932     {
    3933         /* Configure exclusive action-group: */
     3935    if (pActionGroup)
     3936    {
     3937        /* Configure exclusive 'remap' action-group: */
    39343938        pActionGroup->setExclusive(true);
     3939
     3940        /* For every host-screen index: */
    39353941        for (int iHostScreenIndex = 0; iHostScreenIndex < m_cHostScreens; ++iHostScreenIndex)
    39363942        {
    3937             QAction *pAction = pActionGroup->addAction(QApplication::translate("UIMultiScreenLayout",
    3938                                                                               "Use Host Screen %1")
     3943            /* Create exclusive 'remap' action: */
     3944            QAction *pAction = pActionGroup->addAction(QApplication::translate("UIMultiScreenLayout", "Use Host Screen %1")
    39393945                                                                               .arg(iHostScreenIndex + 1));
    3940             AssertPtrReturnVoid(pAction);
     3946            if (pAction)
    39413947            {
     3948                /* Configure exclusive 'remap' action: */
    39423949                pAction->setCheckable(true);
    39433950                pAction->setProperty("Guest Screen Index", iGuestScreenIndex);
    39443951                pAction->setProperty("Host Screen Index", iHostScreenIndex);
    3945                 if (m_mapHostScreenForGuestScreen.contains(iGuestScreenIndex) &&
    3946                     m_mapHostScreenForGuestScreen.value(iGuestScreenIndex) == iHostScreenIndex)
     3952                if (   m_mapHostScreenForGuestScreen.contains(iGuestScreenIndex)
     3953                    && m_mapHostScreenForGuestScreen.value(iGuestScreenIndex) == iHostScreenIndex)
    39473954                    pAction->setChecked(true);
    39483955            }
    39493956        }
     3957
    39503958        /* Insert group actions into menu: */
    39513959        pMenu->addActions(pActionGroup->actions());
    39523960        /* Install listener for exclusive action-group: */
    3953         connect(pActionGroup, SIGNAL(triggered(QAction*)),
    3954                 this, SLOT(sltHandleActionTriggerViewScreenRemap(QAction*)));
     3961        connect(pActionGroup, &QActionGroup::triggered,
     3962                this, &UIActionPoolRuntime::sltHandleActionTriggerViewScreenRemap);
    39553963    }
    39563964}
     
    39603968    AssertPtrReturnVoid(pMenu);
    39613969
    3962     /* Create exclusive 'scale-factor' action-group: */
     3970    /* Get corresponding screen index and scale-factor: */
     3971    const int iGuestScreenIndex = pMenu->property("Guest Screen Index").toInt();
     3972    const double dCurrentScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid(), iGuestScreenIndex);
     3973
     3974    /* Create exclusive 'rescale' action-group: */
    39633975    QActionGroup *pActionGroup = new QActionGroup(pMenu);
    3964     AssertPtrReturnVoid(pActionGroup);
    3965     {
    3966         /* Configure exclusive 'scale-factor' action-group: */
     3976    if (pActionGroup)
     3977    {
     3978        /* Configure exclusive 'rescale' action-group: */
    39673979        pActionGroup->setExclusive(true);
    3968 
    3969         /* Get current scale-factor: */
    3970         const int iGuestScreenIndex = pMenu->property("Guest Screen Index").toInt();
    3971         const double dCurrentScaleFactor = gEDataManager->scaleFactor(vboxGlobal().managedVMUuid(), iGuestScreenIndex);
    39723980
    39733981        /* Get device-pixel-ratio: */
     
    39853993        do
    39863994        {
    3987             /* Create exclusive 'scale-factor' action: */
     3995            /* Create exclusive 'rescale' action: */
    39883996            QAction *pAction = pActionGroup->addAction(QString());
    3989             AssertPtrReturnVoid(pAction);
     3997            if (pAction)
    39903998            {
    39913999                pAction->setProperty("Guest Screen Index", iGuestScreenIndex);
     
    40334041        pMenu->addActions(pActionGroup->actions());
    40344042        /* Install listener for exclusive action-group: */
    4035         connect(pActionGroup, SIGNAL(triggered(QAction*)),
    4036                 this, SLOT(sltHandleActionTriggerViewScaleFactor(QAction*)));
     4043        connect(pActionGroup, &QActionGroup::triggered,
     4044                this, &UIActionPoolRuntime::sltHandleActionTriggerViewRescale);
    40374045    }
    40384046}
Note: See TracChangeset for help on using the changeset viewer.

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