mirror of
https://github.com/deskflow/deskflow.git
synced 2026-06-28 21:02:21 +08:00
#6538 Loading of global settings if user setting dont exist
This commit is contained in:
parent
59254c1c10
commit
969595dfe0
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "QSynergyApplication.h"
|
||||
#include "AppConfig.h"
|
||||
#include "QUtility.h"
|
||||
|
||||
@ -70,8 +71,8 @@ static const char* logLevelNames[] =
|
||||
"DEBUG2"
|
||||
};
|
||||
|
||||
AppConfig::AppConfig(QSettings* settings) :
|
||||
m_pSettings(settings),
|
||||
AppConfig::AppConfig(QSettings* userSettings, QSettings* systemSettings) :
|
||||
m_pSettings(userSettings),
|
||||
m_ScreenName(),
|
||||
m_Port(24800),
|
||||
m_Interface(),
|
||||
@ -88,6 +89,15 @@ AppConfig::AppConfig(QSettings* settings) :
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
@ -356,5 +366,3 @@ void AppConfig::setSetting(AppConfig::Setting name, T value) {
|
||||
QVariant AppConfig::loadSetting(AppConfig::Setting name, const QVariant& defaultValue) {
|
||||
return settings().value(settingName(name), defaultValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include "ElevateMode.h"
|
||||
#include <shared/EditionType.h>
|
||||
|
||||
@ -59,7 +60,7 @@ class AppConfig: public QObject
|
||||
friend class SetupWizard;
|
||||
|
||||
public:
|
||||
AppConfig(QSettings* settings);
|
||||
AppConfig(QSettings* userSettings, QSettings* systemSettings);
|
||||
~AppConfig();
|
||||
|
||||
public:
|
||||
@ -205,6 +206,9 @@ protected:
|
||||
/// @param [in] defaultValue The default value of the setting
|
||||
QVariant loadSetting(AppConfig::Setting name, const QVariant& defaultValue = QVariant());
|
||||
|
||||
/// @brief This will save the settings to globalScope instead of userScope
|
||||
void saveToGlobalScope();
|
||||
|
||||
signals:
|
||||
void sslToggled(bool enabled);
|
||||
};
|
||||
|
||||
@ -89,8 +89,17 @@ int main(int argc, char* argv[])
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
#endif
|
||||
|
||||
QSettings settings;
|
||||
AppConfig appConfig (&settings);
|
||||
//Config will default to User settings if they exist,
|
||||
// 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");
|
||||
#ifndef SYNERGY_ENTERPRISE
|
||||
LicenseManager licenseManager (&appConfig);
|
||||
@ -101,7 +110,7 @@ int main(int argc, char* argv[])
|
||||
#ifdef SYNERGY_ENTERPRISE
|
||||
MainWindow mainWindow(settings, appConfig);
|
||||
#else
|
||||
MainWindow mainWindow(settings, appConfig, licenseManager);
|
||||
MainWindow mainWindow(userSettings, appConfig, licenseManager);
|
||||
#endif
|
||||
|
||||
QObject::connect(dynamic_cast<QObject*>(&app), SIGNAL(aboutToQuit()),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user