Clementine-audio-player-Mac.../src/internet/amazon/amazonsettingspage.cpp

81 lines
2.5 KiB
C++
Raw Normal View History

Amazon Cloud Drive support. Squashed commit of the following: commit 451a327fabb5f9aba077d93a33d75d8a6a288f5f Author: John Maguire <john.maguire@gmail.com> Date: Fri Mar 27 14:55:36 2015 +0100 Revert debug console changes. commit 52f643c3dc524a837f56268b6da4881187204165 Author: John Maguire <john.maguire@gmail.com> Date: Fri Mar 27 14:49:28 2015 +0100 Revert extra logging commit 23645f9fea4caa65d93c2a0a5ad5e2a164c3b535 Author: John Maguire <john.maguire@gmail.com> Date: Fri Mar 27 14:47:55 2015 +0100 How did you get there commit 8153388f19db17caf4286618922516b495a3f1d3 Author: John Maguire <john.maguire@gmail.com> Date: Fri Mar 27 14:45:12 2015 +0100 Update copyright headers. commit fa9e279259604a16564287291180b69cbb22d74f Author: John Maguire <john.maguire@gmail.com> Date: Fri Mar 27 14:43:27 2015 +0100 Remove logging commit 47a405543c8f6924adb60fbc34ec7360c608a9ec Author: John Maguire <john.maguire@gmail.com> Date: Fri Mar 27 14:42:05 2015 +0100 Show login state correctly for Amazon. commit 748d88d993fb56ecd97e14b8e7c7b6c49f11c410 Author: John Maguire <john.maguire@gmail.com> Date: Fri Mar 27 14:28:55 2015 +0100 Ensure Amazon is connected before serving URLs. commit 25ec9c65f4b0be4fc2df13cf941cf236f7cf6b46 Author: John Maguire <john.maguire@gmail.com> Date: Fri Mar 27 14:22:28 2015 +0100 Refresh Amazon authorisation & follow changes. commit 27c1a37173a76e04341b87abe2ada8438d6ee59f Author: John Maguire <john.maguire@gmail.com> Date: Thu Mar 26 18:27:27 2015 +0100 Revert unneeded OAuthenticator change. commit 3594af5be12d979762719010535db8f5aaec0905 Author: John Maguire <john.maguire@gmail.com> Date: Thu Mar 26 16:52:19 2015 +0100 Initial support for Amazon Cloud Drive.
2015-03-27 14:56:08 +01:00
/* This file is part of Clementine.
Copyright 2015, John Maguire <john.maguire@gmail.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "amazonsettingspage.h"
#include "ui_amazonsettingspage.h"
#include "core/application.h"
#include "internet/amazon/amazonclouddrive.h"
#include "internet/core/internetmodel.h"
#include "ui/settingsdialog.h"
AmazonSettingsPage::AmazonSettingsPage(SettingsDialog* parent)
: SettingsPage(parent),
ui_(new Ui::AmazonSettingsPage),
service_(dialog()->app()->internet_model()->Service<AmazonCloudDrive>()) {
ui_->setupUi(this);
ui_->login_state->AddCredentialGroup(ui_->login_container);
connect(ui_->login_button, SIGNAL(clicked()), SLOT(LoginClicked()));
connect(ui_->login_state, SIGNAL(LogoutClicked()), SLOT(LogoutClicked()));
connect(service_, SIGNAL(Connected()), SLOT(Connected()));
dialog()->installEventFilter(this);
}
AmazonSettingsPage::~AmazonSettingsPage() { delete ui_; }
void AmazonSettingsPage::Load() {
QSettings s;
s.beginGroup(AmazonCloudDrive::kSettingsGroup);
const QString token = s.value("refresh_token").toString();
if (!token.isEmpty()) {
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn);
}
}
void AmazonSettingsPage::Save() {
QSettings s;
s.beginGroup(AmazonCloudDrive::kSettingsGroup);
}
void AmazonSettingsPage::LoginClicked() {
service_->Connect();
ui_->login_button->setEnabled(false);
ui_->login_state->SetLoggedIn(LoginStateWidget::LoginInProgress);
}
bool AmazonSettingsPage::eventFilter(QObject* object, QEvent* event) {
if (object == dialog() && event->type() == QEvent::Enter) {
ui_->login_button->setEnabled(true);
return false;
}
return SettingsPage::eventFilter(object, event);
}
void AmazonSettingsPage::LogoutClicked() {
service_->ForgetCredentials();
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedOut);
}
void AmazonSettingsPage::Connected() {
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn);
}