Prechádzať zdrojové kódy

Merge branch 'develop' of http://git.kdan.cc:8865/Mac_PDF/PDF_Office into develop

liaoxiaoyue 1 rok pred
rodič
commit
ccfb407a2b

BIN
PDF Office/PDF Office.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile.xcuserdatad/UserInterfaceState.xcuserstate


+ 5 - 0
PDF Office/PDF Office/Class/Merge/OCPart/KMBlankView.h

@@ -17,13 +17,18 @@ typedef NS_ENUM(NSUInteger, KMBlankViewMouseEventType) {
 
 NS_ASSUME_NONNULL_BEGIN
 
+typedef void(^DragSuccessCallBack)(NSMutableArray *fileNames);
 @interface KMBlankView : NSView
 
 @property (nonatomic,assign) IBOutlet NSTextField *titleLabel;
 @property (nonatomic,assign) IBOutlet NSTextField *secondTitleLabel;
 @property (nonatomic,assign) IBOutlet NSImageView *imageView;
 @property (assign) IBOutlet KMPDFEditAppendCustomView *customView;
+
+@property (nonatomic, strong) NSArray *allowedFileTypes;
+
 @property (nonatomic, copy) void(^mouseActionCallBack)(KMBlankViewMouseEventType mouseType);
+@property(nonatomic , copy) DragSuccessCallBack dragSuccessBlock;
 
 @end
 

+ 48 - 0
PDF Office/PDF Office/Class/Merge/OCPart/KMBlankView.m

@@ -26,6 +26,8 @@
     self.wantsLayer = YES;
     
     [self.customView addSubview:self.button];
+    
+    [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
 }
 
 - (void)layout {
@@ -34,6 +36,52 @@
     self.button.frame = self.imageView.frame;
 }
 
+#pragma mark -
+#pragma mark - Drag
+
+
+- (void)draggingExited:(nullable id <NSDraggingInfo>)sender {}
+
+- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
+    NSPasteboard *pboard = [sender draggingPasteboard];
+    BOOL isCanDrag = NO;
+    NSDragOperation result = NSDragOperationNone;
+    if ([pboard availableTypeFromArray:[NSArray arrayWithObject:NSFilenamesPboardType]])
+    {
+        NSArray *fileNames = [pboard propertyListForType:NSFilenamesPboardType];
+        for (NSString* path in fileNames) {
+            if ([self.allowedFileTypes containsObject:path.pathExtension.lowercaseString]) {
+                isCanDrag = YES;
+            } else {
+                isCanDrag = NO;
+                break;
+            }
+        }
+    }
+    self.layer.borderColor = [NSColor clearColor].CGColor;
+
+    if (isCanDrag) {
+        
+        result = NSDragOperationCopy;
+    }
+    return result;
+}
+
+- (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender
+{
+    NSPasteboard *pboard = [sender draggingPasteboard];
+    if ([pboard availableTypeFromArray:[NSArray arrayWithObject:NSFilenamesPboardType]]) {
+        NSMutableArray *fileNames = [pboard propertyListForType:NSFilenamesPboardType];
+        if (self.dragSuccessBlock) {
+            self.dragSuccessBlock(fileNames);
+        }
+    }
+    return YES;
+}
+
+#pragma mark -
+#pragma mark - mouse Methods
+
 - (void)addTrackingArea {
     NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:self.imageView.bounds options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways owner:self userInfo:nil];
     [self.imageView addTrackingArea:trackingArea];

+ 0 - 7
PDF Office/PDF Office/Class/Merge/OCPart/KMPDFEditAppendCustomView.h

@@ -7,14 +7,7 @@
 
 #import <Cocoa/Cocoa.h>
 
-//typedef void(^DragEnteredCallBack)(BOOL isDragEntered);
-typedef void(^DragSuccessCallBack)(NSMutableArray *fileNames);
-
 @interface KMPDFEditAppendCustomView : NSView
 
-//@property(nonatomic , copy) DragEnteredCallBack dragEnteredBlock;
-
-@property(nonatomic , copy) DragSuccessCallBack dragSuccessBlock;
-
 @end
 

+ 0 - 47
PDF Office/PDF Office/Class/Merge/OCPart/KMPDFEditAppendCustomView.m

@@ -9,51 +9,4 @@
 
 @implementation KMPDFEditAppendCustomView
 
-- (void)dealloc {}
-
-- (void)awakeFromNib {
-    [super awakeFromNib];
-    
-    [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
-}
-
-- (void)draggingExited:(nullable id <NSDraggingInfo>)sender {}
-
-- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
-    NSPasteboard *pboard = [sender draggingPasteboard];
-    BOOL isCanDrag = NO;
-    NSDragOperation result = NSDragOperationNone;
-    if ([pboard availableTypeFromArray:[NSArray arrayWithObject:NSFilenamesPboardType]])
-    {
-        NSArray *fileNames = [pboard propertyListForType:NSFilenamesPboardType];
-        for (NSString* path in fileNames) {
-            if ([[path lowercaseString] hasSuffix:@"pdf"]) {
-                isCanDrag = YES;
-            }else{
-                isCanDrag = NO;
-                break;
-            }
-        }
-    }
-    self.layer.borderColor = [NSColor clearColor].CGColor;
-
-    if (isCanDrag) {
-        
-        result = NSDragOperationCopy;
-    }
-    return result;
-}
-
-- (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender
-{
-    NSPasteboard *pboard = [sender draggingPasteboard];
-    if ([pboard availableTypeFromArray:[NSArray arrayWithObject:NSFilenamesPboardType]]) {
-        NSMutableArray *fileNames = [pboard propertyListForType:NSFilenamesPboardType];
-        if (self.dragSuccessBlock) {
-            self.dragSuccessBlock(fileNames);
-        }
-    }
-    return YES;
-}
-
 @end

+ 8 - 7
PDF Office/PDF Office/Class/Merge/OCPart/KMPDFEditAppendWindow.m

@@ -322,15 +322,15 @@ static NSString * const KMTableColumnSizeID = @"size";
     self.tableHeaderBottomLine.fillColor = [NSColor colorWithRed:223/255.f green:225/255.f blue:229/255.f alpha:1.f];
     [self.tableView removeTableColumn:self.tableView.tableColumns.firstObject];
     NSTableColumn *column1 = [[NSTableColumn alloc] initWithIdentifier:KMTableColumnFileNameID];
-    column1.width = 242+16;
+    column1.width = 446+16;
     column1.title = NSLocalizedString(@"File Name", nil);
     [self.tableView addTableColumn:column1];
     NSTableColumn *column2 = [[NSTableColumn alloc] initWithIdentifier:KMTableColumnPageRangeID];
-    column2.width = 160;
+    column2.width = 160+8;
     column2.title = NSLocalizedString(@"Page Range", nil);
     [self.tableView addTableColumn:column2];
     NSTableColumn *column3 = [[NSTableColumn alloc] initWithIdentifier:KMTableColumnSizeID];
-    column3.width = 90+12;
+    column3.width = 139+12;
     column3.title = NSLocalizedString(@"Size", nil);
     [self.tableView addTableColumn:column3];
     self.tableView.rowHeight = 76;
@@ -344,7 +344,7 @@ static NSString * const KMTableColumnSizeID = @"size";
     [self.tableView addSubview:self.myBlankView];
     [self.myBlankView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.top.width.equalTo(self.tableView);
-        make.height.equalTo(self.tableView).offset(-60);
+        make.height.equalTo(self.tableView).offset(0);
     }];
     self.myBlankView.wantsLayer = YES;
     self.myBlankView.layer.backgroundColor = [NSColor clearColor].CGColor;
@@ -357,6 +357,7 @@ static NSString * const KMTableColumnSizeID = @"size";
     self.myBlankView.secondTitleLabel.font = [NSFont fontWithName:@"SFProText-Regular" size:12];
     
     self.myBlankView.imageView.image = [NSImage imageNamed:@"KMImageNameEmptyAddNormal"];
+    self.myBlankView.allowedFileTypes = [KMImageAccessoryController supportedImageTypes];
     self.myBlankView.mouseActionCallBack = ^(KMBlankViewMouseEventType mouseType) {
         if (mouseType == KMBlankViewMouseEventType_MouseEnter) {
             weakSelf.myBlankView.imageView.image = [NSImage imageNamed:@"KMImageNameEmptyAddHover"];
@@ -369,7 +370,7 @@ static NSString * const KMTableColumnSizeID = @"size";
             weakSelf.myBlankView.imageView.image = [NSImage imageNamed:@"KMImageNameEmptyAddHover"];
         }
     };
-    self.myBlankView.customView.dragSuccessBlock = ^(NSMutableArray *fileNames) {
+    self.myBlankView.dragSuccessBlock = ^(NSMutableArray *fileNames) {
         NSMutableArray *array = [NSMutableArray array];
         
         for(NSString *path in fileNames){
@@ -1259,7 +1260,7 @@ static NSString * const KMTableColumnSizeID = @"size";
     NSOpenPanel *openPanel = [[NSOpenPanel alloc] init];
     [openPanel setAllowedFileTypes:[KMImageAccessoryController supportedImageTypes]];
     [openPanel setAllowsMultipleSelection:YES];
-    openPanel.message = NSLocalizedString(@"Select files to merge. To select multiple files press cmd ⌘ button on keyboard and click on the target files one by one.", nil);
+    openPanel.message = NSLocalizedString(@"Select multiple files on the key disk ⌘/⇧", nil);
     [openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result){
         
         if (result == NSModalResponseOK) {
@@ -1289,7 +1290,7 @@ static NSString * const KMTableColumnSizeID = @"size";
     [openPanel setAllowsMultipleSelection:YES];
     openPanel.canChooseFiles = NO;
     openPanel.canChooseDirectories = YES;
-    openPanel.message = NSLocalizedString(@"Select files to merge. To select multiple files press cmd ⌘ button on keyboard and click on the target files one by one.", nil);
+    openPanel.message = NSLocalizedString(@"Select multiple files on the key disk ⌘/⇧", nil);
     [openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result){
         
         if (result == NSModalResponseOK) {

+ 19 - 19
PDF Office/PDF Office/Class/Merge/OCPart/KMPDFEditAppendWindow.xib

@@ -56,13 +56,13 @@
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="122" horizontalPageScroll="10" verticalLineScroll="122" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ggk-eO-LzC">
-                        <rect key="frame" x="16" y="60" width="786" height="484"/>
+                        <rect key="frame" x="0.0" y="60" width="802" height="492"/>
                         <clipView key="contentView" drawsBackground="NO" id="Mfh-Ax-kRE">
-                            <rect key="frame" x="0.0" y="0.0" width="786" height="484"/>
+                            <rect key="frame" x="0.0" y="0.0" width="802" height="492"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
                                 <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" tableStyle="plain" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="120" rowSizeStyle="automatic" viewBased="YES" id="hj6-Zp-r0z">
-                                    <rect key="frame" x="0.0" y="0.0" width="786" height="484"/>
+                                    <rect key="frame" x="0.0" y="0.0" width="802" height="492"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <size key="intercellSpacing" width="3" height="2"/>
                                     <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -207,8 +207,8 @@
                             <nil key="backgroundColor"/>
                         </clipView>
                         <constraints>
-                            <constraint firstAttribute="height" constant="484" id="09E-fS-UGH"/>
-                            <constraint firstAttribute="width" constant="786" id="yWQ-fV-ium"/>
+                            <constraint firstAttribute="height" constant="492" id="09E-fS-UGH"/>
+                            <constraint firstAttribute="width" constant="802" id="yWQ-fV-ium"/>
                         </constraints>
                         <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="uXJ-M9-xFS">
                             <rect key="frame" x="1" y="428" width="478" height="16"/>
@@ -220,15 +220,15 @@
                         </scroller>
                     </scrollView>
                     <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="7Ci-3J-z10">
-                        <rect key="frame" x="16" y="552" width="771" height="32"/>
+                        <rect key="frame" x="0.0" y="560" width="803" height="32"/>
                         <view key="contentView" id="Vig-qK-Oc8">
-                            <rect key="frame" x="0.0" y="0.0" width="771" height="32"/>
+                            <rect key="frame" x="0.0" y="0.0" width="803" height="32"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
                                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="MiB-cx-nmS">
-                                    <rect key="frame" x="48" y="8" width="205" height="16"/>
+                                    <rect key="frame" x="48" y="8" width="414" height="16"/>
                                     <constraints>
-                                        <constraint firstAttribute="width" constant="201" id="xE4-A5-LKS"/>
+                                        <constraint firstAttribute="width" constant="410" id="xE4-A5-LKS"/>
                                     </constraints>
                                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="FRD-3G-VyU">
                                         <font key="font" usesAppearanceFont="YES"/>
@@ -237,10 +237,10 @@
                                     </textFieldCell>
                                 </textField>
                                 <box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="eiO-1W-3yk">
-                                    <rect key="frame" x="0.0" y="-2" width="771" height="5"/>
+                                    <rect key="frame" x="0.0" y="-2" width="803" height="5"/>
                                 </box>
                                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="P5F-ew-xgE">
-                                    <rect key="frame" x="265" y="8" width="164" height="16"/>
+                                    <rect key="frame" x="474" y="8" width="164" height="16"/>
                                     <constraints>
                                         <constraint firstAttribute="width" constant="160" id="o5v-Uf-L60"/>
                                     </constraints>
@@ -251,9 +251,9 @@
                                     </textFieldCell>
                                 </textField>
                                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4NV-bt-MWP">
-                                    <rect key="frame" x="441" y="8" width="37" height="16"/>
+                                    <rect key="frame" x="650" y="8" width="101" height="16"/>
                                     <constraints>
-                                        <constraint firstAttribute="width" constant="33" id="G5d-Mn-ipQ"/>
+                                        <constraint firstAttribute="width" constant="97" id="G5d-Mn-ipQ"/>
                                     </constraints>
                                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="hu4-wm-nYF">
                                         <font key="font" metaFont="system"/>
@@ -493,12 +493,12 @@ Gw
                 </subviews>
                 <constraints>
                     <constraint firstAttribute="bottom" secondItem="HqV-Cr-IvX" secondAttribute="bottom" constant="16" id="3xl-pe-oik"/>
-                    <constraint firstItem="SNg-B0-ys5" firstAttribute="leading" secondItem="7Ci-3J-z10" secondAttribute="trailing" constant="16" id="72G-rH-m08"/>
+                    <constraint firstItem="SNg-B0-ys5" firstAttribute="leading" secondItem="7Ci-3J-z10" secondAttribute="trailing" id="72G-rH-m08"/>
                     <constraint firstAttribute="trailing" secondItem="bs2-mn-H2R" secondAttribute="trailing" constant="16" id="Bfb-cd-fN2"/>
                     <constraint firstItem="SNg-B0-ys5" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" id="EIV-N9-5mk"/>
                     <constraint firstAttribute="bottom" secondItem="Ggk-eO-LzC" secondAttribute="bottom" constant="60" id="FmD-vC-lz3"/>
                     <constraint firstItem="SNg-B0-ys5" firstAttribute="bottom" secondItem="se5-gp-TjO" secondAttribute="bottom" id="GbZ-tV-MXY"/>
-                    <constraint firstItem="Ggk-eO-LzC" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="16" id="LEN-lk-9rV"/>
+                    <constraint firstItem="Ggk-eO-LzC" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" id="LEN-lk-9rV"/>
                     <constraint firstItem="HqV-Cr-IvX" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="16" id="Lia-zA-HV0"/>
                     <constraint firstItem="bs2-mn-H2R" firstAttribute="leading" secondItem="0Yl-kV-CW1" secondAttribute="trailing" constant="16" id="N15-0u-3on"/>
                     <constraint firstAttribute="trailing" secondItem="SNg-B0-ys5" secondAttribute="trailing" id="d0q-Hn-baS"/>
@@ -506,11 +506,11 @@ Gw
                     <constraint firstAttribute="bottom" secondItem="bs2-mn-H2R" secondAttribute="bottom" constant="16" id="mPi-Wn-mri"/>
                     <constraint firstItem="Uex-2T-CgC" firstAttribute="centerX" secondItem="se5-gp-TjO" secondAttribute="centerX" id="oIl-2n-ghc"/>
                     <constraint firstItem="Zrt-3W-HbQ" firstAttribute="leading" secondItem="HqV-Cr-IvX" secondAttribute="trailing" constant="16" id="qiG-BM-Tt9"/>
-                    <constraint firstItem="7Ci-3J-z10" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="16" id="sgd-dw-rOw"/>
+                    <constraint firstItem="7Ci-3J-z10" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" id="sgd-dw-rOw"/>
                     <constraint firstAttribute="bottom" secondItem="0Yl-kV-CW1" secondAttribute="bottom" constant="16" id="t2f-AF-bQ8"/>
                     <constraint firstItem="Uex-2T-CgC" firstAttribute="centerY" secondItem="se5-gp-TjO" secondAttribute="centerY" id="t3J-uR-7G2"/>
                     <constraint firstAttribute="bottom" secondItem="Zrt-3W-HbQ" secondAttribute="bottom" constant="16" id="yPE-8o-ux5"/>
-                    <constraint firstItem="7Ci-3J-z10" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="16" id="zCm-dk-fmd"/>
+                    <constraint firstItem="7Ci-3J-z10" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="8" id="zCm-dk-fmd"/>
                 </constraints>
             </view>
             <connections>
@@ -557,7 +557,7 @@ Gw
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="h67-mo-mZ1">
-                    <rect key="frame" x="176" y="116" width="418" height="188"/>
+                    <rect key="frame" x="176" y="146" width="418" height="188"/>
                     <subviews>
                         <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="t1l-8E-kYD">
                             <rect key="frame" x="139" y="48" width="140" height="140"/>
@@ -607,7 +607,7 @@ Gw
             </subviews>
             <constraints>
                 <constraint firstItem="h67-mo-mZ1" firstAttribute="centerX" secondItem="Bxz-CR-NgQ" secondAttribute="centerX" id="QIV-Ne-18k"/>
-                <constraint firstItem="h67-mo-mZ1" firstAttribute="centerY" secondItem="Bxz-CR-NgQ" secondAttribute="centerY" id="p7U-T9-Ar7"/>
+                <constraint firstItem="h67-mo-mZ1" firstAttribute="centerY" secondItem="Bxz-CR-NgQ" secondAttribute="centerY" constant="-30" id="p7U-T9-Ar7"/>
             </constraints>
             <connections>
                 <outlet property="customView" destination="yde-fB-mTL" id="UIb-V0-7ai"/>

+ 1 - 1
PDF Office/PDF Office/Class/Merge/OCPart/KMPDFMergeFileNameTabelViewCell.m

@@ -204,7 +204,7 @@
     CGFloat height = NSHeight(self.bounds);
     
     CGFloat labelH = 22;
-    self.label.frame = NSMakeRect(16, (height-labelH)*0.5, width-40, labelH);
+    self.label.frame = NSMakeRect(16, (height-labelH)*0.5, 70, labelH);
     CGFloat buttonSize = 20;
     self.button.frame = NSMakeRect(NSMaxX(self.label.frame)+5, (height-buttonSize)*0.5, buttonSize, buttonSize);
 }