Enable organise without gstreamer

This commit is contained in:
Jonas Kvinge 2019-01-06 16:48:23 +01:00
parent 14cfd1a34e
commit ffd16e5401
11 changed files with 80 additions and 115 deletions

View File

@ -273,6 +273,11 @@ set(SOURCES
scrobbler/librefmscrobbler.cpp
scrobbler/listenbrainzscrobbler.cpp
organise/organise.cpp
organise/organiseformat.cpp
organise/organisedialog.cpp
organise/organiseerrordialog.cpp
)
set(HEADERS
@ -439,6 +444,10 @@ set(HEADERS
scrobbler/librefmscrobbler.h
scrobbler/listenbrainzscrobbler.h
organise/organise.h
organise/organisedialog.h
organise/organiseerrordialog.h
)
set(UI
@ -492,6 +501,9 @@ set(UI
internet/internetsearchview.ui
organise/organisedialog.ui
organise/organiseerrordialog.ui
)
set(RESOURCES ../data/data.qrc ../data/icons.qrc)
@ -765,13 +777,9 @@ optional_source(HAVE_LIBPULSE
engine/pulsedevicefinder.cpp
)
# MusicBrainz, Organise and transcode require GStreamer
# MusicBrainz and transcoder require GStreamer
optional_source(HAVE_GSTREAMER
SOURCES
organise/organise.cpp
organise/organiseformat.cpp
organise/organisedialog.cpp
organise/organiseerrordialog.cpp
transcoder/transcoder.cpp
transcoder/transcodedialog.cpp
transcoder/transcoderoptionsdialog.cpp
@ -785,17 +793,12 @@ SOURCES
transcoder/transcoderoptionsmp3.cpp
settings/transcodersettingspage.cpp
HEADERS
organise/organise.h
organise/organisedialog.h
organise/organiseerrordialog.h
transcoder/transcoder.h
transcoder/transcodedialog.h
transcoder/transcoderoptionsdialog.h
transcoder/transcoderoptionsmp3.h
settings/transcodersettingspage.h
UI
organise/organisedialog.ui
organise/organiseerrordialog.ui
transcoder/transcodedialog.ui
transcoder/transcodelogdialog.ui
transcoder/transcoderoptionsaac.ui

View File

@ -73,9 +73,7 @@
# include "device/devicestatefiltermodel.h"
#endif
#include "dialogs/edittagdialog.h"
#ifdef HAVE_GSTREAMER
#include "organise/organisedialog.h"
#endif
#include "settings/collectionsettingspage.h"
CollectionItemDelegate::CollectionItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {}
@ -460,14 +458,12 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) {
add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, SLOT(AddToPlaylistEnqueue()));
add_to_playlist_enqueue_next_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue to play next"), this, SLOT(AddToPlaylistEnqueueNext()));
#ifdef HAVE_GSTREAMER
context_menu_->addSeparator();
organise_ = context_menu_->addAction(IconLoader::Load("edit-copy"), tr("Organise files..."), this, SLOT(Organise()));
#ifndef Q_OS_WIN
copy_to_device_ = context_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, SLOT(CopyToDevice()));
#endif
//delete_ = context_menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."), this, SLOT(Delete()));
#endif
context_menu_->addSeparator();
edit_track_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit track information..."), this, SLOT(EditTracks()));
@ -482,7 +478,7 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) {
context_menu_->addMenu(filter_->menu());
#if defined(HAVE_GSTREAMER) && !defined(Q_OS_WIN)
#ifndef Q_OS_WIN
copy_to_device_->setDisabled(app_->device_manager()->connected_devices_model()->rowCount() == 0);
connect(app_->device_manager()->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)), copy_to_device_, SLOT(setDisabled(bool)));
#endif
@ -520,25 +516,20 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) {
edit_track_->setVisible(regular_editable <= 1);
edit_track_->setEnabled(regular_editable == 1);
// only when no smart playlists selected
#ifdef HAVE_GSTREAMER
organise_->setVisible(regular_elements_only);
#ifndef Q_OS_WIN
copy_to_device_->setVisible(regular_elements_only);
#endif
//delete_->setVisible(regular_elements_only);
#endif
show_in_various_->setVisible(regular_elements_only);
no_show_in_various_->setVisible(regular_elements_only);
// only when all selected items are editable
#ifdef HAVE_GSTREAMER
organise_->setEnabled(regular_elements == regular_editable);
#ifndef Q_OS_WIN
copy_to_device_->setEnabled(regular_elements == regular_editable);
#endif
//delete_->setEnabled(regular_elements == regular_editable);
#endif
context_menu_->popup(e->globalPos());
@ -661,7 +652,6 @@ SongList CollectionView::GetSelectedSongs() const {
}
#ifdef HAVE_GSTREAMER
void CollectionView::Organise() {
if (!organise_dialog_)
@ -675,7 +665,6 @@ void CollectionView::Organise() {
QMessageBox::warning(this, tr("Error"), tr("None of the selected songs were suitable for copying to a device"));
}
}
#endif
void CollectionView::EditTracks() {
@ -687,7 +676,6 @@ void CollectionView::EditTracks() {
}
#ifdef HAVE_GSTREAMER
void CollectionView::CopyToDevice() {
#ifndef Q_OS_WIN
if (!organise_dialog_)
@ -699,7 +687,6 @@ void CollectionView::CopyToDevice() {
organise_dialog_->show();
#endif
}
#endif
void CollectionView::FilterReturnPressed() {

View File

@ -52,9 +52,7 @@ class QPaintEvent;
class Application;
class CollectionFilterWidget;
class EditTagDialog;
#ifdef HAVE_GSTREAMER
class OrganiseDialog;
#endif
class CollectionItemDelegate : public QStyledItemDelegate {
Q_OBJECT
@ -119,10 +117,8 @@ signals:
void AddToPlaylistEnqueue();
void AddToPlaylistEnqueueNext();
void OpenInNewPlaylist();
#ifdef HAVE_GSTREAMER
void Organise();
void CopyToDevice();
#endif
void EditTracks();
void ShowInBrowser();
void ShowInVarious();
@ -151,11 +147,9 @@ signals:
QAction *add_to_playlist_enqueue_;
QAction *add_to_playlist_enqueue_next_;
QAction *open_in_new_playlist_;
#ifdef HAVE_GSTREAMER
QAction *organise_;
#ifndef Q_OS_WIN
QAction *copy_to_device_;
#endif
#endif
QAction *delete_;
QAction *edit_track_;
@ -164,9 +158,7 @@ signals:
QAction *show_in_various_;
QAction *no_show_in_various_;
#ifdef HAVE_GSTREAMER
std::unique_ptr<OrganiseDialog> organise_dialog_;
#endif
std::unique_ptr<EditTagDialog> edit_tag_dialog_;
bool is_in_keyboard_search_;

View File

@ -73,9 +73,7 @@
# include "device/devicestatefiltermodel.h"
#endif
#include "dialogs/edittagdialog.h"
#ifdef HAVE_GSTREAMER
#include "organise/organisedialog.h"
#endif
#include "settings/collectionsettingspage.h"
#include "contextview.h"
@ -367,12 +365,10 @@ void ContextAlbumsView::contextMenuEvent(QContextMenuEvent *e) {
context_menu_->addSeparator();
add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, SLOT(AddToPlaylistEnqueue()));
#ifdef HAVE_GSTREAMER
context_menu_->addSeparator();
organise_ = context_menu_->addAction(IconLoader::Load("edit-copy"), tr("Organise files..."), this, SLOT(Organise()));
#ifndef Q_OS_WIN
copy_to_device_ = context_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, SLOT(CopyToDevice()));
#endif
#endif
context_menu_->addSeparator();
@ -382,7 +378,7 @@ void ContextAlbumsView::contextMenuEvent(QContextMenuEvent *e) {
context_menu_->addSeparator();
#if defined(HAVE_GSTREAMER) && !defined(Q_OS_WIN)
#ifndef Q_OS_WIN
copy_to_device_->setDisabled(app_->device_manager()->connected_devices_model()->rowCount() == 0);
connect(app_->device_manager()->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)), copy_to_device_, SLOT(setDisabled(bool)));
#endif
@ -405,9 +401,7 @@ void ContextAlbumsView::contextMenuEvent(QContextMenuEvent *e) {
// TODO: check if custom plugin actions should be enabled / visible
const int songs_selected = regular_elements;
#ifdef HAVE_GSTREAMER
const bool regular_elements_only = songs_selected == regular_elements && regular_elements > 0;
#endif
// in all modes
load_->setEnabled(songs_selected);
@ -419,19 +413,15 @@ void ContextAlbumsView::contextMenuEvent(QContextMenuEvent *e) {
edit_track_->setVisible(regular_editable <= 1);
edit_track_->setEnabled(regular_editable == 1);
#ifdef HAVE_GSTREAMER
organise_->setVisible(regular_elements_only);
#ifndef Q_OS_WIN
copy_to_device_->setVisible(regular_elements_only);
#endif
#endif
// only when all selected items are editable
#ifdef HAVE_GSTREAMER
organise_->setEnabled(regular_elements == regular_editable);
#ifndef Q_OS_WIN
copy_to_device_->setEnabled(regular_elements == regular_editable);
#endif
#endif
context_menu_->popup(e->globalPos());
@ -488,7 +478,6 @@ SongList ContextAlbumsView::GetSelectedSongs() const {
return model_->GetChildSongs(selected_indexes);
}
#ifdef HAVE_GSTREAMER
void ContextAlbumsView::Organise() {
if (!organise_dialog_)
@ -502,7 +491,6 @@ void ContextAlbumsView::Organise() {
QMessageBox::warning(this, tr("Error"), tr("None of the selected songs were suitable for copying to a device"));
}
}
#endif
void ContextAlbumsView::EditTracks() {
@ -514,7 +502,6 @@ void ContextAlbumsView::EditTracks() {
}
#ifdef HAVE_GSTREAMER
void ContextAlbumsView::CopyToDevice() {
#ifndef Q_OS_WIN
if (!organise_dialog_)
@ -526,7 +513,6 @@ void ContextAlbumsView::CopyToDevice() {
organise_dialog_->show();
#endif
}
#endif
void ContextAlbumsView::ShowInBrowser() {

View File

@ -47,9 +47,7 @@
class Application;
class EditTagDialog;
#ifdef HAVE_GSTREAMER
class OrganiseDialog;
#endif
class ContextAlbumsModel;
class ContextItemDelegate : public QStyledItemDelegate {
@ -101,12 +99,8 @@ signals:
void AddToPlaylist();
void AddToPlaylistEnqueue();
void OpenInNewPlaylist();
#ifdef HAVE_GSTREAMER
void Organise();
//#ifndef Q_OS_WIN
void CopyToDevice();
//#endif
#endif
void EditTracks();
void ShowInBrowser();
@ -124,20 +118,16 @@ signals:
QAction *add_to_playlist_;
QAction *add_to_playlist_enqueue_;
QAction *open_in_new_playlist_;
#ifdef HAVE_GSTREAMER
QAction *organise_;
#ifndef Q_OS_WIN
QAction *copy_to_device_;
#endif
#endif
QAction *delete_;
QAction *edit_track_;
QAction *edit_tracks_;
QAction *show_in_browser_;
#ifdef HAVE_GSTREAMER
std::unique_ptr<OrganiseDialog> organise_dialog_;
#endif
std::unique_ptr<EditTagDialog> edit_tag_dialog_;
bool is_in_keyboard_search_;

View File

@ -84,9 +84,7 @@
#include "dialogs/console.h"
#include "dialogs/trackselectiondialog.h"
#include "dialogs/edittagdialog.h"
#ifdef HAVE_GSTREAMER
# include "organise/organisedialog.h"
#endif
#include "organise/organisedialog.h"
#include "widgets/fancytabwidget.h"
#include "widgets/playingwidget.h"
#include "widgets/sliderwidget.h"
@ -201,13 +199,11 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
//organise_dialog_(new OrganiseDialog(app_->task_manager())),
equalizer_(new Equalizer),
#ifdef HAVE_GSTREAMER
organise_dialog_([=]() {
OrganiseDialog *dialog = new OrganiseDialog(app->task_manager());
dialog->SetDestinationModel(app->collection()->model()->directory_model());
return dialog;
}),
#endif
#ifdef HAVE_STREAM_TIDAL
tidal_search_view_(new InternetSearchView(app_, app_->tidal_search(), TidalSettingsPage::kSettingsGroup, SettingsDialog::Page_Tidal, this)),
#endif
@ -315,9 +311,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
#endif
playlist_list_->SetApplication(app_);
#ifdef HAVE_GSTREAMER
organise_dialog_->SetDestinationModel(app_->collection()->model()->directory_model());
#endif
// Icons
qLog(Debug) << "Creating UI";
@ -364,7 +358,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
ui_->action_update_collection->setIcon(IconLoader::Load("view-refresh"));
ui_->action_full_collection_scan->setIcon(IconLoader::Load("view-refresh"));
ui_->action_settings->setIcon(IconLoader::Load("configure"));
// Scrobble
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble-disabled", 22));
@ -412,11 +406,19 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
connect(ui_->action_add_folder, SIGNAL(triggered()), SLOT(AddFolder()));
connect(ui_->action_cover_manager, SIGNAL(triggered()), SLOT(ShowCoverManager()));
connect(ui_->action_equalizer, SIGNAL(triggered()), equalizer_.get(), SLOT(show()));
#if defined(HAVE_GSTREAMER)
connect(ui_->action_transcoder, SIGNAL(triggered()), SLOT(ShowTranscodeDialog()));
#else
ui_->action_transcoder->setDisabled(true);
#endif
connect(ui_->action_jump, SIGNAL(triggered()), ui_->playlist->view(), SLOT(JumpToCurrentlyPlayingTrack()));
connect(ui_->action_update_collection, SIGNAL(triggered()), app_->collection(), SLOT(IncrementalScan()));
connect(ui_->action_full_collection_scan, SIGNAL(triggered()), app_->collection(), SLOT(FullScan()));
#if defined(HAVE_GSTREAMER)
connect(ui_->action_add_files_to_transcoder, SIGNAL(triggered()), SLOT(AddFilesToTranscoder()));
#else
ui_->action_add_files_to_transcoder->setDisabled(true);
#endif
connect(ui_->action_toggle_scrobbling, SIGNAL(triggered()), app_->scrobbler(), SLOT(ToggleScrobbling()));
connect(app_->scrobbler(), SIGNAL(ErrorMessage(QString)), SLOT(ShowErrorDialog(QString)));
@ -571,16 +573,16 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
playlist_menu_->addAction(ui_->action_renumber_tracks);
playlist_menu_->addAction(ui_->action_selection_set_value);
playlist_menu_->addAction(ui_->action_auto_complete_tags);
playlist_menu_->addAction(ui_->action_add_files_to_transcoder);
playlist_menu_->addSeparator();
#ifdef HAVE_GSTREAMER
playlist_menu_->addAction(ui_->action_add_files_to_transcoder);
#endif
playlist_menu_->addSeparator();
#if defined(HAVE_GSTREAMER) && !defined(Q_OS_WIN)
playlist_copy_to_device_ = playlist_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, SLOT(PlaylistCopyToDevice()));
#endif
playlist_copy_to_collection_ = playlist_menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy to collection..."), this, SLOT(PlaylistCopyToCollection()));
playlist_move_to_collection_ = playlist_menu_->addAction(IconLoader::Load("go-jump"), tr("Move to collection..."), this, SLOT(PlaylistMoveToCollection()));
playlist_organise_ = playlist_menu_->addAction(IconLoader::Load("edit-copy"), tr("Organise files..."), this, SLOT(PlaylistMoveToCollection()));
#ifndef Q_OS_WIN
playlist_copy_to_device_ = playlist_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, SLOT(PlaylistCopyToDevice()));
#endif
#endif
playlist_open_in_browser_ = playlist_menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, SLOT(PlaylistOpenInBrowser()));
playlist_open_in_browser_->setVisible(false);
playlist_show_in_collection_ = playlist_menu_->addAction(IconLoader::Load("edit-find"), tr("Show in collection..."), this, SLOT(ShowInCollection()));
@ -1428,14 +1430,12 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex
ui_->action_remove_from_playlist->setEnabled(!selection.isEmpty());
playlist_show_in_collection_->setVisible(false);
#ifdef HAVE_GSTREAMER
playlist_copy_to_collection_->setVisible(false);
playlist_move_to_collection_->setVisible(false);
playlist_organise_->setVisible(false);
#ifndef Q_OS_WIN
#if defined(HAVE_GSTREAMER) && !defined(Q_OS_WIN)
playlist_copy_to_device_->setVisible(false);
#endif
#endif
playlist_organise_->setVisible(false);
playlist_open_in_browser_->setVisible(false);
if (selected < 1) {
@ -1495,18 +1495,14 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex
// Is it a collection item?
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
if (item->IsLocalCollectionItem() && item->Metadata().id() != -1) {
#ifdef HAVE_GSTREAMER
playlist_organise_->setVisible(editable);
#endif
playlist_show_in_collection_->setVisible(editable);
playlist_open_in_browser_->setVisible(true);
}
#ifdef HAVE_GSTREAMER
else {
playlist_copy_to_collection_->setVisible(editable);
playlist_move_to_collection_->setVisible(editable);
}
#endif
#if defined(HAVE_GSTREAMER) && !defined(Q_OS_WIN)
playlist_copy_to_device_->setVisible(editable);
@ -1941,7 +1937,6 @@ void MainWindow::PlayingWidgetPositionChanged(bool above_status_bar) {
ui_->status_bar->show();
}
#ifdef HAVE_GSTREAMER
void MainWindow::CopyFilesToCollection(const QList<QUrl> &urls) {
organise_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
organise_dialog_->SetUrls(urls);
@ -1957,7 +1952,7 @@ void MainWindow::MoveFilesToCollection(const QList<QUrl> &urls) {
}
void MainWindow::CopyFilesToDevice(const QList<QUrl> &urls) {
#ifndef Q_OS_WIN
#if defined(HAVE_GSTREAMER) && !defined(Q_OS_WIN)
organise_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
organise_dialog_->SetCopy(true);
if (organise_dialog_->SetUrls(urls))
@ -1967,10 +1962,8 @@ void MainWindow::CopyFilesToDevice(const QList<QUrl> &urls) {
}
#endif
}
#endif
void MainWindow::EditFileTags(const QList<QUrl> &urls) {
//EnsureEditTagDialogCreated();
SongList songs;
for (const QUrl &url : urls) {
@ -1985,7 +1978,6 @@ void MainWindow::EditFileTags(const QList<QUrl> &urls) {
edit_tag_dialog_->show();
}
#ifdef HAVE_GSTREAMER
void MainWindow::PlaylistCopyToCollection() {
PlaylistOrganiseSelected(true);
}
@ -2009,7 +2001,6 @@ void MainWindow::PlaylistOrganiseSelected(bool copy) {
organise_dialog_->SetCopy(copy);
organise_dialog_->show();
}
#endif
void MainWindow::PlaylistOpenInBrowser() {
@ -2055,9 +2046,8 @@ void MainWindow::PlaylistSkip() {
}
#if defined(HAVE_GSTREAMER)
void MainWindow::PlaylistCopyToDevice() {
#if !defined(Q_OS_WIN)
#ifndef Q_OS_WIN
QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
SongList songs;
@ -2075,7 +2065,6 @@ void MainWindow::PlaylistCopyToDevice() {
}
#endif
}
#endif
void MainWindow::ChangeCollectionQueryMode(QAction *action) {
if (action == collection_show_duplicates_) {

View File

@ -186,14 +186,10 @@ signals:
void AddFilesToTranscoder();
#endif
#ifdef HAVE_GSTREAMER
void PlaylistCopyToCollection();
void PlaylistMoveToCollection();
#ifndef Q_OS_WIN_
void PlaylistCopyToDevice();
#endif
void PlaylistOrganiseSelected(bool copy);
#endif
void PlaylistOpenInBrowser();
void ShowInCollection();
@ -206,11 +202,9 @@ signals:
void SongChanged(const Song& song);
void VolumeChanged(int volume);
#ifdef HAVE_GSTREAMER
void CopyFilesToCollection(const QList<QUrl>& urls);
void MoveFilesToCollection(const QList<QUrl>& urls);
void CopyFilesToDevice(const QList<QUrl>& urls);
#endif
void EditFileTags(const QList<QUrl>& urls);
void AddToPlaylist(QMimeData *data);
@ -327,9 +321,7 @@ signals:
Lazy<TranscodeDialog> transcode_dialog_;
#endif
Lazy<ErrorDialog> error_dialog_;
#ifdef HAVE_GSTREAMER
Lazy<OrganiseDialog> organise_dialog_;
#endif
#if defined(HAVE_GSTREAMER) && defined(HAVE_CHROMAPRINT)
std::unique_ptr<TagFetcher> tag_fetcher_;
@ -352,12 +344,10 @@ signals:
QAction *playlist_undoredo_;
QAction *playlist_organise_;
QAction *playlist_show_in_collection_;
#ifdef HAVE_GSTREAMER
QAction *playlist_copy_to_collection_;
QAction *playlist_move_to_collection_;
#ifndef Q_OS_WIN
QAction *playlist_copy_to_device_;
#endif
#endif
QAction *playlist_open_in_browser_;
QAction *playlist_queue_;

View File

@ -210,10 +210,8 @@ void DeviceView::SetApplication(Application *app) {
properties_dialog_->SetDeviceManager(app_->device_manager());
#ifdef HAVE_GSTREAMER
organise_dialog_.reset(new OrganiseDialog(app_->task_manager()));
organise_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
#endif
}
@ -235,9 +233,7 @@ void DeviceView::contextMenuEvent(QContextMenuEvent *e) {
open_in_new_playlist_ = collection_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist()));
collection_menu_->addSeparator();
#ifdef HAVE_GSTREAMER
organise_action_ = collection_menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy to collection..."), this, SLOT(Organise()));
#endif
delete_action_ = collection_menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from device..."), this, SLOT(Delete()));
}
@ -409,7 +405,6 @@ void DeviceView::OpenInNewPlaylist() {
emit AddToPlaylistSignal(data);
}
#ifdef HAVE_GSTREAMER
void DeviceView::Delete() {
if (selectedIndexes().isEmpty()) return;
@ -444,14 +439,12 @@ void DeviceView::Organise() {
organise_dialog_->show();
}
#endif
void DeviceView::Unmount() {
QModelIndex device_idx = MapToDevice(menu_index_);
app_->device_manager()->Unmount(device_idx.row());
}
#ifdef HAVE_GSTREAMER
void DeviceView::DeleteFinished(const SongList &songs_with_errors) {
if (songs_with_errors.isEmpty()) return;
@ -461,7 +454,6 @@ void DeviceView::DeleteFinished(const SongList &songs_with_errors) {
// It deletes itself when the user closes it
}
#endif
bool DeviceView::CanRecursivelyExpand(const QModelIndex &index) const {
// Never expand devices

View File

@ -85,17 +85,13 @@ class DeviceView : public AutoExpandingTreeView {
void Load();
void AddToPlaylist();
void OpenInNewPlaylist();
#ifdef HAVE_GSTREAMER
void Organise();
void Delete();
#endif
void DeviceConnected(int row);
void DeviceDisconnected(int row);
#ifdef HAVE_GSTREAMER
void DeleteFinished(const SongList &songs_with_errors);
#endif
// AutoExpandingTreeView
bool CanRecursivelyExpand(const QModelIndex &index) const;
@ -112,9 +108,7 @@ class DeviceView : public AutoExpandingTreeView {
QSortFilterProxyModel *sort_model_;
std::unique_ptr<DeviceProperties> properties_dialog_;
#ifdef HAVE_GSTREAMER
std::unique_ptr<OrganiseDialog> organise_dialog_;
#endif
QMenu *device_menu_;
QAction *eject_action_;

View File

@ -35,19 +35,25 @@
#include "core/taskmanager.h"
#include "core/musicstorage.h"
#include "organise.h"
#include "transcoder/transcoder.h"
#ifdef HAVE_GSTREAMER
# include "transcoder/transcoder.h"
#endif
class OrganiseFormat;
using std::placeholders::_1;
const int Organise::kBatchSize = 10;
#ifdef HAVE_GSTREAMER
const int Organise::kTranscodeProgressInterval = 500;
#endif
Organise::Organise(TaskManager *task_manager, std::shared_ptr<MusicStorage> destination, const OrganiseFormat &format, bool copy, bool overwrite, bool mark_as_listened, const NewSongInfoList &songs_info, bool eject_after)
: thread_(nullptr),
task_manager_(task_manager),
#ifdef HAVE_GSTREAMER
transcoder_(new Transcoder(this)),
#endif
destination_(destination),
format_(format),
copy_(copy),
@ -55,7 +61,9 @@ Organise::Organise(TaskManager *task_manager, std::shared_ptr<MusicStorage> dest
mark_as_listened_(mark_as_listened),
eject_after_(eject_after),
task_count_(songs_info.count()),
#ifdef HAVE_GSTREAMER
transcode_suffix_(1),
#endif
tasks_complete_(0),
started_(false),
task_id_(0),
@ -78,7 +86,9 @@ void Organise::Start() {
thread_ = new QThread;
connect(thread_, SIGNAL(started()), SLOT(ProcessSomeFiles()));
#ifdef HAVE_GSTREAMER
connect(transcoder_, SIGNAL(JobComplete(QString, QString, bool)), SLOT(FileTranscoded(QString, QString, bool)));
#endif
moveToThread(thread_);
thread_->start();
@ -87,7 +97,9 @@ void Organise::Start() {
void Organise::ProcessSomeFiles() {
if (!started_) {
#ifdef HAVE_GSTREAMER
transcode_temp_name_.open();
#endif
if (!destination_->StartCopy(&supported_filetypes_)) {
// Failed to start - mark everything as failed :(
@ -99,12 +111,14 @@ void Organise::ProcessSomeFiles() {
// None left?
if (tasks_pending_.isEmpty()) {
#ifdef HAVE_GSTREAMER
if (!tasks_transcoding_.isEmpty()) {
// Just wait - FileTranscoded will start us off again in a little while
qLog(Debug) << "Waiting for transcoding jobs";
transcode_progress_timer_.start(kTranscodeProgressInterval, this);
return;
}
#endif
UpdateProgress();
@ -137,6 +151,7 @@ void Organise::ProcessSomeFiles() {
Song song = task.song_info_.song_;
if (!song.is_valid()) continue;
#ifdef HAVE_GSTREAMER
// Maybe this file is one that's been transcoded already?
if (!task.transcoded_filename_.isEmpty()) {
qLog(Debug) << "This file has already been transcoded";
@ -174,6 +189,7 @@ void Organise::ProcessSomeFiles() {
continue;
}
}
#endif
MusicStorage::CopyJob job;
job.source_ = task.transcoded_filename_.isEmpty() ? task.song_info_.song_.url().toLocalFile() : task.transcoded_filename_;
@ -204,6 +220,7 @@ void Organise::ProcessSomeFiles() {
}
#ifdef HAVE_GSTREAMER
Song::FileType Organise::CheckTranscode(Song::FileType original_type) const {
if (original_type == Song::FileType_Stream) return Song::FileType_Unknown;
@ -230,6 +247,7 @@ Song::FileType Organise::CheckTranscode(Song::FileType original_type) const {
return Song::FileType_Unknown;
}
#endif
void Organise::SetSongProgress(float progress, bool transcoded) {
@ -243,12 +261,14 @@ void Organise::UpdateProgress() {
const int total = task_count_ * 100;
#ifdef HAVE_GSTREAMER
// Update transcoding progress
QMap<QString, float> transcode_progress = transcoder_->GetProgress();
for (const QString &filename : transcode_progress.keys()) {
if (!tasks_transcoding_.contains(filename)) continue;
tasks_transcoding_[filename].transcode_progress_ = transcode_progress[filename];
}
#endif
// Count the progress of all tasks that are in the queue.
// Files that need transcoding total 50 for the transcode and 50 for the copy, files that only need to be copied total 100.
@ -257,9 +277,11 @@ void Organise::UpdateProgress() {
for (const Task &task : tasks_pending_) {
progress += qBound(0, static_cast<int>(task.transcode_progress_ * 50), 50);
}
#ifdef HAVE_GSTREAMER
for (const Task &task : tasks_transcoding_.values()) {
progress += qBound(0, static_cast<int>(task.transcode_progress_ * 50), 50);
}
#endif
// Add the progress of the track that's currently copying
progress += current_copy_progress_;
@ -268,6 +290,7 @@ void Organise::UpdateProgress() {
}
#ifdef HAVE_GSTREAMER
void Organise::FileTranscoded(const QString &input, const QString &output, bool success) {
qLog(Info) << "File finished" << input << success;
@ -283,14 +306,17 @@ void Organise::FileTranscoded(const QString &input, const QString &output, bool
QTimer::singleShot(0, this, SLOT(ProcessSomeFiles()));
}
#endif
void Organise::timerEvent(QTimerEvent *e) {
QObject::timerEvent(e);
#ifdef HAVE_GSTREAMER
if (e->timerId() == transcode_progress_timer_.timerId()) {
UpdateProgress();
}
#endif
}

View File

@ -44,7 +44,9 @@ class QTimerEvent;
class MusicStorage;
class TaskManager;
#ifdef HAVE_GSTREAMER
class Transcoder;
#endif
class Organise : public QObject {
Q_OBJECT
@ -60,7 +62,9 @@ class Organise : public QObject {
Organise(TaskManager *task_manager, std::shared_ptr<MusicStorage> destination, const OrganiseFormat &format, bool copy, bool overwrite, bool mark_as_listened, const NewSongInfoList &songs, bool eject_after);
static const int kBatchSize;
#ifdef HAVE_GSTREAMER
static const int kTranscodeProgressInterval;
#endif
void Start();
@ -73,19 +77,25 @@ signals:
private slots:
void ProcessSomeFiles();
#ifdef HAVE_GSTREAMER
void FileTranscoded(const QString &input, const QString &output, bool success);
#endif
private:
void SetSongProgress(float progress, bool transcoded = false);
void UpdateProgress();
#ifdef HAVE_GSTREAMER
Song::FileType CheckTranscode(Song::FileType original_type) const;
#endif
private:
struct Task {
explicit Task(const NewSongInfo &song_info = NewSongInfo()) : song_info_(song_info), transcode_progress_(0.0) {}
explicit Task(const NewSongInfo &song_info = NewSongInfo()) :
song_info_(song_info),
transcode_progress_(0.0)
{}
NewSongInfo song_info_;
float transcode_progress_;
QString transcoded_filename_;
QString new_extension_;
@ -95,7 +105,9 @@ signals:
QThread *thread_;
QThread *original_thread_;
TaskManager *task_manager_;
#ifdef HAVE_GSTREAMER
Transcoder *transcoder_;
#endif
std::shared_ptr<MusicStorage> destination_;
QList<Song::FileType> supported_filetypes_;
@ -106,12 +118,16 @@ signals:
const bool eject_after_;
int task_count_;
#ifdef HAVE_GSTREAMER
QBasicTimer transcode_progress_timer_;
QTemporaryFile transcode_temp_name_;
int transcode_suffix_;
#endif
QList<Task> tasks_pending_;
#ifdef HAVE_GSTREAMER
QMap<QString, Task> tasks_transcoding_;
#endif
int tasks_complete_;
bool started_;