Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: settings lost on GUI state change #3144

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() );
pljones marked this conversation as resolved.
Show resolved Hide 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