Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
dfc57131 by Claudio Cambra at 2022-11-11T01:45:47+00:00
macosx: Fix year · duration strings in media item supplementary views, have
fallbacks for items with no set year
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
3 changed files:
-
modules/gui/macosx/library/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.m
- modules/gui/macosx/library/VLCLibraryDataTypes.h
- modules/gui/macosx/library/VLCLibraryDataTypes.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.m
=====================================
@@ -61,6 +61,24 @@ NSCollectionViewSupplementaryElementKind const
VLCLibraryCollectionViewMediaItem
[self updateRepresentation];
}
+- (NSString*)formattedYearAndDurationString
+{
+ if (_representedMediaItem.year > 0) {
+ return [NSString stringWithFormat:@"%u · %@",
_representedMediaItem.year, _representedMediaItem.durationString];
+ } else if (_representedMediaItem.files.count > 0) {
+ VLCMediaLibraryFile *firstFile =
_representedMediaItem.files.firstObject;
+ time_t fileLastModTime = firstFile.lastModificationDate;
+
+ if (fileLastModTime > 0) {
+ NSDate *lastModDate = [NSDate
dateWithTimeIntervalSince1970:fileLastModTime];
+ NSDateComponents *components = [[NSCalendar currentCalendar]
components:NSCalendarUnitYear fromDate:lastModDate];
+ return [NSString stringWithFormat:@"%ld · %@", components.year,
_representedMediaItem.durationString];
+ }
+ }
+
+ return _representedMediaItem.durationString;
+}
+
- (void)updateRepresentation
{
if (_representedMediaItem == nil) {
@@ -69,7 +87,7 @@ NSCollectionViewSupplementaryElementKind const
VLCLibraryCollectionViewMediaItem
}
_mediaItemTitleTextField.stringValue = _representedMediaItem.displayString;
- _mediaItemYearAndDurationTextField.stringValue = [NSString
stringWithFormat:@"%u · %@", _representedMediaItem.year,
_representedMediaItem.durationString];
+ _mediaItemYearAndDurationTextField.stringValue = [self
formattedYearAndDurationString];
_mediaItemFileNameTextField.stringValue =
_representedMediaItem.inputItem.name;
_mediaItemPathTextField.stringValue =
_representedMediaItem.inputItem.decodedMRL;
_mediaItemArtworkImageView.image = _representedMediaItem.smallArtworkImage;
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.h
=====================================
@@ -49,6 +49,7 @@ extern const long long int
VLCMediaLibraryMediaItemDurationDenominator;
@property (readonly) BOOL external;
@property (readonly) BOOL removable;
@property (readonly) BOOL present;
+@property (readonly) time_t lastModificationDate;
@end
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -123,6 +123,7 @@ static NSArray<VLCMediaLibraryArtist *>
*fetchArtistsForLibraryItem(library_arti
_external = p_file->b_external;
_removable = p_file->b_removable;
_present = p_file->b_present;
+ _lastModificationDate = p_file->i_last_modification_date;
}
return self;
}
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/commit/dfc57131228ac2795d0ce6942c60ab1735e6ab3c
--
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/commit/dfc57131228ac2795d0ce6942c60ab1735e6ab3c
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