Look up the autostart directory using QT's helper methods.

This fixes https://github.com/flameshot-org/flameshot/issues/928.
This commit is contained in:
Jeremy Fleischman
2020-10-29 00:26:47 -07:00
committed by borgmanJeremy
parent 841b40a412
commit f814e2d6b8

View File

@@ -22,6 +22,7 @@
#include <QDir>
#include <QFile>
#include <QKeySequence>
#include <QStandardPaths>
#include <algorithm>
ConfigHandler::ConfigHandler()
@@ -310,7 +311,10 @@ bool ConfigHandler::verifyLaunchFile()
bool res = false;
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
QString path = QDir::homePath() + "/.config/autostart/Flameshot.desktop";
QString path = QStandardPaths::locate(QStandardPaths::GenericConfigLocation,
"autostart/",
QStandardPaths::LocateDirectory) +
"Flameshot.desktop";
res = QFile(path).exists();
#elif defined(Q_OS_WIN)
QSettings bootUpSettings(
@@ -325,7 +329,9 @@ bool ConfigHandler::verifyLaunchFile()
void ConfigHandler::setStartupLaunch(const bool start)
{
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
QString path = QDir::homePath() + "/.config/autostart/";
QString path = QStandardPaths::locate(QStandardPaths::GenericConfigLocation,
"autostart/",
QStandardPaths::LocateDirectory);
QDir autostartDir(path);
if (!autostartDir.exists()) {
autostartDir.mkpath(".");