Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <QSettings>
#include <QDir>
#ifndef HEADLESS
# include <QApplication>
# include <QMessageBox>
#endif
#include "global.h"
Expand All @@ -50,6 +51,31 @@ class CSettings : public QObject
strFileName ( "" )
{
QObject::connect ( QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CSettings::OnAboutToQuit );
#ifndef HEADLESS

// The Jamulus App will be created as either a QCoreApplication or QApplication (a subclass of QGuiApplication).
// State signals are only delivered to QGuiApplications, so we determine here whether we instantiated the GUI.
const QGuiApplication* pGApp = dynamic_cast<const QGuiApplication*> ( QCoreApplication::instance() );
Comment thread
pljones marked this conversation as resolved.

if ( pGApp != nullptr )
{
# ifndef QT_NO_SESSIONMANAGER
QObject::connect (
pGApp,
&QGuiApplication::saveStateRequest,
this,
[=] ( QSessionManager& ) { Save(); },
Qt::DirectConnection );

# endif
QObject::connect ( pGApp, &QGuiApplication::applicationStateChanged, this, [=] ( Qt::ApplicationState state ) {
if ( Qt::ApplicationActive != state )
{
Save();
}
} );
}
#endif
}

void Load ( const QList<QString>& CommandLineOptions );
Expand Down