diff --git a/src/platform/autorun_osx.cpp b/src/platform/autorun_osx.cpp index 743ed9f1a..545bd3016 100644 --- a/src/platform/autorun_osx.cpp +++ b/src/platform/autorun_osx.cpp @@ -25,29 +25,30 @@ #include namespace { -bool state; +QString getAutorunFile() +{ + return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + + QDir::separator() + "Library" + QDir::separator() + "LaunchAgents" + + QDir::separator() + "chat.tox.qtox.autorun.plist"); +} } // namespace bool Platform::setAutorun(const Settings& settings, bool on) { std::ignore = settings; - QString qtoxPlist = - QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) - + QDir::separator() + "Library" + QDir::separator() + "LaunchAgents" - + QDir::separator() + "chat.tox.qtox.autorun.plist"); QString qtoxDir = QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() + "qtox"); - QSettings autoRun(qtoxPlist, QSettings::NativeFormat); + QSettings autoRun(getAutorunFile(), QSettings::NativeFormat); autoRun.setValue("Label", "chat.tox.qtox.autorun"); autoRun.setValue("Program", qtoxDir); - state = on; - autoRun.setValue("RunAtLoad", state); + autoRun.setValue("RunAtLoad", on); return true; } bool Platform::getAutorun(const Settings& settings) { std::ignore = settings; - return state; + QSettings autoRun(getAutorunFile(), QSettings::NativeFormat); + return autoRun.value("RunAtLoad", false).toBool(); }