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 "resources/config.h"
|
||||||
|
|
||||||
|
#include <qtutilities/misc/compat.h>
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
@ -17,14 +19,10 @@ namespace Data {
|
||||||
|
|
||||||
QString SyncthingConfig::locateConfigFile()
|
QString SyncthingConfig::locateConfigFile()
|
||||||
{
|
{
|
||||||
auto
|
auto path = qEnvironmentVariable(PROJECT_VARNAME_UPPER "_SYNCTHING_CONFIG_DIR");
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
||||||
path
|
|
||||||
= qEnvironmentVariable(PROJECT_VARNAME_UPPER "_SYNCTHING_CONFIG_DIR");
|
|
||||||
if (!path.isEmpty() && QFile::exists(path += QStringLiteral("/config.xml"))) {
|
if (!path.isEmpty() && QFile::exists(path += QStringLiteral("/config.xml"))) {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
path = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("syncthing/config.xml"));
|
path = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("syncthing/config.xml"));
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
path = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("Syncthing/config.xml"));
|
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)
|
use_cpp_utilities(VISIBILITY PUBLIC)
|
||||||
|
|
||||||
# find qtutilities
|
# 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()
|
use_qt_utilities()
|
||||||
|
|
||||||
# find backend libraries
|
# find backend libraries
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include "../misc/syncthinglauncher.h"
|
#include "../misc/syncthinglauncher.h"
|
||||||
|
|
||||||
|
#include <qtutilities/misc/compat.h>
|
||||||
|
|
||||||
#include <syncthingconnector/syncthingconfig.h>
|
#include <syncthingconnector/syncthingconfig.h>
|
||||||
#include <syncthingconnector/syncthingconnection.h>
|
#include <syncthingconnector/syncthingconnection.h>
|
||||||
#include <syncthingconnector/syncthingprocess.h>
|
#include <syncthingconnector/syncthingprocess.h>
|
||||||
|
@ -771,17 +773,6 @@ bool isAutostartEnabled()
|
||||||
#endif
|
#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.
|
* \brief Sets whether the application is launchedc on startup.
|
||||||
* \remarks
|
* \remarks
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
// use meta-data of syncthingtray application here
|
// use meta-data of syncthingtray application here
|
||||||
#include "resources/../../tray/resources/config.h"
|
#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))
|
#if defined(LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD) && (defined(PLATFORM_UNIX) || defined(PLATFORM_MINGW) || defined(PLATFORM_CYGWIN))
|
||||||
#define PLATFORM_HAS_GETLOGIN
|
#define PLATFORM_HAS_GETLOGIN
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -15,15 +17,7 @@ SetupDetection::SetupDetection(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
// assume default service names
|
// assume default service names
|
||||||
const auto defaultUserUnit =
|
const auto defaultUserUnit = qEnvironmentVariable(PROJECT_VARNAME_UPPER "_SYSTEMD_USER_UNIT", QStringLiteral("syncthing.service"));
|
||||||
#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
|
|
||||||
;
|
|
||||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||||
userService.setUnitName(defaultUserUnit);
|
userService.setUnitName(defaultUserUnit);
|
||||||
systemService.setUnitName(QStringLiteral("syncthing@") %
|
systemService.setUnitName(QStringLiteral("syncthing@") %
|
||||||
|
|
Loading…
Reference in New Issue