]> granicus.if.org Git - handbrake/commitdiff
MacGui: add a short source description after the source name.
authorDamiano Galassi <damiog@gmail.com>
Fri, 15 Dec 2017 17:21:27 +0000 (18:21 +0100)
committerDamiano Galassi <damiog@gmail.com>
Fri, 15 Dec 2017 17:21:27 +0000 (18:21 +0100)
macosx/HBController.m
macosx/HBTitle.h
macosx/HBTitle.m
macosx/HBUtilities.h
macosx/HBUtilities.m

index 75338bcc7f33fb93e99fc5f1ef09af38d2e9f49d..172a291b62e82d5a39b7420469fc2654a48689c7 100644 (file)
     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"];
                  {
                      [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;
              }
                  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];
          }];
         // 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
     {
          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];
          }
index 37d5a360b808913cf06957f7ab26bc91a83f456c..79869ea20217526ec4a0fbf943884f9eea968ded 100644 (file)
@@ -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;
 
index b75e25117f042e8cca4f7055809ddc99b1bf10c6..02720183385342a7cda7337c85a9d4004b83bb4c 100644 (file)
@@ -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)];
index 1807cdca8159eca7d4d4796aad7d8f521fee4ff6..4b4fa035a2a6be5c103d3d9288e7ec4aacff49ef 100644 (file)
@@ -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;
index 973953f69cda028095b572ca7eebf0b8d5f63b85..c40d148292df44e855c35d0e7fb1e002de265ecc 100644 (file)
     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;