VirtualBox

Changeset 5160 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Oct 4, 2007 4:31:41 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
25055
Message:

FE/Qt: Cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h

    r5148 r5160  
    186186    void onExitFullscreen();
    187187
    188     void onToggleRegMenuItem (bool aEnable);
    189 
    190188private:
    191189
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h

    r5148 r5160  
    132132        MachineDataChangeEventType,
    133133        MachineRegisteredEventType,
    134         ShowRegDlgEventType,
    135         ToggleRegMenuItemEvent,
    136134        SessionStateChangeEventType,
    137135        SnapshotEventType,
     136        CanShowRegDlgEventType,
    138137        NetworkAdapterChangeEventType,
    139138        USBCtlStateChangeEventType,
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r5148 r5160  
    100100};
    101101
    102 class VBoxShowRegDlgEvent : public QEvent
    103 {
    104 public:
    105     VBoxShowRegDlgEvent()
    106         : QEvent ((QEvent::Type) VBoxDefs::ShowRegDlgEventType)
    107         {}
    108 };
    109 
    110 class VBoxToggleRegMenuItem : public QEvent
    111 {
    112 public:
    113     VBoxToggleRegMenuItem (bool aEnable)
    114         : QEvent ((QEvent::Type) VBoxDefs::ToggleRegMenuItemEvent)
    115         , mEnable (aEnable)
    116         {}
    117 
    118     bool mEnable;
    119 };
    120 
    121102class VBoxSessionStateChangeEvent : public QEvent
    122103{
     
    148129    const QUuid machineId;
    149130    const QUuid snapshotId;
     131};
     132
     133class VBoxCanShowRegDlgEvent : public QEvent
     134{
     135public:
     136    VBoxCanShowRegDlgEvent (bool aCanShow)
     137        : QEvent ((QEvent::Type) VBoxDefs::CanShowRegDlgEventType)
     138        , mCanShow (aCanShow)
     139        {}
     140
     141    const bool mCanShow;
    150142};
    151143
     
    516508    void sessionStateChanged (const VBoxSessionStateChangeEvent &e);
    517509    void snapshotChanged (const VBoxSnapshotEvent &e);
    518     void toggleRegMenuItem (bool aEnable);
     510
     511    void canShowRegDlg (bool aCanShow);
    519512
    520513public slots:
     
    522515    bool openURL (const QString &aURL);
    523516
    524     void checkRegistration (bool aForced = true);
     517    void showRegistrationDialog (bool aForce = true);
    525518
    526519protected:
     
    528521    bool event (QEvent *e);
    529522    bool eventFilter (QObject *, QEvent *);
    530 
    531     void showRegistrationDialog();
    532523
    533524private:
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxSelectorWnd.h

    r5148 r5160  
    103103    void snapshotChanged (const VBoxSnapshotEvent &e);
    104104
    105     void onToggleRegMenuItem (bool aEnable);
    106 
    107105private:
    108106
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r5154 r5160  
    267267    helpRegisterAction = new QAction (this, "helpRegisterAction");
    268268    helpRegisterAction->setIconSet (VBoxGlobal::iconSet ("register_16px.png",
    269                                                 "register_disabled_16px.png"));
     269                                                         "register_disabled_16px.png"));
    270270    helpAboutAction = new QAction (this, "helpAboutAction");
    271271    helpAboutAction->setIconSet (VBoxGlobal::iconSet ("about_16px.png"));
     
    533533             &vboxProblem(), SLOT (showHelpWebDialog()));
    534534    connect (helpRegisterAction, SIGNAL (activated()),
    535              &vboxGlobal(), SLOT (checkRegistration()));
    536     connect (&vboxGlobal(), SIGNAL (toggleRegMenuItem (bool)),
    537              this, SLOT (onToggleRegMenuItem (bool)));
     535             &vboxGlobal(), SLOT (showRegistrationDialog()));
     536    connect (&vboxGlobal(), SIGNAL (canShowRegDlg (bool)),
     537             helpRegisterAction, SLOT (setEnabled (bool)));
    538538    connect (helpAboutAction, SIGNAL (activated()),
    539539             &vboxProblem(), SLOT (showHelpAboutDialog()));
     
    10231023    console->setIgnoreMainwndResize (false);
    10241024    console->normalizeGeometry (true /* adjustPosition */);
    1025 }
    1026 
    1027 void VBoxConsoleWnd::onToggleRegMenuItem (bool aEnable)
    1028 {
    1029     helpRegisterAction->setEnabled (aEnable);
    10301025}
    10311026
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r5148 r5160  
    131131public:
    132132
    133     VBoxCallback (VBoxGlobal &aGlobal) : global (aGlobal), mShowRegDlg (false)
     133    VBoxCallback (VBoxGlobal &aGlobal)
     134        : mGlobal (aGlobal), mIsRegDlgOwner (false)
    134135    {
    135136#if defined (Q_OS_WIN32)
     
    211212                if (sKey == VBoxDefs::GUI_RegistrationDlgWinID)
    212213                {
    213                     if (mShowRegDlg)
     214                    if (mIsRegDlgOwner)
    214215                    {
    215216                        if (sVal.isEmpty() ||
     
    261262                    if (sVal.isEmpty())
    262263                    {
    263                         mShowRegDlg = false;
    264                         QApplication::postEvent (&global, new VBoxToggleRegMenuItem (true));
     264                        mIsRegDlgOwner = false;
     265                        QApplication::postEvent (&mGlobal, new VBoxCanShowRegDlgEvent (true));
    265266                    }
    266                     else if (sVal == QString ("%1").arg ((long)qApp->mainWidget()->winId()))
     267                    else if (sVal == QString ("%1").arg ((long) qApp->mainWidget()->winId()))
    267268                    {
    268                         mShowRegDlg = true;
    269                         QApplication::postEvent (&global, new VBoxToggleRegMenuItem (true));
    270                         QApplication::postEvent (&global, new VBoxShowRegDlgEvent());
     269                        mIsRegDlgOwner = true;
     270                        QApplication::postEvent (&mGlobal, new VBoxCanShowRegDlgEvent (true));
    271271                    }
    272272                    else
    273                         QApplication::postEvent (&global, new VBoxToggleRegMenuItem (false));
     273                        QApplication::postEvent (&mGlobal, new VBoxCanShowRegDlgEvent (false));
    274274                }
    275275
    276                 mutex.lock();
    277                 global.gset.setPublicProperty (sKey, sVal);
    278                 mutex.unlock();
    279                 Assert (!!global.gset);
     276                mMutex.lock();
     277                mGlobal.gset.setPublicProperty (sKey, sVal);
     278                mMutex.unlock();
     279                Assert (!!mGlobal.gset);
    280280            }
    281281        }
     
    339339        // to handle VirtualBox callback events in the execution console mode)
    340340
    341         if (!global.isVMConsoleProcess())
    342             QApplication::postEvent (&global, e);
    343     }
    344 
    345     VBoxGlobal &global;
     341        if (!mGlobal.isVMConsoleProcess())
     342            QApplication::postEvent (&mGlobal, e);
     343    }
     344
     345    VBoxGlobal &mGlobal;
    346346
    347347    /** protects #OnExtraDataChange() */
    348     QMutex mutex;
    349 
    350     bool mShowRegDlg;
     348    QMutex mMutex;
     349
     350    bool mIsRegDlgOwner;
    351351
    352352#if defined (Q_OS_WIN32)
     
    16691669}
    16701670#endif
    1671 
    1672 void VBoxGlobal::checkRegistration (bool aForced)
    1673 {
    1674 #ifdef VBOX_WITH_REGISTRATION
    1675     if (!aForced && !VBoxRegistrationDlg::hasToBeShown())
    1676         return;
    1677 
    1678     if (mRegDlg)
    1679     {
    1680         /* Show already opened registration dialog */
    1681         mRegDlg->setWindowState (mRegDlg->windowState() & ~WindowMinimized);
    1682         mRegDlg->raise();
    1683         mRegDlg->setActiveWindow();
    1684     }
    1685     /* Store the ID of the main window to ensure that only one registration
    1686      * dialog is shown at a time. This operation will implicitly cause the
    1687      * dialog to show if it's not already shown. */
    1688     else
    1689         virtualBox().SetExtraData (VBoxDefs::GUI_RegistrationDlgWinID,
    1690             QString ("%1").arg ((long) qApp->mainWidget()->winId()));
    1691 #endif
    1692 }
    1693 
    1694 void VBoxGlobal::showRegistrationDialog()
    1695 {
    1696 #ifdef VBOX_WITH_REGISTRATION
    1697     if (!mRegDlg)
    1698     {
    1699         /* Create new registration dialog */
    1700         VBoxRegistrationDlg *dlg =
    1701             new VBoxRegistrationDlg (0, 0, false, WDestructiveClose);
    1702         dlg->setup (&mRegDlg);
    1703         Assert (dlg == mRegDlg);
    1704         mRegDlg->show();
    1705     }
    1706 #endif
    1707 }
    17081671
    17091672/**
     
    34443407}
    34453408
     3409void VBoxGlobal::showRegistrationDialog (bool aForce)
     3410{
     3411#ifdef VBOX_WITH_REGISTRATION
     3412    if (!aForce && !VBoxRegistrationDlg::hasToBeShown())
     3413        return;
     3414
     3415    if (mRegDlg)
     3416    {
     3417        /* Show the already opened registration dialog */
     3418        mRegDlg->setWindowState (mRegDlg->windowState() & ~WindowMinimized);
     3419        mRegDlg->raise();
     3420        mRegDlg->setActiveWindow();
     3421    }
     3422    else
     3423    {
     3424        /* Store the ID of the main window to ensure that only one
     3425         * registration dialog is shown at a time. Due to manipulations with
     3426         * OnExtraDataCanChange() and OnExtraDataChange() signals, this extra
     3427         * data item acts like an inter-process mutex, so the first process
     3428         * that attempts to set it will win, the rest will get a failure from
     3429         * the SetExtraData() call. */
     3430        mVBox.SetExtraData (VBoxDefs::GUI_RegistrationDlgWinID,
     3431            QString ("%1").arg ((long) qApp->mainWidget()->winId()));
     3432
     3433        if (mVBox.isOk())
     3434        {
     3435            /* We've got the "mutex", create a new registration dialog */
     3436            VBoxRegistrationDlg *dlg =
     3437                new VBoxRegistrationDlg (0, 0, false, WDestructiveClose);
     3438            dlg->setup (&mRegDlg);
     3439            Assert (dlg == mRegDlg);
     3440            mRegDlg->show();
     3441        }
     3442    }
     3443#endif
     3444}
     3445
    34463446// Protected members
    34473447////////////////////////////////////////////////////////////////////////////////
     
    35123512            return true;
    35133513        }
    3514         case VBoxDefs::ShowRegDlgEventType:
    3515         {
    3516             showRegistrationDialog();
    3517             return true;
    3518         }
    3519         case VBoxDefs::ToggleRegMenuItemEvent:
    3520         {
    3521             emit toggleRegMenuItem (((VBoxToggleRegMenuItem *)e)->mEnable);
    3522             return true;
    3523         }
    35243514        case VBoxDefs::SessionStateChangeEventType:
    35253515        {
     
    35303520        {
    35313521            emit snapshotChanged (*(VBoxSnapshotEvent *) e);
     3522            return true;
     3523        }
     3524        case VBoxDefs::CanShowRegDlgEventType:
     3525        {
     3526            emit canShowRegDlg (((VBoxCanShowRegDlgEvent *) e)->mCanShow);
    35323527            return true;
    35333528        }
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp

    r5153 r5160  
    431431    helpRegisterAction = new QAction (this, "helpRegisterAction");
    432432    helpRegisterAction->setIconSet (VBoxGlobal::iconSet ("register_16px.png",
    433                                                 "register_disabled_16px.png"));
     433                                                         "register_disabled_16px.png"));
    434434    helpAboutAction = new QAction (this, "helpAboutAction");
    435435    helpAboutAction->setIconSet (VBoxGlobal::iconSet ("about_16px.png"));
     
    594594             &vboxProblem(), SLOT (showHelpWebDialog()));
    595595    connect (helpRegisterAction, SIGNAL (activated()),
    596              &vboxGlobal(), SLOT (checkRegistration()));
    597     connect (&vboxGlobal(), SIGNAL (toggleRegMenuItem (bool)),
    598              this, SLOT (onToggleRegMenuItem (bool)));
     596             &vboxGlobal(), SLOT (showRegistrationDialog()));
     597    connect (&vboxGlobal(), SIGNAL (canShowRegDlg (bool)),
     598             helpRegisterAction, SLOT (setEnabled (bool)));
    599599    connect (helpAboutAction, SIGNAL (activated()),
    600600             &vboxProblem(), SLOT (showHelpAboutDialog()));
     
    13911391}
    13921392
    1393 void VBoxSelectorWnd::onToggleRegMenuItem (bool aEnable)
    1394 {
    1395     helpRegisterAction->setEnabled (aEnable);
    1396 }
    1397 
    13981393#include "VBoxSelectorWnd.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r5148 r5160  
    234234                if (vboxGlobal().startMachine (vboxGlobal().managedVMUuid()))
    235235                {
    236                     vboxGlobal().checkRegistration (false);
     236                    vboxGlobal().showRegistrationDialog (false /* aForce */);
    237237                    rc = a.exec();
    238238                }
     
    245245            {
    246246                a.setMainWidget (&vboxGlobal().selectorWnd());
    247                 vboxGlobal().checkRegistration (false);
     247                vboxGlobal().showRegistrationDialog (false /* aForce */);
    248248                vboxGlobal().selectorWnd().show();
    249249                vboxGlobal().startEnumeratingMedia();
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