Commit 8da3155e authored by Luke Horwell's avatar Luke Horwell Committed by Albert Astals Cid
Browse files

Add "Open Containing Folder" action

parent 2b5c814c
Pipeline #61041 passed with stage
in 9 minutes and 4 seconds
......@@ -32,6 +32,7 @@
#include <ktoggleaction.h>
#include <QCursor>
#include <QDesktopServices>
#include <QDir>
#include <QDirIterator>
#include <QHash>
......@@ -39,6 +40,7 @@
#include <QFile>
#include <QFileDialog>
#include <QHeaderView>
#include <QList>
#include <QResizeEvent>
#include <QMouseEvent>
#include <QKeyEvent>
......@@ -558,6 +560,37 @@ void Playlist::slotRefresh()
QApplication::restoreOverrideCursor();
}
void Playlist::slotOpenItemDir()
{
PlaylistItemList itemList = selectedItems();
QList<QUrl> pathList;
for(auto &item : itemList) {
QUrl path = QUrl::fromLocalFile(item->file().fileInfo().absoluteDir().absolutePath());
if(!pathList.contains(path))
pathList.append(path);
}
if (pathList.length() > 4) {
if(KMessageBox::warningContinueCancel(
this,
i18n("You are about to open %1 directories. Are you sure you want to continue?", pathList.length()),
i18n("Open Containing Folder")
) == KMessageBox::Cancel)
{
return;
}
}
QApplication::setOverrideCursor(Qt::WaitCursor);
for(auto &path : pathList) {
QDesktopServices::openUrl(path);
processEvents();
}
QApplication::restoreOverrideCursor();
}
void Playlist::slotRenameFile()
{
FileRenamer renamer;
......@@ -1690,6 +1723,7 @@ void Playlist::createPlaylistRMBMenu()
m_rmbEdit = m_rmbMenu->addAction(i18n("Edit"));
m_rmbMenu->addAction(action("refresh"));
m_rmbMenu->addAction(action("openItemDir"));
m_rmbMenu->addAction(action("removeItem"));
m_rmbMenu->addSeparator();
......
......@@ -364,6 +364,11 @@ public slots:
*/
virtual void slotRefresh();
/**
* Opens the containing folder of the selected files.
*/
virtual void slotOpenItemDir();
void slotGuessTagInfo(TagGuesser::Type type);
/**
......
......@@ -473,6 +473,11 @@ void PlaylistCollection::refreshItems()
visiblePlaylist()->slotRefresh();
}
void PlaylistCollection::openItemDir()
{
visiblePlaylist()->slotOpenItemDir();
}
void PlaylistCollection::renameItems()
{
visiblePlaylist()->slotRenameFile();
......@@ -977,6 +982,8 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection)
"removeItem", "edit-delete");
createAction(i18n("Refresh"), &PlaylistCollection::refreshItems,
"refresh", "view-refresh");
createAction(i18n("Open Containing Folder"), &PlaylistCollection::openItemDir,
"openItemDir", "stock_folder");
createAction(i18n("&Rename File"), &PlaylistCollection::renameItems,
"renameFile", "document-save-as",
QKeySequence(Qt::CTRL + Qt::Key_R));
......
......@@ -105,6 +105,7 @@ public:
void removeItems();
void refreshItems();
void openItemDir();
void renameItems();
void addCovers(bool fromFile);
void addLocalCover();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment