Use `qEnvironmentVariable` via compat header from qtutilities
This commit is contained in:
parent
037c5a309b
commit
2b5c8b6059
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "resources/config.h"
|
||||
|
||||
#include <qtutilities/misc/compat.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QStandardPaths>
|
||||
#include <QXmlStreamReader>
|
||||
|
@ -17,14 +19,10 @@ namespace Data {
|
|||
|
||||
QString SyncthingConfig::locateConfigFile()
|
||||
{
|
||||
auto
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
path
|
||||
= qEnvironmentVariable(PROJECT_VARNAME_UPPER "_SYNCTHING_CONFIG_DIR");
|
||||
auto path = qEnvironmentVariable(PROJECT_VARNAME_UPPER "_SYNCTHING_CONFIG_DIR");
|
||||
if (!path.isEmpty() && QFile::exists(path += QStringLiteral("/config.xml"))) {
|
||||
return path;
|
||||
}
|
||||
#endif
|
||||
path = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("syncthing/config.xml"));
|
||||
if (path.isEmpty()) {
|
||||
path = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("Syncthing/config.xml"));
|
||||
|
|
|
@ -89,7 +89,7 @@ find_package(${PACKAGE_NAMESPACE_PREFIX}c++utilities${CONFIGURATION_PACKAGE_SUFF
|
|||
use_cpp_utilities(VISIBILITY PUBLIC)
|
||||
|
||||
# find qtutilities
|
||||
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.9.0 REQUIRED)
|
||||
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.10.0 REQUIRED)
|
||||
use_qt_utilities()
|
||||
|
||||
# find backend libraries
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "../misc/syncthinglauncher.h"
|
||||
|
||||
#include <qtutilities/misc/compat.h>
|
||||
|
||||
#include <syncthingconnector/syncthingconfig.h>
|
||||
#include <syncthingconnector/syncthingconnection.h>
|
||||
#include <syncthingconnector/syncthingprocess.h>
|
||||
|
@ -771,17 +773,6 @@ bool isAutostartEnabled()
|
|||
#endif
|
||||
}
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
|
||||
/*!
|
||||
* \brief Provides a fallback for qEnvironmentVariable() when using old Qt versions.
|
||||
*/
|
||||
static QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
|
||||
{
|
||||
const auto val(qgetenv(varName));
|
||||
return !val.isEmpty() ? QString::fromLocal8Bit(val) : defaultValue;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief Sets whether the application is launchedc on startup.
|
||||
* \remarks
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// use meta-data of syncthingtray application here
|
||||
#include "resources/../../tray/resources/config.h"
|
||||
|
||||
#include <qtutilities/misc/compat.h>
|
||||
|
||||
#if defined(LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD) && (defined(PLATFORM_UNIX) || defined(PLATFORM_MINGW) || defined(PLATFORM_CYGWIN))
|
||||
#define PLATFORM_HAS_GETLOGIN
|
||||
#include <unistd.h>
|
||||
|
@ -15,15 +17,7 @@ SetupDetection::SetupDetection(QObject *parent)
|
|||
: QObject(parent)
|
||||
{
|
||||
// assume default service names
|
||||
const auto defaultUserUnit =
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
qEnvironmentVariable(PROJECT_VARNAME_UPPER "_SYSTEMD_USER_UNIT",
|
||||
#endif
|
||||
QStringLiteral("syncthing.service")
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
)
|
||||
#endif
|
||||
;
|
||||
const auto defaultUserUnit = qEnvironmentVariable(PROJECT_VARNAME_UPPER "_SYSTEMD_USER_UNIT", QStringLiteral("syncthing.service"));
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
userService.setUnitName(defaultUserUnit);
|
||||
systemService.setUnitName(QStringLiteral("syncthing@") %
|
||||
|
|
Loading…
Reference in New Issue