diff --git a/src/utils/configenterprise.cpp b/src/utils/configenterprise.cpp index 2c3b0788..0880e7ec 100644 --- a/src/utils/configenterprise.cpp +++ b/src/utils/configenterprise.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include ConfigEnterprise::ConfigEnterprise() @@ -9,11 +11,18 @@ ConfigEnterprise::ConfigEnterprise() // get enterprise settings m_settings = nullptr; QString configIniPath = QDir(QDir::currentPath()).filePath("config.ini"); -#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) if(!(QFileInfo::exists(configIniPath) && QFileInfo(configIniPath).isFile())) { +#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) configIniPath = "/etc/flameshot/config.ini"; - } +#elif defined(Q_OS_WIN) + // calculate workdir for flameshot on startup if is not set yet + QSettings bootUpSettings( + "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", + QSettings::NativeFormat); + QFileInfo fi(bootUpSettings.value("Flameshot").toString()); + configIniPath = QDir(fi.absolutePath()).filePath("config.ini"); #endif + } m_settings = new QSettings(configIniPath, QSettings::IniFormat); } diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 904fac3d..494d6fe8 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -310,6 +310,7 @@ void ConfigHandler::setStartupLaunch(const bool start) { QSettings bootUpSettings( "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); + // set workdir for flameshot on startup QSettings bootUpPath( "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths", QSettings::NativeFormat); @@ -320,7 +321,7 @@ void ConfigHandler::setStartupLaunch(const bool start) { // set application workdir bootUpPath.beginGroup("flameshot.exe"); - bootUpPath.setValue("Path", QCoreApplication::applicationFilePath()); + bootUpPath.setValue("Path", QCoreApplication::applicationDirPath()); bootUpPath.endGroup(); } else {