Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
cd371307 by Claudio Cambra at 2022-08-04T06:43:51+00:00
macosx: Remember last opened library view
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
6 changed files:
- modules/gui/macosx/UI/VLCLibraryWindow.xib
- modules/gui/macosx/library/VLCLibraryAudioDataSource.m
- modules/gui/macosx/library/VLCLibraryWindow.h
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/main/VLCMain.h
- modules/gui/macosx/main/VLCMain.m
Changes:
=====================================
modules/gui/macosx/UI/VLCLibraryWindow.xib
=====================================
@@ -14,7 +14,7 @@
</customObject>
<customObject id="-1" userLabel="First Responder"
customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
- <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO"
autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO"
frameAutosaveName="librarywindow" animationBehavior="default"
titlebarAppearsTransparent="YES" toolbarStyle="unified"
titleVisibility="hidden" id="QvC-M9-y7g" customClass="VLCLibraryWindow">
+ <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO"
autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO"
frameAutosaveName="librarywindow" animationBehavior="default"
tabbingIdentifier="VLCLibraryWindow" titlebarAppearsTransparent="YES"
toolbarStyle="unified" titleVisibility="hidden" id="QvC-M9-y7g"
customClass="VLCLibraryWindow">
<windowStyleMask key="styleMask" titled="YES" closable="YES"
miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES"
rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="896" height="456"/>
@@ -598,8 +598,8 @@
<segmentedCell key="cell" borderStyle="border"
alignment="left" style="rounded" trackingMode="selectOne" id="jcw-1T-HPS">
<font key="font" metaFont="system"/>
<segments>
- <segment image="NSIconViewTemplate"/>
- <segment image="NSListViewTemplate"
selected="YES" tag="1"/>
+ <segment image="NSIconViewTemplate"
selected="YES"/>
+ <segment image="NSListViewTemplate"
tag="1"/>
</segments>
</segmentedCell>
</segmentedControl>
=====================================
modules/gui/macosx/library/VLCLibraryAudioDataSource.m
=====================================
@@ -143,6 +143,8 @@
_collectionSelectionTableView.doubleAction =
@selector(collectionSelectionDoubleClickAction:);
_currentSelectedSegment = -1; // Force segmentedControlAction to do what
it must
+ _segmentedControl.selectedSegment = 0;
+
_placeholderImageNames = @[@"placeholder-group2", @"placeholder-music",
@"placeholder-music", @"placeholder-music"];
_placeholderLabelStrings = @[
_NS("Your favorite artists will appear here.\nGo to the Browse section
to add artists you love."),
=====================================
modules/gui/macosx/library/VLCLibraryWindow.h
=====================================
@@ -37,13 +37,13 @@ NS_ASSUME_NONNULL_BEGIN
@class VLCPlaylistSortingMenuController;
@class VLCFSPanelController;
-@interface VLCLibraryWindowController : NSWindowController
+@interface VLCLibraryWindowController : NSWindowController<NSWindowRestoration>
- (instancetype)initWithLibraryWindow;
@end
-@interface VLCLibraryWindow : VLCVideoWindowCommon
+@interface VLCLibraryWindow :
VLCVideoWindowCommon<NSUserInterfaceItemIdentification>
@property (readwrite, weak) IBOutlet NSSegmentedControl *segmentedTitleControl;
@property (readwrite, weak) IBOutlet NSToolbarItem
*segmentedTitleControlToolbarItem;
=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -249,7 +249,7 @@ static void addShadow(NSImageView *__unsafe_unretained
imageView)
_fspanel = [[VLCFSPanelController alloc] init];
[_fspanel showWindow:self];
- _currentSelectedSegment = 5; // To enforce action on the selected segment
+ _currentSelectedSegment = -1; // To enforce action on the selected segment
_segmentedTitleControl.segmentCount = 4;
[_segmentedTitleControl setTarget:self];
[_segmentedTitleControl setLabel:_NS("Video") forSegment:0];
@@ -257,7 +257,6 @@ static void addShadow(NSImageView *__unsafe_unretained
imageView)
[_segmentedTitleControl setLabel:_NS("Browse") forSegment:2];
[_segmentedTitleControl setLabel:_NS("Streams") forSegment:3];
[_segmentedTitleControl sizeToFit];
- [_segmentedTitleControl setSelectedSegment:0];
_playlistDragDropView.dropTarget = self;
_playlistCounterTextField.useStrongRounding = YES;
@@ -403,6 +402,14 @@ static void addShadow(NSImageView *__unsafe_unretained
imageView)
var_DelCallback(libvlc, "intf-show", ShowController, (__bridge void
*)self);
}
+- (void)encodeRestorableStateWithCoder:(NSCoder *)coder
+{
+ [super encodeRestorableStateWithCoder:coder];
+ [coder encodeInteger:_segmentedTitleControl.selectedSegment
forKey:@"macosx-library-selected-segment"];
+ [coder encodeInteger:_gridVsListSegmentedControl.selectedSegment
forKey:@"macosx-library-view-mode-selected-segment"];
+ [coder
encodeInteger:_libraryAudioDataSource.segmentedControl.selectedSegment
forKey:@"macosx-library-audio-view-selected-segment"];
+}
+
#pragma mark - appearance setters
- (void)observeValueForKeyPath:(NSString *)keyPath
@@ -502,6 +509,8 @@ static void addShadow(NSImageView *__unsafe_unretained
imageView)
_currentSelectedSegment = _segmentedTitleControl.selectedSegment;
_currentSelectedViewModeSegment =
_gridVsListSegmentedControl.selectedSegment;
+ [self invalidateRestorableState];
+
switch (_segmentedTitleControl.selectedSegment) {
case 0:
[self showVideoLibrary];
@@ -720,7 +729,7 @@ static void addShadow(NSImageView *__unsafe_unretained
imageView)
- (IBAction)goToBrowseSection:(id)sender
{
[_segmentedTitleControl setSelected:YES forSegment:2];
- [self segmentedControlAction:nil];
+ [self segmentedControlAction:_segmentedTitleControl];
}
#pragma mark - split view delegation
@@ -907,7 +916,7 @@ static void addShadow(NSImageView *__unsafe_unretained
imageView)
- (void)windowDidLoad
{
VLCLibraryWindow *window = (VLCLibraryWindow *)self.window;
- [window setRestorable:NO];
+ [window setRestorationClass:[self class]];
[window setExcludedFromWindowsMenu:YES];
[window setAcceptsMouseMovedEvents:YES];
[window setContentMinSize:NSMakeSize(VLCLibraryWindowMinimalWidth,
VLCLibraryWindowMinimalHeight)];
@@ -920,7 +929,32 @@ static void addShadow(NSImageView *__unsafe_unretained
imageView)
// Toggling the playlist is simplest.
[window togglePlaylist];
[window togglePlaylist];
+}
+
++ (void)restoreWindowWithIdentifier:(NSUserInterfaceItemIdentifier)identifier
+ state:(NSCoder *)state
+ completionHandler:(void (^)(NSWindow *, NSError
*))completionHandler
+{
+ if([VLCMain sharedInstance].libraryWindowController == nil) {
+ [VLCMain sharedInstance].libraryWindowController =
[[VLCLibraryWindowController alloc] initWithLibraryWindow];
+ }
+
+ VLCLibraryWindow *libraryWindow = [VLCMain sharedInstance].libraryWindow;
+
+ if([identifier isEqualToString:[libraryWindow identifier]]) {
+ NSInteger rememberedSelectedLibrarySegment = [state
decodeIntegerForKey:@"macosx-library-selected-segment"];
+ NSInteger rememberedSelectedLibraryViewModeSegment = [state
decodeIntegerForKey:@"macosx-library-view-mode-selected-segment"];
+ NSInteger rememberedSelectedLibraryViewAudioSegment = [state
decodeIntegerForKey:@"macosx-library-audio-view-selected-segment"];
+
+ [libraryWindow.segmentedTitleControl
setSelectedSegment:rememberedSelectedLibrarySegment];
+ [libraryWindow.gridVsListSegmentedControl
setSelectedSegment:rememberedSelectedLibraryViewModeSegment];
+ [libraryWindow.libraryAudioDataSource.segmentedControl
setSelectedSegment:rememberedSelectedLibraryViewAudioSegment];
+
+ [libraryWindow segmentedControlAction:libraryWindow.navigationStack];
// Prevent actions being added to the nav stack
+ [libraryWindow.libraryAudioDataSource
segmentedControlAction:libraryWindow.navigationStack];
+ }
+ completionHandler(libraryWindow, nil);
}
@end
=====================================
modules/gui/macosx/main/VLCMain.h
=====================================
@@ -76,7 +76,7 @@ extern NSString *VLCConfigurationChangedNotification;
@property (readonly) VLCLogWindowController *debugMsgPanel;
@property (readonly) VLCLibraryController *libraryController;
@property (readonly) VLCLibraryWindow *libraryWindow;
-@property (readonly) VLCLibraryWindowController *libraryWindowController;
+@property (readwrite) VLCLibraryWindowController *libraryWindowController;
@property (readonly) VLCMainMenu *mainMenu;
@property (readonly) VLCOpenWindowController *open;
@property (readonly) VLCPlaylistController *playlistController;
=====================================
modules/gui/macosx/main/VLCMain.m
=====================================
@@ -253,7 +253,11 @@ static VLCMain *sharedInstance = nil;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
_launched = YES;
- _libraryWindowController = [[VLCLibraryWindowController alloc]
initWithLibraryWindow];
+
+ if (_libraryWindowController == nil) {
+ _libraryWindowController = [[VLCLibraryWindowController alloc]
initWithLibraryWindow];
+ }
+
[_libraryWindowController.window makeKeyAndOrderFront:nil];
if (!_p_intf)
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/commit/cd3713079038be57d8f7226ea9b42c6a74351afd
--
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/commit/cd3713079038be57d8f7226ea9b42c6a74351afd
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits