mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(macos): Represent autorun state in UI persistently
Check file setting rather than reporting a global value that isn't persisted across client restart.
This commit is contained in:
parent
009369118f
commit
ad6b510417
|
@ -25,29 +25,30 @@
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
namespace {
|
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
|
} // namespace
|
||||||
|
|
||||||
bool Platform::setAutorun(const Settings& settings, bool on)
|
bool Platform::setAutorun(const Settings& settings, bool on)
|
||||||
{
|
{
|
||||||
std::ignore = settings;
|
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 =
|
QString qtoxDir =
|
||||||
QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() + "qtox");
|
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("Label", "chat.tox.qtox.autorun");
|
||||||
autoRun.setValue("Program", qtoxDir);
|
autoRun.setValue("Program", qtoxDir);
|
||||||
|
|
||||||
state = on;
|
autoRun.setValue("RunAtLoad", on);
|
||||||
autoRun.setValue("RunAtLoad", state);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Platform::getAutorun(const Settings& settings)
|
bool Platform::getAutorun(const Settings& settings)
|
||||||
{
|
{
|
||||||
std::ignore = settings;
|
std::ignore = settings;
|
||||||
return state;
|
QSettings autoRun(getAutorunFile(), QSettings::NativeFormat);
|
||||||
|
return autoRun.value("RunAtLoad", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user