]> granicus.if.org Git - handbrake/commitdiff
MacGui: show the start/end seconds range as formatted time strings.
authorDamiano Galassi <damiog@gmail.com>
Wed, 6 Mar 2019 09:14:02 +0000 (10:14 +0100)
committerDamiano Galassi <damiog@gmail.com>
Wed, 6 Mar 2019 09:14:02 +0000 (10:14 +0100)
macosx/Base.lproj/MainWindow.xib
macosx/HBRange+UIAdditions.h
macosx/HBRange+UIAdditions.m

index d2d7383e8177727f9bcdd3b4499fd98cee1552c3..59b5a211d36d9653fb2f5534d5fc9ec7f4b05a65 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.59" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.68" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.59"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.68"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
                             <constraint firstAttribute="width" constant="54" id="siy-Fa-XFI"/>
                         </constraints>
                         <textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" drawsBackground="YES" id="5492">
-                            <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" minimumIntegerDigits="0" maximumIntegerDigits="42" id="Fdv-uE-tUA">
-                                <real key="minimum" value="0.0"/>
-                            </numberFormatter>
                             <font key="font" metaFont="smallSystem"/>
                             <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                     <string key="NSValueTransformerName">NSNegateBoolean</string>
                                 </dictionary>
                             </binding>
-                            <binding destination="-2" name="value" keyPath="self.job.range.secondsStart" id="0Cj-wW-5Se">
+                            <binding destination="-2" name="value" keyPath="self.job.range.secondsStart" id="ETl-ke-STQ">
                                 <dictionary key="options">
                                     <bool key="NSContinuouslyUpdatesValue" value="YES"/>
                                     <bool key="NSValidatesImmediately" value="YES"/>
+                                    <string key="NSValueTransformerName">HBTimeInSecondsTransformer</string>
                                 </dictionary>
                             </binding>
                         </connections>
                     <textField hidden="YES" toolTip="Last second to encode." verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5493" userLabel="Time End Encoding Field">
                         <rect key="frame" x="687" y="537" width="54" height="19"/>
                         <textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" drawsBackground="YES" id="5494">
-                            <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" minimumIntegerDigits="0" maximumIntegerDigits="42" id="tD5-HN-B7h">
-                                <real key="minimum" value="0.0"/>
-                            </numberFormatter>
                             <font key="font" metaFont="smallSystem"/>
                             <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                     <string key="NSValueTransformerName">NSNegateBoolean</string>
                                 </dictionary>
                             </binding>
-                            <binding destination="-2" name="value" keyPath="self.job.range.secondsStop" id="5SR-rs-7eh">
+                            <binding destination="-2" name="value" keyPath="self.job.range.secondsStop" id="AL1-NB-med">
                                 <dictionary key="options">
                                     <bool key="NSContinuouslyUpdatesValue" value="YES"/>
                                     <bool key="NSValidatesImmediately" value="YES"/>
+                                    <string key="NSValueTransformerName">HBTimeInSecondsTransformer</string>
                                 </dictionary>
                             </binding>
                         </connections>
index 47b7cde4f8ec74deff19f74452f05c163936a44f..21d323ebb236a099c0011c2d0268902bb93d8ea4 100644 (file)
@@ -22,3 +22,6 @@
 
 @interface HBTimeTransformer : NSValueTransformer
 @end
+
+@interface HBTimeInSecondsTransformer: NSValueTransformer
+@end
index f574225a386f985c038b6ee5821b49f15713e726..559d5e26ecbdf8dd9ba9af788eddb56636bab49e 100644 (file)
 }
 
 @end
+
+@implementation HBTimeInSecondsTransformer
+
++ (Class)transformedValueClass
+{
+    return [NSString class];
+}
+
+- (id)transformedValue:(id)value
+{
+    uint64_t duration = [value integerValue];
+    uint64_t hours    = duration / 3600;
+    uint64_t minutes  = (duration % 3600) / 60;
+    uint64_t seconds  = duration % 60;
+
+    NSString *result = [NSString stringWithFormat:@"%02llu:%02llu:%02llu", hours, minutes, seconds];
+    return result;
+}
+
++ (BOOL)allowsReverseTransformation
+{
+    return YES;
+}
+
+- (id)reverseTransformedValue:(id)value
+{
+    const char *time = [value UTF8String];
+    if (time)
+    {
+        unsigned hour, minute, second, timeval;
+
+        if (sscanf(time, "%2u:%u:%u", &hour, &minute, &second) < 3) {
+            if (sscanf(time, "%u:%u:%u", &hour, &minute, &second) < 3) {
+                return 0;
+            }
+        }
+
+        if (second > 60) {
+            second = 0;
+        }
+
+        timeval = hour * 60 * 60 + minute * 60 + second;
+
+        return @(timeval);
+    }
+    return @"00:00:00";
+}
+
+@end