mirror of
https://github.com/LMMS/lmms.git
synced 2026-03-04 14:18:58 -05:00
Add "Open containing folder" (#5453)
Add functionality to open the containing folder of a file that's selected in LMMS' file browser. Technical details ------------------ Add a new private method openContainingFolder to FileBrowser. Add a new action to the context menu of a selected file. This action in turn calls the added method. The current implementation of openContainingFolder delegates to QDesktopServices::openUrl with the directory of the selected file. Please note that this will only open the directory but not select the file as this is much more complicated due to different implementations that are needed for the different platforms (Linux/Windows/MacOS). Using QDesktopServices::openUrl seems to be the most simple cross platform way which uses functionality that's already available in Qt.
This commit is contained in:
@@ -125,6 +125,7 @@ private slots:
|
||||
void activateListItem( QTreeWidgetItem * item, int column );
|
||||
void openInNewInstrumentTrackBBE( void );
|
||||
void openInNewInstrumentTrackSE( void );
|
||||
void openContainingFolder();
|
||||
void sendToActiveInstrumentTrack( void );
|
||||
void updateDirectory( QTreeWidgetItem * item );
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QHBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QLineEdit>
|
||||
@@ -380,6 +381,11 @@ void FileBrowserTreeWidget::contextMenuEvent(QContextMenuEvent * e )
|
||||
"B+B Editor" ),
|
||||
this,
|
||||
SLOT( openInNewInstrumentTrackBBE() ) );
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction( QIcon(embed::getIconPixmap( "folder" )),
|
||||
tr( "Open containing folder" ),
|
||||
this,
|
||||
SLOT( openContainingFolder() ) );
|
||||
contextMenu.exec( e->globalPos() );
|
||||
m_contextMenuItem = NULL;
|
||||
}
|
||||
@@ -671,6 +677,16 @@ void FileBrowserTreeWidget::openInNewInstrumentTrackSE( void )
|
||||
|
||||
|
||||
|
||||
void FileBrowserTreeWidget::openContainingFolder()
|
||||
{
|
||||
if (m_contextMenuItem)
|
||||
{
|
||||
QFileInfo fileInfo(m_contextMenuItem->fullName());
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.dir().path()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FileBrowserTreeWidget::sendToActiveInstrumentTrack( void )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user