From bd607b6c549e5210a914a956d491468d24c61779 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 18 Feb 2016 15:40:08 +0100 Subject: [PATCH 1/2] DRY in ContextMenu --- src/libtomahawk/ContextMenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libtomahawk/ContextMenu.cpp b/src/libtomahawk/ContextMenu.cpp index efd76c0ac..f68cea5c5 100644 --- a/src/libtomahawk/ContextMenu.cpp +++ b/src/libtomahawk/ContextMenu.cpp @@ -51,7 +51,7 @@ ContextMenu::ContextMenu( QWidget* parent ) m_sigmap = new QSignalMapper( this ); connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( onTriggered( int ) ) ); - m_supportedActions = ActionPlay | ActionQueue | ActionPlaylist | ActionCopyLink | ActionLove | ActionStopAfter | ActionPage | ActionEditMetadata | ActionSend; + clear(); } From ff34afb4e38d4908c30515dd1af4db5b86b442a4 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 18 Feb 2016 15:40:31 +0100 Subject: [PATCH 2/2] Fix #425: add "Open in Folder in File Manager..." context menu to local results --- src/libtomahawk/ContextMenu.cpp | 21 ++++++++++++++++++++- src/libtomahawk/ContextMenu.h | 31 ++++++++++++++++--------------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/libtomahawk/ContextMenu.cpp b/src/libtomahawk/ContextMenu.cpp index f68cea5c5..3f6d238bd 100644 --- a/src/libtomahawk/ContextMenu.cpp +++ b/src/libtomahawk/ContextMenu.cpp @@ -37,6 +37,9 @@ #include "utils/ImageRegistry.h" #include "utils/Logger.h" +#include +#include + using namespace Tomahawk; @@ -69,7 +72,7 @@ ContextMenu::clear() m_albums.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& queries ) 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 ) m_sigmap->setMapping( addAction( queries.count() > 1 ? tr( "&Remove Items" ) : tr( "&Remove Item" ) ), ActionDelete ); @@ -394,6 +404,15 @@ ContextMenu::onTriggered( int action ) } 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: emit triggered( action ); } diff --git a/src/libtomahawk/ContextMenu.h b/src/libtomahawk/ContextMenu.h index d7b188a69..592602fb5 100644 --- a/src/libtomahawk/ContextMenu.h +++ b/src/libtomahawk/ContextMenu.h @@ -37,21 +37,22 @@ Q_OBJECT public: enum MenuActions { - ActionPlay = 1, - ActionQueue = 2, - ActionDelete = 4, - ActionCopyLink = 8, - ActionLove = 16, - ActionStopAfter = 32, - ActionPage = 64, - ActionTrackPage = 128, - ActionArtistPage = 256, - ActionAlbumPage = 512, - ActionEditMetadata = 1024, - ActionPlaylist = 2048, - ActionSend = 4096, - ActionMarkListened = 8192, - ActionDownload = 16384 + ActionPlay = 1, + ActionQueue = 2, + ActionDelete = 4, + ActionCopyLink = 8, + ActionLove = 16, + ActionStopAfter = 32, + ActionPage = 64, + ActionTrackPage = 128, + ActionArtistPage = 256, + ActionAlbumPage = 512, + ActionEditMetadata = 1024, + ActionPlaylist = 2048, + ActionSend = 4096, + ActionMarkListened = 8192, + ActionDownload = 16384, + ActionOpenFileManager = 32768 }; explicit ContextMenu( QWidget* parent = 0 );