Changeset 3806 in vbox for trunk/src/VBox
- Timestamp:
- Jul 24, 2007 11:06:48 AM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h
r3802 r3806 117 117 118 118 /** VM display rendering mode. */ 119 enum RenderMode { 119 enum RenderMode 120 { 120 121 InvalidRenderMode, TimerMode, QImageMode, SDLMode, DDRAWMode 121 122 }; 122 123 123 124 /** Additional Qt event types. */ 124 enum { 125 ResizeEventType = QEvent::User, 125 enum 126 { 127 AsyncEventType = QEvent::User + 100, 128 ResizeEventType, 126 129 RepaintEventType, 127 130 SetRegionEventType, … … 137 140 RuntimeErrorEventType, 138 141 ModifierKeyChangeEventType, 139 EnumerateMediaEventType = QEvent::User + 100,142 EnumerateMediaEventType, 140 143 #if defined (Q_WS_WIN) 141 144 ShellExecuteEventType, -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r3448 r3806 435 435 static QString removeAccelMark (const QString &aText); 436 436 437 static QWidget *findWidget (QWidget *aParent, const char *aName, 438 const char *aClassName = NULL, 439 bool aRecursive = false); 440 437 441 signals: 438 442 … … 548 552 inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); } 549 553 554 // Helper classes 555 //////////////////////////////////////////////////////////////////////////////// 556 557 /** 558 * Generic asyncronous event. 559 * 560 * This abstract class is intended to provide a conveinent way to execute 561 * code on the main GUI thread asynchronously to the calling party. This is 562 * done by putting necessary actions to the #handle() function in a subclass 563 * and then posting an instance of the subclass using #post(). The instance 564 * must be allocated on the heap using the <tt>new</tt> operation and will be 565 * automatically deleted after processing. Note that if you don't call #post() 566 * on the created instance, you have to delete it yourself. 567 */ 568 class VBoxAsyncEvent : public QEvent 569 { 570 public: 571 572 VBoxAsyncEvent() : QEvent ((QEvent::Type) VBoxDefs::AsyncEventType) {} 573 574 /** 575 * Worker function. Gets executed on the GUI thread when the posted event 576 * is processed by the main event loop. 577 */ 578 virtual void handle() = 0; 579 580 /** 581 * Posts this event to the main event loop. 582 * The caller loses ownership of this object after this method returns 583 * and must not delete the object. 584 */ 585 void post() 586 { 587 QApplication::postEvent (&vboxGlobal(), this); 588 } 589 }; 550 590 551 591 /** -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r3762 r3806 2990 2990 } 2991 2991 2992 /** 2993 * Searches for a widget that with @a aName (if it is not NULL) which inherits 2994 * @a aClassName (if it is not NULL) and among children of @a aParent. If @a 2995 * aParent is NULL, all top-level widgets are searched. If @a aRecursive is 2996 * true, child widgets are recursively searched as well. 2997 */ 2998 /* static */ 2999 QWidget *VBoxGlobal::findWidget (QWidget *aParent, const char *aName, 3000 const char *aClassName /* = NULL */, 3001 bool aRecursive /* = false */) 3002 { 3003 if (aParent == NULL) 3004 { 3005 QWidgetList *list = QApplication::topLevelWidgets(); 3006 QWidgetListIt it (*list); 3007 QWidget *w = NULL; 3008 for (; (w = it.current()) != NULL; ++ it) 3009 { 3010 if ((!aName || strcmp (w->name(), aName) == 0) && 3011 (!aClassName || strcmp (w->className(), aClassName) == 0)) 3012 break; 3013 if (aRecursive) 3014 { 3015 w = findWidget (w, aName, aClassName, aRecursive); 3016 if (w) 3017 break; 3018 } 3019 } 3020 delete list; 3021 return w; 3022 } 3023 3024 QObjectList *list = aParent->queryList (aName, aClassName, false, true); 3025 QObjectListIt it (*list); 3026 QObject *obj = NULL; 3027 for (; (obj = it.current()) != NULL; ++ it) 3028 { 3029 if (obj->isWidgetType()) 3030 break; 3031 } 3032 delete list; 3033 return (QWidget *) obj; 3034 } 3035 2992 3036 // Protected members 2993 3037 //////////////////////////////////////////////////////////////////////////////// … … 3009 3053 } 3010 3054 #endif 3055 3056 case VBoxDefs::AsyncEventType: 3057 { 3058 VBoxAsyncEvent *ev = (VBoxAsyncEvent *) e; 3059 ev->handle(); 3060 return true; 3061 } 3011 3062 3012 3063 case VBoxDefs::EnumerateMediaEventType:
Note:
See TracChangeset
for help on using the changeset viewer.