summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2017-12-15 18:21:27 +0100
committerDamiano Galassi <[email protected]>2017-12-15 18:21:27 +0100
commitcba8c83616bd26bbb2d206e768fb139dd5a17f28 (patch)
tree5471f9b80aa20e3a54e45ef9a4f4cf88a6a78d15
parent88e715fafa47e8e7a8d484aec9ecca4e77cbdcee (diff)
MacGui: add a short source description after the source name.
-rw-r--r--macosx/HBController.m26
-rw-r--r--macosx/HBTitle.h1
-rw-r--r--macosx/HBTitle.m45
-rw-r--r--macosx/HBUtilities.h1
-rw-r--r--macosx/HBUtilities.m12
5 files changed, 61 insertions, 24 deletions
diff --git a/macosx/HBController.m b/macosx/HBController.m
index 75338bcc7..172a291b6 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -595,7 +595,6 @@
self.window.title = NSLocalizedString(@"HandBrake", nil);
NSURL *mediaURL = [HBUtilities mediaURLFromURL:fileURL];
- NSString *displayName = [HBUtilities displayNameForURL:fileURL];
NSError *outError = NULL;
BOOL suppressWarning = [[NSUserDefaults standardUserDefaults] boolForKey:@"suppressCopyProtectionAlert"];
@@ -650,10 +649,6 @@
{
[fSrcTitlePopUp addItemWithTitle:title.description];
}
-
- // Set Source Name at top of window with the browsedSourceDisplayName grokked right before -performScan
- fSrcDVD2Field.stringValue = displayName;
-
self.window.representedURL = mediaURL;
self.window.title = mediaURL.lastPathComponent;
}
@@ -663,6 +658,16 @@
fSrcDVD2Field.stringValue = NSLocalizedString(@"No Valid Source Found", @"");
}
+ // Set the last searched source directory in the prefs here
+ if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:mediaURL.URLByDeletingLastPathComponent.path])
+ {
+ [[NSUserDefaults standardUserDefaults] setURL:mediaURL.URLByDeletingLastPathComponent.URLByDeletingLastPathComponent forKey:@"HBLastSourceDirectoryURL"];
+ }
+ else
+ {
+ [[NSUserDefaults standardUserDefaults] setURL:mediaURL.URLByDeletingLastPathComponent forKey:@"HBLastSourceDirectoryURL"];
+ }
+
completionHandler(self.core.titles);
[self.window.toolbar validateVisibleItems];
}];
@@ -839,11 +844,15 @@
// Update the title selection popup.
[fSrcTitlePopUp selectItemWithTitle:title.description];
- // If we are a stream type and a batch scan, grok the output file name from title->name upon title change
+ // Grok the output file name from title.name upon title change
if (title.isStream && self.core.titles.count > 1)
{
// Change the source to read out the parent folder also
- fSrcDVD2Field.stringValue = [NSString stringWithFormat:@"%@/%@", title.url.URLByDeletingLastPathComponent.lastPathComponent, title.name];
+ fSrcDVD2Field.stringValue = [NSString stringWithFormat:@"%@/%@, %@", title.url.URLByDeletingLastPathComponent.lastPathComponent, title.name, title.shortFormatDescription];
+ }
+ else
+ {
+ fSrcDVD2Field.stringValue = [NSString stringWithFormat:@"%@, %@", title.name, title.shortFormatDescription];
}
}
else
@@ -897,9 +906,6 @@
{
if (result == NSFileHandlingPanelOKButton)
{
- // Set the last searched source directory in the prefs here
- [[NSUserDefaults standardUserDefaults] setURL:panel.URL.URLByDeletingLastPathComponent forKey:@"HBLastSourceDirectoryURL"];
-
NSInteger titleIdx = self.scanSpecificTitle ? self.scanSpecificTitleIdx : 0;
[self openURL:panel.URL titleIndex:titleIdx];
}
diff --git a/macosx/HBTitle.h b/macosx/HBTitle.h
index 37d5a360b..79869ea20 100644
--- a/macosx/HBTitle.h
+++ b/macosx/HBTitle.h
@@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface HBTitle : NSObject
@property (nonatomic, readonly) NSString *name;
+@property (nonatomic, readonly) NSString *shortFormatDescription;
@property (nonatomic, readonly, getter=isFeatured) BOOL featured;
@property (nonatomic, readonly, getter=isStream) BOOL stream;
diff --git a/macosx/HBTitle.m b/macosx/HBTitle.m
index b75e25117..027201833 100644
--- a/macosx/HBTitle.m
+++ b/macosx/HBTitle.m
@@ -73,7 +73,7 @@ extern NSString *keySubTrackType;
// If the name is empty use file/directory name
if (_name.length == 0)
{
- _name = [@(self.hb_title->path) lastPathComponent];
+ _name = @(self.hb_title->path).lastPathComponent;
}
}
@@ -104,6 +104,49 @@ extern NSString *keySubTrackType;
}
}
+- (NSString *)shortFormatDescription
+{
+ NSMutableString *format = [[NSMutableString alloc] init];
+
+ [format appendFormat:@"%dx%d", _hb_title->geometry.width, _hb_title->geometry.height];
+
+ if (_hb_title->geometry.par.num != 1 || _hb_title->geometry.par.den != 1)
+ {
+ [format appendFormat:@" (%dx%d)", _hb_title->geometry.width * _hb_title->geometry.par.num / _hb_title->geometry.par.den,
+ _hb_title->geometry.height];
+ }
+
+ [format appendString:@", "];
+
+ [format appendFormat:@"%.6g FPS", _hb_title->vrate.num / (double)_hb_title->vrate.den];
+
+ hb_list_t *audioList = _hb_title->list_audio;
+ int audioCount = hb_list_count(audioList);
+
+ if (audioCount > 1)
+ {
+ [format appendFormat:NSLocalizedString(@", %d audio tracks", nil), audioCount];
+ }
+ else if (audioCount == 1)
+ {
+ [format appendFormat:NSLocalizedString(@", 1 audio track", nil)];
+ }
+
+ hb_list_t *subList = _hb_title->list_subtitle;
+ int subCount = hb_list_count(subList);
+
+ if (subCount > 1)
+ {
+ [format appendFormat:NSLocalizedString(@", %d subtitles tracks", nil), subCount];
+ }
+ else if (subCount == 1)
+ {
+ [format appendFormat:NSLocalizedString(@", 1 subtitles track", nil)];
+ }
+
+ return format;
+}
+
- (NSURL *)url
{
return [NSURL fileURLWithPath:@(_hb_title->path)];
diff --git a/macosx/HBUtilities.h b/macosx/HBUtilities.h
index 1807cdca8..4b4fa035a 100644
--- a/macosx/HBUtilities.h
+++ b/macosx/HBUtilities.h
@@ -34,7 +34,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (nullable NSData *)bookmarkFromURL:(NSURL *)url;
+ (nullable NSData *)bookmarkFromURL:(NSURL *)url options:(NSURLBookmarkCreationOptions)options;
-+ (NSString *)displayNameForURL:(NSURL *)URL;
+ (NSURL *)mediaURLFromURL:(NSURL *)URL;
+ (NSString *)automaticNameForJob:(HBJob *)job;
diff --git a/macosx/HBUtilities.m b/macosx/HBUtilities.m
index 973953f69..c40d14829 100644
--- a/macosx/HBUtilities.m
+++ b/macosx/HBUtilities.m
@@ -93,18 +93,6 @@
return [HBUtilities bookmarkFromURL:url options:NSURLBookmarkCreationWithSecurityScope];
}
-+ (NSString *)displayNameForURL:(NSURL *)URL
-{
- NSString *displayName = URL.lastPathComponent;
-
- if ([URL.lastPathComponent isEqualToString:@"VIDEO_TS"])
- {
- displayName = URL.URLByDeletingLastPathComponent.lastPathComponent;
- }
-
- return displayName;
-}
-
+ (NSURL *)mediaURLFromURL:(NSURL *)URL
{
NSURL *mediaURL = URL;