1 //=============================================================================
2 //  MusE Score
3 //  Linux Music Score Editor
4 //
5 //  Copyright (C) 2008-2009 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 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //=============================================================================
19 
20 #ifndef __NEWWIZARD_H__
21 #define __NEWWIZARD_H__
22 
23 #include "ui_timesigwizard.h"
24 #include "ui_newwizard.h"
25 
26 #include <QWizard>
27 
28 #include "libmscore/timesig.h"
29 #include "libmscore/key.h"
30 #include "libmscore/fraction.h"
31 
32 namespace Ms {
33 
34 class Score;
35 class PaletteListView;
36 class StaffListItem;
37 class InstrumentsWidget;
38 class TemplateBrowser;
39 
40 //---------------------------------------------------------
41 //   TimesigWizard
42 //---------------------------------------------------------
43 
44 class TimesigWizard : public QWidget, private Ui::TimesigWizard {
45       Q_OBJECT
46 
47    private slots:
48       void commonTimeToggled(bool);
49       void cutTimeToggled(bool);
50       void fractionToggled(bool);
51 
52    public:
53       TimesigWizard(QWidget* parent = 0);
54       int measures() const;
55       Fraction timesig() const;
56       bool pickup(int* z, int* n) const;
57       bool tempo(double* t) const;
58       TimeSigType type() const;
59       };
60 
61 //---------------------------------------------------------
62 //   TitleWizard
63 //---------------------------------------------------------
64 
65 class TitleWizard : public QWidget, public Ui::NewWizard {
66       Q_OBJECT
67 
68    public:
69       TitleWizard(QWidget* parent = 0);
70       };
71 
72 //---------------------------------------------------------
73 //   NewWizardInfoPage
74 //    Enter score information such as title and composer
75 //---------------------------------------------------------
76 
77 class NewWizardInfoPage : public QWizardPage {
78       Q_OBJECT
79 
80       TitleWizard* w;
81 
82    public:
83       NewWizardInfoPage(QWidget* parent = 0);
title()84       QString title() const              { return w->title->text();      }
subtitle()85       QString subtitle() const           { return w->subtitle->text();   }
composer()86       QString composer() const           { return w->composer->text();   }
poet()87       QString poet() const               { return w->poet->text();       }
copyright()88       QString copyright() const          { return w->copyright->text();  }
89       virtual void initializePage() override;
90       };
91 
92 //---------------------------------------------------------
93 //   NewWizardInstrumentsPage
94 //    Choose instruments to appear in the score
95 //---------------------------------------------------------
96 
97 class NewWizardInstrumentsPage : public QWizardPage {
98       Q_OBJECT
99 
100       bool complete;
101       InstrumentsWidget* instrumentsWidget;
102 
103    public slots:
104       void setComplete(bool);
105 
106    public:
107       NewWizardInstrumentsPage(QWidget* parent = 0);
108       virtual bool isComplete() const override;
109       void createInstruments(Score* s);
110       virtual void initializePage() override;
111       };
112 
113 //---------------------------------------------------------
114 //   NewWizardTimesigPage
115 //    Choose time signature for the score
116 //---------------------------------------------------------
117 
118 class NewWizardTimesigPage : public QWizardPage {
119       Q_OBJECT
120 
121       TimesigWizard* w;
122 
123    public:
124       NewWizardTimesigPage(QWidget* parent = 0);
measures()125       int measures() const                     { return w->measures();   }
timesig()126       Fraction timesig() const                 { return w->timesig();    }
pickupMeasure(int * z,int * n)127       bool pickupMeasure(int* z, int* n) const { return w->pickup(z, n); }
timesigType()128       TimeSigType timesigType() const          { return w->type();       }
tempo(double * t)129       bool tempo(double* t) const              { return w->tempo(t);     }
130       };
131 
132 //---------------------------------------------------------
133 //   NewWizardTemplatePage
134 //    Choose a template on which to base the score
135 //---------------------------------------------------------
136 
137 class NewWizardTemplatePage : public QWizardPage {
138       Q_OBJECT
139 
140       TemplateBrowser* templateFileBrowser;
141       QString path;
142 
143    private slots:
144       void templateChanged(const QString&);
145       void fileAccepted(const QString&);
146 
147    public:
148       NewWizardTemplatePage(QWidget* parent = 0);
149       virtual bool isComplete() const override;
150       QString templatePath() const;
151       virtual void initializePage();
152       void buildTemplatesList();
153       };
154 
155 //---------------------------------------------------------
156 //   NewWizardKeysigPage
157 //    Choose key signature for the score
158 //---------------------------------------------------------
159 
160 class NewWizardKeysigPage : public QWizardPage {
161       Q_OBJECT
162 
163       PaletteListView* _plv;
164 
165    public:
166       NewWizardKeysigPage(QWidget* parent = 0);
isComplete()167       virtual bool isComplete() const override { return true; }
168       KeySigEvent keysig() const;
169       void init();
170       };
171 
172 //---------------------------------------------------------
173 //   NewWizard
174 //    New Score Wizard - create a new score
175 //---------------------------------------------------------
176 
177 class NewWizard : public QWizard {
178       Q_OBJECT
179 
180       NewWizardInfoPage* infoPage;
181       NewWizardInstrumentsPage* instrumentsPage;
182       NewWizardTimesigPage* timesigPage;
183       NewWizardTemplatePage* templatePage;
184       NewWizardKeysigPage* keysigPage;
185 
186       virtual void hideEvent(QHideEvent*);
187 
188    private slots:
189       void idChanged(int);
190 
191    public:
192       NewWizard(QWidget* parent = 0);
193       friend class QWizardPage;
194       virtual int nextId() const;
195 
196       enum Page { Invalid = -1, Type, Instruments, Template, Keysig, Timesig};
197 
templatePath()198       QString templatePath() const       { return templatePage->templatePath(); }
measures()199       int measures() const               { return timesigPage->measures();    }
timesig()200       Fraction timesig() const           { return timesigPage->timesig();     }
createInstruments(Score * s)201       void createInstruments(Score* s)   { instrumentsPage->createInstruments(s); }
title()202       QString title() const              { return infoPage->title();       }
subtitle()203       QString subtitle() const           { return infoPage->subtitle();    }
composer()204       QString composer() const           { return infoPage->composer();    }
poet()205       QString poet() const               { return infoPage->poet();        }
copyright()206       QString copyright() const          { return infoPage->copyright();   }
keysig()207       KeySigEvent keysig() const         { return keysigPage->keysig();    }
pickupMeasure(int * z,int * n)208       bool pickupMeasure(int* z, int* n) const { return timesigPage->pickupMeasure(z, n); }
timesigType()209       TimeSigType timesigType() const    { return timesigPage->timesigType();}
tempo(double * t)210       bool tempo(double* t) const        { return timesigPage->tempo(t);   }
211       bool emptyScore() const;
212       void updateValues() const;
213       };
214 
215 
216 } // namespace Ms
217 #endif
218 
219