menuentry.h 968 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef CLICKABLELABEL_H
  2. #define CLICKABLELABEL_H
  3. #include <QObject>
  4. #include <QWidget>
  5. #include <QLabel>
  6. #include <QMouseEvent>
  7. class MenuEntry : public QLabel {
  8. Q_OBJECT
  9. public:
  10. explicit MenuEntry(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
  11. ~MenuEntry();
  12. static MenuEntry *getActiveLabel();
  13. static void setActiveLabel(MenuEntry *label);
  14. static MenuEntry *getHoverLabel();
  15. static void setHoverLabel(MenuEntry *label);
  16. signals:
  17. void clicked();
  18. void active_label_changed();
  19. void hover_label_changed();
  20. protected:
  21. void mousePressEvent(QMouseEvent* event);
  22. void mouseMoveEvent(QMouseEvent *event) override;
  23. private slots:
  24. void on_clicked();
  25. private:
  26. static MenuEntry *active_label;
  27. static MenuEntry *hover_label;
  28. const QString default_stylesheet = "color:rgb(255, 255, 255);";
  29. const QString active_stylesheet = "color:rgb(200, 200, 200);";
  30. };
  31. #endif // CLICKABLELABEL_H