MuseScore  3.4
Music composition and notation
inspectorBase.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2011 Werner Schweer and others
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENSE.GPL
11 //=============================================================================
12 
13 #ifndef __INSPECTOR_BASE_H__
14 #define __INSPECTOR_BASE_H__
15 
16 #include "libmscore/property.h"
17 #include "libmscore/style.h"
18 
19 namespace Ms {
20 
21 class Inspector;
22 class Element;
23 
24 //---------------------------------------------------------
25 // InspectorPanel
26 //---------------------------------------------------------
27 
29  QToolButton* title;
30  QWidget* panel;
31  };
32 
33 //---------------------------------------------------------
34 // InspectorItem
35 //---------------------------------------------------------
36 
37 struct InspectorItem {
38  Pid t; // property id
39  int parent; // apply to parent() element level
40  QWidget* w;
41  // QToolButton* r; // reset to default button (if any)
42  QWidget* r; // reset to default button (if any)
43  };
44 
45 //---------------------------------------------------------
46 // InspectorBase
47 //---------------------------------------------------------
48 
49 class InspectorBase : public QWidget {
50  Q_OBJECT
51 
52  bool dirty() const;
53  void checkDifferentValues(const InspectorItem&);
54  bool compareValues(const InspectorItem& ii, QVariant a, QVariant b);
55  Element* effectiveElement(const InspectorItem&) const;
56 
57  signals:
58  void elementChanged();
59 
60  private slots:
61  void resetToStyle();
62 
63  protected slots:
64  virtual void valueChanged(int idx, bool reset);
65  virtual void valueChanged(int idx);
66  void resetClicked(int);
67  void setStyleClicked(int);
68 
69  protected:
70  std::vector<InspectorItem> iList;
71  std::vector<InspectorPanel> pList;
72  QVBoxLayout* _layout;
74 
75  virtual void setValue(const InspectorItem&, QVariant);
76  QVariant getValue(const InspectorItem&) const;
77  bool isDefault(const InspectorItem&);
78  void mapSignals(const std::vector<InspectorItem>& il = std::vector<InspectorItem>(), const std::vector<InspectorPanel>& pl = std::vector<InspectorPanel>());
79  void setupLineStyle(QComboBox*);
80 
81  public:
82  InspectorBase(QWidget* parent);
83  virtual void setElement();
84  virtual void postInit() {} // called in setElement and valueChanged
85  QWidget* addWidget();
86 
87  friend class InspectorScriptEntry;
88  };
89 
90 //---------------------------------------------------------
91 // InspectorEventObserver
92 //---------------------------------------------------------
93 
95  static std::unique_ptr<InspectorEventObserver> i;
96 
97  InspectorEventObserver() = default;
98 
99  public:
100  enum EventType {
104  };
105  void event(EventType evtType, const InspectorItem& ii, const Element* e);
106 
108  {
109  if (!i)
110  i.reset(new InspectorEventObserver());
111  return i.get();
112  }
113  };
114 
115 } // namespace Ms
116 #endif
117 
Inspector * inspector
Definition: inspectorBase.h:73
Pid
Definition: property.h:62
QVBoxLayout * _layout
Definition: inspectorBase.h:72
QWidget * r
Definition: inspectorBase.h:42
Definition: inspector.h:371
std::vector< InspectorItem > iList
Definition: inspectorBase.h:70
Base class of score layout elements.
Definition: element.h:158
virtual void postInit()
Definition: inspectorBase.h:84
Definition: inspectorBase.h:94
Definition: inspectorBase.h:37
Definition: inspectorBase.h:103
Definition: inspectorBase.h:49
Definition: scriptentry.h:96
Definition: aeolus.cpp:26
int parent
Definition: inspectorBase.h:39
QWidget * panel
Definition: inspectorBase.h:30
static InspectorEventObserver * instance()
Definition: inspectorBase.h:107
Pid t
Definition: inspectorBase.h:38
static std::unique_ptr< InspectorEventObserver > i
Definition: inspectorBase.h:95
Definition: inspectorBase.h:28
Definition: inspectorBase.h:102
std::vector< InspectorPanel > pList
Definition: inspectorBase.h:71
QWidget * w
Definition: inspectorBase.h:40
EventType
Definition: inspectorBase.h:100
QToolButton * title
Definition: inspectorBase.h:29
Definition: inspectorBase.h:101