summaryrefslogtreecommitdiff
path: root/src/settingsdialog.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-07-11 05:49:12 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-07-11 05:49:12 -0400
commitbe1ee2a97c867a80c07c4b865c306977d96249dc (patch)
tree17c828745ad3e2399177042781a66ed7d2577118 /src/settingsdialog.cpp
parent226372dba2f8a06ef2349a331da91010d97e72bf (diff)
refactored state messages
Diffstat (limited to 'src/settingsdialog.cpp')
-rw-r--r--src/settingsdialog.cpp118
1 files changed, 6 insertions, 112 deletions
diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp
index 12dbc482..df957f87 100644
--- a/src/settingsdialog.cpp
+++ b/src/settingsdialog.cpp
@@ -450,66 +450,10 @@ void SettingsDialog::onSSOKeyChanged(const QString& key)
void SettingsDialog::onSSOStateChanged(NexusSSOLogin::States s, const QString& e)
{
- QString log;
+ const auto log = NexusSSOLogin::stateToString(s, e);
- switch (s)
- {
- case NexusSSOLogin::ConnectingToSSO:
- {
- log = tr("Connecting to Nexus...");
- break;
- }
-
- case NexusSSOLogin::WaitingForToken:
- {
- log = tr("Waiting for Nexus...");
- break;
- }
-
- case NexusSSOLogin::WaitingForBrowser:
- {
- log = tr("Opened browser, waiting for user...");
- break;
- }
-
- case NexusSSOLogin::Finished:
- {
- log = tr("Connected.");
- break;
- }
-
- case NexusSSOLogin::Timeout:
- {
- log = QObject::tr(
- "No answer from Nexus.\n"
- "A firewall might be blocking Mod Organizer.");
-
- break;
- }
-
- case NexusSSOLogin::ClosedByRemote:
- {
- log = QObject::tr("Nexus closed the connection.");
- break;
- }
-
- case NexusSSOLogin::Cancelled:
- {
- log = QObject::tr("Cancelled.");
- break;
- }
-
- case NexusSSOLogin::Error:
- {
- log = tr("Error: %1.").arg(e);
- break;
- }
- }
-
- if (!log.isEmpty()) {
- for (auto&& line : log.split("\n")) {
- ui->nexusLog->addItem(line);
- }
+ for (auto&& line : log.split("\n")) {
+ ui->nexusLog->addItem(line);
}
updateNexusButtons();
@@ -518,60 +462,10 @@ void SettingsDialog::onSSOStateChanged(NexusSSOLogin::States s, const QString& e
void SettingsDialog::onValidatorStateChanged(
NexusKeyValidator::States s, const QString& e)
{
- QString log;
-
- switch (s)
- {
- case NexusKeyValidator::Connecting:
- {
- log = tr("Connecting to Nexus...");
- break;
- }
-
- case NexusKeyValidator::Finished:
- {
- log = tr("Connected.");
- break;
- }
-
- case NexusKeyValidator::InvalidJson:
- {
- log = tr("Invalid JSON");
- break;
- }
-
- case NexusKeyValidator::BadResponse:
- {
- log = tr("Bad response");
- break;
- }
-
- case NexusKeyValidator::Timeout:
- {
- log = QObject::tr(
- "No answer from Nexus.\n"
- "A firewall might be blocking Mod Organizer.");
+ const auto log = NexusKeyValidator::stateToString(s, e);
- break;
- }
-
- case NexusKeyValidator::Cancelled:
- {
- log = QObject::tr("Cancelled.");
- break;
- }
-
- case NexusKeyValidator::Error:
- {
- log = tr("Error: %1.").arg(e);
- break;
- }
- }
-
- if (!log.isEmpty()) {
- for (auto&& line : log.split("\n")) {
- ui->nexusLog->addItem(line);
- }
+ for (auto&& line : log.split("\n")) {
+ ui->nexusLog->addItem(line);
}
updateNexusButtons();