pQueuedMessageWidget.sip 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*!
  2. \brief The is the \c message structure used by the pQueuedMessageWidget class.
  3. \details It allow to configure the message to show.
  4. \details Each variable is directly accessible and mostly optionnal except \c message.
  5. \details A default \c Ok button is added if \c buttons is empty.
  6. */
  7. struct pQueuedMessage
  8. {
  9. %TypeHeaderCode
  10. #include <gui/queuedmessage/pQueuedMessageWidget.h>
  11. %End
  12. pQueuedMessage();
  13. bool operator==( const pQueuedMessage& other ) const;
  14. /*! \details The message to show */
  15. QString message;
  16. /*! \details The millisecond time to wait before the message is auto closed. Use 0 for unilimited time */
  17. int milliSeconds;
  18. /*! \details The pixmap to show before the message */
  19. QPixmap pixmap;
  20. /*! \details The brush to use as background */
  21. QBrush background;
  22. /*! \details The brush to use as foreground */
  23. QBrush foreground;
  24. /*! \details A hash representing a StandardButton role, and it's optionnal text overridding the default StandardButton text */
  25. QHash<QDialogButtonBox::StandardButton, QString> buttons; // StandardButton, Button Text ( null text for standard text )
  26. /*! \details The object that is used to invoke \c Slot */
  27. //QWeakPointer<QObject> object;
  28. /*!
  29. \details If \c object is not null, it will invoke this \c slot, the slot must take 2 parameters :
  30. \details QDialogButtonBox::StandardButton : The StandardButton clicked
  31. \details pQueuedMessage : The message from where the button was clicked
  32. */
  33. const char* slot;
  34. /*! \details A place to stock custom user data */
  35. QVariant userData;
  36. };
  37. /*!
  38. \brief A QMessageBox like Widget, that can show queued message.
  39. \details The messages are queued until they are closed by user or elapsed time is timeout
  40. */
  41. class pQueuedMessageWidget : QWidget
  42. {
  43. %TypeHeaderCode
  44. #include <gui/queuedmessage/pQueuedMessageWidget.h>
  45. %End
  46. public:
  47. pQueuedMessageWidget( QWidget* parent = 0 );
  48. virtual QSize sizeHint() const;
  49. bool openExternalLinks() const;
  50. int defaultTimeout() const;
  51. QPixmap defaultPixmap() const;
  52. QBrush defaultBackground() const;
  53. QBrush defaultForeground() const;
  54. void currentMessageInformations( QPixmap* pixmap, QBrush* background, QBrush* foreground ) const;
  55. int pendingMessageCount() const;
  56. pQueuedMessage currentMessage() const;
  57. pQueuedMessage append( const QString& message, int milliSeconds = -1 );
  58. public slots:
  59. void setOpenExternalLinks( bool open );
  60. void setDefaultTimeout( int timeout );
  61. void setDefaultPixmap( const QPixmap& pixmap );
  62. void setDefaultBackground( const QBrush& brush );
  63. void setDefaultForeground( const QBrush& brush );
  64. void append( const pQueuedMessage& message );
  65. void remove( const pQueuedMessage& message );
  66. void clear();
  67. protected:
  68. void paintEvent( QPaintEvent* event );
  69. protected slots:
  70. void buttonClicked( QAbstractButton* button );
  71. void showMessage();
  72. void closeMessage();
  73. void clearMessage();
  74. signals:
  75. void shown( const pQueuedMessage& message );
  76. void closed( const pQueuedMessage& message );
  77. void cleared();
  78. void finished();
  79. void linkActivated( const QString& link );
  80. void linkHovered( const QString& link );
  81. };