MainWindow.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006-2007 Chris Cannam and QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_MAIN_WINDOW_H
17 #define SV_MAIN_WINDOW_H
18 
19 #include "framework/MainWindowBase.h"
20 
21 class VersionTester;
22 class Surveyer;
23 class LayerTreeDialog;
24 class ActivityLog;
25 class UnitConverter;
26 
27 class QFileSystemWatcher;
28 class QScrollArea;
29 
30 class MainWindow : public MainWindowBase
31 {
32  Q_OBJECT
33 
34 public:
35  MainWindow(AudioMode audioMode, MIDIMode midiMode, bool withOSCSupport);
36  virtual ~MainWindow();
37 
38 signals:
39  void canChangeSolo(bool);
40  void canAlign(bool);
41 
42 public slots:
43  void preferenceChanged(PropertyContainer::PropertyName) override;
44  virtual void coloursChanged();
45 
46  virtual bool commitData(bool mayAskUser);
47 
48  void goFullScreen();
49  void endFullScreen();
50 
51 protected slots:
52  virtual void importAudio();
53  virtual void importMoreAudio();
54  virtual void replaceMainAudio();
55  virtual void openSomething();
56  virtual void openLocation();
57  virtual void openRecentFile();
58  virtual void applyTemplate();
59  virtual void exportAudio();
60  virtual void exportAudioData();
61  virtual void convertAudio();
62  virtual void importLayer();
63  virtual void exportLayer();
64  virtual void exportImage();
65  virtual void exportSVG();
66  virtual void browseRecordedAudio();
67  virtual void saveSession();
68  virtual void saveSessionAs();
69  virtual void newSession();
70  void closeSession() override;
71  virtual void preferences();
72 
73  void sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool) override;
74  void audioOverloadPluginDisabled() override;
75 
76  virtual void toolNavigateSelected();
77  virtual void toolSelectSelected();
78  virtual void toolEditSelected();
79  virtual void toolDrawSelected();
80  virtual void toolEraseSelected();
81  virtual void toolMeasureSelected();
82 
83  void documentModified() override;
84  void documentRestored() override;
85  virtual void documentReplaced();
86 
87  void updateMenuStates() override;
88  void updateDescriptionLabel() override;
89 
90  virtual void setInstantsNumbering();
91  virtual void setInstantsCounterCycle();
92  virtual void setInstantsCounters();
93  virtual void resetInstantsCounters();
94  virtual void subdivideInstants();
95  virtual void winnowInstants();
96 
97  void modelGenerationFailed(QString, QString) override;
98  void modelGenerationWarning(QString, QString) override;
99  void modelRegenerationFailed(QString, QString, QString) override;
100  void modelRegenerationWarning(QString, QString, QString) override;
101  void alignmentFailed(ModelId, QString) override;
102 
103  void paneRightButtonMenuRequested(Pane *, QPoint point) override;
104  void panePropertiesRightButtonMenuRequested(Pane *, QPoint point) override;
105  void layerPropertiesRightButtonMenuRequested(Pane *, Layer *, QPoint point) override;
106 
107  virtual void propertyStacksResized(int);
108 
109  virtual void addPane();
110  virtual void addLayer();
111  virtual void addLayer(QString transformId);
112  virtual void renameCurrentLayer();
113 
114  virtual void findTransform();
115 
116  void paneAdded(Pane *) override;
117  void paneHidden(Pane *) override;
118  void paneAboutToBeDeleted(Pane *) override;
119  void paneDropAccepted(Pane *, QStringList) override;
120  void paneDropAccepted(Pane *, QString) override;
121 
122  void paneCancelButtonPressed(Layer *);
123 
124  virtual void setupRecentFilesMenu();
125  virtual void setupRecentTransformsMenu();
126  virtual void setupTemplatesMenu();
127 
128  virtual void playSpeedChanged(int);
129  void playSoloToggled() override;
130  virtual void alignToggled();
131 
132  void currentPaneChanged(Pane *) override;
133 
134  virtual void speedUpPlayback();
135  virtual void slowDownPlayback();
136  virtual void restoreNormalPlayback();
137 
138  void monitoringLevelsChanged(float, float) override;
139 
140  void layerRemoved(Layer *) override;
141  void layerInAView(Layer *, bool) override;
142 
143  void mainModelChanged(ModelId) override;
144  virtual void mainModelGainChanged(float);
145  virtual void mainModelPanChanged(float);
146  void modelAdded(ModelId) override;
147 
148  virtual void showLayerTree();
149  virtual void showActivityLog();
150  virtual void showUnitConverter();
151 
152  virtual void mouseEnteredWidget();
153  virtual void mouseLeftWidget();
154 
155  void handleOSCMessage(const OSCMessage &) override;
156  virtual void midiEventsAvailable();
157  virtual void playStatusChanged(bool);
158 
159  void populateTransformsMenu();
160 
161  virtual void betaReleaseWarning();
162  virtual void pluginPopulationWarning(QString text);
163 
164  virtual void saveSessionAsTemplate();
165  virtual void manageSavedTemplates();
166 
167  virtual void website();
168  virtual void help();
169  virtual void about();
170  virtual void whatsNew();
171  virtual void keyReference();
172  void newerVersionAvailable(QString) override;
173 
174 protected:
175  Overview *m_overview;
176  LevelPanToolButton *m_mainLevelPan;
177  AudioDial *m_playSpeed;
178  WaveformLayer *m_panLayer;
179 
180  QScrollArea *m_mainScroll;
181 
183  QMenu *m_paneMenu;
184  QMenu *m_layerMenu;
188  QMenu *m_sliceMenu;
197 
199  QAction *m_soloAction;
202  QAction *m_rwdAction;
203  QAction *m_ffwdAction;
205  QAction *m_ffwdEndAction;
206  QAction *m_playAction;
207  QAction *m_recordAction;
211  QAction *m_zoomInAction;
212  QAction *m_zoomOutAction;
213  QAction *m_zoomFitAction;
217 
220 
223 
225  QLabel *m_currentLabel;
226 
227  QPointer<PreferencesDialog> m_preferencesDialog;
228  QPointer<LayerTreeDialog> m_layerTreeDialog;
229 
230  ActivityLog *m_activityLog;
231  UnitConverter *m_unitConverter;
232  KeyReference *m_keyReference;
233 
234  QFileSystemWatcher *m_templateWatcher;
235 
237  VersionTester *m_versionTester;
239 
241  LayerConfiguration(LayerFactory::LayerType _layer
242  = LayerFactory::TimeRuler,
243  ModelId _source = ModelId(),
244  int _channel = -1) :
245  layer(_layer), sourceModel(_source), channel(_channel) { }
246  LayerFactory::LayerType layer;
247  ModelId sourceModel;
248  int channel;
249  };
250 
251  QString shortcutFor(LayerFactory::LayerType, bool isPaneMenu);
252  void updateLayerShortcutsFor(ModelId);
253 
254  // Map from menu action to the resulting layer configurations
255  // etc. These all used to be std::maps, but we sometimes want to
256  // iterate through actions in order of creation, not in order of
257  // arbitrary QAction pointer. And speed of random lookup is not
258  // important.
259  //
260  // Some of these would still be fine as maps, but we might as well
261  // consistently use the same arrangement throughout.
262 
263  typedef std::vector<std::pair<QAction *, LayerConfiguration>> PaneActions;
264  PaneActions m_paneActions;
265 
266  typedef std::vector<std::pair<QAction *, LayerConfiguration>> LayerActions;
267  LayerActions m_layerActions;
268 
269  typedef std::vector<std::pair<QAction *, Layer *>> ExistingLayerActions;
270  ExistingLayerActions m_existingLayerActions;
271  ExistingLayerActions m_sliceActions;
272 
273  typedef std::vector<std::pair<ViewManager::ToolMode, QAction *>> ToolActions;
274  ToolActions m_toolActions;
275 
276  typedef std::vector<std::pair<QAction *, int>> NumberingActions;
277  NumberingActions m_numberingActions;
278 
279  typedef std::vector<std::pair<QAction *, TransformId>> TransformActions;
280  TransformActions m_transformActions;
281 
282  // This one only makes sense as a map though
283  typedef std::map<TransformId, QAction *> TransformActionReverseMap;
284  TransformActionReverseMap m_transformActionsReverse;
285 
286  QString getReleaseText() const;
287 
288  void setupMenus() override;
289 
290  void setupFileMenu();
291  void setupEditMenu();
292  void setupViewMenu();
293  void setupPaneAndLayerMenus();
294  void prepareTransformsMenu();
295  void setupHelpMenu();
297  void setupToolbars();
298 
299  class TransformPopulater : public QThread {
300  public:
301  TransformPopulater(MainWindow *mw) : QThread(mw), m_mw(mw) { }
302  void run() override;
303  private:
305  };
307 
308  void addPane(const LayerConfiguration &configuration, QString text);
309 
310  void closeEvent(QCloseEvent *e) override;
311  bool checkSaveModified() override;
312 
313  void exportAudio(bool asData);
314 
315  void updateVisibleRangeDisplay(Pane *p) const override;
316  void updatePositionStatusDisplays() const override;
317 
318  bool shouldCreateNewSessionForRDFAudio(bool *cancel) override;
319 
320  void connectLayerEditDialog(ModelDataTableDialog *) override;
321 };
322 
323 
324 #endif
virtual void openRecentFile()
virtual void showActivityLog()
virtual void whatsNew()
std::map< TransformId, QAction * > TransformActionReverseMap
Definition: MainWindow.h:283
void modelRegenerationFailed(QString, QString, QString) override
virtual void toolEraseSelected()
QFileSystemWatcher * m_templateWatcher
Definition: MainWindow.h:234
virtual void importMoreAudio()
QMenu * m_recentTransformsMenu
Definition: MainWindow.h:190
std::vector< std::pair< QAction *, LayerConfiguration > > PaneActions
Definition: MainWindow.h:263
TransformPopulater(MainWindow *mw)
Definition: MainWindow.h:301
virtual void coloursChanged()
virtual void convertAudio()
QMenu * m_transformsMenu
Definition: MainWindow.h:185
virtual void preferences()
ExistingLayerActions m_existingLayerActions
Definition: MainWindow.h:270
std::vector< std::pair< QAction *, Layer * > > ExistingLayerActions
Definition: MainWindow.h:269
QAction * m_playAction
Definition: MainWindow.h:206
QAction * m_playLoopAction
Definition: MainWindow.h:209
QMenu * m_templatesMenu
Definition: MainWindow.h:191
QAction * m_zoomOutAction
Definition: MainWindow.h:212
void endFullScreen()
Definition: MainWindow.cpp:506
void setupMenus() override
Definition: MainWindow.cpp:412
void paneCancelButtonPressed(Layer *)
void canAlign(bool)
void paneRightButtonMenuRequested(Pane *, QPoint point) override
QString shortcutFor(LayerFactory::LayerType, bool isPaneMenu)
bool checkSaveModified() override
virtual void website()
QMenu * m_sliceMenu
Definition: MainWindow.h:188
virtual void midiEventsAvailable()
void populateTransformsMenu()
void layerPropertiesRightButtonMenuRequested(Pane *, Layer *, QPoint point) override
virtual void setupRecentFilesMenu()
virtual void openSomething()
virtual void saveSession()
virtual void pluginPopulationWarning(QString text)
bool m_prevSolo
Definition: MainWindow.h:219
QPointer< PreferencesDialog > m_preferencesDialog
Definition: MainWindow.h:227
virtual void findTransform()
virtual void showUnitConverter()
QMenu * m_rightButtonPlaybackMenu
Definition: MainWindow.h:195
void monitoringLevelsChanged(float, float) override
virtual void resetInstantsCounters()
QAction * m_showPropertyBoxesAction
Definition: MainWindow.h:216
QAction * m_deleteSelectedAction
Definition: MainWindow.h:198
ToolActions m_toolActions
Definition: MainWindow.h:274
QAction * m_soloAction
Definition: MainWindow.h:199
void prepareTransformsMenu()
void setupToolbars()
virtual void importAudio()
virtual void manageSavedTemplates()
void modelGenerationFailed(QString, QString) override
virtual void keyReference()
virtual void about()
LayerActions m_layerActions
Definition: MainWindow.h:267
virtual void setInstantsCounters()
void setupEditMenu()
Definition: MainWindow.cpp:706
virtual void importLayer()
virtual void mainModelPanChanged(float)
virtual void toolMeasureSelected()
virtual void exportImage()
void updateVisibleRangeDisplay(Pane *p) const override
VersionTester * m_versionTester
Definition: MainWindow.h:237
void setupHelpMenu()
void playSoloToggled() override
void documentRestored() override
QMenu * m_playbackMenu
Definition: MainWindow.h:186
virtual void applyTemplate()
virtual void winnowInstants()
QScrollArea * m_mainScroll
Definition: MainWindow.h:180
void setupExistingLayersMenus()
virtual void slowDownPlayback()
void panePropertiesRightButtonMenuRequested(Pane *, QPoint point) override
KeyReference * m_keyReference
Definition: MainWindow.h:232
virtual void openLocation()
virtual void subdivideInstants()
virtual void setInstantsNumbering()
void modelRegenerationWarning(QString, QString, QString) override
LayerConfiguration(LayerFactory::LayerType _layer=LayerFactory::TimeRuler, ModelId _source=ModelId(), int _channel=-1)
Definition: MainWindow.h:241
void setupPaneAndLayerMenus()
PaneActions m_paneActions
Definition: MainWindow.h:264
TransformActions m_transformActions
Definition: MainWindow.h:280
virtual void exportAudio()
NumberingActions m_numberingActions
Definition: MainWindow.h:277
void currentPaneChanged(Pane *) override
virtual void restoreNormalPlayback()
std::vector< std::pair< QAction *, int > > NumberingActions
Definition: MainWindow.h:276
Overview * m_overview
Definition: MainWindow.h:175
void closeEvent(QCloseEvent *e) override
virtual void mouseEnteredWidget()
virtual void addLayer()
virtual void replaceMainAudio()
virtual void playStatusChanged(bool)
UnitConverter * m_unitConverter
Definition: MainWindow.h:231
QPointer< LayerTreeDialog > m_layerTreeDialog
Definition: MainWindow.h:228
void closeSession() override
void setupFileMenu()
Definition: MainWindow.cpp:520
bool m_mainMenusCreated
Definition: MainWindow.h:182
void updateDescriptionLabel() override
TransformActionReverseMap m_transformActionsReverse
Definition: MainWindow.h:284
bool m_soloModified
Definition: MainWindow.h:218
void connectLayerEditDialog(ModelDataTableDialog *) override
virtual void saveSessionAsTemplate()
LevelPanToolButton * m_mainLevelPan
Definition: MainWindow.h:176
virtual void toolEditSelected()
QAction * m_manageTemplatesAction
Definition: MainWindow.h:210
void newerVersionAvailable(QString) override
virtual void toolSelectSelected()
QAction * m_scrollLeftAction
Definition: MainWindow.h:214
int m_playControlsWidth
Definition: MainWindow.h:222
QMenu * m_rightButtonMenu
Definition: MainWindow.h:192
virtual void addPane()
void sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool) override
QAction * m_rwdSimilarAction
Definition: MainWindow.h:201
void modelGenerationWarning(QString, QString) override
QMenu * m_rightButtonLayerMenu
Definition: MainWindow.h:193
void documentModified() override
QLabel * m_descriptionLabel
Definition: MainWindow.h:224
AudioDial * m_playSpeed
Definition: MainWindow.h:177
QMenu * m_recentFilesMenu
Definition: MainWindow.h:189
virtual void speedUpPlayback()
virtual void betaReleaseWarning()
void handleOSCMessage(const OSCMessage &) override
Definition: OSCHandler.cpp:46
virtual void help()
ActivityLog * m_activityLog
Definition: MainWindow.h:230
void mainModelChanged(ModelId) override
void updatePositionStatusDisplays() const override
QMenu * m_rightButtonTransformsMenu
Definition: MainWindow.h:194
void audioOverloadPluginDisabled() override
void paneAboutToBeDeleted(Pane *) override
virtual void setupRecentTransformsMenu()
QAction * m_ffwdAction
Definition: MainWindow.h:203
QMenu * m_lastRightButtonPropertyMenu
Definition: MainWindow.h:196
QString getReleaseText() const
virtual void saveSessionAs()
ExistingLayerActions m_sliceActions
Definition: MainWindow.h:271
void updateLayerShortcutsFor(ModelId)
virtual void exportLayer()
virtual void mouseLeftWidget()
virtual void propertyStacksResized(int)
virtual void exportAudioData()
void preferenceChanged(PropertyContainer::PropertyName) override
virtual void documentReplaced()
QAction * m_zoomInAction
Definition: MainWindow.h:211
Surveyer * m_surveyer
Definition: MainWindow.h:236
void modelAdded(ModelId) override
virtual void playSpeedChanged(int)
void alignmentFailed(ModelId, QString) override
QLabel * m_currentLabel
Definition: MainWindow.h:225
TransformPopulater * m_transformPopulater
Definition: MainWindow.h:306
void paneAdded(Pane *) override
QAction * m_ffwdEndAction
Definition: MainWindow.h:205
LayerFactory::LayerType layer
Definition: MainWindow.h:246
void updateMenuStates() override
std::vector< std::pair< QAction *, LayerConfiguration > > LayerActions
Definition: MainWindow.h:266
void canChangeSolo(bool)
virtual ~MainWindow()
Definition: MainWindow.cpp:391
virtual bool commitData(bool mayAskUser)
virtual void toolNavigateSelected()
MainWindow(AudioMode audioMode, MIDIMode midiMode, bool withOSCSupport)
Definition: MainWindow.cpp:141
virtual void setInstantsCounterCycle()
QString m_newerVersionIs
Definition: MainWindow.h:238
QAction * m_zoomFitAction
Definition: MainWindow.h:213
QAction * m_playSelectionAction
Definition: MainWindow.h:208
virtual void exportSVG()
virtual void newSession()
void goFullScreen()
Definition: MainWindow.cpp:474
QMenu * m_paneMenu
Definition: MainWindow.h:183
void setupViewMenu()
Definition: MainWindow.cpp:956
QAction * m_rwdStartAction
Definition: MainWindow.h:200
QMenu * m_layerMenu
Definition: MainWindow.h:184
virtual void showLayerTree()
virtual void browseRecordedAudio()
virtual void alignToggled()
virtual void toolDrawSelected()
virtual void mainModelGainChanged(float)
bool shouldCreateNewSessionForRDFAudio(bool *cancel) override
virtual void setupTemplatesMenu()
QAction * m_rwdAction
Definition: MainWindow.h:202
QFrame * m_playControlsSpacer
Definition: MainWindow.h:221
QAction * m_recordAction
Definition: MainWindow.h:207
void paneHidden(Pane *) override
void paneDropAccepted(Pane *, QStringList) override
QAction * m_ffwdSimilarAction
Definition: MainWindow.h:204
QMenu * m_existingLayersMenu
Definition: MainWindow.h:187
virtual void renameCurrentLayer()
void layerRemoved(Layer *) override
WaveformLayer * m_panLayer
Definition: MainWindow.h:178
void layerInAView(Layer *, bool) override
std::vector< std::pair< ViewManager::ToolMode, QAction * > > ToolActions
Definition: MainWindow.h:273
std::vector< std::pair< QAction *, TransformId > > TransformActions
Definition: MainWindow.h:279
QAction * m_scrollRightAction
Definition: MainWindow.h:215