VirtualBox

Changeset 34158 in vbox


Ignore:
Timestamp:
Nov 18, 2010 9:56:36 AM (14 years ago)
Author:
vboxsync
Message:

FE/Qt4: make menu handling work in newer Qt versions

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionsPool.cpp

    r33470 r34158  
    11921192     * when creating a new QMenuBar. For simplicity we doing this on all
    11931193     * platforms right now. */
     1194    if (m_actionsPool[UIActionIndex_Simple_Help])
     1195        delete m_actionsPool[UIActionIndex_Simple_Help];
     1196    m_actionsPool[UIActionIndex_Simple_Help] = new ShowHelpAction(this);
     1197    if (m_actionsPool[UIActionIndex_Simple_Web])
     1198        delete m_actionsPool[UIActionIndex_Simple_Web];
     1199    m_actionsPool[UIActionIndex_Simple_Web] = new ShowWebAction(this);
     1200    if (m_actionsPool[UIActionIndex_Simple_ResetWarnings])
     1201        delete m_actionsPool[UIActionIndex_Simple_ResetWarnings];
     1202    m_actionsPool[UIActionIndex_Simple_ResetWarnings] = new PerformResetWarningsAction(this);
     1203#ifdef VBOX_WITH_REGISTRATION
     1204    if (m_actionsPool[UIActionIndex_Simple_Register])
     1205        delete m_actionsPool[UIActionIndex_Simple_Register]
     1206    m_actionsPool[UIActionIndex_Simple_Register] = new PerformRegisterAction(this);
     1207#endif /* VBOX_WITH_REGISTRATION */
     1208#if defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)
     1209    /* For whatever reason, Qt doesn't fully remove items with a
     1210     * ApplicationSpecificRole from the application menu. Although the QAction
     1211     * itself is deleted, a dummy entry is leaved back in the menu. Hiding
     1212     * before deletion helps. */
     1213    m_actionsPool[UIActionIndex_Simple_Update]->setVisible(false);
     1214#endif /* Q_WS_MAC */
     1215    /* Delete the help items as well. This makes sure they are removed also
     1216     * from the Application menu. */
     1217#if !(defined(Q_WS_MAC) && (QT_VERSION < 0x040700))
     1218    if (m_actionsPool[UIActionIndex_Simple_About])
     1219        delete m_actionsPool[UIActionIndex_Simple_About];
     1220    m_actionsPool[UIActionIndex_Simple_About] = new ShowAboutAction(this);
     1221    if (m_actionsPool[UIActionIndex_Simple_Update])
     1222        delete m_actionsPool[UIActionIndex_Simple_Update];
     1223    m_actionsPool[UIActionIndex_Simple_Update] = new PerformUpdateAction(this);
     1224#endif
     1225    if (m_actionsPool[UIActionIndex_Simple_Close])
     1226        delete m_actionsPool[UIActionIndex_Simple_Close];
     1227    m_actionsPool[UIActionIndex_Simple_Close] = new PerformCloseAction(this);
     1228
     1229    /* Menus */
    11941230    if (m_actionsPool[UIActionIndex_Menu_Machine])
    11951231        delete m_actionsPool[UIActionIndex_Menu_Machine];
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp

    r33676 r34158  
    167167#ifndef Q_WS_MAC
    168168    pMenu->addSeparator();
    169 #else /* Q_WS_MAC */
    170     if (m_fIsFirstTime)
    171169#endif /* !Q_WS_MAC */
    172         pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Close));
     170    pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Close));
    173171}
    174172
     
    222220#endif
    223221
    224 #ifdef Q_WS_MAC
     222#if defined(Q_WS_MAC) && (QT_VERSION < 0x040700)
    225223    if (m_fIsFirstTime)
    226 #endif /* Q_WS_MAC */
     224# endif
    227225        pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_Update));
    228 
    229226#ifndef Q_WS_MAC
    230227    pMenu->addSeparator();
    231 #else /* Q_WS_MAC */
     228#endif /* !Q_WS_MAC */
     229#if defined(Q_WS_MAC) && (QT_VERSION < 0x040700)
    232230    if (m_fIsFirstTime)
    233 #endif /* !Q_WS_MAC */
     231# endif
    234232        pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_About));
    235233
     234
     235#if defined(Q_WS_MAC) && (QT_VERSION < 0x040700)
    236236    /* Because this connections are done to VBoxGlobal, they are needed once only.
    237237     * Otherwise we will get the slots called more than once. */
    238238    if (m_fIsFirstTime)
    239239    {
    240         VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Help), SIGNAL(triggered()),
    241                             &vboxProblem(), SLOT(showHelpHelpDialog()));
    242         VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Web), SIGNAL(triggered()),
    243                             &vboxProblem(), SLOT(showHelpWebDialog()));
    244         VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()),
    245                             &vboxProblem(), SLOT(resetSuppressedMessages()));
    246 #ifdef VBOX_WITH_REGISTRATION
    247         VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Register), SIGNAL(triggered()),
    248                             &vboxGlobal(), SLOT(showRegistrationDialog()));
    249 #endif /* VBOX_WITH_REGISTRATION */
     240#endif
     241        VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_About), SIGNAL(triggered()),
     242                            &vboxProblem(), SLOT(showHelpAboutDialog()));
    250243        VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Update), SIGNAL(triggered()),
    251244                            &vboxGlobal(), SLOT(showUpdateDialog()));
    252         VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_About), SIGNAL(triggered()),
    253                             &vboxProblem(), SLOT(showHelpAboutDialog()));
    254 
     245#if defined(Q_WS_MAC) && (QT_VERSION < 0x040700)
     246    }
     247#endif
     248
     249    VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Help), SIGNAL(triggered()),
     250                        &vboxProblem(), SLOT(showHelpHelpDialog()));
     251    VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Web), SIGNAL(triggered()),
     252                        &vboxProblem(), SLOT(showHelpWebDialog()));
     253    VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()),
     254                        &vboxProblem(), SLOT(resetSuppressedMessages()));
    255255#ifdef VBOX_WITH_REGISTRATION
    256         VBoxGlobal::connect(gEDataEvents, SIGNAL(sigCanShowRegistrationDlg(bool)),
    257                             pActionsPool->action(UIActionIndex_Simple_Register), SLOT(setEnabled(bool)));
     256    VBoxGlobal::connect(pActionsPool->action(UIActionIndex_Simple_Register), SIGNAL(triggered()),
     257                        &vboxGlobal(), SLOT(showRegistrationDialog()));
     258    VBoxGlobal::connect(gEDataEvents, SIGNAL(sigCanShowRegistrationDlg(bool)),
     259                        pActionsPool->action(UIActionIndex_Simple_Register), SLOT(setEnabled(bool)));
    258260#endif /* VBOX_WITH_REGISTRATION */
    259         VBoxGlobal::connect(gEDataEvents, SIGNAL(sigCanShowUpdateDlg(bool)),
    260                             pActionsPool->action(UIActionIndex_Simple_Update), SLOT(setEnabled(bool)));
    261 
    262         m_fIsFirstTime = false;
    263     }
     261
     262    m_fIsFirstTime = false;
    264263}
    265264
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