diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/nexusmanualkey.ui | 89 | ||||
| -rw-r--r-- | src/nxmaccessmanager.cpp | 6 | ||||
| -rw-r--r-- | src/nxmaccessmanager.h | 2 | ||||
| -rw-r--r-- | src/settingsdialog.cpp | 43 | ||||
| -rw-r--r-- | src/settingsdialog.h | 2 | ||||
| -rw-r--r-- | src/settingsdialog.ui | 16 |
6 files changed, 156 insertions, 2 deletions
diff --git a/src/nexusmanualkey.ui b/src/nexusmanualkey.ui new file mode 100644 index 00000000..191ca218 --- /dev/null +++ b/src/nexusmanualkey.ui @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>NexusManualKeyDialog</class> + <widget class="QDialog" name="NexusManualKeyDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>452</width> + <height>302</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QWidget" name="widget" native="true"> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QPlainTextEdit" name="key"> + <property name="placeholderText"> + <string>Enter API key here</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>NexusManualKeyDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>NexusManualKeyDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index 00bb2a91..684a53fa 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -176,12 +176,16 @@ bool NXMAccessManager::validateWaiting() const } -void NXMAccessManager::apiCheck(const QString &apiKey) +void NXMAccessManager::apiCheck(const QString &apiKey, bool force) { if (m_ValidateReply != nullptr) { return; } + if (force) { + m_ValidateState = VALIDATE_NOT_CHECKED; + } + if (m_ValidateState == VALIDATE_VALID) { emit validateSuccessful(false); return; diff --git a/src/nxmaccessmanager.h b/src/nxmaccessmanager.h index 54ae14fb..e3608f8d 100644 --- a/src/nxmaccessmanager.h +++ b/src/nxmaccessmanager.h @@ -46,7 +46,7 @@ public: bool validateAttempted() const; bool validateWaiting() const; - void apiCheck(const QString &apiKey); + void apiCheck(const QString &apiKey, bool force=false); void showCookies() const; 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 <http://www.gnu.org/licenses/>. #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 <http://www.gnu.org/licenses/>. #include "settings.h" #include "instancemanager.h" #include "nexusinterface.h" +#include "nxmaccessmanager.h" #include "plugincontainer.h" #include <boost/uuid/uuid_generators.hpp> @@ -47,6 +49,33 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. 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::NexusManualKeyDialog> 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; diff --git a/src/settingsdialog.h b/src/settingsdialog.h index afe988bd..a844b391 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -156,6 +156,8 @@ private slots: void on_nexusConnect_clicked(); + void on_nexusManualKey_clicked(); + void dispatchLogin(); void loginPing(); diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index fa8893b9..088b7a0d 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -495,6 +495,22 @@ p, li { white-space: pre-wrap; } </spacer> </item> <item> + <widget class="QPushButton" name="nexusManualKey"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Manually enter the API key and try to login</string> + </property> + <property name="text"> + <string>Enter API Key Manually</string> + </property> + </widget> + </item> + <item> <widget class="QPushButton" name="revokeNexusAuthButton"> <property name="toolTip"> <string>Clear the stored Nexus API key and force reauthorization.</string> |
