TextFloat.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * TextFloat.h - class textFloat, a floating text-label
  3. *
  4. * Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef TEXT_FLOAT_H
  25. #define TEXT_FLOAT_H
  26. #include <QWidget>
  27. #include <QPixmap>
  28. #include "lmms_export.h"
  29. class LMMS_EXPORT TextFloat : public QWidget
  30. {
  31. Q_OBJECT
  32. public:
  33. TextFloat();
  34. virtual ~TextFloat()
  35. {
  36. }
  37. void setTitle( const QString & _title );
  38. void setText( const QString & _text );
  39. void setPixmap( const QPixmap & _pixmap );
  40. void setVisibilityTimeOut( int _msecs );
  41. static TextFloat * displayMessage( const QString & _msg,
  42. int _timeout = 2000,
  43. QWidget * _parent = NULL,
  44. int _add_y_margin = 0 );
  45. static TextFloat * displayMessage( const QString & _title,
  46. const QString & _msg,
  47. const QPixmap & _pixmap =
  48. QPixmap(),
  49. int _timeout = 2000,
  50. QWidget * _parent = NULL );
  51. void moveGlobal( QWidget * _w, const QPoint & _offset )
  52. {
  53. move( _w->mapToGlobal( QPoint( 0, 0 ) )+_offset );
  54. }
  55. protected:
  56. void paintEvent( QPaintEvent * _me ) override;
  57. void mousePressEvent( QMouseEvent * _me ) override;
  58. private:
  59. void updateSize();
  60. QString m_title;
  61. QString m_text;
  62. QPixmap m_pixmap;
  63. };
  64. #endif