#6538 Loading of global settings if user setting dont exist
This commit is contained in:
parent
59254c1c10
commit
969595dfe0
3 changed files with 29 additions and 8 deletions
|
|
@ -16,6 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "QSynergyApplication.h"
|
||||||
#include "AppConfig.h"
|
#include "AppConfig.h"
|
||||||
#include "QUtility.h"
|
#include "QUtility.h"
|
||||||
|
|
||||||
|
|
@ -70,8 +71,8 @@ static const char* logLevelNames[] =
|
||||||
"DEBUG2"
|
"DEBUG2"
|
||||||
};
|
};
|
||||||
|
|
||||||
AppConfig::AppConfig(QSettings* settings) :
|
AppConfig::AppConfig(QSettings* userSettings, QSettings* systemSettings) :
|
||||||
m_pSettings(settings),
|
m_pSettings(userSettings),
|
||||||
m_ScreenName(),
|
m_ScreenName(),
|
||||||
m_Port(24800),
|
m_Port(24800),
|
||||||
m_Interface(),
|
m_Interface(),
|
||||||
|
|
@ -88,6 +89,15 @@ AppConfig::AppConfig(QSettings* settings) :
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_pSettings);
|
Q_ASSERT(m_pSettings);
|
||||||
|
|
||||||
|
//If user setting dont exist but system ones do, load the system setting and save them to user settings
|
||||||
|
if (!settingsExist(userSettings) && settingsExist(systemSettings))
|
||||||
|
{
|
||||||
|
m_pSettings = systemSettings;
|
||||||
|
loadSettings();
|
||||||
|
m_pSettings = userSettings;
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,5 +366,3 @@ void AppConfig::setSetting(AppConfig::Setting name, T value) {
|
||||||
QVariant AppConfig::loadSetting(AppConfig::Setting name, const QVariant& defaultValue) {
|
QVariant AppConfig::loadSetting(AppConfig::Setting name, const QVariant& defaultValue) {
|
||||||
return settings().value(settingName(name), defaultValue);
|
return settings().value(settingName(name), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QVariant>
|
||||||
#include "ElevateMode.h"
|
#include "ElevateMode.h"
|
||||||
#include <shared/EditionType.h>
|
#include <shared/EditionType.h>
|
||||||
|
|
||||||
|
|
@ -59,7 +60,7 @@ class AppConfig: public QObject
|
||||||
friend class SetupWizard;
|
friend class SetupWizard;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AppConfig(QSettings* settings);
|
AppConfig(QSettings* userSettings, QSettings* systemSettings);
|
||||||
~AppConfig();
|
~AppConfig();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -205,6 +206,9 @@ protected:
|
||||||
/// @param [in] defaultValue The default value of the setting
|
/// @param [in] defaultValue The default value of the setting
|
||||||
QVariant loadSetting(AppConfig::Setting name, const QVariant& defaultValue = QVariant());
|
QVariant loadSetting(AppConfig::Setting name, const QVariant& defaultValue = QVariant());
|
||||||
|
|
||||||
|
/// @brief This will save the settings to globalScope instead of userScope
|
||||||
|
void saveToGlobalScope();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sslToggled(bool enabled);
|
void sslToggled(bool enabled);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -89,8 +89,17 @@ int main(int argc, char* argv[])
|
||||||
QApplication::setQuitOnLastWindowClosed(false);
|
QApplication::setQuitOnLastWindowClosed(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QSettings settings;
|
//Config will default to User settings if they exist,
|
||||||
AppConfig appConfig (&settings);
|
// otherwise it will load System setting and save them to User settings
|
||||||
|
QSettings systemSettings(QSettings::Scope::SystemScope,
|
||||||
|
QCoreApplication::organizationName(),
|
||||||
|
QCoreApplication::applicationName());
|
||||||
|
|
||||||
|
QSettings userSettings(QSettings::Scope::UserScope,
|
||||||
|
QCoreApplication::organizationName(),
|
||||||
|
QCoreApplication::applicationName());
|
||||||
|
|
||||||
|
AppConfig appConfig (&userSettings, &systemSettings);
|
||||||
qRegisterMetaType<Edition>("Edition");
|
qRegisterMetaType<Edition>("Edition");
|
||||||
#ifndef SYNERGY_ENTERPRISE
|
#ifndef SYNERGY_ENTERPRISE
|
||||||
LicenseManager licenseManager (&appConfig);
|
LicenseManager licenseManager (&appConfig);
|
||||||
|
|
@ -101,7 +110,7 @@ int main(int argc, char* argv[])
|
||||||
#ifdef SYNERGY_ENTERPRISE
|
#ifdef SYNERGY_ENTERPRISE
|
||||||
MainWindow mainWindow(settings, appConfig);
|
MainWindow mainWindow(settings, appConfig);
|
||||||
#else
|
#else
|
||||||
MainWindow mainWindow(settings, appConfig, licenseManager);
|
MainWindow mainWindow(userSettings, appConfig, licenseManager);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QObject::connect(dynamic_cast<QObject*>(&app), SIGNAL(aboutToQuit()),
|
QObject::connect(dynamic_cast<QObject*>(&app), SIGNAL(aboutToQuit()),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue