Changeset 5160 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 4, 2007 4:31:41 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 25055
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r5148 r5160 186 186 void onExitFullscreen(); 187 187 188 void onToggleRegMenuItem (bool aEnable);189 190 188 private: 191 189 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h
r5148 r5160 132 132 MachineDataChangeEventType, 133 133 MachineRegisteredEventType, 134 ShowRegDlgEventType,135 ToggleRegMenuItemEvent,136 134 SessionStateChangeEventType, 137 135 SnapshotEventType, 136 CanShowRegDlgEventType, 138 137 NetworkAdapterChangeEventType, 139 138 USBCtlStateChangeEventType, -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r5148 r5160 100 100 }; 101 101 102 class VBoxShowRegDlgEvent : public QEvent103 {104 public:105 VBoxShowRegDlgEvent()106 : QEvent ((QEvent::Type) VBoxDefs::ShowRegDlgEventType)107 {}108 };109 110 class VBoxToggleRegMenuItem : public QEvent111 {112 public:113 VBoxToggleRegMenuItem (bool aEnable)114 : QEvent ((QEvent::Type) VBoxDefs::ToggleRegMenuItemEvent)115 , mEnable (aEnable)116 {}117 118 bool mEnable;119 };120 121 102 class VBoxSessionStateChangeEvent : public QEvent 122 103 { … … 148 129 const QUuid machineId; 149 130 const QUuid snapshotId; 131 }; 132 133 class VBoxCanShowRegDlgEvent : public QEvent 134 { 135 public: 136 VBoxCanShowRegDlgEvent (bool aCanShow) 137 : QEvent ((QEvent::Type) VBoxDefs::CanShowRegDlgEventType) 138 , mCanShow (aCanShow) 139 {} 140 141 const bool mCanShow; 150 142 }; 151 143 … … 516 508 void sessionStateChanged (const VBoxSessionStateChangeEvent &e); 517 509 void snapshotChanged (const VBoxSnapshotEvent &e); 518 void toggleRegMenuItem (bool aEnable); 510 511 void canShowRegDlg (bool aCanShow); 519 512 520 513 public slots: … … 522 515 bool openURL (const QString &aURL); 523 516 524 void checkRegistration (bool aForced= true);517 void showRegistrationDialog (bool aForce = true); 525 518 526 519 protected: … … 528 521 bool event (QEvent *e); 529 522 bool eventFilter (QObject *, QEvent *); 530 531 void showRegistrationDialog();532 523 533 524 private: -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxSelectorWnd.h
r5148 r5160 103 103 void snapshotChanged (const VBoxSnapshotEvent &e); 104 104 105 void onToggleRegMenuItem (bool aEnable);106 107 105 private: 108 106 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r5154 r5160 267 267 helpRegisterAction = new QAction (this, "helpRegisterAction"); 268 268 helpRegisterAction->setIconSet (VBoxGlobal::iconSet ("register_16px.png", 269 "register_disabled_16px.png"));269 "register_disabled_16px.png")); 270 270 helpAboutAction = new QAction (this, "helpAboutAction"); 271 271 helpAboutAction->setIconSet (VBoxGlobal::iconSet ("about_16px.png")); … … 533 533 &vboxProblem(), SLOT (showHelpWebDialog())); 534 534 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))); 538 538 connect (helpAboutAction, SIGNAL (activated()), 539 539 &vboxProblem(), SLOT (showHelpAboutDialog())); … … 1023 1023 console->setIgnoreMainwndResize (false); 1024 1024 console->normalizeGeometry (true /* adjustPosition */); 1025 }1026 1027 void VBoxConsoleWnd::onToggleRegMenuItem (bool aEnable)1028 {1029 helpRegisterAction->setEnabled (aEnable);1030 1025 } 1031 1026 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r5148 r5160 131 131 public: 132 132 133 VBoxCallback (VBoxGlobal &aGlobal) : global (aGlobal), mShowRegDlg (false) 133 VBoxCallback (VBoxGlobal &aGlobal) 134 : mGlobal (aGlobal), mIsRegDlgOwner (false) 134 135 { 135 136 #if defined (Q_OS_WIN32) … … 211 212 if (sKey == VBoxDefs::GUI_RegistrationDlgWinID) 212 213 { 213 if (m ShowRegDlg)214 if (mIsRegDlgOwner) 214 215 { 215 216 if (sVal.isEmpty() || … … 261 262 if (sVal.isEmpty()) 262 263 { 263 m ShowRegDlg= false;264 QApplication::postEvent (& global, new VBoxToggleRegMenuItem(true));264 mIsRegDlgOwner = false; 265 QApplication::postEvent (&mGlobal, new VBoxCanShowRegDlgEvent (true)); 265 266 } 266 else if (sVal == QString ("%1").arg ((long) qApp->mainWidget()->winId()))267 else if (sVal == QString ("%1").arg ((long) qApp->mainWidget()->winId())) 267 268 { 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)); 271 271 } 272 272 else 273 QApplication::postEvent (& global, new VBoxToggleRegMenuItem(false));273 QApplication::postEvent (&mGlobal, new VBoxCanShowRegDlgEvent (false)); 274 274 } 275 275 276 m utex.lock();277 global.gset.setPublicProperty (sKey, sVal);278 m utex.unlock();279 Assert (!! global.gset);276 mMutex.lock(); 277 mGlobal.gset.setPublicProperty (sKey, sVal); 278 mMutex.unlock(); 279 Assert (!!mGlobal.gset); 280 280 } 281 281 } … … 339 339 // to handle VirtualBox callback events in the execution console mode) 340 340 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; 346 346 347 347 /** protects #OnExtraDataChange() */ 348 QMutex m utex;349 350 bool m ShowRegDlg;348 QMutex mMutex; 349 350 bool mIsRegDlgOwner; 351 351 352 352 #if defined (Q_OS_WIN32) … … 1669 1669 } 1670 1670 #endif 1671 1672 void VBoxGlobal::checkRegistration (bool aForced)1673 {1674 #ifdef VBOX_WITH_REGISTRATION1675 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 registration1686 * dialog is shown at a time. This operation will implicitly cause the1687 * dialog to show if it's not already shown. */1688 else1689 virtualBox().SetExtraData (VBoxDefs::GUI_RegistrationDlgWinID,1690 QString ("%1").arg ((long) qApp->mainWidget()->winId()));1691 #endif1692 }1693 1694 void VBoxGlobal::showRegistrationDialog()1695 {1696 #ifdef VBOX_WITH_REGISTRATION1697 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 #endif1707 }1708 1671 1709 1672 /** … … 3444 3407 } 3445 3408 3409 void 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 3446 3446 // Protected members 3447 3447 //////////////////////////////////////////////////////////////////////////////// … … 3512 3512 return true; 3513 3513 } 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 }3524 3514 case VBoxDefs::SessionStateChangeEventType: 3525 3515 { … … 3530 3520 { 3531 3521 emit snapshotChanged (*(VBoxSnapshotEvent *) e); 3522 return true; 3523 } 3524 case VBoxDefs::CanShowRegDlgEventType: 3525 { 3526 emit canShowRegDlg (((VBoxCanShowRegDlgEvent *) e)->mCanShow); 3532 3527 return true; 3533 3528 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
r5153 r5160 431 431 helpRegisterAction = new QAction (this, "helpRegisterAction"); 432 432 helpRegisterAction->setIconSet (VBoxGlobal::iconSet ("register_16px.png", 433 "register_disabled_16px.png"));433 "register_disabled_16px.png")); 434 434 helpAboutAction = new QAction (this, "helpAboutAction"); 435 435 helpAboutAction->setIconSet (VBoxGlobal::iconSet ("about_16px.png")); … … 594 594 &vboxProblem(), SLOT (showHelpWebDialog())); 595 595 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))); 599 599 connect (helpAboutAction, SIGNAL (activated()), 600 600 &vboxProblem(), SLOT (showHelpAboutDialog())); … … 1391 1391 } 1392 1392 1393 void VBoxSelectorWnd::onToggleRegMenuItem (bool aEnable)1394 {1395 helpRegisterAction->setEnabled (aEnable);1396 }1397 1398 1393 #include "VBoxSelectorWnd.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r5148 r5160 234 234 if (vboxGlobal().startMachine (vboxGlobal().managedVMUuid())) 235 235 { 236 vboxGlobal(). checkRegistration (false);236 vboxGlobal().showRegistrationDialog (false /* aForce */); 237 237 rc = a.exec(); 238 238 } … … 245 245 { 246 246 a.setMainWidget (&vboxGlobal().selectorWnd()); 247 vboxGlobal(). checkRegistration (false);247 vboxGlobal().showRegistrationDialog (false /* aForce */); 248 248 vboxGlobal().selectorWnd().show(); 249 249 vboxGlobal().startEnumeratingMedia();
Note:
See TracChangeset
for help on using the changeset viewer.