From ffb470a38035b2eb2cf63909572e8d56082dc83b Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sat, 9 May 2015 18:10:38 +0100 Subject: Add in a tab to allow saving of steam username and password. --- src/organizercore.cpp | 13 ++++++++- src/settings.cpp | 39 +++++++++++++++++++++++++++ src/settings.h | 17 ++++++++++++ src/settingsdialog.ui | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/organizercore.cpp b/src/organizercore.cpp index c2eaeae7..30d38be3 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -86,7 +86,18 @@ static void startSteam(QWidget *widget) QString exe = steamSettings.value("SteamExe", "").toString(); if (!exe.isEmpty()) { QString temp = QString("\"%1\"").arg(exe); - if (!QProcess::startDetached(temp)) { + //See if username and password supplied. If so, pass them into steam. + QStringList args; + QString username; + QString password; + if (Settings::instance().getSteamLogin(username, password)) { + args << "-login"; + args << username; + if (password != "") { + args << password; + } + } + if (!QProcess::startDetached(temp, args)) { reportError(QObject::tr("Failed to start \"%1\"").arg(temp)); } else { QMessageBox::information(widget, QObject::tr("Waiting"), diff --git a/src/settings.cpp b/src/settings.cpp index 862ed5f3..c40450b1 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -261,6 +261,20 @@ bool Settings::getNexusLogin(QString &username, QString &password) const } } +bool Settings::getSteamLogin(QString &username, QString &password) const +{ + if (m_Settings.contains("Settings/steam_username")) { + username = m_Settings.value("Settings/steam_username", "").toString(); + if (m_Settings.contains("Settings/steam_password")) { + password = deObfuscate(m_Settings.value("Settings/steam_password", "").toString()); + } else { + password = ""; + } + return true; + } else { + return false; + } +} bool Settings::compactDownloads() const { return m_Settings.value("Settings/compact_downloads", false).toBool(); @@ -289,6 +303,20 @@ void Settings::setNexusLogin(QString username, QString password) m_Settings.setValue("Settings/nexus_password", obfuscate(password)); } +void Settings::setSteamLogin(QString username, QString password) +{ + if (username == "") { + m_Settings.remove("Settings/steam_username"); + password = ""; + } else { + m_Settings.setValue("Settings/steam_username", username); + } + if (password == "") { + m_Settings.remove("Settings/steam_password"); + } else { + m_Settings.setValue("Settings/steam_password", obfuscate(password)); + } +} LoadMechanism::EMechanism Settings::getLoadMechanism() const { @@ -542,6 +570,9 @@ void Settings::query(QWidget *parent) QCheckBox *hideUncheckedBox = dialog.findChild("hideUncheckedBox"); QCheckBox *displayForeignBox = dialog.findChild("displayForeignBox"); + // steam login page + QLineEdit *steamUserEdit = dialog.findChild("steamUserEdit"); + QLineEdit *steamPassEdit = dialog.findChild("steamPassEdit"); // // set up current settings @@ -609,6 +640,13 @@ void Settings::query(QWidget *parent) passwordEdit->setText(deObfuscate(m_Settings.value("Settings/nexus_password", "").toString())); } + if (m_Settings.contains("Settings/steam_username")) { + steamUserEdit->setText(m_Settings.value("Settings/steam_username", "").toString()); + if (m_Settings.contains("Settings/steam_password")) { + steamPassEdit->setText(deObfuscate(m_Settings.value("Settings/steam_password", "").toString())); + } + } + downloadDirEdit->setText(getDownloadDirectory()); modDirEdit->setText(getModDirectory()); cacheDirEdit->setText(getCacheDirectory()); @@ -723,6 +761,7 @@ void Settings::query(QWidget *parent) m_Settings.remove("Settings/nexus_username"); m_Settings.remove("Settings/nexus_password"); } + setSteamLogin(steamUserEdit->text(), steamPassEdit->text()); m_Settings.setValue("Settings/offline_mode", offlineBox->isChecked()); m_Settings.setValue("Settings/use_proxy", proxyBox->isChecked()); m_Settings.setValue("Settings/display_foreign", displayForeignBox->isChecked()); diff --git a/src/settings.h b/src/settings.h index 51e109c4..0818c2fb 100644 --- a/src/settings.h +++ b/src/settings.h @@ -142,6 +142,15 @@ public: **/ bool getNexusLogin(QString &username, QString &password) const; + /** + * @brief retrieve the login information for steam + * + * @param username (out) receives the user name for nexus + * @param password (out) received the password for nexus + * @return true if a username has been specified, false otherwise + **/ + bool getSteamLogin(QString &username, QString &password) const; + /** * @return true if the user disabled internet features */ @@ -170,6 +179,14 @@ public: */ void setNexusLogin(QString username, QString password); + /** + * @brief set the steam login information + * + * @param username username + * @param password password + */ + void setSteamLogin(QString username, QString password); + /** * @return the load mechanism to be used **/ diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index f04e4d7a..f2ab3908 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -811,6 +811,79 @@ For the other games this is not a sufficient replacement for AI! + + + Steam + + + + + + Username + + + + + + + If you save your steam user ID and password here, they will be used when logging into steam. Note, however, your password will be stored unencrypted, so make sure your computer is secure. + + + true + + + + + + + Password + + + + + + + + + + QLineEdit::Password + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 40 + + + + + + -- cgit v1.3.1