diff options
author | B3n30 <bene_thomas@web.de> | 2017-09-19 03:18:26 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2017-09-19 03:18:26 +0200 |
commit | 28c726f20545744a3052a3e8a0a3bf5ff95a5042 (patch) | |
tree | 496b81a9d2cefbdb3ac2ed12c6525ecd72610c14 /src/citra_qt/configuration | |
parent | Merge pull request #2906 from Subv/ns_new_framework (diff) | |
download | yuzu-28c726f20545744a3052a3e8a0a3bf5ff95a5042.tar yuzu-28c726f20545744a3052a3e8a0a3bf5ff95a5042.tar.gz yuzu-28c726f20545744a3052a3e8a0a3bf5ff95a5042.tar.bz2 yuzu-28c726f20545744a3052a3e8a0a3bf5ff95a5042.tar.lz yuzu-28c726f20545744a3052a3e8a0a3bf5ff95a5042.tar.xz yuzu-28c726f20545744a3052a3e8a0a3bf5ff95a5042.tar.zst yuzu-28c726f20545744a3052a3e8a0a3bf5ff95a5042.zip |
Diffstat (limited to 'src/citra_qt/configuration')
-rw-r--r-- | src/citra_qt/configuration/config.cpp | 6 | ||||
-rw-r--r-- | src/citra_qt/configuration/configure_web.cpp | 58 | ||||
-rw-r--r-- | src/citra_qt/configuration/configure_web.h | 12 | ||||
-rw-r--r-- | src/citra_qt/configuration/configure_web.ui | 75 |
4 files changed, 127 insertions, 24 deletions
diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index ef114aad3..5261f4c4c 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -146,6 +146,10 @@ void Config::ReadValues() { qt_config->value("telemetry_endpoint_url", "https://services.citra-emu.org/api/telemetry") .toString() .toStdString(); + Settings::values.verify_endpoint_url = + qt_config->value("verify_endpoint_url", "https://services.citra-emu.org/api/profile") + .toString() + .toStdString(); Settings::values.citra_username = qt_config->value("citra_username").toString().toStdString(); Settings::values.citra_token = qt_config->value("citra_token").toString().toStdString(); qt_config->endGroup(); @@ -293,6 +297,8 @@ void Config::SaveValues() { qt_config->setValue("enable_telemetry", Settings::values.enable_telemetry); qt_config->setValue("telemetry_endpoint_url", QString::fromStdString(Settings::values.telemetry_endpoint_url)); + qt_config->setValue("verify_endpoint_url", + QString::fromStdString(Settings::values.verify_endpoint_url)); qt_config->setValue("citra_username", QString::fromStdString(Settings::values.citra_username)); qt_config->setValue("citra_token", QString::fromStdString(Settings::values.citra_token)); qt_config->endGroup(); diff --git a/src/citra_qt/configuration/configure_web.cpp b/src/citra_qt/configuration/configure_web.cpp index 8715fb018..38ce19c0f 100644 --- a/src/citra_qt/configuration/configure_web.cpp +++ b/src/citra_qt/configuration/configure_web.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <QMessageBox> #include "citra_qt/configuration/configure_web.h" #include "core/settings.h" #include "core/telemetry_session.h" @@ -11,7 +12,9 @@ ConfigureWeb::ConfigureWeb(QWidget* parent) : QWidget(parent), ui(std::make_unique<Ui::ConfigureWeb>()) { ui->setupUi(this); connect(ui->button_regenerate_telemetry_id, &QPushButton::clicked, this, - &ConfigureWeb::refreshTelemetryID); + &ConfigureWeb::RefreshTelemetryID); + connect(ui->button_verify_login, &QPushButton::clicked, this, &ConfigureWeb::VerifyLogin); + connect(this, &ConfigureWeb::LoginVerified, this, &ConfigureWeb::OnLoginVerified); this->setConfiguration(); } @@ -34,19 +37,66 @@ void ConfigureWeb::setConfiguration() { ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry); ui->edit_username->setText(QString::fromStdString(Settings::values.citra_username)); ui->edit_token->setText(QString::fromStdString(Settings::values.citra_token)); + // Connect after setting the values, to avoid calling OnLoginChanged now + connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); + connect(ui->edit_username, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); ui->label_telemetry_id->setText("Telemetry ID: 0x" + QString::number(Core::GetTelemetryId(), 16).toUpper()); + user_verified = true; } void ConfigureWeb::applyConfiguration() { Settings::values.enable_telemetry = ui->toggle_telemetry->isChecked(); - Settings::values.citra_username = ui->edit_username->text().toStdString(); - Settings::values.citra_token = ui->edit_token->text().toStdString(); + if (user_verified) { + Settings::values.citra_username = ui->edit_username->text().toStdString(); + Settings::values.citra_token = ui->edit_token->text().toStdString(); + } else { + QMessageBox::warning(this, tr("Username and token not verfied"), + tr("Username and token were not verified. The changes to your " + "username and/or token have not been saved.")); + } Settings::Apply(); } -void ConfigureWeb::refreshTelemetryID() { +void ConfigureWeb::RefreshTelemetryID() { const u64 new_telemetry_id{Core::RegenerateTelemetryId()}; ui->label_telemetry_id->setText("Telemetry ID: 0x" + QString::number(new_telemetry_id, 16).toUpper()); } + +void ConfigureWeb::OnLoginChanged() { + if (ui->edit_username->text().isEmpty() && ui->edit_token->text().isEmpty()) { + user_verified = true; + ui->label_username_verified->setPixmap(QPixmap(":/icons/checked.png")); + ui->label_token_verified->setPixmap(QPixmap(":/icons/checked.png")); + } else { + user_verified = false; + ui->label_username_verified->setPixmap(QPixmap(":/icons/failed.png")); + ui->label_token_verified->setPixmap(QPixmap(":/icons/failed.png")); + } +} + +void ConfigureWeb::VerifyLogin() { + verified = + Core::VerifyLogin(ui->edit_username->text().toStdString(), + ui->edit_token->text().toStdString(), [&]() { emit LoginVerified(); }); + ui->button_verify_login->setDisabled(true); + ui->button_verify_login->setText(tr("Verifying")); +} + +void ConfigureWeb::OnLoginVerified() { + ui->button_verify_login->setEnabled(true); + ui->button_verify_login->setText(tr("Verify")); + if (verified.get()) { + user_verified = true; + ui->label_username_verified->setPixmap(QPixmap(":/icons/checked.png")); + ui->label_token_verified->setPixmap(QPixmap(":/icons/checked.png")); + } else { + ui->label_username_verified->setPixmap(QPixmap(":/icons/failed.png")); + ui->label_token_verified->setPixmap(QPixmap(":/icons/failed.png")); + QMessageBox::critical( + this, tr("Verification failed"), + tr("Verification failed. Check that you have entered your username and token " + "correctly, and that your internet connection is working.")); + } +} diff --git a/src/citra_qt/configuration/configure_web.h b/src/citra_qt/configuration/configure_web.h index 20bc254b9..ad2d58f6e 100644 --- a/src/citra_qt/configuration/configure_web.h +++ b/src/citra_qt/configuration/configure_web.h @@ -4,6 +4,7 @@ #pragma once +#include <future> #include <memory> #include <QWidget> @@ -21,10 +22,19 @@ public: void applyConfiguration(); public slots: - void refreshTelemetryID(); + void RefreshTelemetryID(); + void OnLoginChanged(); + void VerifyLogin(); + void OnLoginVerified(); + +signals: + void LoginVerified(); private: void setConfiguration(); + bool user_verified = true; + std::future<bool> verified; + std::unique_ptr<Ui::ConfigureWeb> ui; }; diff --git a/src/citra_qt/configuration/configure_web.ui b/src/citra_qt/configuration/configure_web.ui index d8d283fad..dd996ab62 100644 --- a/src/citra_qt/configuration/configure_web.ui +++ b/src/citra_qt/configuration/configure_web.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>400</width> - <height>300</height> + <width>926</width> + <height>561</height> </rect> </property> <property name="windowTitle"> @@ -31,14 +31,30 @@ </item> <item> <layout class="QGridLayout" name="gridLayoutCitraUsername"> - <item row="0" column="0"> - <widget class="QLabel" name="label_username"> + <item row="2" column="3"> + <widget class="QPushButton" name="button_verify_login"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="layoutDirection"> + <enum>Qt::RightToLeft</enum> + </property> <property name="text"> - <string>Username: </string> + <string>Verify</string> </property> </widget> </item> - <item row="0" column="1"> + <item row="2" column="0"> + <widget class="QLabel" name="web_signup_link"> + <property name="text"> + <string>Sign up</string> + </property> + </widget> + </item> + <item row="0" column="1" colspan="3"> <widget class="QLineEdit" name="edit_username"> <property name="maxLength"> <number>36</number> @@ -52,7 +68,22 @@ </property> </widget> </item> - <item row="1" column="1"> + <item row="1" column="4"> + <widget class="QLabel" name="label_token_verified"> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_username"> + <property name="text"> + <string>Username: </string> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="QLabel" name="label_username_verified"> + </widget> + </item> + <item row="1" column="1" colspan="3"> <widget class="QLineEdit" name="edit_token"> <property name="maxLength"> <number>36</number> @@ -62,13 +93,6 @@ </property> </widget> </item> - <item row="2" column="0"> - <widget class="QLabel" name="web_signup_link"> - <property name="text"> - <string>Sign up</string> - </property> - </widget> - </item> <item row="2" column="1"> <widget class="QLabel" name="web_token_info_link"> <property name="text"> @@ -76,6 +100,19 @@ </property> </widget> </item> + <item row="2" column="2"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> </layout> </item> </layout> @@ -105,17 +142,17 @@ <layout class="QGridLayout" name="gridLayoutTelemetryId"> <item row="0" column="0"> <widget class="QLabel" name="label_telemetry_id"> - <property name="text"> - <string>Telemetry ID:</string> - </property> + <property name="text"> + <string>Telemetry ID:</string> + </property> </widget> </item> <item row="0" column="1"> <widget class="QPushButton" name="button_regenerate_telemetry_id"> <property name="sizePolicy"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> + <horstretch>0</horstretch> + <verstretch>0</verstretch> </sizepolicy> </property> <property name="layoutDirection"> |