MainStatusBar.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 "ISourceControl.h"
  13. #include <QStatusBar>
  14. #include <QWidget>
  15. #include <QIcon>
  16. #endif
  17. class MainStatusBar;
  18. class QLabel;
  19. class QString;
  20. class QPixmap;
  21. class QTimerEvent;
  22. class QMenu;
  23. class QAction;
  24. class StatusBarItem
  25. : public QWidget
  26. {
  27. Q_OBJECT
  28. Q_PROPERTY(bool clickable MEMBER m_isClickable)
  29. public:
  30. StatusBarItem(const QString& name, MainStatusBar* parent, bool hasLeadingSpacer = false);
  31. StatusBarItem(const QString& name, bool isClickable, MainStatusBar* parent, bool hasLeadingSpacer = false);
  32. void SetText(const QString& text);
  33. void SetIcon(const QPixmap& icon);
  34. void SetIcon(const QIcon& icon);
  35. void SetToolTip(const QString& tip);
  36. QSize sizeHint() const override;
  37. QSize minimumSizeHint() const override;
  38. signals:
  39. void clicked();
  40. protected:
  41. void mousePressEvent(QMouseEvent* me) override;
  42. void paintEvent(QPaintEvent* pe) override;
  43. virtual QString CurrentText() const;
  44. MainStatusBar* StatusBar() const;
  45. private:
  46. QIcon m_icon;
  47. QString m_text;
  48. bool m_isClickable;
  49. bool m_hasLeadingSpacer;
  50. };
  51. class MainStatusBar
  52. : public QStatusBar
  53. , public IMainStatusBar
  54. {
  55. Q_OBJECT
  56. public:
  57. MainStatusBar(QWidget* parent = nullptr);
  58. //implement IMainStatusBar interface
  59. void SetStatusText(const QString& text) override;
  60. QWidget* SetItem(QString indicatorName, QString text, QString tip, int iconId) override;
  61. QWidget* GetItem(QString indicatorName) override;
  62. QWidget* SetItem(QString indicatorName, QString text, QString tip, const QPixmap& icon) override;
  63. void Init();
  64. signals:
  65. void requestStatusUpdate();
  66. };
  67. #endif // CRYINCLUDE_EDITOR_MAINSTATUSBAR_H