mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
Add a "Show in file browser..." to the library context menu as well. Fixes issue #1563
This commit is contained in:
parent
0594fc53af
commit
9086ab8ed4
@ -20,10 +20,12 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QIODevice>
|
||||
#include <QStringList>
|
||||
#include <QTemporaryFile>
|
||||
#include <QUrl>
|
||||
#include <QtDebug>
|
||||
#include <QtGlobal>
|
||||
|
||||
@ -276,6 +278,27 @@ QString GetConfigPath(ConfigPath config) {
|
||||
}
|
||||
}
|
||||
|
||||
void OpenInFileBrowser(const QStringList& filenames) {
|
||||
QSet<QString> dirs;
|
||||
|
||||
foreach (const QString& filename, filenames) {
|
||||
// Ignore things that look like URLs
|
||||
if (filename.contains("://"))
|
||||
continue;
|
||||
|
||||
if (!QFile::exists(filename))
|
||||
continue;
|
||||
|
||||
const QString directory = QFileInfo(filename).dir().path();
|
||||
|
||||
if (dirs.contains(directory))
|
||||
continue;
|
||||
dirs.insert(directory);
|
||||
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(directory));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Utilities
|
||||
|
||||
|
||||
|
@ -45,6 +45,8 @@ namespace Utilities {
|
||||
bool CopyRecursive(const QString& source, const QString& destination);
|
||||
bool Copy(QIODevice* source, QIODevice* destination);
|
||||
|
||||
void OpenInFileBrowser(const QStringList& filenames);
|
||||
|
||||
|
||||
enum ConfigPath {
|
||||
Path_Root,
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "core/deletefiles.h"
|
||||
#include "core/mimedata.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/utilities.h"
|
||||
#include "devices/devicemanager.h"
|
||||
#include "devices/devicestatefiltermodel.h"
|
||||
#include "scripting/scriptmanager.h"
|
||||
@ -265,6 +266,8 @@ void LibraryView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
tr("Edit track information..."), this, SLOT(EditTracks()));
|
||||
edit_tracks_ = context_menu_->addAction(IconLoader::Load("edit-rename"),
|
||||
tr("Edit tracks information..."), this, SLOT(EditTracks()));
|
||||
show_in_browser_ = context_menu_->addAction(IconLoader::Load("document-open-folder"),
|
||||
tr("Show in file browser..."), this, SLOT(ShowInBrowser()));
|
||||
|
||||
context_menu_->addSeparator();
|
||||
show_in_various_ = context_menu_->addAction(
|
||||
@ -579,3 +582,12 @@ QString LibraryView::GetNameForNewPlaylist(const SongList& songs) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void LibraryView::ShowInBrowser() {
|
||||
QStringList filenames;
|
||||
foreach (const Song& song, GetSelectedSongs()) {
|
||||
filenames << song.filename();
|
||||
}
|
||||
|
||||
Utilities::OpenInFileBrowser(filenames);
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
void CopyToDevice();
|
||||
void Delete();
|
||||
void EditTracks();
|
||||
void ShowInBrowser();
|
||||
void ShowInVarious();
|
||||
void NoShowInVarious();
|
||||
|
||||
@ -137,6 +138,7 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
QAction* delete_;
|
||||
QAction* edit_track_;
|
||||
QAction* edit_tracks_;
|
||||
QAction* show_in_browser_;
|
||||
QAction* show_in_various_;
|
||||
QAction* no_show_in_various_;
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "core/songloader.h"
|
||||
#include "core/stylesheetloader.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/utilities.h"
|
||||
#include "devices/devicemanager.h"
|
||||
#include "devices/devicestatefiltermodel.h"
|
||||
#include "devices/deviceview.h"
|
||||
@ -111,7 +112,6 @@
|
||||
#endif
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QFileSystemModel>
|
||||
@ -1607,29 +1607,16 @@ void MainWindow::PlaylistDelete() {
|
||||
delete_files->Start(selected_songs);
|
||||
}
|
||||
|
||||
void MainWindow::PlaylistOpenInBrowser(){
|
||||
QSet<QString> dirs;
|
||||
void MainWindow::PlaylistOpenInBrowser() {
|
||||
QStringList filenames;
|
||||
QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
|
||||
|
||||
foreach (const QModelIndex& proxy_index, proxy_indexes) {
|
||||
const QModelIndex index = playlists_->current()->proxy()->mapToSource(proxy_index);
|
||||
const QString filename =
|
||||
index.sibling(index.row(), Playlist::Column_Filename).data().toString();
|
||||
|
||||
// Ignore things that look like URLs
|
||||
if (filename.contains("://"))
|
||||
continue;
|
||||
|
||||
if (!QFile::exists(filename))
|
||||
continue;
|
||||
|
||||
const QString directory = QFileInfo(filename).dir().path();
|
||||
|
||||
if (dirs.contains(directory))
|
||||
continue;
|
||||
dirs.insert(directory);
|
||||
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(directory));
|
||||
filenames << index.sibling(index.row(), Playlist::Column_Filename).data().toString();
|
||||
}
|
||||
|
||||
Utilities::OpenInFileBrowser(filenames);
|
||||
}
|
||||
|
||||
void MainWindow::DeleteFinished(const SongList& songs_with_errors) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user