summaryrefslogtreecommitdiff
path: root/src/settings.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-06-04 20:58:30 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-06-04 20:58:30 -0400
commit2db29cffda538c6a9be24dff705e1d032bd42008 (patch)
tree82240665b18d4652507fedb1b1c541251f90996f /src/settings.cpp
parent933f460ee61a89ff71038c478de92d6c3760cc9a (diff)
renamed "revoke nexus authorization" to "disconnect from nexus" because "revoking" is ambiguous
reworked manual key dialog to look more like MO1 moved all the UI stuff from callbacks in Settings back to SettingsDialog in a central updateNexusButtons(), which also enables/disables buttons as needed
Diffstat (limited to 'src/settings.cpp')
-rw-r--r--src/settings.cpp78
1 files changed, 27 insertions, 51 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index a844fdc9..53dd32dc 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -363,6 +363,32 @@ bool Settings::getNexusApiKey(QString &apiKey) const
return true;
}
+bool Settings::setNexusApiKey(const QString& apiKey)
+{
+ if (!obfuscate("APIKEY", apiKey)) {
+ wchar_t buffer[256];
+
+ FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ buffer, (sizeof(buffer) / sizeof(wchar_t)), NULL);
+
+ qCritical() << "Storing API key failed:" << buffer;
+ return false;
+ }
+
+ return true;
+}
+
+bool Settings::clearNexusApiKey()
+{
+ return setNexusApiKey("");
+}
+
+bool Settings::hasNexusApiKey() const
+{
+ return !deObfuscate("APIKEY").isEmpty();
+}
+
bool Settings::getSteamLogin(QString &username, QString &password) const
{
if (m_Settings.contains("Settings/steam_username")) {
@@ -452,17 +478,6 @@ QString Settings::executablesBlacklist() const
).toString();
}
-void Settings::setNexusApiKey(QString apiKey)
-{
- if (!obfuscate("APIKEY", apiKey)) {
- wchar_t buffer[256];
- FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- buffer, (sizeof(buffer) / sizeof(wchar_t)), NULL);
- qCritical() << "Storing API key failed:" << buffer;
- }
-}
-
void Settings::setSteamLogin(QString username, QString password)
{
if (username == "") {
@@ -706,43 +721,10 @@ void Settings::resetDialogs()
QuestionBoxMemory::resetDialogs();
}
-void Settings::processApiKey(const QString &apiKey)
-{
- if (!obfuscate("APIKEY", apiKey)) {
- wchar_t buffer[256];
- FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- buffer, (sizeof(buffer) / sizeof(wchar_t)), NULL);
- qCritical() << "Storing or deleting API key failed:" << buffer;
- }
-}
-
-void Settings::clearApiKey(QPushButton *nexusButton)
-{
- obfuscate("APIKEY", "");
- nexusButton->setEnabled(true);
- nexusButton->setText("Connect to Nexus");
-}
-
-void Settings::checkApiKey(QPushButton *nexusButton)
-{
- if (deObfuscate("APIKEY").isEmpty()) {
- nexusButton->setEnabled(true);
- nexusButton->setText("Connect to Nexus");
- QMessageBox::warning(qApp->activeWindow(), tr("Error"),
- tr("Failed to retrieve a Nexus API key! Please try again. "
- "A browser window should open asking you to authorize."));
- }
-}
-
void Settings::query(PluginContainer *pluginContainer, QWidget *parent)
{
- SettingsDialog dialog(pluginContainer, parent);
-
+ SettingsDialog dialog(pluginContainer, this, parent);
connect(&dialog, SIGNAL(resetDialogs()), this, SLOT(resetDialogs()));
- connect(&dialog, SIGNAL(processApiKey(const QString &)), this, SLOT(processApiKey(const QString &)));
- connect(&dialog, SIGNAL(closeApiConnection(QPushButton *)), this, SLOT(checkApiKey(QPushButton *)));
- connect(&dialog, SIGNAL(revokeApiKey(QPushButton *)), this, SLOT(clearApiKey(QPushButton *)));
std::vector<std::unique_ptr<SettingsTab>> tabs;
@@ -1043,7 +1025,6 @@ void Settings::DiagnosticsTab::update()
Settings::NexusTab::NexusTab(Settings *parent, SettingsDialog &dialog)
: Settings::SettingsTab(parent, dialog)
- , m_nexusConnect(dialog.findChild<QPushButton *>("nexusConnect"))
, m_offlineBox(dialog.findChild<QCheckBox *>("offlineBox"))
, m_proxyBox(dialog.findChild<QCheckBox *>("proxyBox"))
, m_knownServersList(dialog.findChild<QListWidget *>("knownServersList"))
@@ -1052,11 +1033,6 @@ Settings::NexusTab::NexusTab(Settings *parent, SettingsDialog &dialog)
, m_endorsementBox(dialog.findChild<QCheckBox *>("endorsementBox"))
, m_hideAPICounterBox(dialog.findChild<QCheckBox *>("hideAPICounterBox"))
{
- if (!deObfuscate("APIKEY").isEmpty()) {
- m_nexusConnect->setText("Nexus API Key Stored");
- m_nexusConnect->setDisabled(true);
- }
-
m_offlineBox->setChecked(parent->offlineMode());
m_proxyBox->setChecked(parent->useProxy());
m_endorsementBox->setChecked(parent->endorsementIntegration());