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 Class Reference

The main application singleton class. More...

#include <tunerapplication.h>

+ Inheritance diagram for TunerApplication:
+ Collaboration diagram for TunerApplication:

Public Slots

bool openFile (QString filePath, bool cached)
 Open the given file. More...
 

Public Member Functions

 TunerApplication (int &argc, char **argv)
 Constructor for the application. More...
 
virtual ~TunerApplication ()
 Destructor of the application. More...
 
void init ()
 Function to initialise the application. More...
 
void exit ()
 Function called upon exitting the application. More...
 
void start ()
 Function to start the MainWindow and the Core. More...
 
void stop ()
 Function to stop the MainWindow and the Core. More...
 
void playStartupSound ()
 Function to play the startup sound. More...
 
CoregetCore ()
 Getter function for the core. More...
 

Static Public Member Functions

static TunerApplicationgetSingleton ()
 Getter for the singleton instance. More...
 
static TunerApplicationgetSingletonPtr ()
 Getter for the singleton instance. More...
 
static void setApplicationExitState (int errorcode=EXIT_SUCCESS)
 This is sets the exit code if the app would be terminated now. More...
 

Static Public Attributes

static TunerApplicationmSingleton
 The one and only instance. More...
 

Protected Member Functions

bool event (QEvent *e)
 Handling of general events. More...
 
void timerEvent (QTimerEvent *event)
 Called when the internal timer was shot. More...
 
bool notify (QObject *receiver, QEvent *event)
 Reimplemented to catch exceptions. More...
 

Private Slots

void onApplicationStateChanged (Qt::ApplicationState state)
 Depending on the application state the core will be started or stopped. More...
 
void onAboutToQuit ()
 

Private Member Functions

void initCore ()
 Initialising of the core. More...
 
void exitCore ()
 Exit from the core. More...
 
void startCore ()
 Start the core. More...
 
void stopCore ()
 Stop the core. More...
 

Private Attributes

int mLastExitCode
 last exit code to detect if the application crashed More...
 
int mMessageHandlerTimerId
 Id of the timer that progresses the MessageHandler. More...
 
QString mStartupFile
 Absolute path to the startup file or an empty string. More...
 
std::shared_ptr< CoremCore
 Shared pointer of the Core. More...
 
std::shared_ptr< MainWindowmMainWindow
 Shared pointer of the MainWindow. More...
 
AudioRecorderForQt mAudioRecorder
 Instance of the Qt audio recorder. More...
 
AudioPlayerForQt mAudioPlayer
 Instance of the Qt audio player. More...
 

Detailed Description

The main application singleton class.

This class handles the initialisation of the MainWindow and the Core. It also stores the instances of the platform dependent audio player and recorder. Moreover this class will progress the messages in MessageHandler.

Definition at line 37 of file tunerapplication.h.

Constructor & Destructor Documentation

TunerApplication::TunerApplication ( int &  argc,
char **  argv 
)
explicit

Constructor for the application.

Parameters
argc: Number of arguments
argv: Array of the arguments

The constructor will create the MainWindow and the Core without initializing them. It will also call the platform dependent function to disable the screen saver.

Definition at line 43 of file tunerapplication.cpp.

+ Here is the call graph for this function:

TunerApplication::~TunerApplication ( )
virtual

Destructor of the application.

The destructor makes sure that all components are exitted and enables the screen saver.

Definition at line 69 of file tunerapplication.cpp.

+ Here is the call graph for this function:

Member Function Documentation

bool TunerApplication::event ( QEvent *  e)
protected

Handling of general events.

Parameters
e: The QEvent
Returns
If the event was processed.

On MacOS X this function will listen to QEvent::FileOpen to open a startup file.

Definition at line 217 of file tunerapplication.cpp.

+ Here is the call graph for this function:

void TunerApplication::exit ( )

Function called upon exitting the application.

This will stop and exit the core.

Definition at line 139 of file tunerapplication.cpp.

+ Here is the call graph for this function:

void TunerApplication::exitCore ( )
private

Exit from the core.

Definition at line 267 of file tunerapplication.cpp.

Core* TunerApplication::getCore ( )
inline

Getter function for the core.

Returns
Pointer stored in mCore

Definition at line 125 of file tunerapplication.h.

TunerApplication & TunerApplication::getSingleton ( )
static

Getter for the singleton instance.

Returns
mSingleton

Definition at line 79 of file tunerapplication.cpp.

TunerApplication * TunerApplication::getSingletonPtr ( )
static

Getter for the singleton instance.

Returns
Pointer to mSingleton or nullptr if not created yet.

Definition at line 84 of file tunerapplication.cpp.

void TunerApplication::init ( )

Function to initialise the application.

This will initialize the MainWindow and show it. Secondly the Core will be initialized.

Definition at line 94 of file tunerapplication.cpp.

+ Here is the call graph for this function:

void TunerApplication::initCore ( )
private

Initialising of the core.

Definition at line 252 of file tunerapplication.cpp.

bool TunerApplication::notify ( QObject *  receiver,
QEvent *  event 
)
protected

Reimplemented to catch exceptions.

Parameters
receiver: The receiving QObject.
event: The QEvent
Returns
The result of QApplication::notify(QObject*, QEvent*)

Definition at line 232 of file tunerapplication.cpp.

+ Here is the call graph for this function:

void TunerApplication::onAboutToQuit ( )
privateslot

Definition at line 323 of file tunerapplication.cpp.

+ Here is the call graph for this function:

void TunerApplication::onApplicationStateChanged ( Qt::ApplicationState  state)
privateslot

Depending on the application state the core will be started or stopped.

Parameters
state: The Qt::ApplicationState

When minimized the core will stop. On mobile devices the core will already stop if the application is in inavtive state.

Definition at line 296 of file tunerapplication.cpp.

+ Here is the call graph for this function:

bool TunerApplication::openFile ( QString  filePath,
bool  cached 
)
slot

Open the given file.

Parameters
filePath: The absolute file path
cached: Is the file stored in cache
Returns
Result of the open command

Definition at line 207 of file tunerapplication.cpp.

void TunerApplication::playStartupSound ( )

Function to play the startup sound.

Definition at line 172 of file tunerapplication.cpp.

void TunerApplication::setApplicationExitState ( int  errorcode = EXIT_SUCCESS)
static

This is sets the exit code if the app would be terminated now.

If it is expected that the app may exit in the future, usually at the end of the program all this with EXIT_SUCCESS. If it is not expected that the app exits call this using EXIT_FAILURE This is used to detect whether the app crashed

Definition at line 88 of file tunerapplication.cpp.

void TunerApplication::start ( )

Function to start the MainWindow and the Core.

Definition at line 146 of file tunerapplication.cpp.

+ Here is the call graph for this function:

void TunerApplication::startCore ( )
private

Start the core.

Definition at line 274 of file tunerapplication.cpp.

void TunerApplication::stop ( )

Function to stop the MainWindow and the Core.

Definition at line 167 of file tunerapplication.cpp.

void TunerApplication::stopCore ( )
private

Stop the core.

Definition at line 284 of file tunerapplication.cpp.

void TunerApplication::timerEvent ( QTimerEvent *  event)
protected

Called when the internal timer was shot.

Parameters
event: The QTimerEvent

This function will progress the messages in MessageHandler.

Definition at line 227 of file tunerapplication.cpp.

+ Here is the call graph for this function:

Member Data Documentation

AudioPlayerForQt TunerApplication::mAudioPlayer
private

Instance of the Qt audio player.

Definition at line 223 of file tunerapplication.h.

AudioRecorderForQt TunerApplication::mAudioRecorder
private

Instance of the Qt audio recorder.

Definition at line 220 of file tunerapplication.h.

std::shared_ptr<Core> TunerApplication::mCore
private

Shared pointer of the Core.

Definition at line 214 of file tunerapplication.h.

int TunerApplication::mLastExitCode
private

last exit code to detect if the application crashed

Definition at line 205 of file tunerapplication.h.

std::shared_ptr<MainWindow> TunerApplication::mMainWindow
private

Shared pointer of the MainWindow.

Definition at line 217 of file tunerapplication.h.

int TunerApplication::mMessageHandlerTimerId
private

Id of the timer that progresses the MessageHandler.

Definition at line 208 of file tunerapplication.h.

TunerApplication * TunerApplication::mSingleton
static

The one and only instance.

Definition at line 42 of file tunerapplication.h.

QString TunerApplication::mStartupFile
private

Absolute path to the startup file or an empty string.

Definition at line 211 of file tunerapplication.h.


The documentation for this class was generated from the following files: