mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Autorun:xdg: create autostart dir if needed
After a fresh installation of Ubuntu, 'autostart' dir is not available. Simply create it with QDir::mkpath() (= mkdir -p).
This commit is contained in:
parent
f1419ac245
commit
aaf9b95d97
|
@ -26,14 +26,19 @@
|
|||
|
||||
namespace Platform
|
||||
{
|
||||
QString getAutostartFilePath()
|
||||
QString getAutostartDirPath()
|
||||
{
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
QString config = env.value("XDG_CONFIG_HOME");
|
||||
if (config.isEmpty())
|
||||
config = QDir::homePath() + "/" + ".config";
|
||||
return config + "/" + "autostart/qTox - " +
|
||||
Settings::getInstance().getCurrentProfile() + ".desktop";
|
||||
return config + "/autostart";
|
||||
}
|
||||
|
||||
QString getAutostartFilePath(QString dir)
|
||||
{
|
||||
return dir + "/qTox - " + Settings::getInstance().getCurrentProfile() +
|
||||
".desktop";
|
||||
}
|
||||
|
||||
inline QString currentCommandLine()
|
||||
|
@ -45,11 +50,12 @@ namespace Platform
|
|||
|
||||
bool Platform::setAutorun(bool on)
|
||||
{
|
||||
|
||||
QFile desktop(getAutostartFilePath());
|
||||
QString dirPath = getAutostartDirPath();
|
||||
QFile desktop(getAutostartFilePath(dirPath));
|
||||
if (on)
|
||||
{
|
||||
if (!desktop.open(QFile::WriteOnly | QFile::Truncate))
|
||||
if (!QDir().mkpath(dirPath) ||
|
||||
!desktop.open(QFile::WriteOnly | QFile::Truncate))
|
||||
return false;
|
||||
desktop.write("[Desktop Entry]\n");
|
||||
desktop.write("Type=Application\n");
|
||||
|
@ -66,7 +72,7 @@ bool Platform::setAutorun(bool on)
|
|||
|
||||
bool Platform::getAutorun()
|
||||
{
|
||||
return QFile(getAutostartFilePath()).exists();
|
||||
return QFile(getAutostartFilePath(getAutostartDirPath())).exists();
|
||||
}
|
||||
|
||||
#endif // defined(Q_OS_UNIX) && !defined(__APPLE__) && !defined(__MACH__)
|
||||
|
|
Loading…
Reference in New Issue
Block a user