summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <mutlaqja@ikarustech.com>2016-11-08 19:34:17 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-11-08 19:34:17 (GMT)
commit64a2d1ed533ece24e6d85dfe6f960a9c56acb7c0 (patch)
treee546b4cbc0e6c14957bb4a444d9a0e7f6fbefe05
parent1934a83957815df635d428294eadce809d113753 (diff)
Fixing problems with saving configuration on Android
-rw-r--r--apk/AndroidManifest.xml2
-rw-r--r--kstars/kstarslite.cpp53
-rw-r--r--kstars/kstarslite.h6
-rw-r--r--kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml2
4 files changed, 37 insertions, 26 deletions
diff --git a/apk/AndroidManifest.xml b/apk/AndroidManifest.xml
index f492fff..1bbfe0b 100644
--- a/apk/AndroidManifest.xml
+++ b/apk/AndroidManifest.xml
@@ -1,5 +1,5 @@
<?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>
diff --git a/kstars/kstarslite.cpp b/kstars/kstarslite.cpp
index b97137b..7cc45b3 100644
--- a/kstars/kstarslite.cpp
+++ b/kstars/kstarslite.cpp
@@ -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();
diff --git a/kstars/kstarslite.h b/kstars/kstarslite.h
index 0424f3d..074303a 100644
--- a/kstars/kstarslite.h
+++ b/kstars/kstarslite.h
@@ -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 */
diff --git a/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml b/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml
index 168aced..b830211 100644
--- a/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml
+++ b/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml
@@ -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)
}
}
}