1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 03:27:40 +01:00

Make the 'dont ask on first connect' more generic

This commit is contained in:
Arnaud Bienner 2011-08-11 00:59:34 +02:00
parent f963ae524a
commit 1a4aa8f641
4 changed files with 21 additions and 20 deletions

View File

@ -37,6 +37,7 @@ public:
quint64 DeviceCapacity(const QString& id);
quint64 DeviceFreeSpace(const QString& id);
QVariantMap DeviceHardwareInfo(const QString& id);
bool AskForScan() { return false; }
QString MakeFriendlyName(const QString&);
QList<QUrl> MakeDeviceUrls(const QString&);
void UnmountDevice(const QString&);

View File

@ -51,6 +51,10 @@ public:
virtual QVariantMap DeviceHardwareInfo(const QString& id) = 0;
virtual bool DeviceNeedsMount(const QString& id) { return false; }
// When connecting to a device for the first time, do we want an user's
// confirmation for scanning it? (by default yes)
virtual bool AskForScan() { return true; }
virtual QString MakeFriendlyName(const QString& id) = 0;
virtual QList<QUrl> MakeDeviceUrls(const QString& id) = 0;

View File

@ -318,15 +318,7 @@ QVariant DeviceManager::data(const QModelIndex& index, int role) const {
if (info.database_id_ == -1 &&
!info.BestBackend()->lister_->DeviceNeedsMount(info.BestBackend()->unique_id_)) {
bool prompt_connect = info.device_;
#ifdef HAVE_AUDIOCD
// Don't ask user if it is a CD device
prompt_connect = prompt_connect &&
!dynamic_cast<CddaDevice*>(info.device_.get());
#endif
if (prompt_connect) {
if (info.BestBackend()->lister_->AskForScan()) {
boost::scoped_ptr<QMessageBox> dialog(new QMessageBox(
QMessageBox::Information, tr("Connect device"),
tr("This is the first time you have connected this device. Clementine will now scan the device to find music files - this may take some time."),

View File

@ -16,6 +16,7 @@
*/
#include "connecteddevice.h"
#include "devicelister.h"
#include "devicemanager.h"
#include "deviceproperties.h"
#include "deviceview.h"
@ -306,18 +307,21 @@ void DeviceView::DeviceDisconnected(int row) {
}
void DeviceView::Forget() {
boost::scoped_ptr<QMessageBox> dialog(new QMessageBox(
QMessageBox::Question, tr("Forget device"),
tr("Forgetting a device will remove it from this list and Clementine will have to rescan all the songs again next time you connect it."),
QMessageBox::Cancel, this));
QPushButton* forget =
dialog->addButton(tr("Forget device"), QMessageBox::DestructiveRole);
dialog->exec();
if (dialog->clickedButton() != forget)
return;
QModelIndex device_idx = MapToDevice(menu_index_);
if (manager_->GetLister(device_idx.row()) &&
manager_->GetLister(device_idx.row())->AskForScan()) {
boost::scoped_ptr<QMessageBox> dialog(new QMessageBox(
QMessageBox::Question, tr("Forget device"),
tr("Forgetting a device will remove it from this list and Clementine will have to rescan all the songs again next time you connect it."),
QMessageBox::Cancel, this));
QPushButton* forget =
dialog->addButton(tr("Forget device"), QMessageBox::DestructiveRole);
dialog->exec();
if (dialog->clickedButton() != forget)
return;
}
manager_->Forget(device_idx.row());
}