Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mainwin.h
Go to the documentation of this file.
1 
8 #ifndef MAINWIN_H_
9 #define MAINWIN_H_
10 
11 #include <QObject>
12 #include <QFileDialog>
13 #include <QTime>
14 #include <QTimer>
15 #include <QHash>
16 
17 #include "ui_mainwin.h"
18 
19 #include "core/document.h"
20 #include "core/muselement.h"
21 #include "core/note.h"
22 #include "core/clef.h"
23 
24 #include "interface/playback.h"
26 
28 #include "widgets/scoreviewport.h"
29 #include "widgets/resourceview.h"
30 
31 class QKeyEvent;
32 class QSlider;
33 class QSpinBox;
34 class QToolBar;
35 class QLabel;
36 class QLineEdit;
37 class QComboBox;
38 class QCheckBox;
39 class QAction;
40 
41 class CAHelpBrowser;
42 class CAMenuToolButton;
43 class CAUndoToolButton;
44 class CALCDNumber;
45 class CASheet;
46 class CAScoreViewPort;
47 class CASourceViewPort;
49 class CAPrintPreviewCtl;
50 class CAPrintCtl;
51 class CAPreviewCtl;
52 class CAPyConsole;
53 class CATransposeView;
54 class CAMidiRecorderView;
55 class CAKeybdInput;
56 class CAExport;
57 
58 class CAMainWin : public QMainWindow, private Ui::uiMainWindow
59 {
60  Q_OBJECT
61 
62 public:
63  enum CAMode {
69  };
70 
71  CAMainWin(QMainWindow *oParent = 0);
72  ~CAMainWin();
73 
74  void clearUI();
75  void rebuildUI(CASheet *sheet, bool repaint=true);
76  void rebuildUI(bool repaint=true);
77  inline bool rebuildUILock() { return _rebuildUILock; }
78  void updateWindowTitle();
79 
80  void newDocument();
81  void addSheet(CASheet *s);
82  void removeSheet(CASheet *s);
83  void insertMusElementAt( const QPoint coords, CAScoreViewPort *v );
85  void deleteSelection( CAScoreViewPort *v, bool deleteSyllable, bool deleteNotes, bool undo );
86  void copySelection( CAScoreViewPort *v );
87  void pasteAt( const QPoint coords, CAScoreViewPort *v );
88 
89  CADocument *openDocument( const QString& fileName );
91  bool saveDocument( QString fileName );
92 
93  inline CAMode mode() { return _mode; }
94  inline QFileDialog *exportDialog() { return uiExportDialog; }
95  inline QFileDialog *importDialog() { return uiImportDialog; }
101  inline void removeViewPort(CAViewPort* v) { _viewPortList.removeAll(v); }
102  inline QList<CAViewPort*> viewPortList() { return _viewPortList; }
103 
105  if (currentViewPort()) return dynamic_cast<CAScoreViewPort*>(currentViewPort());
106  else return 0;
107  }
108 
109  inline CASheet *currentSheet() {
111  if (v) return v->sheet();
112  else return 0;
113  }
114 
115  inline CAStaff *currentStaff() {
116  CAContext *context = currentContext();
117  if (context && context->contextType()==CAContext::Staff) return static_cast<CAStaff*>(context);
118  else return 0;
119  }
120 
124  inline CADocument *document() { return _document; }
125 
127 
128  // Dialogs, Windows
129  static QFileDialog *uiSaveDialog;
130  static QFileDialog *uiOpenDialog;
131  static QFileDialog *uiExportDialog;
132  static QFileDialog *uiImportDialog;
133 
134  // Python Console
137 
140 
141 private slots:
143  // ToolBar/Menus actions //
145  void closeEvent(QCloseEvent *event);
146  // File
157 
158  // Edit
159  void on_uiUndo_toggled(bool, int);
160  void on_uiRedo_toggled(bool, int);
161  void on_uiCopy_triggered();
162  void on_uiCut_triggered();
163  void on_uiPaste_triggered();
167 
168  // Insert
169  void on_uiSelectMode_toggled(bool);
170  void on_uiEditMode_toggled(bool);
173  void on_uiContextType_toggled(bool, int);
174  void on_uiClefType_toggled(bool, int);
175  void on_uiInsertKeySig_toggled(bool);
176  void on_uiTimeSigType_toggled(bool, int);
177  void on_uiBarlineType_toggled(bool, int);
178  void on_uiInsertPlayable_toggled(bool);
179  void on_uiSlurType_toggled(bool, int);
180  void on_uiMarkType_toggled(bool, int);
181  void on_uiArticulationType_toggled(bool, int);
182  void on_uiInsertSyllable_toggled(bool);
183  void on_uiInsertFM_toggled(bool);
184 
185  // View
186  void on_uiFullscreen_toggled(bool);
187  void on_uiAnimatedScroll_toggled(bool);
196  void on_uiResourceView_toggled(bool);
197 
198  // Sheet
202 
203  // Context
209 
210  // Playback
212 
213  // Playable
214  void on_uiPlayableLength_toggled(bool, int);
215  void on_uiTupletType_toggled(bool, int);
218  void on_uiNoteStemDirection_toggled(bool, int);
219  void on_uiHiddenRest_toggled( bool checked );
220  void onMidiInEvent( QVector<unsigned char> message );
221 
222  // Key Signature
223  void on_uiKeySig_activated( int );
224 
225  // Time Signature
228 
229  // Clef
231 
232  // Lyrics
233  void onTextEditKeyPressEvent(QKeyEvent *);
234 
235  // Function marks
236  void on_uiFMFunction_toggled(bool, int);
237  void on_uiFMChordArea_toggled(bool, int);
238  void on_uiFMTonicDegree_toggled(bool, int);
239  void on_uiFMEllipse_toggled(bool);
240 
241  // Dynamic marks
242  void on_uiDynamicText_toggled(bool, int);
245 
246  // Instrument change
248 
249  // Fermata
250  void on_uiFermataType_toggled( bool, int );
251 
252  // Repeat Mark
253  void on_uiRepeatMarkType_toggled( bool, int );
254 
255  // Fingering
256  void on_uiFinger_toggled( bool checked, int t );
257  void on_uiFingeringOriginal_toggled( bool checked );
258 
259  // Tempo
260  void on_uiTempoBeat_toggled( bool, int );
262 
263  // Tools
267 
268  // Voice
269  void on_uiVoiceNum_valChanged(int);
273  void on_uiVoiceStemDirection_toggled(bool, int);
275 
276  // Window
283 
284  // Help
285 public slots:
287 private slots:
289  void on_uiAboutQt_triggered();
290 
292  // Handle other widgets signals //
294  void keyPressEvent(QKeyEvent *);
296 
297  void viewPortClicked();
298 
299  void scoreViewPortMousePress(QMouseEvent *e, const QPoint coords);
300  void scoreViewPortMouseMove(QMouseEvent *e, const QPoint coords);
301  void scoreViewPortMouseRelease(QMouseEvent *e, const QPoint coords);
302  void scoreViewPortDoubleClick(QMouseEvent *e, const QPoint coords);
303  void scoreViewPortTripleClick(QMouseEvent *e, const QPoint coords);
304  void scoreViewPortWheel(QWheelEvent *e, const QPoint coords);
305  void scoreViewPortKeyPress(QKeyEvent *e);
306  void sourceViewPortCommit(QString inputString);
308 
310 
311  void playbackFinished();
313  void onRepaintTimerTimeout();
314 
315 private:
316  void playImmediately( QList<CAMusElement*> elements );
317 
319  // General properties //
323 
326  CAExport *_poExp; // abstract export instance
330 
331  void setMode(CAMode mode);
332  inline void setCurrentViewPort( CAViewPort *viewPort ) { _currentViewPort = viewPort; }
334  { _currentViewPortContainer = vpc; }
335 
337  QList<CAViewPortContainer *>_viewPortContainerList;
338 
339  QList<CAViewPort *> _viewPortList;
340  QHash<CAViewPortContainer*, CASheet*> _sheetMap;
345  QList<CADrawableMusElement*> _prePlaybackSelection;
346  QTimer *_repaintTimer;
348  inline void setRebuildUILock(bool l) { _rebuildUILock = l; }
349 
352  unsigned int _timeEditedTime;
354 public:
356 private:
357  inline bool stopPlayback() {
358  if(_playback && _playback->isRunning())
359  _playback->stopNow();
360  }
361 
362  bool handleUnsavedChanges();
363 
366  // Pure user interface - widgets that weren't created by Qt Designer yet //
368  void createCustomActions();
369  void setupCustomUi();
370  void initViewPort(CAViewPort*);
371  void updateUndoRedoButtons();
372  void updateToolBars();
373  void updateSheetToolBar();
374  void updateContextToolBar();
375  void updateVoiceToolBar();
376  void updateInsertToolBar();
377  void updatePlayableToolBar();
378  void updateKeySigToolBar();
379  void updateTimeSigToolBar();
380  void updateClefToolBar();
381  void updateFMToolBar();
382  void updateDynamicToolBar();
384  void updateTempoToolBar();
385  void updateFermataToolBar();
387  void updateFingeringToolBar();
388 
390  // Toolbar section //
392  // Standard toolbar
393  //QToolBar *uiStandardToolBar;
396 
397  // Insert toolbar
398  QToolBar *uiInsertToolBar;
399  QActionGroup *uiInsertGroup; // Group for mutual exclusive selection of music elements
400  // QAction *uiSelectMode; // made by Qt Designer
401  // QAction *uiNewSheet; // made by Qt Designer
403 
404  // QAction *uiInsertPlayable; // made by Qt Designer
406  // QAction *uiInsertKeySig; // made by Qt Designer
407  CAMenuToolButton *uiTimeSigType; // made by Qt Designer
411  // QAction *uiInsertSyllable; // made by Qt Designer
412  // QAction *uiInsertFM; // made by Qt Designer
413 
414  QToolBar *uiSheetToolBar;
415  // QAction *uiNewSheet; // made by Qt Designer
417  // QAction *uiRemoveSheet; // made by Qt Designer
418  // QAction *uiSheetProperties; // made by Qt Designer
419 
420  QToolBar *uiContextToolBar;
421  // CAContext
423  //QAction *uiRemoveContext; // made by Qt Designer
424  //QAction *uiContextProperties; // made by Qt Designer
425  // CAStaff
426  // CALyricsContext
427  QSpinBox *uiStanzaNumber;
429  QComboBox *uiAssociatedVoice;
431  // CAFunctionMarkContext
432 
433  QToolBar *uiVoiceToolBar;
434  // QAction *uiNewVoice; // made by Qt Designer
437  QComboBox *uiVoiceInstrument;
438  // QAction *uiRemoveVoice; // made by Qt Designer
440  // QAction *uiVoiceProperties; // made by Qt Designer
441 
442  QToolBar *uiPlayableToolBar; // note and rest properties are merged for the time being
443  // Note properties
447 public: // Because CAKeyboardInput (input with midi keyboard) needs to operate these widgets to
448  // provide gui feedback, these, probably even more, should become public.
449  // Some clean interface would be appropriate.
451  QSpinBox *uiTupletNumber;
453 private:
458  // QAction *uiNoteAccsVisible; // made by Qt Designer
460  // Rest properties
461  // CAMenuToolButton *uiPlayableLength; // same as note properties
462  // QLabel *uiPlayableDotted; // same as note properties
463  // QAction *uiHiddenRest; // made by Qt Designer
464 
465  QToolBar *uiKeySigToolBar;
466  // CAKeySigPSP *uiKeySigPSP; /// Key signature perspective. \todo Reimplement it.
467  QComboBox *uiKeySig;
468  // QComboBox *uiKeySigGender;
469 
470  QToolBar *uiClefToolBar;
471  QSpinBox *uiClefOffset;
473 
474  QToolBar *uiTimeSigToolBar;
475  QSpinBox *uiTimeSigBeats;
476  QLabel *uiTimeSigSlash;
477  QSpinBox *uiTimeSigBeat;
478  // CAMenuToolButton *uiTimeSigStyle; /// \todo Implement it. -Matevz
479 
480  QToolBar *uiFMToolBar; // function mark tool bar
484  QComboBox *uiFMKeySig;
485  //QSpinBox *uiKeySigNumberOfAccs; // defined in uiKeySigToolBar
486  //QComboBox *uiKeySigGender; // defined in uiKeySigToolBar
487  //QAction *uiFMEllipse; // made by Qt Designer
488 
489  // Marks tool bars:
490  QToolBar *uiDynamicToolBar;
492  QSpinBox *uiDynamicVolume;
495  QComboBox *uiInstrumentChange;
496  QToolBar *uiTempoToolBar;
498  QLabel *uiTempoEquals;
500  QToolBar *uiFermataToolBar;
507 
508  // Python console
510 
511  // Help widget
514 };
515 #endif /* MAINWIN_H_ */