statusflagwidget.h 918 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef STATUSFLAGWIDGET_H
  2. #define STATUSFLAGWIDGET_H
  3. #include <QWidget>
  4. #include <QMutex>
  5. class StatusFlagWidget : public QWidget
  6. {
  7. Q_OBJECT
  8. public:
  9. explicit StatusFlagWidget(QWidget *parent = nullptr);
  10. protected:
  11. virtual void leaveEvent(QEvent * event) override;
  12. virtual void enterEvent(QEvent * event) override;
  13. virtual void paintEvent(QPaintEvent *event) override;
  14. virtual void mousePressEvent(QMouseEvent *ev) override;
  15. signals:
  16. void mouseEntered(QString tooltip);
  17. void flagIdChanged(int flag_id);
  18. void mouseLeaved();
  19. public slots:
  20. void changeImageSrcAnimated(const QString& src);
  21. void changeImageSrcInstantly(const QString& src);
  22. void changeFlagId(int new_flag_id);
  23. private:
  24. QMutex bg_lock;
  25. int flag_id;
  26. bool is_hovered;
  27. QString current_flag_src;
  28. QString current_flag_hover_src;
  29. QPixmap current_bg;
  30. };
  31. #endif // STATUSFLAGWIDGET_H