hydrogen 1.2.6
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-2025 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 <memory>
36#include <set>
37#include <vector>
38
39#include <QtGui>
40#include <QtWidgets>
41#include <QStringList>
42
47constexpr uint16_t QUEUE_TIMER_PERIOD = 50;
48
49
50namespace H2Core
51{
52 class Song;
53}
54
55class SongEditorPanel;
56class MainForm;
57class PlayerControl;
60class SongEditor;
61class Mixer;
64class SimpleHTMLBrowser;
66class LadspaFXInfo;
67class LadspaFXGroup;
68class InstrumentRack;
69class PlaylistDialog;
70class SampleEditor;
71class Director;
72class InfoBar;
73class CommonStrings;
74
76class HydrogenApp : public QObject, public EventListener, public H2Core::Object<HydrogenApp>
77{
79 Q_OBJECT
80 public:
81 HydrogenApp( MainForm* pMainForm );
82
84 static HydrogenApp* get_instance();
85
86 virtual ~HydrogenApp();
87
92 static bool openSong( QString sFilename );
93 static bool openSong( std::shared_ptr<H2Core::Song> pSong );
103 static bool recoverEmptySong();
104
107 void showMixer(bool bShow);
108 void showInstrumentPanel(bool);
111 void showPlaylistDialog();
112 void showDirector();
113 void showSampleEditor( QString name, int mSelectedComponemt, int mSelectedLayer );
114
115 bool hideKeyboardCursor();
116 void setHideKeyboardCursor( bool bHidden );
117
118 Mixer* getMixer();
128 std::shared_ptr<CommonStrings> getCommonStrings();
130
131 QUndoStack* m_pUndoStack;
132
133 void showStatusBarMessage( const QString& sMessage, const QString& sCaller = "" );
134 void updateWindowTitle();
135
136#ifdef H2CORE_HAVE_LADSPA
137 LadspaFXProperties* getLadspaFXProperties(uint nFX) { return m_pLadspaFXProperties[nFX]; }
138#endif
139 void addEventListener( EventListener* pListener );
140 void removeEventListener( EventListener* pListener );
141 void closeFXProperties();
142
144
154
155 void setWindowProperties( QWidget *pWindow, H2Core::WindowProperties &prop, unsigned flags = SetAll );
157
158 static bool checkDrumkitLicense( std::shared_ptr<H2Core::Drumkit> pDrumkit );
159
160signals:
169
170 public slots:
181 void onEventQueueTimer();
182 void currentTabChanged(int);
183
191
192 private slots:
194
195 private:
197
199
200#ifdef H2CORE_HAVE_LADSPA
201 LadspaFXProperties * m_pLadspaFXProperties[MAX_FX];
202#endif
203
207 QScrollArea* m_pMainScrollArea;
220 std::vector<EventListener*> m_eventListeners;
221 std::set<EventListener*> m_eventListenersToAdd;
222 std::set<EventListener*> m_eventListenersToRemove;
223 QTabWidget * m_pTab;
224 QSplitter * m_pSplitter;
225 QVBoxLayout * m_pMainVBox;
226 std::shared_ptr<CommonStrings> m_pCommonStrings;
227
232
233 // implement EngineListener interface
234 void engineError(uint nErrorCode);
235
237 virtual void songModifiedEvent() override;
238 virtual void XRunEvent() override;
239
253 virtual void updatePreferencesEvent( int nValue ) override;
268 virtual void updateSongEvent( int nValue ) override;
269 virtual void drumkitLoadedEvent() override;
270
271};
272
273
278
280{
281 return m_pMixer;
282}
283
285{
286 return m_pMainForm;
287}
288
293
298
303
305{
306 return m_pDirector;
307}
308
313
318
323
328
329inline std::shared_ptr<CommonStrings> HydrogenApp::getCommonStrings()
330{
331 return m_pCommonStrings;
332}
333
335{
337}
338
339inline void HydrogenApp::setHideKeyboardCursor( bool bHidden )
340{
341 if ( bHidden && ! m_bHideKeyboardCursor ) {
343 if ( pPref->hideKeyboardCursor() ) {
345 }
346 } else {
347 m_bHideKeyboardCursor = bHidden;
348 }
349}
350
351
352#endif
constexpr uint16_t QUEUE_TIMER_PERIOD
Amount of time to pass between successive calls to HydrogenApp::onEventQueueTimer() in milliseconds.
Definition HydrogenApp.h:47
#define H2_OBJECT(name)
Definition Object.h:227
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:79
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
void updateEventListeners()
InfoBar * addInfoBar()
int m_nPreferencesUpdateTimeout
QUndoStack * m_pUndoStack
PatternEditorPanel * getPatternEditorPanel()
bool hideKeyboardCursor()
Director * m_pDirector
std::vector< EventListener * > m_eventListeners
void showAudioEngineInfoForm()
QSplitter * m_pSplitter
void showFilesystemInfoForm()
QScrollArea * m_pMainScrollArea
Used for accessibility reasons to show scroll bars in case Hydrogen has to be shrunk below its minimu...
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
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.
std::set< EventListener * > m_eventListenersToRemove
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)
std::set< EventListener * > m_eventListenersToAdd
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