PanelDelegate.hpp
1 #pragma once
2 #include <score/document/DocumentContext.hpp>
3 #include <score/tools/std/Optional.hpp>
4 
5 #include <QIcon>
6 #include <QKeySequence>
7 
8 #include <score_lib_base_export.h>
9 class Selection;
10 namespace score
11 {
12 struct GUIApplicationContext;
13 struct DocumentContext;
14 class PanelModel;
15 class PanelView;
16 
23 struct SCORE_LIB_BASE_EXPORT PanelStatus
24 {
26  bool isShown, bool fixed, Qt::DockWidgetArea d, int prio, QString name,
27  QString icon, const QKeySequence& sc);
28 
29  const bool shown; // Controls if it is shown by default.
30  const bool fixed;
31  const Qt::DockWidgetArea dock; // Which dock.
32  const int priority; // Higher priority will come up first.
33  const QString prettyName; // Used in the header.
34  const QIcon icon; // Same
35  const QKeySequence shortcut; // Keyboard shortcut to show or hide the panel.
36 };
37 
49 class SCORE_LIB_BASE_EXPORT PanelDelegate
50 {
51 public:
53  virtual ~PanelDelegate();
54 
55  const score::GUIApplicationContext& context() const;
56 
57  void setModel(const score::DocumentContext& model);
58  void setModel(std::nullopt_t n);
59 
65  MaybeDocument document() const;
66 
71  virtual QWidget* widget() = 0;
72 
76  virtual const PanelStatus& defaultPanelStatus() const = 0;
77 
85  virtual void setNewSelection(const Selection& s);
86 
87 protected:
94  virtual void on_modelChanged(MaybeDocument oldm, MaybeDocument newm);
95 
96 private:
97  const score::GUIApplicationContext& m_context;
98  MaybeDocument m_model{};
99 };
100 }
Definition: Selection.hpp:12
The PanelDelegate class.
Definition: PanelDelegate.hpp:50
virtual const PanelStatus & defaultPanelStatus() const =0
defaultPanelStatus Metadata of the panel.
virtual QWidget * widget()=0
widget The widget of the panel.
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: DocumentContext.hpp:18
Specializes ApplicationContext with the QMainWindow.
Definition: GUIApplicationContext.hpp:15
The PanelStatus struct.
Definition: PanelDelegate.hpp:24