#include <QtxComboBox.h>
#include <QtxActionSet.h>
#include <QVBoxLayout>
+#include <QApplication>
+#include <QEvent>
/*!
\class LightApp_ModuleAction::ActionSet
\param item identifier
*/
+/*!
+ \class LightApp_ModuleAction::ActivateEvent
+ \brief Internal class to represent custom event for transfer the activation item id.
+ \internal
+*/
+class LightApp_ModuleAction::ActivateEvent : public QEvent
+{
+public:
+ ActivateEvent( QEvent::Type type, int id ) : QEvent( type ), myId( id ) {};
+ ~ActivateEvent() {};
+
+ int id() const { return myId; }
+
+private:
+ int myId;
+};
+
/*!
\class LightApp_ModuleAction
\brief An action, representing the list of modules to be inserted to the
w->removeAction( mySet );
}
+/*!
+ \brief Perform delayed activation with specified id.
+ \param e custom event
+ \return \c true if the event was processed successfully and \c false otherwise.
+*/
+bool LightApp_ModuleAction::event( QEvent* e )
+{
+ if ( e->type() == QEvent::MaxUser )
+ activate( ((ActivateEvent*)e)->id(), false );
+ else
+ return QtxAction::event( e );
+}
+
/*!
\fn void LightApp_ModuleAction::moduleActivated( const QString& name );
\brief Emitted when the module is activated
*/
void LightApp_ModuleAction::onComboActivated( int id )
{
- activate( id, false );
+ QApplication::postEvent( this, new ActivateEvent( QEvent::MaxUser, id ) );
}
private:
class ActionSet;
class ComboAction;
+ class ActivateEvent;
public:
enum { None = 0x00, Buttons = 0x01, ComboItem = 0x02, All = Buttons | ComboItem };
virtual void addedTo( QWidget* );
virtual void removedFrom( QWidget* );
+ virtual bool event( QEvent* );
+
signals:
void moduleActivated( const QString& );
QList<QtxComboBox*> widgets() const;
-protected:
- virtual QWidget* createWidget( QWidget* );
-
signals:
void activatedId( int );
+
+protected:
+ virtual QWidget* createWidget( QWidget* );
};
#endif // LIGHTAPP_MODULEACTION_H