cloudfileservices: Common rescan confirmation dialog

Move Google Drive's rescan confirmation dialog to CloudFileService for
reuse.
This commit is contained in:
Jim Broadus 2021-02-24 21:15:23 -08:00 committed by John Maguire
parent 5767317678
commit b57e66dd51
4 changed files with 24 additions and 22 deletions

View File

@ -21,6 +21,8 @@
#include "internet/core/cloudfileservice.h" #include "internet/core/cloudfileservice.h"
#include <QMenu> #include <QMenu>
#include <QMessageBox>
#include <QPushButton>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include "core/application.h" #include "core/application.h"
@ -243,3 +245,21 @@ void CloudFileService::AbortReadTagsReplies() {
indexing_task_id_ = -1; indexing_task_id_ = -1;
emit AllIndexingTasksFinished(); emit AllIndexingTasksFinished();
} }
void CloudFileService::FullRescanRequested() {
QMessageBox* message_box = new QMessageBox(
QMessageBox::Warning, tr("Do a full rescan"),
tr("Doing a full rescan will lose any metadata you've saved in "
"Clementine such as cover art, play counts and ratings. Clementine "
"will rescan all your music in %1 which may take some "
"time.")
.arg(name()),
QMessageBox::NoButton);
QPushButton* button = message_box->addButton(tr("Do a full rescan"),
QMessageBox::DestructiveRole);
connect(button, SIGNAL(clicked()), SLOT(DoFullRescan()));
message_box->addButton(QMessageBox::Cancel);
message_box->setAttribute(Qt::WA_DeleteOnClose);
message_box->show();
}

View File

@ -72,6 +72,8 @@ class CloudFileService : public InternetService {
void AddToPlaylist(QMimeData* mime); void AddToPlaylist(QMimeData* mime);
void ReadTagsFinished(TagReaderClient::ReplyType* reply, void ReadTagsFinished(TagReaderClient::ReplyType* reply,
const Song& metadata); const Song& metadata);
void FullRescanRequested();
virtual void DoFullRescan() {}
protected: protected:
QStandardItem* root_; QStandardItem* root_;

View File

@ -22,8 +22,6 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QEventLoop> #include <QEventLoop>
#include <QMenu> #include <QMenu>
#include <QMessageBox>
#include <QPushButton>
#include <QScopedPointer> #include <QScopedPointer>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QUrlQuery> #include <QUrlQuery>
@ -225,7 +223,7 @@ void GoogleDriveService::ShowContextMenu(const QPoint& global_pos) {
tr("Check for updates"), this, SLOT(CheckForUpdates())); tr("Check for updates"), this, SLOT(CheckForUpdates()));
full_rescan_action_ = context_menu_->addAction( full_rescan_action_ = context_menu_->addAction(
IconLoader::Load("view-refresh", IconLoader::Base), IconLoader::Load("view-refresh", IconLoader::Base),
tr("Do a full rescan..."), this, SLOT(ConfirmFullRescan())); tr("Do a full rescan..."), this, SLOT(FullRescanRequested()));
context_menu_->addSeparator(); context_menu_->addSeparator();
context_menu_->addAction(IconLoader::Load("download", IconLoader::Base), context_menu_->addAction(IconLoader::Load("download", IconLoader::Base),
tr("Cover Manager"), this, tr("Cover Manager"), this,
@ -268,23 +266,6 @@ void GoogleDriveService::OpenWithDrive() {
} }
} }
void GoogleDriveService::ConfirmFullRescan() {
QMessageBox* message_box = new QMessageBox(
QMessageBox::Warning, tr("Do a full rescan"),
tr("Doing a full rescan will lose any metadata you've saved in "
"Clementine such as cover art, play counts and ratings. Clementine "
"will rescan all your music in Google Drive which may take some "
"time."),
QMessageBox::NoButton);
QPushButton* button = message_box->addButton(tr("Do a full rescan"),
QMessageBox::DestructiveRole);
connect(button, SIGNAL(clicked()), SLOT(DoFullRescan()));
message_box->addButton(QMessageBox::Cancel);
message_box->setAttribute(Qt::WA_DeleteOnClose);
message_box->show();
}
void GoogleDriveService::DoFullRescan() { void GoogleDriveService::DoFullRescan() {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup); s.beginGroup(kSettingsGroup);

View File

@ -62,8 +62,7 @@ class GoogleDriveService : public CloudFileService {
void SaveCursor(const QString& cursor); void SaveCursor(const QString& cursor);
void OpenWithDrive(); void OpenWithDrive();
void ConfirmFullRescan(); void DoFullRescan() override;
void DoFullRescan();
void CheckForUpdates(); void CheckForUpdates();
private: private: