hydrogen 1.2.3
HydrogenApp.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#ifndef HYDROGEN_APP_H
24#define HYDROGEN_APP_H
25
26#include <core/config.h>
27#include <core/Object.h>
28#include <core/Globals.h>
30
31#include "EventListener.h"
32
33#include <iostream>
34#include <cstdint>
35#include <vector>
36#include <memory>
37
38#include <QtGui>
39#include <QtWidgets>
40#include <QStringList>
41
46constexpr uint16_t QUEUE_TIMER_PERIOD = 50;
47
48
49namespace H2Core
50{
51 class Song;
52}
53
54class SongEditorPanel;
55class MainForm;
56class PlayerControl;
59class SongEditor;
60class Mixer;
63class SimpleHTMLBrowser;
65class LadspaFXInfo;
66class LadspaFXGroup;
67class InstrumentRack;
68class PlaylistDialog;
69class SampleEditor;
70class Director;
71class InfoBar;
72class CommonStrings;
73
75class HydrogenApp : public QObject, public EventListener, public H2Core::Object<HydrogenApp>
76{
78 Q_OBJECT
79 public:
80 HydrogenApp( MainForm* pMainForm );
81
83 static HydrogenApp* get_instance();
84
85 virtual ~HydrogenApp();
86
91 static bool openSong( QString sFilename );
92 static bool openSong( std::shared_ptr<H2Core::Song> pSong );
102 static bool recoverEmptySong();
103
106 void showMixer(bool bShow);
107 void showInstrumentPanel(bool);
110 void showPlaylistDialog();
111 void showDirector();
112 void showSampleEditor( QString name, int mSelectedComponemt, int mSelectedLayer );
113
114 bool hideKeyboardCursor();
115 void setHideKeyboardCursor( bool bHidden );
116
117 Mixer* getMixer();
127 std::shared_ptr<CommonStrings> getCommonStrings();
129
130 QUndoStack* m_pUndoStack;
131
132 void showStatusBarMessage( const QString& sMessage, const QString& sCaller = "" );
133 void updateWindowTitle();
134
135#ifdef H2CORE_HAVE_LADSPA
136 LadspaFXProperties* getLadspaFXProperties(uint nFX) { return m_pLadspaFXProperties[nFX]; }
137#endif
138 void addEventListener( EventListener* pListener );
139 void removeEventListener( EventListener* pListener );
140 void closeFXProperties();
141
143
153
154 void setWindowProperties( QWidget *pWindow, H2Core::WindowProperties &prop, unsigned flags = SetAll );
156
157 static bool checkDrumkitLicense( std::shared_ptr<H2Core::Drumkit> pDrumkit );
158
159signals:
168
169 public slots:
180 void onEventQueueTimer();
181 void currentTabChanged(int);
182
190
191private slots:
193
194 private:
196
197#ifdef H2CORE_HAVE_LADSPA
198 LadspaFXProperties * m_pLadspaFXProperties[MAX_FX];
199#endif
200
213 std::vector<EventListener*> m_EventListeners;
214 QTabWidget * m_pTab;
215 QSplitter * m_pSplitter;
216 QVBoxLayout * m_pMainVBox;
217 std::shared_ptr<CommonStrings> m_pCommonStrings;
218
223
224 // implement EngineListener interface
225 void engineError(uint nErrorCode);
226
228 virtual void songModifiedEvent() override;
229 virtual void XRunEvent() override;
230
244 virtual void updatePreferencesEvent( int nValue ) override;
259 virtual void updateSongEvent( int nValue ) override;
260 virtual void drumkitLoadedEvent() override;
261
262};
263
264
269
271{
272 return m_pMixer;
273}
274
276{
277 return m_pMainForm;
278}
279
284
289
294
296{
297 return m_pDirector;
298}
299
304
309
314
319
320inline std::shared_ptr<CommonStrings> HydrogenApp::getCommonStrings()
321{
322 return m_pCommonStrings;
323}
324
326{
328}
329
330inline void HydrogenApp::setHideKeyboardCursor( bool bHidden )
331{
332 if ( bHidden && ! m_bHideKeyboardCursor ) {
334 if ( pPref->hideKeyboardCursor() ) {
336 }
337 } else {
338 m_bHideKeyboardCursor = bHidden;
339 }
340}
341
342
343#endif
constexpr uint16_t QUEUE_TIMER_PERIOD
Amount of time to pass between successive calls to HydrogenApp::onEventQueueTimer() in milliseconds.
Definition HydrogenApp.h:46
#define H2_OBJECT(name)
Definition Object.h:224
Audio Engine information form.
A container class to collect all translatable strings at one place in order to allow for the reusage.
Manager for User Preferences File (singleton)
Definition Preferences.h:78
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
Changes
Bitwise or-able options showing which part of the Preferences were altered using the PreferencesDialo...
void setHideKeyboardCursor(bool bHidden)
PlayerControl * getPlayerControl()
AudioEngineInfoForm * m_pAudioEngineInfoForm
MainForm * getMainForm()
void updateWindowTitle()
void addEventListener(EventListener *pListener)
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
std::shared_ptr< CommonStrings > getCommonStrings()
std::shared_ptr< CommonStrings > m_pCommonStrings
InfoBar * addInfoBar()
int m_nPreferencesUpdateTimeout
QUndoStack * m_pUndoStack
PatternEditorPanel * getPatternEditorPanel()
bool hideKeyboardCursor()
Director * m_pDirector
void showAudioEngineInfoForm()
QSplitter * m_pSplitter
void showFilesystemInfoForm()
SongEditorPanel * m_pSongEditorPanel
InstrumentRack * getInstrumentRack()
void updateMixerCheckbox()
void closeFXProperties()
virtual void updatePreferencesEvent(int nValue) override
Handles the loading and saving of the H2Core::Preferences from the core part of H2Core::Hydrogen.
static bool openSong(QString sFilename)
void onPreferencesChanged(H2Core::Preferences::Changes changes)
PlayerControl * m_pPlayerControl
PlaylistDialog * getPlayListDialog()
PlaylistDialog * m_pPlaylistDialog
virtual void updateSongEvent(int nValue) override
Refreshes and updates the GUI after the Song was changed in the core part of Hydrogen.
static bool checkDrumkitLicense(std::shared_ptr< H2Core::Drumkit > pDrumkit)
void showDirector()
PatternEditorPanel * m_pPatternEditorPanel
void showStatusBarMessage(const QString &sMessage, const QString &sCaller="")
QVBoxLayout * m_pMainVBox
QTimer * m_pPreferencesUpdateTimer
std::vector< EventListener * > m_EventListeners
virtual void drumkitLoadedEvent() override
void showMixer(bool bShow)
void showPlaylistDialog()
void onEventQueueTimer()
Function called every QUEUE_TIMER_PERIOD millisecond to pop all Events from the EventQueue and invoke...
void preferencesChanged(H2Core::Preferences::Changes changes)
Propagates a change in the Preferences through the GUI.
void changePreferences(H2Core::Preferences::Changes changes)
Propagates a change in the Preferences through the GUI.
QTimer * m_pEventQueueTimer
void showInstrumentPanel(bool)
void showSampleEditor(QString name, int mSelectedComponemt, int mSelectedLayer)
static bool recoverEmptySong()
Specialized version of openSong( QString sFilename ) trying to open the autosave file corresponding t...
void currentTabChanged(int)
void engineError(uint nErrorCode)
SampleEditor * getSampleEditor()
void removeEventListener(EventListener *pListener)
virtual void songModifiedEvent() override
InstrumentRack * m_pInstrumentRack
virtual void XRunEvent() override
H2Core::WindowProperties getWindowProperties(QWidget *pWindow)
AudioEngineInfoForm * getAudioEngineInfoForm()
virtual ~HydrogenApp()
Mixer * m_pMixer
void showPreferencesDialog()
SongEditorPanel * getSongEditorPanel()
void cleanupTemporaryFiles()
Removes temporary files that were created for undo'ing things.
Director * getDirector()
H2Core::Preferences::Changes m_bufferedChanges
Mixer * getMixer()
void setWindowProperties(QWidget *pWindow, H2Core::WindowProperties &prop, unsigned flags=SetAll)
MainForm * m_pMainForm
SampleEditor * m_pSampleEditor
QTabWidget * m_pTab
void setupSinglePanedInterface()
void propagatePreferences()
HydrogenApp(MainForm *pMainForm)
FilesystemInfoForm * m_pFilesystemInfoForm
static HydrogenApp * m_pInstance
HydrogenApp instance.
bool m_bHideKeyboardCursor
Container for the Instrument Editor (Singleton).
debug only
Definition MainForm.h:47
Definition Mixer.h:44
Pattern Editor Panel.
This dialog is used to use the H2PlayList.
This dialog is used to preview audiofiles.
Song editor.
Definition SongEditor.h:72
#define MAX_FX
Maximum number of effects.
Definition config.dox:83