refactor: replace EnvVars.h with a new item in settings Settings::Core::UpdateUrl
This commit is contained in:
parent
65b6fe7ca3
commit
eb74d8ca99
7 changed files with 13 additions and 37 deletions
|
|
@ -6,8 +6,7 @@
|
||||||
|
|
||||||
#include "VersionChecker.h"
|
#include "VersionChecker.h"
|
||||||
|
|
||||||
#include "common/Constants.h"
|
#include "common/Settings.h"
|
||||||
#include "gui/EnvVars.h"
|
|
||||||
|
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
|
|
@ -17,8 +16,6 @@
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace deskflow::gui;
|
|
||||||
|
|
||||||
VersionChecker::VersionChecker(QObject *parent) : QObject(parent), m_network{new QNetworkAccessManager(this)}
|
VersionChecker::VersionChecker(QObject *parent) : QObject(parent), m_network{new QNetworkAccessManager(this)}
|
||||||
{
|
{
|
||||||
connect(m_network, &QNetworkAccessManager::finished, this, &VersionChecker::replyFinished, Qt::UniqueConnection);
|
connect(m_network, &QNetworkAccessManager::finished, this, &VersionChecker::replyFinished, Qt::UniqueConnection);
|
||||||
|
|
@ -26,7 +23,7 @@ VersionChecker::VersionChecker(QObject *parent) : QObject(parent), m_network{new
|
||||||
|
|
||||||
void VersionChecker::checkLatest() const
|
void VersionChecker::checkLatest() const
|
||||||
{
|
{
|
||||||
const QString url = env_vars::versionUrl();
|
const QString url = Settings::value(Settings::Core::UpdateUrl).toString();
|
||||||
qDebug("checking for updates at: %s", qPrintable(url));
|
qDebug("checking for updates at: %s", qPrintable(url));
|
||||||
auto request = QNetworkRequest(url);
|
auto request = QNetworkRequest(url);
|
||||||
auto userAgent = QString("%1 %2 on %3").arg(kAppName, kVersion, QSysInfo::prettyProductName());
|
auto userAgent = QString("%1 %2 on %3").arg(kAppName, kVersion, QSysInfo::prettyProductName());
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
|
#include "UrlConstants.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
|
|
||||||
|
|
@ -110,6 +112,9 @@ QVariant Settings::defaultValue(const QString &key)
|
||||||
if (key == Core::ElevateMode)
|
if (key == Core::ElevateMode)
|
||||||
return Settings::ElevateMode::Always;
|
return Settings::ElevateMode::Always;
|
||||||
|
|
||||||
|
if (key == Core::UpdateUrl)
|
||||||
|
return kUrlUpdateCheck;
|
||||||
|
|
||||||
if (key == Server::ExternalConfigFile)
|
if (key == Server::ExternalConfigFile)
|
||||||
return QStringLiteral("%1/%2.conf").arg(instance()->settingsPath(), kAppId);
|
return QStringLiteral("%1/%2.conf").arg(instance()->settingsPath(), kAppId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ public:
|
||||||
inline static const auto ProcessMode = QStringLiteral("core/processMode");
|
inline static const auto ProcessMode = QStringLiteral("core/processMode");
|
||||||
inline static const auto ScreenName = QStringLiteral("core/screenName");
|
inline static const auto ScreenName = QStringLiteral("core/screenName");
|
||||||
inline static const auto StartedBefore = QStringLiteral("core/startedBefore");
|
inline static const auto StartedBefore = QStringLiteral("core/startedBefore");
|
||||||
|
inline static const auto UpdateUrl = QStringLiteral("core/updateUrl");
|
||||||
};
|
};
|
||||||
struct Daemon
|
struct Daemon
|
||||||
{
|
{
|
||||||
|
|
@ -189,6 +190,7 @@ private:
|
||||||
, Settings::Core::ProcessMode
|
, Settings::Core::ProcessMode
|
||||||
, Settings::Core::ScreenName
|
, Settings::Core::ScreenName
|
||||||
, Settings::Core::StartedBefore
|
, Settings::Core::StartedBefore
|
||||||
|
, Settings::Core::UpdateUrl
|
||||||
, Settings::Daemon::Command
|
, Settings::Daemon::Command
|
||||||
, Settings::Daemon::Elevate
|
, Settings::Daemon::Elevate
|
||||||
, Settings::Daemon::LogFile
|
, Settings::Daemon::LogFile
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace deskflow::gui {
|
|
||||||
|
|
||||||
// important: this is used for settings paths on some platforms,
|
// important: this is used for settings paths on some platforms,
|
||||||
// and must not be a url. qt automatically converts this to reverse domain
|
// and must not be a url. qt automatically converts this to reverse domain
|
||||||
// notation (rdn), e.g. org.deskflow
|
// notation (rdn), e.g. org.deskflow
|
||||||
|
|
@ -20,8 +18,8 @@ const auto kUrlApp = QStringLiteral("https://%1").arg(kOrgDomain);
|
||||||
const auto kUrlHelp = QStringLiteral("%1/help?%2").arg(kUrlApp, kUrlSourceQuery);
|
const auto kUrlHelp = QStringLiteral("%1/help?%2").arg(kUrlApp, kUrlSourceQuery);
|
||||||
const auto kUrlDownload = QStringLiteral("%1/download?%2").arg(kUrlApp, kUrlSourceQuery);
|
const auto kUrlDownload = QStringLiteral("%1/download?%2").arg(kUrlApp, kUrlSourceQuery);
|
||||||
|
|
||||||
|
const auto kUrlUpdateCheck = QStringLiteral("https://api.%1/version").arg(kOrgDomain);
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
const auto kUrlGnomeTrayFix = QStringLiteral("https://extensions.gnome.org/extension/615/appindicator-support/");
|
const auto kUrlGnomeTrayFix = QStringLiteral("https://extensions.gnome.org/extension/615/appindicator-support/");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace deskflow::gui
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ add_library(${target} STATIC
|
||||||
Diagnostic.h
|
Diagnostic.h
|
||||||
DotEnv.cpp
|
DotEnv.cpp
|
||||||
DotEnv.h
|
DotEnv.h
|
||||||
EnvVars.h
|
|
||||||
FileTail.cpp
|
FileTail.cpp
|
||||||
FileTail.h
|
FileTail.h
|
||||||
Logger.cpp
|
Logger.cpp
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
namespace deskflow::gui::env_vars {
|
|
||||||
|
|
||||||
inline QString versionUrl()
|
|
||||||
{
|
|
||||||
return qEnvironmentVariable("DESKFLOW_VERSION_URL", QStringLiteral("https://api.deskflow.org/version"));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace deskflow::gui::env_vars
|
|
||||||
|
|
@ -6,18 +6,11 @@
|
||||||
|
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
#include "Constants.h"
|
|
||||||
#include "EnvVars.h"
|
|
||||||
#include "Logger.h"
|
|
||||||
#include "Styles.h"
|
|
||||||
#include "common/Constants.h"
|
|
||||||
=======
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Styles.h"
|
#include "Styles.h"
|
||||||
|
|
||||||
#include "common/Settings.h"
|
#include "common/Settings.h"
|
||||||
#include "common/UrlConstants.h"
|
#include "common/UrlConstants.h"
|
||||||
>>>>>>> 25c5bfa2b (refactor: move lib/gui/Constants.h => lib/common/UrlConstants.h)
|
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
@ -310,7 +303,7 @@ bool showUpdateCheckOption(QWidget *parent)
|
||||||
"<p>Checking for updates requires an Internet connection.</p>"
|
"<p>Checking for updates requires an Internet connection.</p>"
|
||||||
"<p>URL: <pre>%2</pre></p>"
|
"<p>URL: <pre>%2</pre></p>"
|
||||||
)
|
)
|
||||||
.arg(kAppName, env_vars::versionUrl()));
|
.arg(kAppName, Settings::value(Settings::Core::UpdateUrl).toString()));
|
||||||
|
|
||||||
message.exec();
|
message.exec();
|
||||||
return message.clickedButton() == checkButton;
|
return message.clickedButton() == checkButton;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue