mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-07 06:35:15 +01:00
skydrive: Add rescan option
Add menu option to drop all items from the database and rescan the cloud drive.
This commit is contained in:
parent
c87409c896
commit
05f513ab6f
@ -30,6 +30,7 @@
|
||||
#include "core/waitforsignal.h"
|
||||
#include "internet/core/oauthenticator.h"
|
||||
#include "internet/skydrive/skydriveurlhandler.h"
|
||||
#include "library/librarybackend.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
namespace {
|
||||
@ -137,9 +138,11 @@ void SkydriveService::FetchUserInfoFinished(QNetworkReply* reply) {
|
||||
|
||||
emit Connected();
|
||||
|
||||
ListFiles("root");
|
||||
ListFiles();
|
||||
}
|
||||
|
||||
void SkydriveService::ListFiles() { ListFiles("root"); }
|
||||
|
||||
void SkydriveService::ListFiles(const QString& folder) {
|
||||
QUrl url(QString(kDriveBase) + folder + "/children");
|
||||
QNetworkRequest request(url);
|
||||
@ -206,6 +209,24 @@ QUrl SkydriveService::GetStreamingUrlFromSongId(const QString& file_id) {
|
||||
return ItemUrl(file_id, "content");
|
||||
}
|
||||
|
||||
void SkydriveService::PopulateContextMenu() {
|
||||
context_menu_->addActions(GetPlaylistActions());
|
||||
full_rescan_action_ = context_menu_->addAction(
|
||||
IconLoader::Load("view-refresh", IconLoader::Base),
|
||||
tr("Do a full rescan..."), this, SLOT(FullRescanRequested()));
|
||||
context_menu_->addSeparator();
|
||||
context_menu_->addAction(IconLoader::Load("download", IconLoader::Base),
|
||||
tr("Cover Manager"), this, SLOT(ShowCoverManager()));
|
||||
context_menu_->addSeparator();
|
||||
context_menu_->addAction(IconLoader::Load("configure", IconLoader::Base),
|
||||
tr("Configure..."), this,
|
||||
SLOT(ShowSettingsDialog()));
|
||||
}
|
||||
|
||||
void SkydriveService::UpdateContextMenu() {
|
||||
full_rescan_action_->setEnabled(!is_indexing());
|
||||
}
|
||||
|
||||
void SkydriveService::EnsureConnected() {
|
||||
if (!access_token_.isEmpty()) {
|
||||
return;
|
||||
@ -222,3 +243,8 @@ void SkydriveService::ForgetCredentials() {
|
||||
s.remove("refresh_token");
|
||||
s.remove("name");
|
||||
}
|
||||
|
||||
void SkydriveService::DoFullRescan() {
|
||||
library_backend_->DeleteAll();
|
||||
ListFiles();
|
||||
}
|
||||
|
@ -62,12 +62,19 @@ class SkydriveService : public CloudFileService {
|
||||
QString refresh_token() const;
|
||||
void AddAuthorizationHeader(QNetworkRequest* request);
|
||||
void FetchUserInfo();
|
||||
void ListFiles();
|
||||
void ListFiles(const QString& folder);
|
||||
void EnsureConnected();
|
||||
QUrl ItemUrl(const QString& id, const QString& path);
|
||||
void DoFullRescan() override;
|
||||
|
||||
void PopulateContextMenu() override;
|
||||
void UpdateContextMenu() override;
|
||||
|
||||
QString access_token_;
|
||||
QDateTime expiry_time_;
|
||||
|
||||
QAction* full_rescan_action_;
|
||||
};
|
||||
|
||||
#endif // INTERNET_SKYDRIVE_SKYDRIVESERVICE_H_
|
||||
|
Loading…
x
Reference in New Issue
Block a user