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