Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tunerapplication.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2015 Haye Hinrichsen, Christoph Wick
3  *
4  * This file is part of Entropy Piano Tuner.
5  *
6  * Entropy Piano Tuner is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * Entropy Piano Tuner is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * Entropy Piano Tuner. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 #ifndef TUNERAPPLICATION_H
21 #define TUNERAPPLICATION_H
22 
23 #include <QApplication>
26 #include "mainwindow.h"
27 #include "initializedialog.h"
28 
37 class TunerApplication : public QApplication
38 {
39  Q_OBJECT
40 public:
43 public:
54  explicit TunerApplication(int & argc, char ** argv);
55 
62  virtual ~TunerApplication();
63 
70 
77 
78 
85  static void setApplicationExitState(int errorcode = EXIT_SUCCESS);
86 
93  void init();
94 
100  void exit();
101 
106  void start();
107 
112  void stop();
113 
118  void playStartupSound();
119 
125  Core *getCore() {return mCore.get();}
126 
127 protected:
136  bool event(QEvent *e);
137 
144  void timerEvent(QTimerEvent *event);
145 
153  bool notify(QObject* receiver, QEvent* event);
154 
155 private:
160  void initCore();
161 
166  void exitCore();
167 
172  void startCore();
173 
178  void stopCore();
179 
180 public slots:
188  bool openFile(QString filePath, bool cached);
189 
190 private slots:
199  void onApplicationStateChanged(Qt::ApplicationState state);
200 
201  void onAboutToQuit();
202 
203 private:
206 
209 
211  QString mStartupFile;
212 
214  std::shared_ptr<Core> mCore;
215 
217  std::shared_ptr<MainWindow> mMainWindow;
218 
221 
224 };
225 
226 #endif // TUNERAPPLICATION_H
bool notify(QObject *receiver, QEvent *event)
Reimplemented to catch exceptions.
static TunerApplication * mSingleton
The one and only instance.
int mMessageHandlerTimerId
Id of the timer that progresses the MessageHandler.
bool openFile(QString filePath, bool cached)
Open the given file.
QString mStartupFile
Absolute path to the startup file or an empty string.
AudioRecorderForQt mAudioRecorder
Instance of the Qt audio recorder.
Core * getCore()
Getter function for the core.
TunerApplication(int &argc, char **argv)
Constructor for the application.
std::shared_ptr< MainWindow > mMainWindow
Shared pointer of the MainWindow.
The main application singleton class.
void start()
Function to start the MainWindow and the Core.
static TunerApplication & getSingleton()
Getter for the singleton instance.
static TunerApplication * getSingletonPtr()
Getter for the singleton instance.
void playStartupSound()
Function to play the startup sound.
AudioPlayerForQt mAudioPlayer
Instance of the Qt audio player.
The AudioPlayerForQt class.
void exit()
Function called upon exitting the application.
std::shared_ptr< Core > mCore
Shared pointer of the Core.
void stop()
Function to stop the MainWindow and the Core.
int mLastExitCode
last exit code to detect if the application crashed
void stopCore()
Stop the core.
void initCore()
Initialising of the core.
void init()
Function to initialise the application.
CORE : Class managing the core.
Definition: core.h:45
void timerEvent(QTimerEvent *event)
Called when the internal timer was shot.
void startCore()
Start the core.
virtual ~TunerApplication()
Destructor of the application.
bool event(QEvent *e)
Handling of general events.
void exitCore()
Exit from the core.
static void setApplicationExitState(int errorcode=EXIT_SUCCESS)
This is sets the exit code if the app would be terminated now.
void onApplicationStateChanged(Qt::ApplicationState state)
Depending on the application state the core will be started or stopped.