refactor: replace EnvVars.h with a new item in settings Settings::Core::UpdateUrl
This commit is contained in:
@ -6,8 +6,7 @@
|
||||
|
||||
#include "VersionChecker.h"
|
||||
|
||||
#include "common/Constants.h"
|
||||
#include "gui/EnvVars.h"
|
||||
#include "common/Settings.h"
|
||||
|
||||
#include <QLocale>
|
||||
#include <QNetworkAccessManager>
|
||||
@ -17,8 +16,6 @@
|
||||
#include <QRegularExpression>
|
||||
#include <memory>
|
||||
|
||||
using namespace deskflow::gui;
|
||||
|
||||
VersionChecker::VersionChecker(QObject *parent) : QObject(parent), m_network{new QNetworkAccessManager(this)}
|
||||
{
|
||||
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
|
||||
{
|
||||
const QString url = env_vars::versionUrl();
|
||||
const QString url = Settings::value(Settings::Core::UpdateUrl).toString();
|
||||
qDebug("checking for updates at: %s", qPrintable(url));
|
||||
auto request = QNetworkRequest(url);
|
||||
auto userAgent = QString("%1 %2 on %3").arg(kAppName, kVersion, QSysInfo::prettyProductName());
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
|
||||
#include "Settings.h"
|
||||
|
||||
#include "UrlConstants.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QRect>
|
||||
|
||||
@ -110,6 +112,9 @@ QVariant Settings::defaultValue(const QString &key)
|
||||
if (key == Core::ElevateMode)
|
||||
return Settings::ElevateMode::Always;
|
||||
|
||||
if (key == Core::UpdateUrl)
|
||||
return kUrlUpdateCheck;
|
||||
|
||||
if (key == Server::ExternalConfigFile)
|
||||
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 ScreenName = QStringLiteral("core/screenName");
|
||||
inline static const auto StartedBefore = QStringLiteral("core/startedBefore");
|
||||
inline static const auto UpdateUrl = QStringLiteral("core/updateUrl");
|
||||
};
|
||||
struct Daemon
|
||||
{
|
||||
@ -189,6 +190,7 @@ private:
|
||||
, Settings::Core::ProcessMode
|
||||
, Settings::Core::ScreenName
|
||||
, Settings::Core::StartedBefore
|
||||
, Settings::Core::UpdateUrl
|
||||
, Settings::Daemon::Command
|
||||
, Settings::Daemon::Elevate
|
||||
, Settings::Daemon::LogFile
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace deskflow::gui {
|
||||
|
||||
// important: this is used for settings paths on some platforms,
|
||||
// and must not be a url. qt automatically converts this to reverse domain
|
||||
// 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 kUrlDownload = QStringLiteral("%1/download?%2").arg(kUrlApp, kUrlSourceQuery);
|
||||
|
||||
const auto kUrlUpdateCheck = QStringLiteral("https://api.%1/version").arg(kOrgDomain);
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
const auto kUrlGnomeTrayFix = QStringLiteral("https://extensions.gnome.org/extension/615/appindicator-support/");
|
||||
#endif
|
||||
|
||||
} // namespace deskflow::gui
|
||||
|
||||
@ -19,7 +19,6 @@ add_library(${target} STATIC
|
||||
Diagnostic.h
|
||||
DotEnv.cpp
|
||||
DotEnv.h
|
||||
EnvVars.h
|
||||
FileTail.cpp
|
||||
FileTail.h
|
||||
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"
|
||||
|
||||
<<<<<<< HEAD
|
||||
#include "Constants.h"
|
||||
#include "EnvVars.h"
|
||||
#include "Logger.h"
|
||||
#include "Styles.h"
|
||||
#include "common/Constants.h"
|
||||
=======
|
||||
#include "Logger.h"
|
||||
#include "Styles.h"
|
||||
|
||||
#include "common/Settings.h"
|
||||
#include "common/UrlConstants.h"
|
||||
>>>>>>> 25c5bfa2b (refactor: move lib/gui/Constants.h => lib/common/UrlConstants.h)
|
||||
|
||||
#include <QAction>
|
||||
#include <QDateTime>
|
||||
@ -310,7 +303,7 @@ bool showUpdateCheckOption(QWidget *parent)
|
||||
"<p>Checking for updates requires an Internet connection.</p>"
|
||||
"<p>URL: <pre>%2</pre></p>"
|
||||
)
|
||||
.arg(kAppName, env_vars::versionUrl()));
|
||||
.arg(kAppName, Settings::value(Settings::Core::UpdateUrl).toString()));
|
||||
|
||||
message.exec();
|
||||
return message.clickedButton() == checkButton;
|
||||
|
||||
Reference in New Issue
Block a user