From 77bab2a8c2b0658ed79b8711f1bf69a455f7cfcc Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 20 Jan 2015 17:11:46 -0800 Subject: [PATCH] Setup Thread and timer for settings --- interface/src/Application.cpp | 10 +++++++++- interface/src/Application.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ba1512749f..91b37095e4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -451,7 +451,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : } loadSettings(); - + int SAVE_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND; // Let's save every seconds for now + connect(&_settingsTimer, &QTimer::timeout, this, &Application::saveSettings); + connect(&_settingsThread, SIGNAL(started), &_settingsTimer, SLOT(start)); + connect(&_settingsThread, &QThread::finished, &_settingsTimer, &QTimer::deleteLater); + _settingsTimer.moveToThread(&_settingsThread); + _settingsTimer.setSingleShot(false); + _settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL); + _settingsThread.start(); + _trayIcon->show(); // set the local loopback interface for local sounds from audio scripts diff --git a/interface/src/Application.h b/interface/src/Application.h index 509091f8e1..d49dbb9d50 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -586,6 +586,9 @@ private: bool _aboutToQuit; Bookmarks* _bookmarks; + + QThread _settingsThread; + QTimer _settingsTimer; }; #endif // hifi_Application_h