diff options
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() { | |||
| 146 | qt_config->value("telemetry_endpoint_url", "https://services.citra-emu.org/api/telemetry") | 146 | qt_config->value("telemetry_endpoint_url", "https://services.citra-emu.org/api/telemetry") |
| 147 | .toString() | 147 | .toString() |
| 148 | .toStdString(); | 148 | .toStdString(); |
| 149 | Settings::values.verify_endpoint_url = | ||
| 150 | qt_config->value("verify_endpoint_url", "https://services.citra-emu.org/api/profile") | ||
| 151 | .toString() | ||
| 152 | .toStdString(); | ||
| 149 | Settings::values.citra_username = qt_config->value("citra_username").toString().toStdString(); | 153 | Settings::values.citra_username = qt_config->value("citra_username").toString().toStdString(); |
| 150 | Settings::values.citra_token = qt_config->value("citra_token").toString().toStdString(); | 154 | Settings::values.citra_token = qt_config->value("citra_token").toString().toStdString(); |
| 151 | qt_config->endGroup(); | 155 | qt_config->endGroup(); |
| @@ -293,6 +297,8 @@ void Config::SaveValues() { | |||
| 293 | qt_config->setValue("enable_telemetry", Settings::values.enable_telemetry); | 297 | qt_config->setValue("enable_telemetry", Settings::values.enable_telemetry); |
| 294 | qt_config->setValue("telemetry_endpoint_url", | 298 | qt_config->setValue("telemetry_endpoint_url", |
| 295 | QString::fromStdString(Settings::values.telemetry_endpoint_url)); | 299 | QString::fromStdString(Settings::values.telemetry_endpoint_url)); |
| 300 | qt_config->setValue("verify_endpoint_url", | ||
| 301 | QString::fromStdString(Settings::values.verify_endpoint_url)); | ||
| 296 | qt_config->setValue("citra_username", QString::fromStdString(Settings::values.citra_username)); | 302 | qt_config->setValue("citra_username", QString::fromStdString(Settings::values.citra_username)); |
| 297 | qt_config->setValue("citra_token", QString::fromStdString(Settings::values.citra_token)); | 303 | qt_config->setValue("citra_token", QString::fromStdString(Settings::values.citra_token)); |
| 298 | qt_config->endGroup(); | 304 | 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 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <QMessageBox> | ||
| 5 | #include "citra_qt/configuration/configure_web.h" | 6 | #include "citra_qt/configuration/configure_web.h" |
| 6 | #include "core/settings.h" | 7 | #include "core/settings.h" |
| 7 | #include "core/telemetry_session.h" | 8 | #include "core/telemetry_session.h" |
| @@ -11,7 +12,9 @@ ConfigureWeb::ConfigureWeb(QWidget* parent) | |||
| 11 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureWeb>()) { | 12 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureWeb>()) { |
| 12 | ui->setupUi(this); | 13 | ui->setupUi(this); |
| 13 | connect(ui->button_regenerate_telemetry_id, &QPushButton::clicked, this, | 14 | connect(ui->button_regenerate_telemetry_id, &QPushButton::clicked, this, |
| 14 | &ConfigureWeb::refreshTelemetryID); | 15 | &ConfigureWeb::RefreshTelemetryID); |
| 16 | connect(ui->button_verify_login, &QPushButton::clicked, this, &ConfigureWeb::VerifyLogin); | ||
| 17 | connect(this, &ConfigureWeb::LoginVerified, this, &ConfigureWeb::OnLoginVerified); | ||
| 15 | 18 | ||
| 16 | this->setConfiguration(); | 19 | this->setConfiguration(); |
| 17 | } | 20 | } |
| @@ -34,19 +37,66 @@ void ConfigureWeb::setConfiguration() { | |||
| 34 | ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry); | 37 | ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry); |
| 35 | ui->edit_username->setText(QString::fromStdString(Settings::values.citra_username)); | 38 | ui->edit_username->setText(QString::fromStdString(Settings::values.citra_username)); |
| 36 | ui->edit_token->setText(QString::fromStdString(Settings::values.citra_token)); | 39 | ui->edit_token->setText(QString::fromStdString(Settings::values.citra_token)); |
| 40 | // Connect after setting the values, to avoid calling OnLoginChanged now | ||
| 41 | connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); | ||
| 42 | connect(ui->edit_username, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); | ||
| 37 | ui->label_telemetry_id->setText("Telemetry ID: 0x" + | 43 | ui->label_telemetry_id->setText("Telemetry ID: 0x" + |
| 38 | QString::number(Core::GetTelemetryId(), 16).toUpper()); | 44 | QString::number(Core::GetTelemetryId(), 16).toUpper()); |
| 45 | user_verified = true; | ||
| 39 | } | 46 | } |
| 40 | 47 | ||
| 41 | void ConfigureWeb::applyConfiguration() { | 48 | void ConfigureWeb::applyConfiguration() { |
| 42 | Settings::values.enable_telemetry = ui->toggle_telemetry->isChecked(); | 49 | Settings::values.enable_telemetry = ui->toggle_telemetry->isChecked(); |
| 43 | Settings::values.citra_username = ui->edit_username->text().toStdString(); | 50 | if (user_verified) { |
| 44 | Settings::values.citra_token = ui->edit_token->text().toStdString(); | 51 | Settings::values.citra_username = ui->edit_username->text().toStdString(); |
| 52 | Settings::values.citra_token = ui->edit_token->text().toStdString(); | ||
| 53 | } else { | ||
| 54 | QMessageBox::warning(this, tr("Username and token not verfied"), | ||
| 55 | tr("Username and token were not verified. The changes to your " | ||
| 56 | "username and/or token have not been saved.")); | ||
| 57 | } | ||
| 45 | Settings::Apply(); | 58 | Settings::Apply(); |
| 46 | } | 59 | } |
| 47 | 60 | ||
| 48 | void ConfigureWeb::refreshTelemetryID() { | 61 | void ConfigureWeb::RefreshTelemetryID() { |
| 49 | const u64 new_telemetry_id{Core::RegenerateTelemetryId()}; | 62 | const u64 new_telemetry_id{Core::RegenerateTelemetryId()}; |
| 50 | ui->label_telemetry_id->setText("Telemetry ID: 0x" + | 63 | ui->label_telemetry_id->setText("Telemetry ID: 0x" + |
| 51 | QString::number(new_telemetry_id, 16).toUpper()); | 64 | QString::number(new_telemetry_id, 16).toUpper()); |
| 52 | } | 65 | } |
| 66 | |||
| 67 | void ConfigureWeb::OnLoginChanged() { | ||
| 68 | if (ui->edit_username->text().isEmpty() && ui->edit_token->text().isEmpty()) { | ||
| 69 | user_verified = true; | ||
| 70 | ui->label_username_verified->setPixmap(QPixmap(":/icons/checked.png")); | ||
| 71 | ui->label_token_verified->setPixmap(QPixmap(":/icons/checked.png")); | ||
| 72 | } else { | ||
| 73 | user_verified = false; | ||
| 74 | ui->label_username_verified->setPixmap(QPixmap(":/icons/failed.png")); | ||
| 75 | ui->label_token_verified->setPixmap(QPixmap(":/icons/failed.png")); | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | void ConfigureWeb::VerifyLogin() { | ||
| 80 | verified = | ||
| 81 | Core::VerifyLogin(ui->edit_username->text().toStdString(), | ||
| 82 | ui->edit_token->text().toStdString(), [&]() { emit LoginVerified(); }); | ||
| 83 | ui->button_verify_login->setDisabled(true); | ||
| 84 | ui->button_verify_login->setText(tr("Verifying")); | ||
| 85 | } | ||
| 86 | |||
| 87 | void ConfigureWeb::OnLoginVerified() { | ||
| 88 | ui->button_verify_login->setEnabled(true); | ||
| 89 | ui->button_verify_login->setText(tr("Verify")); | ||
| 90 | if (verified.get()) { | ||
| 91 | user_verified = true; | ||
| 92 | ui->label_username_verified->setPixmap(QPixmap(":/icons/checked.png")); | ||
| 93 | ui->label_token_verified->setPixmap(QPixmap(":/icons/checked.png")); | ||
| 94 | } else { | ||
| 95 | ui->label_username_verified->setPixmap(QPixmap(":/icons/failed.png")); | ||
| 96 | ui->label_token_verified->setPixmap(QPixmap(":/icons/failed.png")); | ||
| 97 | QMessageBox::critical( | ||
| 98 | this, tr("Verification failed"), | ||
| 99 | tr("Verification failed. Check that you have entered your username and token " | ||
| 100 | "correctly, and that your internet connection is working.")); | ||
| 101 | } | ||
| 102 | } | ||
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 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <future> | ||
| 7 | #include <memory> | 8 | #include <memory> |
| 8 | #include <QWidget> | 9 | #include <QWidget> |
| 9 | 10 | ||
| @@ -21,10 +22,19 @@ public: | |||
| 21 | void applyConfiguration(); | 22 | void applyConfiguration(); |
| 22 | 23 | ||
| 23 | public slots: | 24 | public slots: |
| 24 | void refreshTelemetryID(); | 25 | void RefreshTelemetryID(); |
| 26 | void OnLoginChanged(); | ||
| 27 | void VerifyLogin(); | ||
| 28 | void OnLoginVerified(); | ||
| 29 | |||
| 30 | signals: | ||
| 31 | void LoginVerified(); | ||
| 25 | 32 | ||
| 26 | private: | 33 | private: |
| 27 | void setConfiguration(); | 34 | void setConfiguration(); |
| 28 | 35 | ||
| 36 | bool user_verified = true; | ||
| 37 | std::future<bool> verified; | ||
| 38 | |||
| 29 | std::unique_ptr<Ui::ConfigureWeb> ui; | 39 | std::unique_ptr<Ui::ConfigureWeb> ui; |
| 30 | }; | 40 | }; |
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 @@ | |||
| 6 | <rect> | 6 | <rect> |
| 7 | <x>0</x> | 7 | <x>0</x> |
| 8 | <y>0</y> | 8 | <y>0</y> |
| 9 | <width>400</width> | 9 | <width>926</width> |
| 10 | <height>300</height> | 10 | <height>561</height> |
| 11 | </rect> | 11 | </rect> |
| 12 | </property> | 12 | </property> |
| 13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
| @@ -31,14 +31,30 @@ | |||
| 31 | </item> | 31 | </item> |
| 32 | <item> | 32 | <item> |
| 33 | <layout class="QGridLayout" name="gridLayoutCitraUsername"> | 33 | <layout class="QGridLayout" name="gridLayoutCitraUsername"> |
| 34 | <item row="0" column="0"> | 34 | <item row="2" column="3"> |
| 35 | <widget class="QLabel" name="label_username"> | 35 | <widget class="QPushButton" name="button_verify_login"> |
| 36 | <property name="sizePolicy"> | ||
| 37 | <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||
| 38 | <horstretch>0</horstretch> | ||
| 39 | <verstretch>0</verstretch> | ||
| 40 | </sizepolicy> | ||
| 41 | </property> | ||
| 42 | <property name="layoutDirection"> | ||
| 43 | <enum>Qt::RightToLeft</enum> | ||
| 44 | </property> | ||
| 36 | <property name="text"> | 45 | <property name="text"> |
| 37 | <string>Username: </string> | 46 | <string>Verify</string> |
| 38 | </property> | 47 | </property> |
| 39 | </widget> | 48 | </widget> |
| 40 | </item> | 49 | </item> |
| 41 | <item row="0" column="1"> | 50 | <item row="2" column="0"> |
| 51 | <widget class="QLabel" name="web_signup_link"> | ||
| 52 | <property name="text"> | ||
| 53 | <string>Sign up</string> | ||
| 54 | </property> | ||
| 55 | </widget> | ||
| 56 | </item> | ||
| 57 | <item row="0" column="1" colspan="3"> | ||
| 42 | <widget class="QLineEdit" name="edit_username"> | 58 | <widget class="QLineEdit" name="edit_username"> |
| 43 | <property name="maxLength"> | 59 | <property name="maxLength"> |
| 44 | <number>36</number> | 60 | <number>36</number> |
| @@ -52,7 +68,22 @@ | |||
| 52 | </property> | 68 | </property> |
| 53 | </widget> | 69 | </widget> |
| 54 | </item> | 70 | </item> |
| 55 | <item row="1" column="1"> | 71 | <item row="1" column="4"> |
| 72 | <widget class="QLabel" name="label_token_verified"> | ||
| 73 | </widget> | ||
| 74 | </item> | ||
| 75 | <item row="0" column="0"> | ||
| 76 | <widget class="QLabel" name="label_username"> | ||
| 77 | <property name="text"> | ||
| 78 | <string>Username: </string> | ||
| 79 | </property> | ||
| 80 | </widget> | ||
| 81 | </item> | ||
| 82 | <item row="0" column="4"> | ||
| 83 | <widget class="QLabel" name="label_username_verified"> | ||
| 84 | </widget> | ||
| 85 | </item> | ||
| 86 | <item row="1" column="1" colspan="3"> | ||
| 56 | <widget class="QLineEdit" name="edit_token"> | 87 | <widget class="QLineEdit" name="edit_token"> |
| 57 | <property name="maxLength"> | 88 | <property name="maxLength"> |
| 58 | <number>36</number> | 89 | <number>36</number> |
| @@ -62,13 +93,6 @@ | |||
| 62 | </property> | 93 | </property> |
| 63 | </widget> | 94 | </widget> |
| 64 | </item> | 95 | </item> |
| 65 | <item row="2" column="0"> | ||
| 66 | <widget class="QLabel" name="web_signup_link"> | ||
| 67 | <property name="text"> | ||
| 68 | <string>Sign up</string> | ||
| 69 | </property> | ||
| 70 | </widget> | ||
| 71 | </item> | ||
| 72 | <item row="2" column="1"> | 96 | <item row="2" column="1"> |
| 73 | <widget class="QLabel" name="web_token_info_link"> | 97 | <widget class="QLabel" name="web_token_info_link"> |
| 74 | <property name="text"> | 98 | <property name="text"> |
| @@ -76,6 +100,19 @@ | |||
| 76 | </property> | 100 | </property> |
| 77 | </widget> | 101 | </widget> |
| 78 | </item> | 102 | </item> |
| 103 | <item row="2" column="2"> | ||
| 104 | <spacer name="horizontalSpacer"> | ||
| 105 | <property name="orientation"> | ||
| 106 | <enum>Qt::Horizontal</enum> | ||
| 107 | </property> | ||
| 108 | <property name="sizeHint" stdset="0"> | ||
| 109 | <size> | ||
| 110 | <width>40</width> | ||
| 111 | <height>20</height> | ||
| 112 | </size> | ||
| 113 | </property> | ||
| 114 | </spacer> | ||
| 115 | </item> | ||
| 79 | </layout> | 116 | </layout> |
| 80 | </item> | 117 | </item> |
| 81 | </layout> | 118 | </layout> |
| @@ -105,17 +142,17 @@ | |||
| 105 | <layout class="QGridLayout" name="gridLayoutTelemetryId"> | 142 | <layout class="QGridLayout" name="gridLayoutTelemetryId"> |
| 106 | <item row="0" column="0"> | 143 | <item row="0" column="0"> |
| 107 | <widget class="QLabel" name="label_telemetry_id"> | 144 | <widget class="QLabel" name="label_telemetry_id"> |
| 108 | <property name="text"> | 145 | <property name="text"> |
| 109 | <string>Telemetry ID:</string> | 146 | <string>Telemetry ID:</string> |
| 110 | </property> | 147 | </property> |
| 111 | </widget> | 148 | </widget> |
| 112 | </item> | 149 | </item> |
| 113 | <item row="0" column="1"> | 150 | <item row="0" column="1"> |
| 114 | <widget class="QPushButton" name="button_regenerate_telemetry_id"> | 151 | <widget class="QPushButton" name="button_regenerate_telemetry_id"> |
| 115 | <property name="sizePolicy"> | 152 | <property name="sizePolicy"> |
| 116 | <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | 153 | <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> |
| 117 | <horstretch>0</horstretch> | 154 | <horstretch>0</horstretch> |
| 118 | <verstretch>0</verstretch> | 155 | <verstretch>0</verstretch> |
| 119 | </sizepolicy> | 156 | </sizepolicy> |
| 120 | </property> | 157 | </property> |
| 121 | <property name="layoutDirection"> | 158 | <property name="layoutDirection"> |