mirror of https://code.videolan.org/videolan/vlc
macosx/library: add right-click menu
This commit is contained in:
parent
787defaa5e
commit
57c2c46285
|
@ -151,6 +151,7 @@
|
|||
7DFBDCA82269E77500B700A5 /* VLCLibraryController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DFBDCA72269E77500B700A5 /* VLCLibraryController.m */; };
|
||||
7DFBDCAB2269E77F00B700A5 /* VLCLibraryModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DFBDCAA2269E77F00B700A5 /* VLCLibraryModel.m */; };
|
||||
7DFBDCAE2269ED0C00B700A5 /* VLCLibraryDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DFBDCAD2269ED0C00B700A5 /* VLCLibraryDataSource.m */; };
|
||||
7DFBDCB1226A518400B700A5 /* VLCLibraryMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DFBDCB0226A518400B700A5 /* VLCLibraryMenuController.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
|
@ -512,6 +513,8 @@
|
|||
7DFBDCAA2269E77F00B700A5 /* VLCLibraryModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryModel.m; sourceTree = "<group>"; };
|
||||
7DFBDCAC2269ED0C00B700A5 /* VLCLibraryDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryDataSource.h; sourceTree = "<group>"; };
|
||||
7DFBDCAD2269ED0C00B700A5 /* VLCLibraryDataSource.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryDataSource.m; sourceTree = "<group>"; };
|
||||
7DFBDCAF226A518400B700A5 /* VLCLibraryMenuController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryMenuController.h; sourceTree = "<group>"; };
|
||||
7DFBDCB0226A518400B700A5 /* VLCLibraryMenuController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryMenuController.m; sourceTree = "<group>"; };
|
||||
8E49720006417F6800370C9F /* VLCInformationWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCInformationWindowController.h; sourceTree = "<group>"; };
|
||||
8E49720106417F6800370C9F /* VLCInformationWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCInformationWindowController.m; sourceTree = "<group>"; };
|
||||
8E55FB7F0459B0FD00FB3317 /* VLCOutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCOutput.h; sourceTree = "<group>"; };
|
||||
|
@ -924,6 +927,8 @@
|
|||
7DFBDCAA2269E77F00B700A5 /* VLCLibraryModel.m */,
|
||||
7DFBDCAC2269ED0C00B700A5 /* VLCLibraryDataSource.h */,
|
||||
7DFBDCAD2269ED0C00B700A5 /* VLCLibraryDataSource.m */,
|
||||
7DFBDCAF226A518400B700A5 /* VLCLibraryMenuController.h */,
|
||||
7DFBDCB0226A518400B700A5 /* VLCLibraryMenuController.m */,
|
||||
);
|
||||
path = library;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1594,6 +1599,7 @@
|
|||
7D0F63FF2201F63400FDB91F /* VLCPlaylistTableCellView.m in Sources */,
|
||||
1C3113D11E508C6900D4DD76 /* prefs.m in Sources */,
|
||||
1C3113D31E508C6900D4DD76 /* VLCResumeDialogController.m in Sources */,
|
||||
7DFBDCB1226A518400B700A5 /* VLCLibraryMenuController.m in Sources */,
|
||||
1C3113D51E508C6900D4DD76 /* VLCTextfieldPanelController.m in Sources */,
|
||||
7DFBDCAE2269ED0C00B700A5 /* VLCLibraryDataSource.m in Sources */,
|
||||
1C3113D71E508C6900D4DD76 /* VLCPopupPanelController.m in Sources */,
|
||||
|
|
|
@ -50,6 +50,8 @@ libmacosx_plugin_la_SOURCES = \
|
|||
gui/macosx/library/VLCLibraryController.m \
|
||||
gui/macosx/library/VLCLibraryDataSource.h \
|
||||
gui/macosx/library/VLCLibraryDataSource.m \
|
||||
gui/macosx/library/VLCLibraryMenuController.h \
|
||||
gui/macosx/library/VLCLibraryMenuController.m \
|
||||
gui/macosx/library/VLCLibraryModel.h \
|
||||
gui/macosx/library/VLCLibraryModel.m \
|
||||
gui/macosx/library/VLCLibraryWindow.h \
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="242" height="291"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<collectionView selectable="YES" id="B8x-e8-7zp">
|
||||
<collectionView selectable="YES" id="B8x-e8-7zp" customClass="VLCLibraryCollectionView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="242" height="291"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<collectionViewFlowLayout key="collectionViewLayout" minimumInteritemSpacing="10" minimumLineSpacing="10" id="Rag-cM-k1g">
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*****************************************************************************
|
||||
* VLCLibraryMenuController.h: MacOS X interface module
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2019 VLC authors and VideoLAN
|
||||
*
|
||||
* Authors: Felix Paul Kühne <fkuehne # videolan -dot- org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface VLCLibraryMenuController : NSObject
|
||||
|
||||
@property (readwrite, weak) NSCollectionView *libraryCollectionView;
|
||||
|
||||
- (void)popupMenuWithEvent:(NSEvent *)theEvent forView:(NSView *)theView;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,90 @@
|
|||
/*****************************************************************************
|
||||
* VLCLibraryMenuController.m: MacOS X interface module
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2019 VLC authors and VideoLAN
|
||||
*
|
||||
* Authors: Felix Paul Kühne <fkuehne # videolan -dot- org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
#import "VLCLibraryMenuController.h"
|
||||
|
||||
#import "main/VLCMain.h"
|
||||
#import "library/VLCLibraryController.h"
|
||||
#import "library/VLCLibraryModel.h"
|
||||
|
||||
#import "extensions/NSString+Helpers.h"
|
||||
|
||||
@interface VLCLibraryMenuController ()
|
||||
{
|
||||
NSMenu *_libraryMenu;
|
||||
NSIndexPath *_actionIndexPath;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation VLCLibraryMenuController
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_libraryMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||
[_libraryMenu addItemWithTitle:_NS("Play") action:@selector(play:) keyEquivalent:@""];
|
||||
[[_libraryMenu itemAtIndex:0] setTarget:self];
|
||||
[_libraryMenu addItemWithTitle:_NS("Add Media...") action:@selector(addMedia:) keyEquivalent:@""];
|
||||
[[_libraryMenu itemAtIndex:1] setTarget:self];
|
||||
[_libraryMenu addItemWithTitle:_NS("Reveal in Finder") action:@selector(revealInFinder:) keyEquivalent:@""];
|
||||
[[_libraryMenu itemAtIndex:2] setTarget:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)popupMenuWithEvent:(NSEvent *)theEvent forView:(NSView *)theView
|
||||
{
|
||||
_actionIndexPath = [self.libraryCollectionView indexPathForItemAtPoint:[NSEvent mouseLocation]];
|
||||
|
||||
[NSMenu popUpContextMenu:_libraryMenu withEvent:theEvent forView:theView];
|
||||
}
|
||||
|
||||
#pragma mark - actions
|
||||
|
||||
- (void)play:(id)sender
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)addMedia:(id)sender
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)revealInFinder:(id)sender
|
||||
{
|
||||
VLCMediaLibraryMediaItem *mediaItem = [[[[VLCMain sharedInstance] libraryController] libraryModel] mediaItemAtIndexPath:_actionIndexPath];
|
||||
if (mediaItem == nil) {
|
||||
return;
|
||||
}
|
||||
VLCMediaLibraryFile *firstFile = mediaItem.files.firstObject;
|
||||
|
||||
if (firstFile) {
|
||||
NSURL *URL = [NSURL URLWithString:firstFile.MRL];
|
||||
if (URL) {
|
||||
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:@[URL]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -30,6 +30,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@end
|
||||
|
||||
@interface VLCLibraryCollectionView : NSCollectionView
|
||||
@end
|
||||
|
||||
@interface VLCLibraryWindow : VLCVideoWindowCommon
|
||||
|
||||
@property (readwrite, weak) IBOutlet NSSegmentedControl *segmentedTitleControl;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#import "library/VLCLibraryDataSource.h"
|
||||
#import "library/VLCLibraryCollectionViewItem.h"
|
||||
#import "library/VLCLibraryModel.h"
|
||||
#import "library/VLCLibraryMenuController.h"
|
||||
|
||||
#import "windows/mainwindow/VLCControlsBarCommon.h"
|
||||
#import "windows/video/VLCFSPanelController.h"
|
||||
|
@ -209,3 +210,36 @@ static const float f_playlist_row_height = 72.;
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface VLCLibraryCollectionView()
|
||||
{
|
||||
VLCLibraryMenuController *_menuController;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation VLCLibraryCollectionView
|
||||
|
||||
-(void)mouseDown:(NSEvent *)theEvent
|
||||
{
|
||||
if (theEvent.modifierFlags & NSControlKeyMask) {
|
||||
if (!_menuController) {
|
||||
_menuController = [[VLCLibraryMenuController alloc] init];
|
||||
}
|
||||
[_menuController popupMenuWithEvent:theEvent forView:self];
|
||||
}
|
||||
|
||||
[super mouseDown:theEvent];
|
||||
}
|
||||
|
||||
- (void)rightMouseDown:(NSEvent *)theEvent
|
||||
{
|
||||
if (!_menuController) {
|
||||
_menuController = [[VLCLibraryMenuController alloc] init];
|
||||
}
|
||||
[_menuController popupMenuWithEvent:theEvent forView:self];
|
||||
|
||||
[super rightMouseDown:theEvent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -468,6 +468,8 @@ modules/gui/macosx/library/VLCLibraryController.h
|
|||
modules/gui/macosx/library/VLCLibraryController.m
|
||||
modules/gui/macosx/library/VLCLibraryDataSource.h
|
||||
modules/gui/macosx/library/VLCLibraryDataSource.m
|
||||
modules/gui/macosx/library/VLCLibraryMenuController.h
|
||||
modules/gui/macosx/library/VLCLibraryMenuController.m
|
||||
modules/gui/macosx/library/VLCLibraryModel.h
|
||||
modules/gui/macosx/library/VLCLibraryModel.m
|
||||
modules/gui/macosx/library/VLCLibraryWindow.h
|
||||
|
|
Loading…
Reference in New Issue