-
Notifications
You must be signed in to change notification settings - Fork 811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move geometry/server version from nextcloud.cfg #5367
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,7 +270,7 @@ void ConfigFile::saveGeometry(QWidget *w) | |
{ | ||
#ifndef TOKEN_AUTH_ONLY | ||
ASSERT(!w->objectName().isNull()); | ||
QSettings settings(configFile(), QSettings::IniFormat); | ||
QSettings settings(localConfigFile(), QSettings::IniFormat); | ||
settings.beginGroup(w->objectName()); | ||
settings.setValue(QLatin1String(geometryC), w->saveGeometry()); | ||
settings.sync(); | ||
|
@@ -291,7 +291,7 @@ void ConfigFile::saveGeometryHeader(QHeaderView *header) | |
return; | ||
ASSERT(!header->objectName().isEmpty()); | ||
|
||
QSettings settings(configFile(), QSettings::IniFormat); | ||
QSettings settings(localConfigFile(), QSettings::IniFormat); | ||
settings.beginGroup(header->objectName()); | ||
settings.setValue(QLatin1String(geometryC), header->saveState()); | ||
settings.sync(); | ||
|
@@ -305,7 +305,7 @@ void ConfigFile::restoreGeometryHeader(QHeaderView *header) | |
return; | ||
ASSERT(!header->objectName().isNull()); | ||
|
||
QSettings settings(configFile(), QSettings::IniFormat); | ||
QSettings settings(localConfigFile(), QSettings::IniFormat); | ||
settings.beginGroup(header->objectName()); | ||
header->restoreState(settings.value(geometryC).toByteArray()); | ||
#endif | ||
|
@@ -363,6 +363,17 @@ QString ConfigFile::configPath() const | |
return dir; | ||
} | ||
|
||
QString ConfigFile::localConfigFile() const | ||
{ | ||
const QString settingspath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); | ||
if(!QDir(settingspath).exists()) { | ||
QDir().mkdir(settingspath); | ||
} | ||
QString filename = settingspath + QLatin1String("/") + QLatin1String("settings.cfg"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly to the |
||
|
||
return filename; | ||
} | ||
|
||
static const QLatin1String exclFile("sync-exclude.lst"); | ||
|
||
QString ConfigFile::excludeFile(Scope scope) const | ||
|
@@ -775,7 +786,7 @@ QVariant ConfigFile::getValue(const QString ¶m, const QString &group, | |
systemSetting = systemSettings.value(param, defaultValue); | ||
} | ||
|
||
QSettings settings(configFile(), QSettings::IniFormat); | ||
QSettings settings((param != QLatin1String(geometryC)) ? configFile() : localConfigFile(), QSettings::IniFormat); | ||
if (!group.isEmpty()) | ||
settings.beginGroup(group); | ||
|
||
|
@@ -1070,13 +1081,13 @@ void ConfigFile::setCertificatePasswd(const QString &cPasswd) | |
|
||
QString ConfigFile::clientVersionString() const | ||
{ | ||
QSettings settings(configFile(), QSettings::IniFormat); | ||
QSettings settings(localConfigFile(), QSettings::IniFormat); | ||
return settings.value(QLatin1String(clientVersionC), QString()).toString(); | ||
} | ||
|
||
void ConfigFile::setClientVersionString(const QString &version) | ||
{ | ||
QSettings settings(configFile(), QSettings::IniFormat); | ||
QSettings settings(localConfigFile(), QSettings::IniFormat); | ||
settings.setValue(QLatin1String(clientVersionC), version); | ||
} | ||
|
||
|
@@ -1094,6 +1105,13 @@ std::unique_ptr<QSettings> ConfigFile::settingsWithGroup(const QString &group, Q | |
return settings; | ||
} | ||
|
||
std::unique_ptr<QSettings> ConfigFile::localSettings(QObject *parent) | ||
{ | ||
ConfigFile cfg; | ||
std::unique_ptr<QSettings> settings(std::make_unique<QSettings>(cfg.localConfigFile(), QSettings::IniFormat, parent)); | ||
return settings; | ||
} | ||
|
||
void ConfigFile::setupDefaultExcludeFilePaths(ExcludedFiles &excludedFiles) | ||
{ | ||
ConfigFile cfg; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,9 @@ class OWNCLOUDSYNC_EXPORT ConfigFile | |
|
||
[[nodiscard]] QString configPath() const; | ||
[[nodiscard]] QString configFile() const; | ||
[[nodiscard]] QString localConfigFile() const; | ||
Comment on lines
47
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is impossible to understand what the difference between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true. I hope for suggestions about more adequate name |
||
[[nodiscard]] QString excludeFile(Scope scope) const; | ||
|
||
static QString excludeFileFromSystem(); // doesn't access config dir | ||
|
||
/** | ||
|
@@ -209,6 +211,8 @@ class OWNCLOUDSYNC_EXPORT ConfigFile | |
with the given parent. If no parent is specified, the caller must destroy the settings */ | ||
static std::unique_ptr<QSettings> settingsWithGroup(const QString &group, QObject *parent = nullptr); | ||
|
||
static std::unique_ptr<QSettings> localSettings(QObject *parent = nullptr); | ||
|
||
/// Add the system and user exclude file path to the ExcludedFiles instance. | ||
static void setupDefaultExcludeFilePaths(ExcludedFiles &excludedFiles); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppDataLocation is the wrong path here.
Use
QStandardPaths::ConfigLocation
.Read the Qt docs for more:
https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum