mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 05:25:50 +03:00
Save the value of 'Launch on system startup' in the config files.
Make sure to migrate older configs to have the value set to true. Signed-off-by: Camila Ayres <hello@camilasan.com>
This commit is contained in:
parent
d677664f9d
commit
30883785e4
4 changed files with 31 additions and 3 deletions
|
@ -158,6 +158,11 @@ bool Application::configVersionMigration()
|
|||
return true;
|
||||
}
|
||||
|
||||
// 'Launch on system startup' defaults to true > 3.11.x
|
||||
const auto theme = Theme::instance();
|
||||
configFile.setLaunchOnSystemStartup(configFile.launchOnSystemStartup());
|
||||
Utility::setLaunchOnStartup(theme->appName(), theme->appNameGUI(), configFile.launchOnSystemStartup());
|
||||
|
||||
// back up all old config files
|
||||
QStringList backupFilesList;
|
||||
QDir configDir(configFile.configPath());
|
||||
|
|
|
@ -159,10 +159,9 @@ GeneralSettings::GeneralSettings(QWidget *parent)
|
|||
_ui->autostartCheckBox->setChecked(hasSystemAutoStart);
|
||||
_ui->autostartCheckBox->setDisabled(hasSystemAutoStart);
|
||||
_ui->autostartCheckBox->setToolTip(tr("You cannot disable autostart because system-wide autostart is enabled."));
|
||||
} else {
|
||||
const auto hasAutoStart = Utility::hasLaunchOnStartup(Theme::instance()->appName());
|
||||
} else {
|
||||
connect(_ui->autostartCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleLaunchOnStartup);
|
||||
_ui->autostartCheckBox->setChecked(hasAutoStart);
|
||||
_ui->autostartCheckBox->setChecked(ConfigFile().launchOnSystemStartup());
|
||||
}
|
||||
|
||||
// setup about section
|
||||
|
@ -455,6 +454,12 @@ void GeneralSettings::saveMiscSettings()
|
|||
void GeneralSettings::slotToggleLaunchOnStartup(bool enable)
|
||||
{
|
||||
const auto theme = Theme::instance();
|
||||
if (enable == Utility::hasLaunchOnStartup(theme->appName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigFile configFile;
|
||||
configFile.setLaunchOnSystemStartup(enable);
|
||||
Utility::setLaunchOnStartup(theme->appName(), theme->appNameGUI(), enable);
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ static constexpr char logExpireC[] = "logExpire";
|
|||
static constexpr char logFlushC[] = "logFlush";
|
||||
static constexpr char showExperimentalOptionsC[] = "showExperimentalOptions";
|
||||
static constexpr char clientVersionC[] = "clientVersion";
|
||||
static constexpr char launchOnSystemStartupC[] = "launchOnSystemStartup";
|
||||
|
||||
static constexpr char proxyHostC[] = "Proxy/host";
|
||||
static constexpr char proxyTypeC[] = "Proxy/type";
|
||||
|
@ -1152,6 +1153,18 @@ void ConfigFile::setClientVersionString(const QString &version)
|
|||
settings.setValue(QLatin1String(clientVersionC), version);
|
||||
}
|
||||
|
||||
bool ConfigFile::launchOnSystemStartup() const
|
||||
{
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
return settings.value(QLatin1String(launchOnSystemStartupC), true).toBool();
|
||||
}
|
||||
|
||||
void ConfigFile::setLaunchOnSystemStartup(const bool autostart)
|
||||
{
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
settings.setValue(QLatin1String(launchOnSystemStartupC), autostart);
|
||||
}
|
||||
|
||||
Q_GLOBAL_STATIC(QString, g_configFileName)
|
||||
|
||||
std::unique_ptr<QSettings> ConfigFile::settingsWithGroup(const QString &group, QObject *parent)
|
||||
|
|
|
@ -220,6 +220,11 @@ public:
|
|||
[[nodiscard]] QString clientVersionString() const;
|
||||
void setClientVersionString(const QString &version);
|
||||
|
||||
/** If the option 'Launch on system startup' is set
|
||||
Updated by configVersionMigration() at client startup. */
|
||||
[[nodiscard]] bool launchOnSystemStartup() const;
|
||||
void setLaunchOnSystemStartup(const bool autostart);
|
||||
|
||||
/** Returns a new settings pre-set in a specific group. The Settings will be created
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue