VirtualBox

Ignore:
Timestamp:
Jul 24, 2007 11:06:48 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
23149
Message:

FE/Qt: Added VBoxAsyncEvent and VBoxGlobal::findWidget() helpers (see class docs for details).

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

Legend:

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

    r3802 r3806  
    117117
    118118    /** VM display rendering mode. */
    119     enum RenderMode {
     119    enum RenderMode
     120    {
    120121        InvalidRenderMode, TimerMode, QImageMode, SDLMode, DDRAWMode
    121122    };
    122123
    123124    /** Additional Qt event types. */
    124     enum {
    125         ResizeEventType = QEvent::User,
     125    enum
     126    {
     127        AsyncEventType = QEvent::User + 100,
     128        ResizeEventType,
    126129        RepaintEventType,
    127130        SetRegionEventType,
     
    137140        RuntimeErrorEventType,
    138141        ModifierKeyChangeEventType,
    139         EnumerateMediaEventType = QEvent::User + 100,
     142        EnumerateMediaEventType,
    140143#if defined (Q_WS_WIN)
    141144        ShellExecuteEventType,
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r3448 r3806  
    435435    static QString removeAccelMark (const QString &aText);
    436436
     437    static QWidget *findWidget (QWidget *aParent, const char *aName,
     438                                const char *aClassName = NULL,
     439                                bool aRecursive = false);
     440
    437441signals:
    438442
     
    548552inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); }
    549553
     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 */
     568class VBoxAsyncEvent : public QEvent
     569{
     570public:
     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};
    550590
    551591/**
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