diff --git a/src/core/filesystemmusicstorage.h b/src/core/filesystemmusicstorage.h index b9b6764f7..509cddf45 100644 --- a/src/core/filesystemmusicstorage.h +++ b/src/core/filesystemmusicstorage.h @@ -19,7 +19,7 @@ #include "musicstorage.h" -class FilesystemMusicStorage : public MusicStorage { +class FilesystemMusicStorage : public virtual MusicStorage { public: FilesystemMusicStorage(const QString& root); diff --git a/src/core/musicstorage.h b/src/core/musicstorage.h index c85bc9057..072572992 100644 --- a/src/core/musicstorage.h +++ b/src/core/musicstorage.h @@ -35,6 +35,7 @@ public: const Song& metadata, bool overwrite, bool remove_original) = 0; virtual void FinishCopy() {} + virtual void Eject() {} }; Q_DECLARE_METATYPE(MusicStorage*); diff --git a/src/core/organise.cpp b/src/core/organise.cpp index 88dc1b038..1d4ab5bb3 100644 --- a/src/core/organise.cpp +++ b/src/core/organise.cpp @@ -27,7 +27,7 @@ const int Organise::kBatchSize = 10; Organise::Organise(TaskManager* task_manager, MusicStorage* destination, const OrganiseFormat &format, bool copy, bool overwrite, - const QStringList& files) + const QStringList& files, bool eject_after) : thread_(NULL), task_manager_(task_manager), destination_(destination), @@ -35,6 +35,7 @@ Organise::Organise(TaskManager* task_manager, MusicStorage* destination, copy_(copy), overwrite_(overwrite), files_(files), + eject_after_(eject_after), started_(false), task_id_(0), progress_(0) @@ -65,7 +66,10 @@ void Organise::ProcessSomeFiles() { // None left? if (progress_ >= files_.count()) { task_manager_->SetTaskProgress(task_id_, progress_, files_.count()); + destination_->FinishCopy(); + if (eject_after_) + destination_->Eject(); task_manager_->SetTaskFinished(task_id_); diff --git a/src/core/organise.h b/src/core/organise.h index b00955e5e..c463e58d3 100644 --- a/src/core/organise.h +++ b/src/core/organise.h @@ -30,7 +30,7 @@ class Organise : public QObject { public: Organise(TaskManager* task_manager, MusicStorage* destination, const OrganiseFormat& format, bool copy, bool overwrite, - const QStringList& files); + const QStringList& files, bool eject_after); static const int kBatchSize; @@ -49,6 +49,7 @@ private: const bool copy_; const bool overwrite_; QStringList files_; + const bool eject_after_; bool started_; diff --git a/src/devices/connecteddevice.cpp b/src/devices/connecteddevice.cpp index 80f2fbc6f..212e19bab 100644 --- a/src/devices/connecteddevice.cpp +++ b/src/devices/connecteddevice.cpp @@ -76,3 +76,7 @@ void ConnectedDevice::InitBackendDirectory(const QString& mount_point, bool firs backend_->LoadDirectoriesAsync(); } } + +void ConnectedDevice::Eject() { + manager_->Unmount(manager_->FindDeviceById(unique_id_)); +} diff --git a/src/devices/connecteddevice.h b/src/devices/connecteddevice.h index ffa2b7e46..fe34a2f54 100644 --- a/src/devices/connecteddevice.h +++ b/src/devices/connecteddevice.h @@ -17,6 +17,8 @@ #ifndef CONNECTEDDEVICE_H #define CONNECTEDDEVICE_H +#include "core/musicstorage.h" + #include #include #include @@ -26,9 +28,8 @@ class DeviceLister; class DeviceManager; class LibraryBackend; class LibraryModel; -class MusicStorage; -class ConnectedDevice : public QObject { +class ConnectedDevice : public QObject, public virtual MusicStorage { Q_OBJECT public: @@ -42,7 +43,7 @@ public: LibraryModel* model() const { return model_; } QUrl url() const { return url_; } - virtual MusicStorage* storage() = 0; + void Eject(); signals: void TaskStarted(int id); diff --git a/src/devices/devicemanager.cpp b/src/devices/devicemanager.cpp index 6e16f9135..f0b53751f 100644 --- a/src/devices/devicemanager.cpp +++ b/src/devices/devicemanager.cpp @@ -241,7 +241,7 @@ QVariant DeviceManager::data(const QModelIndex& index, int role) const { const_cast(this)->Connect(index.row()); if (!info.device_) return QVariant(); - return QVariant::fromValue(info.device_->storage()); + return QVariant::fromValue(info.device_.get()); case Role_MountPath: if (!info.device_) diff --git a/src/devices/filesystemdevice.cpp b/src/devices/filesystemdevice.cpp index cb1051bdf..13a14d1fd 100644 --- a/src/devices/filesystemdevice.cpp +++ b/src/devices/filesystemdevice.cpp @@ -27,8 +27,8 @@ FilesystemDevice::FilesystemDevice( const QUrl& url, DeviceLister* lister, const QString& unique_id, DeviceManager* manager, int database_id, bool first_time) - : ConnectedDevice(url, lister, unique_id, manager, database_id, first_time), - FilesystemMusicStorage(url.toLocalFile()), + : FilesystemMusicStorage(url.toLocalFile()), + ConnectedDevice(url, lister, unique_id, manager, database_id, first_time), watcher_(new BackgroundThreadImplementation(this)) { // Create the library watcher diff --git a/src/devices/filesystemdevice.h b/src/devices/filesystemdevice.h index 09779f708..0306683c0 100644 --- a/src/devices/filesystemdevice.h +++ b/src/devices/filesystemdevice.h @@ -24,7 +24,7 @@ class DeviceManager; class LibraryWatcher; -class FilesystemDevice : public ConnectedDevice, public FilesystemMusicStorage { +class FilesystemDevice : public ConnectedDevice, public virtual FilesystemMusicStorage { Q_OBJECT public: @@ -36,8 +36,6 @@ public: static QStringList url_schemes() { return QStringList() << "file"; } - MusicStorage* storage() { return this; } - private: BackgroundThread* watcher_; }; diff --git a/src/devices/gpoddevice.h b/src/devices/gpoddevice.h index 02763bfcf..3e66085be 100644 --- a/src/devices/gpoddevice.h +++ b/src/devices/gpoddevice.h @@ -27,7 +27,7 @@ class GPodLoader; -class GPodDevice : public ConnectedDevice, public MusicStorage { +class GPodDevice : public ConnectedDevice, public virtual MusicStorage { Q_OBJECT public: @@ -39,8 +39,6 @@ public: static QStringList url_schemes() { return QStringList() << "ipod"; } - MusicStorage* storage() { return this; } - void StartCopy(); bool CopyToStorage(const QString &source, const QString &destination, const Song &metadata, bool overwrite, bool remove_original); diff --git a/src/library/libraryview.cpp b/src/library/libraryview.cpp index 872213c21..9e1880c38 100644 --- a/src/library/libraryview.cpp +++ b/src/library/libraryview.cpp @@ -276,7 +276,7 @@ void LibraryView::Delete() { } void LibraryView::CopyToDevice() { - organise_dialog_->SetDestinationModel(devices_->connected_devices_model()); + organise_dialog_->SetDestinationModel(devices_->connected_devices_model(), true); organise_dialog_->SetCopy(true); organise_dialog_->SetFilenames(GetSelectedFilenames()); organise_dialog_->show(); diff --git a/src/translations/ar.po b/src/translations/ar.po index 1f9d810f9..8b9f4544c 100644 --- a/src/translations/ar.po +++ b/src/translations/ar.po @@ -1299,6 +1299,9 @@ msgstr "" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "" diff --git a/src/translations/bg.po b/src/translations/bg.po index 4a1f67a10..133770860 100644 --- a/src/translations/bg.po +++ b/src/translations/bg.po @@ -1299,6 +1299,9 @@ msgstr "" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "" diff --git a/src/translations/cs.po b/src/translations/cs.po index f46d60cf3..92aff5d60 100644 --- a/src/translations/cs.po +++ b/src/translations/cs.po @@ -1303,6 +1303,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Vzorkovací frekvence" diff --git a/src/translations/da.po b/src/translations/da.po index fdeaecded..507997db7 100644 --- a/src/translations/da.po +++ b/src/translations/da.po @@ -1304,6 +1304,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Samplingsrate" diff --git a/src/translations/de.po b/src/translations/de.po index beb6e6bb7..6a1f9baa1 100644 --- a/src/translations/de.po +++ b/src/translations/de.po @@ -1318,6 +1318,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Abtastrate" diff --git a/src/translations/el.po b/src/translations/el.po index 53db388ef..c0dca0577 100644 --- a/src/translations/el.po +++ b/src/translations/el.po @@ -1320,6 +1320,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Ρυθμός δειγματοληψίας" diff --git a/src/translations/en_CA.po b/src/translations/en_CA.po index 315f2259a..1ba933770 100644 --- a/src/translations/en_CA.po +++ b/src/translations/en_CA.po @@ -1304,6 +1304,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Sample rate" diff --git a/src/translations/en_GB.po b/src/translations/en_GB.po index c52d44d52..9f9750e2d 100644 --- a/src/translations/en_GB.po +++ b/src/translations/en_GB.po @@ -1301,6 +1301,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Sample rate" diff --git a/src/translations/es.po b/src/translations/es.po index bb4d0b500..a22eb2a92 100644 --- a/src/translations/es.po +++ b/src/translations/es.po @@ -1324,6 +1324,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Tasa de muestreo" diff --git a/src/translations/fi.po b/src/translations/fi.po index b7f90bc99..26d7d2f6e 100644 --- a/src/translations/fi.po +++ b/src/translations/fi.po @@ -1301,6 +1301,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "" diff --git a/src/translations/fr.po b/src/translations/fr.po index fba6abc68..5bb5a4596 100644 --- a/src/translations/fr.po +++ b/src/translations/fr.po @@ -1311,6 +1311,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Échantillonnage" diff --git a/src/translations/gl.po b/src/translations/gl.po index 2e3dd2e33..d3f93eaf2 100644 --- a/src/translations/gl.po +++ b/src/translations/gl.po @@ -1301,6 +1301,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Taxa de mostra" diff --git a/src/translations/it.po b/src/translations/it.po index f005ce9ab..669e0a2f1 100644 --- a/src/translations/it.po +++ b/src/translations/it.po @@ -1323,6 +1323,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Campionamento" diff --git a/src/translations/kk.po b/src/translations/kk.po index 8f92fdda7..f2126cc97 100644 --- a/src/translations/kk.po +++ b/src/translations/kk.po @@ -1301,6 +1301,9 @@ msgstr "Рок" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "" diff --git a/src/translations/lt.po b/src/translations/lt.po index b411a93a5..5f6a5aac7 100644 --- a/src/translations/lt.po +++ b/src/translations/lt.po @@ -1299,6 +1299,9 @@ msgstr "" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "" diff --git a/src/translations/nb.po b/src/translations/nb.po index e3a238548..388ff579d 100644 --- a/src/translations/nb.po +++ b/src/translations/nb.po @@ -1302,6 +1302,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Samplingsrate" diff --git a/src/translations/nl.po b/src/translations/nl.po index 3277ad488..a6baf78d8 100644 --- a/src/translations/nl.po +++ b/src/translations/nl.po @@ -1318,6 +1318,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Samplerate" diff --git a/src/translations/oc.po b/src/translations/oc.po index ce834f132..3cbe25603 100644 --- a/src/translations/oc.po +++ b/src/translations/oc.po @@ -1299,6 +1299,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "" diff --git a/src/translations/pl.po b/src/translations/pl.po index 3b6118918..9fc77947c 100644 --- a/src/translations/pl.po +++ b/src/translations/pl.po @@ -1310,6 +1310,9 @@ msgstr "" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "" diff --git a/src/translations/pt.po b/src/translations/pt.po index b889b23dc..70242126e 100644 --- a/src/translations/pt.po +++ b/src/translations/pt.po @@ -1315,6 +1315,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Taxa de amostragem" diff --git a/src/translations/pt_BR.po b/src/translations/pt_BR.po index c59b000da..a8162ab36 100644 --- a/src/translations/pt_BR.po +++ b/src/translations/pt_BR.po @@ -1311,6 +1311,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Taxa de amostragem" diff --git a/src/translations/ro.po b/src/translations/ro.po index f92afdcd3..aacb3ca94 100644 --- a/src/translations/ro.po +++ b/src/translations/ro.po @@ -1300,6 +1300,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Rată de eșantionare" diff --git a/src/translations/ru.po b/src/translations/ru.po index 7b2810744..8e824b523 100644 --- a/src/translations/ru.po +++ b/src/translations/ru.po @@ -1313,6 +1313,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Частота" diff --git a/src/translations/sk.po b/src/translations/sk.po index 90863cab8..ff44457a7 100644 --- a/src/translations/sk.po +++ b/src/translations/sk.po @@ -1314,6 +1314,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Rýchlosť vzorkovania" diff --git a/src/translations/sr.po b/src/translations/sr.po index 5e2307eba..80cf5b86e 100644 --- a/src/translations/sr.po +++ b/src/translations/sr.po @@ -1304,6 +1304,9 @@ msgstr "Рок" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "узорковање" diff --git a/src/translations/sv.po b/src/translations/sv.po index 1a9950266..dc5476871 100644 --- a/src/translations/sv.po +++ b/src/translations/sv.po @@ -1304,6 +1304,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Samplingsfrekvens" diff --git a/src/translations/tr.po b/src/translations/tr.po index 98c4b206b..bf958091c 100644 --- a/src/translations/tr.po +++ b/src/translations/tr.po @@ -1305,6 +1305,9 @@ msgstr "Rock" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Örneklem oranı" diff --git a/src/translations/translations.pot b/src/translations/translations.pot index 71d88bf44..91a98c75f 100644 --- a/src/translations/translations.pot +++ b/src/translations/translations.pot @@ -1289,6 +1289,9 @@ msgstr "" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "" diff --git a/src/translations/uk.po b/src/translations/uk.po index 3905afe25..63f1bda87 100644 --- a/src/translations/uk.po +++ b/src/translations/uk.po @@ -1314,6 +1314,9 @@ msgstr "Рок" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "Частота вибірки" diff --git a/src/translations/zh_CN.po b/src/translations/zh_CN.po index 20c835d85..2e14120c1 100644 --- a/src/translations/zh_CN.po +++ b/src/translations/zh_CN.po @@ -1299,6 +1299,9 @@ msgstr "" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "采样率" diff --git a/src/translations/zh_TW.po b/src/translations/zh_TW.po index 1da5a24f1..74ea60570 100644 --- a/src/translations/zh_TW.po +++ b/src/translations/zh_TW.po @@ -1304,6 +1304,9 @@ msgstr "搖滾" msgid "Safely remove device" msgstr "" +msgid "Safely remove the device after copying" +msgstr "" + msgid "Sample rate" msgstr "取樣頻率" diff --git a/src/ui/organisedialog.cpp b/src/ui/organisedialog.cpp index a75c29a37..46b41e657 100644 --- a/src/ui/organisedialog.cpp +++ b/src/ui/organisedialog.cpp @@ -91,8 +91,10 @@ OrganiseDialog::~OrganiseDialog() { delete ui_; } -void OrganiseDialog::SetDestinationModel(QAbstractItemModel *model) { +void OrganiseDialog::SetDestinationModel(QAbstractItemModel *model, bool devices) { ui_->destination->setModel(model); + + ui_->eject_after->setVisible(devices); } void OrganiseDialog::SetUrls(const QList &urls) { @@ -196,6 +198,7 @@ void OrganiseDialog::Reset() { ui_->replace_spaces->setChecked(false); ui_->replace_the->setChecked(false); ui_->overwrite->setChecked(true); + ui_->eject_after->setChecked(false); } void OrganiseDialog::showEvent(QShowEvent *) { @@ -206,6 +209,7 @@ void OrganiseDialog::showEvent(QShowEvent *) { ui_->replace_spaces->setChecked(s.value("replace_spaces", false).toBool()); ui_->replace_the->setChecked(s.value("replace_the", false).toBool()); ui_->overwrite->setChecked(s.value("overwrite", true).toBool()); + ui_->eject_after->setChecked(s.value("eject_after", false).toBool()); QString destination = s.value("destination").toString(); int index = ui_->destination->findText(destination); @@ -223,6 +227,7 @@ void OrganiseDialog::accept() { s.setValue("replace_the", ui_->replace_the->isChecked()); s.setValue("overwrite", ui_->overwrite->isChecked()); s.setValue("destination", ui_->destination->currentText()); + s.setValue("eject_after", ui_->eject_after->isChecked()); const QModelIndex destination = ui_->destination->model()->index( ui_->destination->currentIndex(), 0); @@ -232,7 +237,8 @@ void OrganiseDialog::accept() { // It deletes itself when it's finished. const bool copy = ui_->aftercopying->currentIndex() == 0; Organise* organise = new Organise( - task_manager_, storage, format_, copy, ui_->overwrite->isChecked(), filenames_); + task_manager_, storage, format_, copy, ui_->overwrite->isChecked(), + filenames_, ui_->eject_after->isChecked()); organise->Start(); QDialog::accept(); diff --git a/src/ui/organisedialog.h b/src/ui/organisedialog.h index 467cef541..4e1283901 100644 --- a/src/ui/organisedialog.h +++ b/src/ui/organisedialog.h @@ -45,7 +45,7 @@ public: QSize sizeHint() const; - void SetDestinationModel(QAbstractItemModel* model); + void SetDestinationModel(QAbstractItemModel* model, bool devices = false); void SetUrls(const QList& urls); void SetFilenames(const QStringList& filenames); diff --git a/src/ui/organisedialog.ui b/src/ui/organisedialog.ui index 03c22e10d..47c86a740 100644 --- a/src/ui/organisedialog.ui +++ b/src/ui/organisedialog.ui @@ -7,7 +7,7 @@ 0 0 588 - 475 + 497 @@ -53,6 +53,13 @@ + + + + Safely remove the device after copying + + + @@ -150,6 +157,19 @@
widgets/linetextedit.h
+ + destination + aftercopying + eject_after + naming + insert + replace_the + replace_spaces + replace_ascii + overwrite + preview + buttonBox + @@ -161,8 +181,8 @@ accept() - 248 - 254 + 257 + 487 157 @@ -177,8 +197,8 @@ reject() - 316 - 260 + 325 + 487 286