Add Edit file information and Show in file browser actions to the files view. Fixes issue 2559
This commit is contained in:
parent
facb366017
commit
281d69581c
@ -477,9 +477,9 @@ void LibraryView::Delete() {
|
||||
void LibraryView::EditTracks() {
|
||||
if(!edit_tag_dialog_) {
|
||||
edit_tag_dialog_.reset(new EditTagDialog(cover_providers_, this));
|
||||
edit_tag_dialog_->SetTagCompleter(library_->backend());
|
||||
}
|
||||
edit_tag_dialog_->SetSongs(GetSelectedSongs());
|
||||
edit_tag_dialog_->SetTagCompleter(library_->backend());
|
||||
edit_tag_dialog_->show();
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@
|
||||
#include <QtConcurrentRun>
|
||||
#include <QtDebug>
|
||||
|
||||
#include <limits>
|
||||
|
||||
const char* EditTagDialog::kHintText = QT_TR_NOOP("(different across multiple songs)");
|
||||
const char* EditTagDialog::kSettingsGroup = "EditTagDialog";
|
||||
|
||||
@ -231,8 +233,18 @@ void EditTagDialog::SetSongsFinished() {
|
||||
return;
|
||||
|
||||
data_ = watcher->result();
|
||||
if (data_.count() == 0)
|
||||
if (data_.count() == 0) {
|
||||
// If there were no valid songs, disable everything
|
||||
ui_->song_list->setEnabled(false);
|
||||
ui_->tab_widget->setEnabled(false);
|
||||
|
||||
// Show a summary with empty information
|
||||
UpdateSummaryTab(Song());
|
||||
ui_->tab_widget->setCurrentWidget(ui_->summary_tab);
|
||||
|
||||
SetSongListVisibility(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the filenames to the list
|
||||
foreach (const Data& data, data_) {
|
||||
@ -244,10 +256,13 @@ void EditTagDialog::SetSongsFinished() {
|
||||
ui_->song_list->selectAll();
|
||||
|
||||
// Hide the list if there's only one song in it
|
||||
const bool multiple = data_.count() != 1;
|
||||
ui_->song_list->setVisible(multiple);
|
||||
previous_button_->setEnabled(multiple);
|
||||
next_button_->setEnabled(multiple);
|
||||
SetSongListVisibility(data_.count() != 1);
|
||||
}
|
||||
|
||||
void EditTagDialog::SetSongListVisibility(bool visible) {
|
||||
ui_->song_list->setVisible(visible);
|
||||
previous_button_->setEnabled(visible);
|
||||
next_button_->setEnabled(visible);
|
||||
}
|
||||
|
||||
void EditTagDialog::SetTagCompleter(LibraryBackend* backend) {
|
||||
@ -390,6 +405,15 @@ static void SetText(QLabel* label, int value, const QString& suffix, const QStri
|
||||
label->setText(value <= 0 ? def : (QString::number(value) + " " + suffix));
|
||||
}
|
||||
|
||||
static void SetDate(QLabel* label, uint time) {
|
||||
if (time == std::numeric_limits<uint>::max()) { // -1
|
||||
label->setText(QObject::tr("Unknown"));
|
||||
} else {
|
||||
label->setText(QDateTime::fromTime_t(time).toString(
|
||||
QLocale::system().dateTimeFormat(QLocale::LongFormat)));
|
||||
}
|
||||
}
|
||||
|
||||
void EditTagDialog::UpdateSummaryTab(const Song& song) {
|
||||
cover_art_id_ = cover_loader_->Worker()->LoadImageAsync(song);
|
||||
|
||||
@ -420,11 +444,15 @@ void EditTagDialog::UpdateSummaryTab(const Song& song) {
|
||||
SetText(ui_->bpm, song.bpm(), tr("bpm"));
|
||||
SetText(ui_->samplerate, song.samplerate(), "Hz");
|
||||
SetText(ui_->bitrate, song.bitrate(), tr("kbps"));
|
||||
ui_->mtime->setText(QDateTime::fromTime_t(song.mtime()).toString(
|
||||
QLocale::system().dateTimeFormat(QLocale::LongFormat)));
|
||||
ui_->ctime->setText(QDateTime::fromTime_t(song.ctime()).toString(
|
||||
QLocale::system().dateTimeFormat(QLocale::LongFormat)));
|
||||
ui_->filesize->setText(Utilities::PrettySize(song.filesize()));
|
||||
SetDate(ui_->mtime, song.mtime());
|
||||
SetDate(ui_->ctime, song.ctime());
|
||||
|
||||
if (song.filesize() == -1) {
|
||||
ui_->filesize->setText(tr("Unknown"));
|
||||
} else {
|
||||
ui_->filesize->setText(Utilities::PrettySize(song.filesize()));
|
||||
}
|
||||
|
||||
ui_->filetype->setText(song.TextForFiletype());
|
||||
|
||||
if (song.url().scheme() == "file")
|
||||
@ -586,11 +614,19 @@ void EditTagDialog::UpdateCoverOf(const Song& selected, const QModelIndexList& s
|
||||
}
|
||||
|
||||
void EditTagDialog::NextSong() {
|
||||
if (ui_->song_list->count() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int row = (ui_->song_list->currentRow() + 1) % ui_->song_list->count();
|
||||
ui_->song_list->setCurrentRow(row);
|
||||
}
|
||||
|
||||
void EditTagDialog::PreviousSong() {
|
||||
if (ui_->song_list->count() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int row = (ui_->song_list->currentRow() - 1 + ui_->song_list->count()) % ui_->song_list->count();
|
||||
ui_->song_list->setCurrentRow(row);
|
||||
}
|
||||
|
@ -129,6 +129,7 @@ private:
|
||||
void UpdateStatisticsTab(const Song& song);
|
||||
|
||||
bool SetLoading(const QString& message);
|
||||
void SetSongListVisibility(bool visible);
|
||||
|
||||
// Called by QtConcurrentRun
|
||||
QList<Data> LoadData(const SongList& songs) const;
|
||||
|
@ -329,6 +329,7 @@ MainWindow::MainWindow(
|
||||
connect(file_view_, SIGNAL(PathChanged(QString)), SLOT(FilePathChanged(QString)));
|
||||
connect(file_view_, SIGNAL(CopyToLibrary(QList<QUrl>)), SLOT(CopyFilesToLibrary(QList<QUrl>)));
|
||||
connect(file_view_, SIGNAL(MoveToLibrary(QList<QUrl>)), SLOT(MoveFilesToLibrary(QList<QUrl>)));
|
||||
connect(file_view_, SIGNAL(EditTags(QList<QUrl>)), SLOT(EditFileTags(QList<QUrl>)));
|
||||
connect(file_view_, SIGNAL(CopyToDevice(QList<QUrl>)), SLOT(CopyFilesToDevice(QList<QUrl>)));
|
||||
file_view_->SetTaskManager(task_manager_);
|
||||
|
||||
@ -1462,7 +1463,6 @@ void MainWindow::EditTracks() {
|
||||
|
||||
EnsureEditTagDialogCreated();
|
||||
edit_tag_dialog_->SetSongs(songs, items);
|
||||
edit_tag_dialog_->SetTagCompleter(library_->model()->backend());
|
||||
edit_tag_dialog_->show();
|
||||
}
|
||||
|
||||
@ -1786,21 +1786,21 @@ void MainWindow::NowPlayingWidgetPositionChanged(bool above_status_bar) {
|
||||
ui_->status_bar->show();
|
||||
}
|
||||
|
||||
void MainWindow::CopyFilesToLibrary(const QList<QUrl> &urls) {
|
||||
void MainWindow::CopyFilesToLibrary(const QList<QUrl>& urls) {
|
||||
organise_dialog_->SetDestinationModel(library_->model()->directory_model());
|
||||
organise_dialog_->SetUrls(urls);
|
||||
organise_dialog_->SetCopy(true);
|
||||
organise_dialog_->show();
|
||||
}
|
||||
|
||||
void MainWindow::MoveFilesToLibrary(const QList<QUrl> &urls) {
|
||||
void MainWindow::MoveFilesToLibrary(const QList<QUrl>& urls) {
|
||||
organise_dialog_->SetDestinationModel(library_->model()->directory_model());
|
||||
organise_dialog_->SetUrls(urls);
|
||||
organise_dialog_->SetCopy(false);
|
||||
organise_dialog_->show();
|
||||
}
|
||||
|
||||
void MainWindow::CopyFilesToDevice(const QList<QUrl> &urls) {
|
||||
void MainWindow::CopyFilesToDevice(const QList<QUrl>& urls) {
|
||||
organise_dialog_->SetDestinationModel(devices_->connected_devices_model(), true);
|
||||
organise_dialog_->SetCopy(true);
|
||||
if (organise_dialog_->SetUrls(urls))
|
||||
@ -1811,6 +1811,22 @@ void MainWindow::CopyFilesToDevice(const QList<QUrl> &urls) {
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::EditFileTags(const QList<QUrl>& urls) {
|
||||
EnsureEditTagDialogCreated();
|
||||
|
||||
SongList songs;
|
||||
foreach (const QUrl& url, urls) {
|
||||
Song song;
|
||||
song.set_url(url);
|
||||
song.set_valid(true);
|
||||
song.set_filetype(Song::Type_Mpeg);
|
||||
songs << song;
|
||||
}
|
||||
|
||||
edit_tag_dialog_->SetSongs(songs);
|
||||
edit_tag_dialog_->show();
|
||||
}
|
||||
|
||||
void MainWindow::PlaylistCopyToLibrary() {
|
||||
PlaylistOrganiseSelected(true);
|
||||
}
|
||||
@ -1979,6 +1995,8 @@ void MainWindow::EnsureEditTagDialogCreated() {
|
||||
edit_tag_dialog_.reset(new EditTagDialog(cover_providers_));
|
||||
connect(edit_tag_dialog_.get(), SIGNAL(accepted()), SLOT(EditTagDialogAccepted()));
|
||||
connect(edit_tag_dialog_.get(), SIGNAL(Error(QString)), SLOT(ShowErrorDialog(QString)));
|
||||
|
||||
edit_tag_dialog_->SetTagCompleter(library_->model()->backend());
|
||||
}
|
||||
|
||||
void MainWindow::ShowAboutDialog() {
|
||||
|
@ -182,6 +182,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
void CopyFilesToLibrary(const QList<QUrl>& urls);
|
||||
void MoveFilesToLibrary(const QList<QUrl>& urls);
|
||||
void CopyFilesToDevice(const QList<QUrl>& urls);
|
||||
void EditFileTags(const QList<QUrl>& urls);
|
||||
|
||||
void AddToPlaylist(QMimeData* data);
|
||||
void AddToPlaylist(QAction* action);
|
||||
|
@ -65,6 +65,7 @@ FileView::FileView(QWidget* parent)
|
||||
connect(ui_->list, SIGNAL(MoveToLibrary(QList<QUrl>)), SIGNAL(MoveToLibrary(QList<QUrl>)));
|
||||
connect(ui_->list, SIGNAL(CopyToDevice(QList<QUrl>)), SIGNAL(CopyToDevice(QList<QUrl>)));
|
||||
connect(ui_->list, SIGNAL(Delete(QStringList)), SLOT(Delete(QStringList)));
|
||||
connect(ui_->list, SIGNAL(EditTags(QList<QUrl>)), SIGNAL(EditTags(QList<QUrl>)));
|
||||
|
||||
QString filter(FileView::kFileFilter);
|
||||
filter_list_ << filter.split(" ");
|
||||
|
@ -57,6 +57,7 @@ class FileView : public QWidget {
|
||||
void CopyToLibrary(const QList<QUrl>& urls);
|
||||
void MoveToLibrary(const QList<QUrl>& urls);
|
||||
void CopyToDevice(const QList<QUrl>& urls);
|
||||
void EditTags(const QList<QUrl>& urls);
|
||||
|
||||
private slots:
|
||||
void FileUp();
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "fileviewlist.h"
|
||||
#include "core/mimedata.h"
|
||||
#include "core/utilities.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
@ -43,6 +44,13 @@ FileViewList::FileViewList(QWidget* parent)
|
||||
tr("Copy to device..."), this, SLOT(CopyToDeviceSlot()));
|
||||
menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."),
|
||||
this, SLOT(DeleteSlot()));
|
||||
|
||||
menu_->addSeparator();
|
||||
menu_->addAction(IconLoader::Load("edit-rename"),
|
||||
tr("Edit track information..."), this, SLOT(EditTagsSlot()));
|
||||
menu_->addAction(IconLoader::Load("document-open-folder"),
|
||||
tr("Show in file browser..."), this, SLOT(ShowInBrowser()));
|
||||
|
||||
setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
}
|
||||
|
||||
@ -120,6 +128,10 @@ void FileViewList::DeleteSlot() {
|
||||
emit Delete(FilenamesFromSelection());
|
||||
}
|
||||
|
||||
void FileViewList::EditTagsSlot() {
|
||||
emit EditTags(UrlListFromSelection());
|
||||
}
|
||||
|
||||
void FileViewList::mousePressEvent(QMouseEvent* e) {
|
||||
QListView::mousePressEvent(e);
|
||||
|
||||
@ -134,3 +146,7 @@ void FileViewList::mousePressEvent(QMouseEvent* e) {
|
||||
emit AddToPlaylist(data);
|
||||
}
|
||||
}
|
||||
|
||||
void FileViewList::ShowInBrowser() {
|
||||
Utilities::OpenInFileBrowser(UrlListFromSelection());
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ class FileViewList : public QListView {
|
||||
void MoveToLibrary(const QList<QUrl>& urls);
|
||||
void CopyToDevice(const QList<QUrl>& urls);
|
||||
void Delete(const QStringList& filenames);
|
||||
void EditTags(const QList<QUrl>& urls);
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent* e);
|
||||
@ -49,6 +50,8 @@ class FileViewList : public QListView {
|
||||
void MoveToLibrarySlot();
|
||||
void CopyToDeviceSlot();
|
||||
void DeleteSlot();
|
||||
void EditTagsSlot();
|
||||
void ShowInBrowser();
|
||||
|
||||
QStringList FilenamesFromSelection() const;
|
||||
QList<QUrl> UrlListFromSelection() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user