MuseScore  3.4
Music composition and notation
tourhandler.h
Go to the documentation of this file.
1 #ifndef TOURHANDLER_H
2 #define TOURHANDLER_H
3 
4 #include "libmscore/xml.h"
5 
6 namespace Ms {
7 
8 //---------------------------------------------------------
9 // TourMessage
10 //---------------------------------------------------------
11 
12 struct TourMessage {
13  QString message;
14  QList<QString> widgetNames;
15  TourMessage(QString m, QList<QString> w) : message(m), widgetNames(w) {}
16  };
17 
18 //---------------------------------------------------------
19 // Tour
20 //---------------------------------------------------------
21 
22 class Tour
23  {
24  QList<TourMessage> _messages;
25  QMultiMap<QString, QWidget*> nameToWidget;
26  QString _tourName;
27  bool _completed = false;
28 
29  public:
30  Tour(QString name) { _tourName = name; }
31 
32  void addMessage(QString m, QList<QString> w) { TourMessage message(m, w);
33  _messages.append(message); }
34  QList<TourMessage> messages() { return _messages; }
35 
36  QList<QWidget*> getWidgetsByName(QString n) { return nameToWidget.values(n); }
37  void addNameAndWidget(QString n, QWidget* w) { nameToWidget.insert(n, w); }
38  void clearWidgets() { nameToWidget.clear(); }
39  bool hasNameForWidget(QString n) { return nameToWidget.contains(n); }
40 
41  void setTourName(QString n) { _tourName = n; }
42  QString tourName() { return _tourName; }
43 
44  void setCompleted(bool c) { _completed = c; }
45  bool completed() { return _completed; }
46  };
47 
48 //---------------------------------------------------------
49 // OverlayWidget
50 //---------------------------------------------------------
51 
52 class OverlayWidget : public QWidget
53  {
54  void newParent();
55  bool eventFilter(QObject * obj, QEvent * ev);
56  virtual bool event(QEvent* ev);
57  virtual void paintEvent(QPaintEvent *);
58 
59  QList<QWidget*> widgets;
60 
61  public:
62  OverlayWidget(QList<QWidget*> widgetList, QWidget* parent = 0);
63  };
64 
65 //---------------------------------------------------------
66 // TourHandler
67 //---------------------------------------------------------
68 
69 class TourHandler : public QObject
70  {
71  Q_OBJECT
72 
73  QMap<QObject*, QMap<QEvent::Type, QString>*> eventHandler;
74 
75  void loadTour(XmlReader& tourXml);
76 
77  static void displayTour(Tour* tour);
78  static void positionMessage(QList<QWidget*> widgets, QMessageBox* mbox);
79  static QHash<QString, Tour*> allTours;
80  static QHash<QString, Tour*> shortcutToTour;
81  static QMap<QString, QMap<QString, QString>*> eventNameLookup;
82  static QList<QWidget*> getWidgetsByNames(Tour* tour, QList<QString> names);
83 
84  bool delayedWelcomeTour = false;
85 
86 public slots:
87  void showWelcomeTour();
88 
89 public:
90  TourHandler(QObject* parent) : QObject(parent) {}
91  void loadTours();
92  void resetCompletedTours();
93  void readCompletedTours();
94  void writeCompletedTours();
95 
96  bool eventFilter(QObject *obj, QEvent* event);
97  static void startTour(QString tourName);
98  void attachTour(QObject* obj, QEvent::Type eventType, QString tourName);
99 
100  static void addWidgetToTour(QString tourName, QWidget* widget, QString widgetName);
101  static void clearWidgetsFromTour(QString tourName);
102 
103  static QList<QString> allTourShortcuts() { return shortcutToTour.keys(); }
104 
105  void delayWelcomeTour() { delayedWelcomeTour = true; }
106  void showDelayedWelcomeTour();
107  };
108 
109 }
110 
111 #endif // TOURHANDLER_H
QList< QString > widgetNames
Definition: tourhandler.h:14
TourMessage(QString m, QList< QString > w)
Definition: tourhandler.h:15
bool hasNameForWidget(QString n)
Definition: tourhandler.h:39
Definition: xml.h:67
QList< QWidget * > widgets
Definition: tourhandler.h:59
static QList< QString > allTourShortcuts()
Definition: tourhandler.h:103
QMap< QObject *, QMap< QEvent::Type, QString > * > eventHandler
Definition: tourhandler.h:73
Definition: tourhandler.h:22
void addNameAndWidget(QString n, QWidget *w)
Definition: tourhandler.h:37
QList< QWidget * > getWidgetsByName(QString n)
Definition: tourhandler.h:36
static QHash< QString, Tour * > shortcutToTour
Definition: tourhandler.h:80
void addMessage(QString m, QList< QString > w)
Definition: tourhandler.h:32
static QHash< QString, Tour * > allTours
Definition: tourhandler.h:79
static QMap< QString, QMap< QString, QString > * > eventNameLookup
Definition: tourhandler.h:81
QString message
Definition: tourhandler.h:13
void setTourName(QString n)
Definition: tourhandler.h:41
QString tourName()
Definition: tourhandler.h:42
void delayWelcomeTour()
Definition: tourhandler.h:105
Definition: aeolus.cpp:26
QList< TourMessage > _messages
Definition: tourhandler.h:24
Definition: tourhandler.h:12
QString _tourName
Definition: tourhandler.h:26
TourHandler(QObject *parent)
Definition: tourhandler.h:90
void clearWidgets()
Definition: tourhandler.h:38
QMultiMap< QString, QWidget * > nameToWidget
Definition: tourhandler.h:25
Definition: tourhandler.h:69
Definition: tourhandler.h:52
void setCompleted(bool c)
Definition: tourhandler.h:44
QList< TourMessage > messages()
Definition: tourhandler.h:34
bool completed()
Definition: tourhandler.h:45
Tour(QString name)
Definition: tourhandler.h:30