mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Merge pull request #442 from tomahawk-player/open-in-file-manager
Add "Open File in File Manager..." context menu
This commit is contained in:
@@ -37,6 +37,9 @@
|
|||||||
#include "utils/ImageRegistry.h"
|
#include "utils/ImageRegistry.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
@@ -51,7 +54,7 @@ ContextMenu::ContextMenu( QWidget* parent )
|
|||||||
m_sigmap = new QSignalMapper( this );
|
m_sigmap = new QSignalMapper( this );
|
||||||
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( onTriggered( int ) ) );
|
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( onTriggered( int ) ) );
|
||||||
|
|
||||||
m_supportedActions = ActionPlay | ActionQueue | ActionPlaylist | ActionCopyLink | ActionLove | ActionStopAfter | ActionPage | ActionEditMetadata | ActionSend;
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +72,7 @@ ContextMenu::clear()
|
|||||||
m_albums.clear();
|
m_albums.clear();
|
||||||
m_artists.clear();
|
m_artists.clear();
|
||||||
|
|
||||||
m_supportedActions = ActionPlay | ActionQueue | ActionPlaylist | ActionCopyLink | ActionLove | ActionStopAfter | ActionPage | ActionEditMetadata | ActionSend;
|
m_supportedActions = ActionPlay | ActionQueue | ActionPlaylist | ActionCopyLink | ActionLove | ActionStopAfter | ActionPage | ActionEditMetadata | ActionSend | ActionOpenFileManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -239,6 +242,13 @@ ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
|
|||||||
m_sigmap->setMapping( addAction( tr( "Mark as &Listened" ) ), ActionMarkListened );
|
m_sigmap->setMapping( addAction( tr( "Mark as &Listened" ) ), ActionMarkListened );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addSeparator();
|
||||||
|
|
||||||
|
if ( m_supportedActions & ActionOpenFileManager && queries.length() == 1 && m_queries.first()->results().first()->resolvedByCollection()->isLocal() )
|
||||||
|
{
|
||||||
|
m_sigmap->setMapping( addAction( tr( "Open Folder in File Manager..." ) ), ActionOpenFileManager );
|
||||||
|
}
|
||||||
|
|
||||||
if ( m_supportedActions & ActionDelete )
|
if ( m_supportedActions & ActionDelete )
|
||||||
m_sigmap->setMapping( addAction( queries.count() > 1 ? tr( "&Remove Items" ) : tr( "&Remove Item" ) ), ActionDelete );
|
m_sigmap->setMapping( addAction( queries.count() > 1 ? tr( "&Remove Items" ) : tr( "&Remove Item" ) ), ActionDelete );
|
||||||
|
|
||||||
@@ -394,6 +404,15 @@ ContextMenu::onTriggered( int action )
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ActionOpenFileManager:
|
||||||
|
{
|
||||||
|
result_ptr result = m_queries.first()->results().first();
|
||||||
|
QString path = QFileInfo( result->url() ).path();
|
||||||
|
tLog() << Q_FUNC_INFO << "open directory" << path;
|
||||||
|
QDesktopServices::openUrl( path );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
emit triggered( action );
|
emit triggered( action );
|
||||||
}
|
}
|
||||||
|
@@ -37,21 +37,22 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
enum MenuActions
|
enum MenuActions
|
||||||
{
|
{
|
||||||
ActionPlay = 1,
|
ActionPlay = 1,
|
||||||
ActionQueue = 2,
|
ActionQueue = 2,
|
||||||
ActionDelete = 4,
|
ActionDelete = 4,
|
||||||
ActionCopyLink = 8,
|
ActionCopyLink = 8,
|
||||||
ActionLove = 16,
|
ActionLove = 16,
|
||||||
ActionStopAfter = 32,
|
ActionStopAfter = 32,
|
||||||
ActionPage = 64,
|
ActionPage = 64,
|
||||||
ActionTrackPage = 128,
|
ActionTrackPage = 128,
|
||||||
ActionArtistPage = 256,
|
ActionArtistPage = 256,
|
||||||
ActionAlbumPage = 512,
|
ActionAlbumPage = 512,
|
||||||
ActionEditMetadata = 1024,
|
ActionEditMetadata = 1024,
|
||||||
ActionPlaylist = 2048,
|
ActionPlaylist = 2048,
|
||||||
ActionSend = 4096,
|
ActionSend = 4096,
|
||||||
ActionMarkListened = 8192,
|
ActionMarkListened = 8192,
|
||||||
ActionDownload = 16384
|
ActionDownload = 16384,
|
||||||
|
ActionOpenFileManager = 32768
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit ContextMenu( QWidget* parent = 0 );
|
explicit ContextMenu( QWidget* parent = 0 );
|
||||||
|
Reference in New Issue
Block a user