From 933f460ee61a89ff71038c478de92d6c3760cc9a Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 3 Jun 2019 17:20:31 -0400 Subject: added new dialog to enter api key manually added button in nexus settings to open the dialog added a force flag to apiCheck() to do a check with the new key even if the login was successful before --- src/settingsdialog.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/settingsdialog.cpp') diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 7f53a9bb..44d7fde5 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -20,6 +20,7 @@ along with Mod Organizer. If not, see . #include "settingsdialog.h" #include "ui_settingsdialog.h" +#include "ui_nexusmanualkey.h" #include "categoriesdialog.h" #include "helper.h" #include "noeditdelegate.h" @@ -27,6 +28,7 @@ along with Mod Organizer. If not, see . #include "settings.h" #include "instancemanager.h" #include "nexusinterface.h" +#include "nxmaccessmanager.h" #include "plugincontainer.h" #include @@ -47,6 +49,33 @@ along with Mod Organizer. If not, see . using namespace MOBase; + +class NexusManualKeyDialog : public QDialog +{ +public: + NexusManualKeyDialog(QWidget* parent) + : QDialog(parent), ui(new Ui::NexusManualKeyDialog) + { + ui->setupUi(this); + } + + void accept() override + { + m_key = ui->key->toPlainText(); + QDialog::accept(); + } + + const QString& key() const + { + return m_key; + } + +private: + std::unique_ptr ui; + QString m_key; +}; + + SettingsDialog::SettingsDialog(PluginContainer *pluginContainer, QWidget *parent) : TutorableDialog("SettingsDialog", parent) , ui(new Ui::SettingsDialog) @@ -344,6 +373,20 @@ void SettingsDialog::on_nexusConnect_clicked() m_nexusLogin->open(url); } +void SettingsDialog::on_nexusManualKey_clicked() +{ + NexusManualKeyDialog dialog(this); + + if (dialog.exec() != QDialog::Accepted) { + return; + } + + const auto key = dialog.key(); + emit processApiKey(key); + ui->nexusConnect->setText("Nexus API Key Stored"); + NexusInterface::instance(m_PluginContainer)->getAccessManager()->apiCheck(key, true); +} + void SettingsDialog::dispatchLogin() { m_KeyReceived = false; -- cgit v1.3.1