Skip to content

Commit

Permalink
Save password as QString
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski committed Sep 24, 2018
1 parent 36563cd commit a8e9aba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/settings/tidalsettingspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void TidalSettingsPage::Load() {
ui_->username->setText(s.value("username").toString());
QByteArray password = s.value("password").toByteArray();
if (password.isEmpty()) ui_->password->setText("");
else ui_->password->setText(QByteArray::fromBase64(password));
else ui_->password->setText(QString::fromUtf8(QByteArray::fromBase64(password)));
dialog()->ComboBoxLoadFromSettings(s, ui_->combobox_quality, "quality", "HIGH");
ui_->spinbox_searchdelay->setValue(s.value("searchdelay", 1500).toInt());
ui_->spinbox_albumssearchlimit->setValue(s.value("albumssearchlimit", 100).toInt());
Expand All @@ -96,7 +96,7 @@ void TidalSettingsPage::Save() {
QSettings s;
s.beginGroup(kSettingsGroup);
s.setValue("username", ui_->username->text());
s.setValue("password", ui_->password->text().toUtf8().toBase64());
s.setValue("password", QString::fromUtf8(ui_->password->text().toUtf8().toBase64()));
s.setValue("quality", ui_->combobox_quality->itemData(ui_->combobox_quality->currentIndex()));
s.setValue("searchdelay", ui_->spinbox_searchdelay->value());
s.setValue("albumssearchlimit", ui_->spinbox_albumssearchlimit->value());
Expand Down
8 changes: 5 additions & 3 deletions src/tidal/tidalservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ void TidalService::ReloadSettings() {
QSettings s;
s.beginGroup(TidalSettingsPage::kSettingsGroup);
username_ = s.value("username").toString();
password_ = QByteArray::fromBase64(s.value("password").toByteArray());
QByteArray password = s.value("password").toByteArray();
if (password.isEmpty()) password_.clear();
else password_ = QString::fromUtf8(QByteArray::fromBase64(password));
quality_ = s.value("quality").toString();
searchdelay_ = s.value("searchdelay", 1500).toInt();
albumssearchlimit_ = s.value("albumssearchlimit", 100).toInt();
Expand All @@ -127,7 +129,7 @@ void TidalService::LoadSessionID() {
session_id_ = s.value("session_id").toString();
user_id_ = s.value("user_id").toInt();
country_code_ = s.value("country_code").toString();
clientuniquekey_ = Utilities::GetRandomStringWithChars(12);
clientuniquekey_ = Utilities::GetRandomStringWithChars(12).toLower();
s.endGroup();

}
Expand Down Expand Up @@ -253,7 +255,7 @@ void TidalService::HandleAuthReply(QNetworkReply *reply) {
country_code_ = json_obj["countryCode"].toString();
session_id_ = json_obj["sessionId"].toString();
user_id_ = json_obj["userId"].toInt();
clientuniquekey_ = Utilities::GetRandomStringWithChars(12);
clientuniquekey_ = Utilities::GetRandomStringWithChars(12).toLower();

QSettings s;
s.beginGroup(TidalSettingsPage::kSettingsGroup);
Expand Down

0 comments on commit a8e9aba

Please sign in to comment.