MainStatusBar.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #ifndef CRYINCLUDE_EDITOR_MAINSTATUSBAR_H
  9. #define CRYINCLUDE_EDITOR_MAINSTATUSBAR_H
  10. #pragma once
  11. #if !defined(Q_MOC_RUN)
  12. #include <QStatusBar>
  13. #include <QWidget>
  14. #include <QIcon>
  15. #endif
  16. class MainStatusBar;
  17. class QLabel;
  18. class QString;
  19. class QPixmap;
  20. class QTimerEvent;
  21. class QMenu;
  22. class QAction;
  23. class StatusBarItem
  24. : public QWidget
  25. {
  26. Q_OBJECT
  27. Q_PROPERTY(bool clickable MEMBER m_isClickable)
  28. public:
  29. StatusBarItem(const QString& name, MainStatusBar* parent, bool hasLeadingSpacer = false);
  30. StatusBarItem(const QString& name, bool isClickable, MainStatusBar* parent, bool hasLeadingSpacer = false);
  31. void SetText(const QString& text);
  32. void SetIcon(const QPixmap& icon);
  33. void SetIcon(const QIcon& icon);
  34. void SetToolTip(const QString& tip);
  35. QSize sizeHint() const override;
  36. QSize minimumSizeHint() const override;
  37. signals:
  38. void clicked();
  39. protected:
  40. void mousePressEvent(QMouseEvent* me) override;
  41. void paintEvent(QPaintEvent* pe) override;
  42. virtual QString CurrentText() const;
  43. MainStatusBar* StatusBar() const;
  44. private:
  45. QIcon m_icon;
  46. QString m_text;
  47. bool m_isClickable;
  48. bool m_hasLeadingSpacer;
  49. };
  50. class MainStatusBar
  51. : public QStatusBar
  52. , public IMainStatusBar
  53. {
  54. Q_OBJECT
  55. public:
  56. MainStatusBar(QWidget* parent = nullptr);
  57. //implement IMainStatusBar interface
  58. void SetStatusText(const QString& text) override;
  59. QWidget* SetItem(QString indicatorName, QString text, QString tip, int iconId) override;
  60. QWidget* GetItem(QString indicatorName) override;
  61. QWidget* SetItem(QString indicatorName, QString text, QString tip, const QPixmap& icon) override;
  62. void Init();
  63. signals:
  64. void requestStatusUpdate();
  65. };
  66. #endif // CRYINCLUDE_EDITOR_MAINSTATUSBAR_H