Move API URL to config file (#7198)
This commit is contained in:
parent
268b0f660f
commit
a48c34932b
7 changed files with 30 additions and 11 deletions
|
|
@ -24,10 +24,10 @@
|
|||
|
||||
#include "OSXHelpers.h"
|
||||
|
||||
AboutDialog::AboutDialog(MainWindow* parent, const QString& synergyApp) :
|
||||
AboutDialog::AboutDialog(MainWindow* parent, const AppConfig& config) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::AboutDialogBase(),
|
||||
credits(*parent)
|
||||
credits(*parent, config)
|
||||
{
|
||||
setupUi(this);
|
||||
setupCreditsLoader();
|
||||
|
|
@ -42,7 +42,7 @@ Ryan Breen, Guido Poschta, Bertrand Landry Hetu, Tom Chadwick, Brent Priddy, Kyl
|
|||
Daun Chung, Serhii Hadzhylov, Oleksandr Lysytsia, Olena Kutytska, Francisco Magalhães.</span>
|
||||
</p>)");
|
||||
|
||||
m_versionChecker.setApp(synergyApp);
|
||||
m_versionChecker.setApp(config.synergycName());
|
||||
QString version = m_versionChecker.getVersion();
|
||||
#ifdef SYNERGY_REVISION
|
||||
version += '-';
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class AboutDialog : public QDialog, public Ui::AboutDialogBase
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AboutDialog(MainWindow* parent, const QString& synergyApp = QString());
|
||||
AboutDialog(MainWindow* parent, const AppConfig& config);
|
||||
public slots:
|
||||
void updateEliteBackers(const QString& eliteBackers) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,8 @@ const char* AppConfig::m_SynergySettingsName[] = {
|
|||
"tlsKeyLength",
|
||||
"preventSleep",
|
||||
"languageSync",
|
||||
"invertScrollDirection"
|
||||
"invertScrollDirection",
|
||||
"eliteBackersUrl"
|
||||
};
|
||||
|
||||
static const char* logLevelNames[] =
|
||||
|
|
@ -245,6 +246,7 @@ void AppConfig::loadSettings()
|
|||
m_PreventSleep = loadSetting(kPreventSleep, false).toBool();
|
||||
m_LanguageSync = loadSetting(kLanguageSync, false).toBool();
|
||||
m_InvertScrollDirection = loadSetting(kInvertScrollDirection, false).toBool();
|
||||
m_eliteBackersUrl = loadCommonSetting(kEliteBackersUrl, "https://api2.prod.symless.com/credits/elite-backers").toString();
|
||||
|
||||
//only change the serial key if the settings being loaded contains a key
|
||||
bool updateSerial = ConfigWriter::make()
|
||||
|
|
@ -277,6 +279,7 @@ void AppConfig::saveSettings()
|
|||
setCommonSetting(kLoadSystemSettings, m_LoadFromSystemScope);
|
||||
setCommonSetting(kGroupClientCheck, m_ClientGroupChecked);
|
||||
setCommonSetting(kGroupServerCheck, m_ServerGroupChecked);
|
||||
setCommonSetting(kEliteBackersUrl, m_eliteBackersUrl);
|
||||
|
||||
if (isWritable()) {
|
||||
setSetting(kScreenName, m_ScreenName);
|
||||
|
|
@ -461,6 +464,14 @@ bool AppConfig::getInvertScrollDirection() const {
|
|||
return m_InvertScrollDirection;
|
||||
}
|
||||
|
||||
void AppConfig::setEliteBackersUrl(const QString& newValue) {
|
||||
setSettingModified(m_eliteBackersUrl, newValue);
|
||||
}
|
||||
|
||||
const QString& AppConfig::getEliteBackersUrl() const {
|
||||
return m_eliteBackersUrl;
|
||||
}
|
||||
|
||||
bool AppConfig::getLanguageSync() const { return m_LanguageSync; }
|
||||
|
||||
void AppConfig::setInvertScrollDirection(bool newValue) {
|
||||
|
|
|
|||
|
|
@ -114,6 +114,8 @@ class AppConfig: public QObject, public GUI::Config::ConfigBase
|
|||
bool getAutoHide();
|
||||
void setInvertScrollDirection(bool b);
|
||||
bool getInvertScrollDirection() const;
|
||||
void setEliteBackersUrl(const QString&);
|
||||
const QString& getEliteBackersUrl() const;
|
||||
void setLanguageSync(bool b);
|
||||
bool getLanguageSync() const;
|
||||
void setPreventSleep(bool b);
|
||||
|
|
@ -208,7 +210,8 @@ protected:
|
|||
kTLSKeyLength,
|
||||
kPreventSleep,
|
||||
kLanguageSync,
|
||||
kInvertScrollDirection
|
||||
kInvertScrollDirection,
|
||||
kEliteBackersUrl
|
||||
};
|
||||
|
||||
void setScreenName(const QString& s);
|
||||
|
|
@ -248,6 +251,7 @@ protected:
|
|||
bool m_AutoHide;
|
||||
QString m_Serialkey;
|
||||
QString m_lastVersion;
|
||||
QString m_eliteBackersUrl;
|
||||
int m_LastExpiringWarningTime;
|
||||
bool m_ActivationHasRun;
|
||||
bool m_MinimizeToTray;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "CreditsLoader.h"
|
||||
#include "MainWindow.h"
|
||||
#include "AppConfig.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
|
|
@ -70,15 +71,16 @@ private:
|
|||
|
||||
}
|
||||
|
||||
CreditsLoader::CreditsLoader(MainWindow& mainWindow) :
|
||||
m_mainWindow(mainWindow)
|
||||
CreditsLoader::CreditsLoader(MainWindow& mainWindow, const AppConfig& config) :
|
||||
m_mainWindow(mainWindow),
|
||||
m_config(config)
|
||||
{
|
||||
connect(&m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void CreditsLoader::loadEliteBackers()
|
||||
{
|
||||
const auto ELITE_BACKERS_URL = "https://api2.prod.symless.com/credits/elite-backers";
|
||||
const auto ELITE_BACKERS_URL = m_config.getEliteBackersUrl();
|
||||
m_mainWindow.appendLogDebug(QString("Send request: %1").arg(ELITE_BACKERS_URL));
|
||||
const auto url = QUrl(ELITE_BACKERS_URL);
|
||||
const auto request = QNetworkRequest(url);
|
||||
|
|
|
|||
|
|
@ -21,12 +21,13 @@
|
|||
|
||||
class QNetworkReply;
|
||||
class MainWindow;
|
||||
class AppConfig;
|
||||
|
||||
class CreditsLoader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CreditsLoader(MainWindow& mainWindow);
|
||||
explicit CreditsLoader(MainWindow& mainWindow, const AppConfig& config);
|
||||
void loadEliteBackers();
|
||||
|
||||
signals:
|
||||
|
|
@ -37,6 +38,7 @@ public slots:
|
|||
|
||||
private:
|
||||
MainWindow& m_mainWindow;
|
||||
const AppConfig& m_config;
|
||||
QNetworkAccessManager m_manager;
|
||||
|
||||
void error(const QString& error) const;
|
||||
|
|
|
|||
|
|
@ -1265,7 +1265,7 @@ bool MainWindow::on_m_pActionSave_triggered()
|
|||
|
||||
void MainWindow::on_m_pActionAbout_triggered()
|
||||
{
|
||||
AboutDialog dlg(this, appPath(appConfig().synergycName()));
|
||||
AboutDialog dlg(this, appConfig());
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue