MessagesPanel.hpp
1 #pragma once
2 #include <score/plugins/panel/PanelDelegate.hpp>
3 #include <score/plugins/panel/PanelDelegateFactory.hpp>
4 
5 #include <QListView>
6 #include <QWidget>
7 
8 #include <score_lib_base_export.h>
9 #include <wobjectimpl.h>
10 class QListWidget;
11 class QListView;
12 class QDockWidget;
13 namespace score
14 {
15 class LogMessagesItemModel;
16 
17 // REFACTORME
18 namespace log
19 {
20 static const QColor dark1 = QColor(Qt::darkGray).darker();
21 static const QColor dark2 = dark1.darker(); // almost darker than black
22 static const QColor dark3 = QColor(Qt::darkRed).darker();
23 static const QColor dark4 = QColor(Qt::darkBlue).darker();
24 }
25 
26 template <typename T>
27 class VisibilityNotifying : public T
28 {
29  W_OBJECT(VisibilityNotifying<T>)
30 public:
31  using T::T;
32 
33  void visibilityChanged(bool visible) W_SIGNAL(visibilityChanged, visible);
34 
35  void showEvent(QShowEvent* event) override
36  {
37  visibilityChanged(true);
38  T::showEvent(event);
39  }
40  void hideEvent(QHideEvent* event) override
41  {
42  visibilityChanged(false);
43  T::hideEvent(event);
44  }
45 };
46 
47 W_OBJECT_IMPL(VisibilityNotifying<T>, template <typename T>)
48 
49 class SCORE_LIB_BASE_EXPORT MessagesPanelDelegate final
50  : public QObject
51  , public score::PanelDelegate
52 {
53  friend class err_sink;
54  W_OBJECT(MessagesPanelDelegate)
55 
56 public:
59 
60  void push(const QString& str, const QColor& col);
61  void qtLog(const std::string& str);
62 
63  VisibilityNotifying<QListView>* widget() override;
64 
65 private:
66  const score::PanelStatus& defaultPanelStatus() const override;
67 
68  LogMessagesItemModel* m_itemModel{};
70 };
71 
73 {
74  SCORE_CONCRETE("84a66cbe-aee3-496a-b7f4-0ea0d699deac")
75 
76  std::unique_ptr<score::PanelDelegate>
77  make(const score::GUIApplicationContext& ctx) override;
78 };
79 }
Definition: MessagesPanel.cpp:33
Definition: MessagesPanel.hpp:73
Definition: MessagesPanel.hpp:52
Reimplement this interface to register new panels.
Definition: PanelDelegateFactory.hpp:10
The PanelDelegate class.
Definition: PanelDelegate.hpp:50
Definition: MessagesPanel.hpp:28
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Specializes ApplicationContext with the QMainWindow.
Definition: GUIApplicationContext.hpp:15
The PanelStatus struct.
Definition: PanelDelegate.hpp:24