Commit 64a2d1ed authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

Fixing problems with saving configuration on Android

parent 1934a839
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0.1" package="org.kde.kstars" android:installLocation="auto" android:versionCode="7">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0.1" package="org.kde.kstars" android:installLocation="auto" android:versionCode="8">
<application android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="KStars Lite" android:icon="@drawable/icon">
<activity android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="KStars Lite" android:screenOrientation="unspecified" android:theme="@style/AppTheme" android:launchMode="singleTop" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation">
<intent-filter>
......
......@@ -119,7 +119,8 @@ KStarsLite::KStarsLite( bool doSplash, bool startClock, const QString &startDate
format.setSwapBehavior(QSurfaceFormat::TripleBuffer);
mainWindow->setFormat(format);
connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( slotAboutToQuit() ) );
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), SLOT(handleStateChange(Qt::ApplicationState)));
//Initialize Time and Date
if (startDateString.isEmpty() == false)
......@@ -151,11 +152,6 @@ KStarsLite::KStarsLite( bool doSplash, bool startClock, const QString &startDate
if( !m_KStarsData->initialize() ) return;
datainitFinished();
#if ( __GLIBC__ >= 2 &&__GLIBC_MINOR__ >= 1 && !defined(__UCLIBC__) )
qDebug() << "glibc >= 2.1 detected. Using GNU extension sincos()";
#else
qDebug() << "Did not find glibc >= 2.1. Will use ANSI-compliant sin()/cos() functions.";
#endif
}
void KStarsLite::slotTrack() {
......@@ -233,30 +229,41 @@ void KStarsLite::updateTime( const bool automaticDSTchange ) {
}
}
void KStarsLite::writeConfig() {
bool KStarsLite::writeConfig()
{
// It seems two config files are saved to android. Must call them both to save all options
// First one save color information, 2nd one rest of config. Bug?
// /data/user/0/org.kde.kstars/files/settings/kstarsrc is used by KSharedConfig::openConfig()
KSharedConfig::openConfig()->sync();
// /data/data/org.kde.kstars/files/settings/kstarsrc is used by Options::self()
Options::self()->save();
//Store current simulation time
//Refer to // FIXME: Used in kstarsdcop.cpp only in kstarsdata.cpp
//data()->StoredDate = data()->lt();
}
void KStarsLite::slotAboutToQuit()
void KStarsLite::handleStateChange(Qt::ApplicationState state)
{
// Delete skymaplite. This required to run destructors and save
// current state in the option.
delete m_SkyMapLite;
//Store Window geometry in Options object
//Options::setWindowWidth( m_RootObject->width() );
//Options::setWindowHeight( m_RootObject->height() );
//explicitly save the colorscheme data to the config file
data()->colorScheme()->saveToConfig();
//synch the config file with the Config object
writeConfig();
if (state == Qt::ApplicationSuspended)
{
// Delete skymaplite. This required to run destructors and save
// current state in the option.
//delete m_SkyMapLite;
//Store Window geometry in Options object
//Options::setWindowWidth( m_RootObject->width() );
//Options::setWindowHeight( m_RootObject->height() );
//explicitly save the colorscheme data to the config file
//data()->colorScheme()->saveToConfig();
//synch the config file with the Config object
writeConfig();
}
}
void KStarsLite::loadColorScheme( const QString &name ) {
void KStarsLite::loadColorScheme( const QString &name )
{
bool ok = data()->colorScheme()->load( name );
QString filename = data()->colorScheme()->fileName();
......@@ -275,6 +282,10 @@ void KStarsLite::loadColorScheme( const QString &name ) {
Options::setColorSchemeFile( name );
data()->colorScheme()->saveToConfig();
//writeConfig();
//Reinitialize stars textures
map()->initStarImages();
......
......@@ -100,7 +100,7 @@ public:
Q_INVOKABLE void fullUpdate();
/** @short currently sets color scheme from config **/
void applyConfig( bool doApplyFocus = true );
Q_INVOKABLE void applyConfig( bool doApplyFocus = true );
/** @short set whether tutorial should be shown on next startup **/
void setRunTutorial(bool runTutorial);
......@@ -188,7 +188,7 @@ public Q_SLOTS:
/** Write current settings to config file. Used to save config file upon exit
*/
void writeConfig();
bool writeConfig();
/** Load a color scheme.
* @param name the name of the color scheme to load (e.g., "Moonless Night")
......@@ -216,7 +216,7 @@ private slots:
void datainitFinished();
/** Save data to config file before exiting.*/
void slotAboutToQuit();
void handleStateChange(Qt::ApplicationState state);
private:
/** Initialize focus position */
......
......@@ -74,7 +74,7 @@ Popup {
for(var i = 0; i < colorsList.model.count; ++i) {
if(formatColorScheme(colorsList.model.get(i).scheme) == colorScheme) {
colorsList.currentIndex = i
KStarsLite.loadColorScheme(colorScheme)
//KStarsLite.loadColorScheme(colorScheme)
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment