Re-enalbe delayed save, destroying window foces ave to be called

This commit is contained in:
craig
2012-02-13 21:04:25 +00:00
parent 96b1345b1e
commit 68ec5db2bd
3 changed files with 35 additions and 10 deletions

View File

@@ -907,7 +907,7 @@ MainWindow::~MainWindow()
}
Settings::self()->saveHiddenPages(hiddenPages);
streamsPage->save();
Settings::self()->save();
Settings::self()->save(true);
disconnect(MPDConnection::self(), 0, 0, 0);
if (Settings::self()->stopOnExit()) {
emit stop();

View File

@@ -34,6 +34,7 @@
#include "kwallet.h"
#include <QtGui/QApplication>
#include <QtGui/QWidget>
#include <QtCore/QTimer>
K_GLOBAL_STATIC(Settings, instance)
#endif
@@ -52,7 +53,8 @@ Settings * Settings::self()
}
Settings::Settings()
: ver(-1)
: timer(0)
, ver(-1)
#ifdef ENABLE_KDE_SUPPORT
, cfg(KGlobal::config(), "General")
, wallet(0)
@@ -507,13 +509,28 @@ void Settings::saveStopFadeDuration(int v)
SET_VALUE("stopFadeDuration", v);
}
void Settings::save()
void Settings::save(bool force)
{
SET_VALUE("version", PACKAGE_VERSION);
#ifdef ENABLE_KDE_SUPPORT
KGlobal::config()->sync();
#else
cfg.sync();
#endif
if (force) {
SET_VALUE("version", PACKAGE_VERSION);
#ifdef ENABLE_KDE_SUPPORT
KGlobal::config()->sync();
#else
cfg.sync();
#endif
if (timer) {
timer->stop();
}
} else {
if (!timer) {
timer=new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(actualSave()));
}
timer->start(30*1000);
}
}
void Settings::actualSave()
{
save(true);
}

View File

@@ -36,8 +36,12 @@ class Wallet;
#define CANTATA_MAKE_VERSION(a, b, c) (((a) << 16) | ((b) << 8) | (c))
class QTimer;
class Settings : public QObject
{
Q_OBJECT
public:
enum Constants
{
@@ -125,13 +129,17 @@ public:
void saveDevicesView(int v);
#endif
void saveStopFadeDuration(int v);
void save();
void save(bool force=false);
#ifdef ENABLE_KDE_SUPPORT
bool openWallet();
#endif
private Q_SLOTS:
void actualSave();
private:
QString mpdDirSetting;
QTimer *timer;
int ver;
#ifdef ENABLE_KDE_SUPPORT
KConfigGroup cfg;