diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/QLPreviewPanel.h | 119 | ||||
-rw-r--r-- | Source/SPFieldEditorController.h | 21 | ||||
-rw-r--r-- | Source/SPFieldEditorController.m | 133 | ||||
-rw-r--r-- | Source/SPTableContent.m | 1 |
4 files changed, 49 insertions, 225 deletions
diff --git a/Source/QLPreviewPanel.h b/Source/QLPreviewPanel.h deleted file mode 100644 index 7c342ed9..00000000 --- a/Source/QLPreviewPanel.h +++ /dev/null @@ -1,119 +0,0 @@ -// -// QLPreviewPanel.h -// sequel-pro -// -// Created by Stuart Connolly (stuconnolly.com) on June 15, 2009. -// Copyright (c) 2009 Stuart Connolly. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// -// More info at <https://github.com/sequelpro/sequelpro> - -// As the QuickLook framework is private we have to make -// these methods public to avoid warnings while compiling -@interface QLPreviewPanel : NSPanel - -+ (id)sharedPreviewPanel; -+ (id)_previewPanel; -+ (BOOL)isSharedPreviewPanelLoaded; -- (id)initWithContentRect:(NSRect)fp8 styleMask:(NSUInteger)fp24 backing:(NSUInteger)fp28 defer:(BOOL)fp32; -- (id)initWithCoder:(id)fp8; -- (void)dealloc; -- (BOOL)isOpaque; -- (BOOL)canBecomeKeyWindow; -- (BOOL)canBecomeMainWindow; -- (BOOL)shouldIgnorePanelFrameChanges; -- (BOOL)isOpen; -- (void)setFrame:(NSRect)fp8 display:(BOOL)fp24 animate:(BOOL)fp28; -- (id)_subEffectsForWindow:(id)fp8 itemFrame:(NSRect)fp12 transitionWindow:(id *)fp28; -- (id)_scaleEffectForItemFrame:(NSRect)fp8 transitionWindow:(id *)fp24; -- (void)_invertCurrentEffect; -- (struct _NSRect)_currentItemFrame; -- (void)setAutosizesAndCenters:(BOOL)fp8; -- (BOOL)autosizesAndCenters; -- (void)makeKeyAndOrderFront:(id)fp8; -- (void)makeKeyAndOrderFrontWithEffect:(NSInteger)fp8; -- (void)makeKeyAndGoFullscreenWithEffect:(NSInteger)fp8; -- (void)makeKeyAndOrderFrontWithEffect:(NSInteger)fp8 canClose:(BOOL)fp12; -- (void)_makeKeyAndOrderFrontWithEffect:(NSInteger)fp8 canClose:(BOOL)fp12 willOpen:(BOOL)fp16 toFullscreen:(BOOL)fp20; -- (NSInteger)openingEffect; -- (void)closePanel; -- (void)close; -- (void)closeWithEffect:(NSInteger)fp8; -- (void)closeWithEffect:(NSInteger)fp8 canReopen:(BOOL)fp12; -- (void)_closeWithEffect:(NSInteger)fp8 canReopen:(BOOL)fp12; -- (void)windowEffectDidTerminate:(id)fp8; -- (void)_close:(id)fp8; -- (void)sendEvent:(id)fp8; -- (void)selectNextItem; -- (void)selectPreviousItem; -- (void)setURLs:(id)fp8 currentIndex:(NSUInteger)fp12 preservingDisplayState:(BOOL)fp16; -- (void)setURLs:(id)fp8 preservingDisplayState:(BOOL)fp12; -- (void)setURLs:(id)fp8; -- (id)URLs; -- (NSUInteger)indexOfCurrentURL; -- (void)setIndexOfCurrentURL:(NSUInteger)fp8; -- (void)setDelegate:(id)fp8; -- (id)sharedPreviewView; -- (void)setSharedPreviewView:(id)fp8; -- (void)setCyclesSelection:(BOOL)fp8; -- (BOOL)cyclesSelection; -- (void)setShowsAddToiPhotoButton:(BOOL)fp8; -- (BOOL)showsAddToiPhotoButton; -- (void)setShowsiChatTheaterButton:(BOOL)fp8; -- (BOOL)showsiChatTheaterButton; -- (void)setShowsFullscreenButton:(BOOL)fp8; -- (BOOL)showsFullscreenButton; -- (void)setShowsIndexSheetButton:(BOOL)fp8; -- (BOOL)showsIndexSheetButton; -- (void)setAutostarts:(BOOL)fp8; -- (BOOL)autostarts; -- (void)setPlaysDuringPanelAnimation:(BOOL)fp8; -- (BOOL)playsDuringPanelAnimation; -- (void)setDeferredLoading:(BOOL)fp8; -- (BOOL)deferredLoading; -- (void)setEnableDragNDrop:(BOOL)fp8; -- (BOOL)enableDragNDrop; -- (void)start:(id)fp8; -- (void)stop:(id)fp8; -- (void)setShowsIndexSheet:(BOOL)fp8; -- (BOOL)showsIndexSheet; -- (void)setShareWithiChat:(BOOL)fp8; -- (BOOL)shareWithiChat; -- (void)setPlaysSlideShow:(BOOL)fp8; -- (BOOL)playsSlideShow; -- (void)setIsFullscreen:(BOOL)fp8; -- (BOOL)isFullscreen; -- (void)setMandatoryClient:(id)fp8; -- (id)mandatoryClient; -- (void)setForcedContentTypeUTI:(id)fp8; -- (id)forcedContentTypeUTI; -- (void)setDocumentURLs:(id)fp8; -- (void)setDocumentURLs:(id)fp8 preservingDisplayState:(BOOL)fp12; -- (void)setDocumentURLs:(id)fp8 itemFrame:(struct _NSRect)fp12; -- (void)setURLs:(id)fp8 itemFrame:(struct _NSRect)fp12; -- (void)setAutoSizeAndCenterOnScreen:(BOOL)fp8; -- (void)setShowsAddToiPhoto:(BOOL)fp8; -- (void)setShowsiChatTheater:(BOOL)fp8; -- (void)setShowsFullscreen:(BOOL)fp8; - -@end diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h index b56c6d1c..fbf04c49 100644 --- a/Source/SPFieldEditorController.h +++ b/Source/SPFieldEditorController.h @@ -28,6 +28,21 @@ // // More info at <https://github.com/sequelpro/sequelpro> +#ifndef SP_CODA + +#import <Quartz/Quartz.h> // QuickLookUI + +//This is an informal protocol +@protocol _QLPreviewPanelController + +- (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel *)panel; +- (void)beginPreviewPanelControl:(QLPreviewPanel *)panel; +- (void)endPreviewPanelControl:(QLPreviewPanel *)panel; + +@end + +#endif + @class SPWindow; /** @@ -38,7 +53,11 @@ * This class offers a sheet for editing different kind of data such as text, blobs (including images) as * editSheet and bit fields as bitSheet. */ -@interface SPFieldEditorController : NSWindowController <NSComboBoxDataSource> +@interface SPFieldEditorController : NSWindowController <NSComboBoxDataSource +#ifndef SP_CODA +, QLPreviewPanelDataSource, QLPreviewPanelDelegate, _QLPreviewPanelController +#endif +> { IBOutlet id editSheetProgressBar; IBOutlet id editSheetSegmentControl; diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index 4f34a998..52242406 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -29,9 +29,6 @@ // More info at <https://github.com/sequelpro/sequelpro> #import "SPFieldEditorController.h" -#ifndef SP_CODA -#import "QLPreviewPanel.h" -#endif #import "RegexKitLite.h" #import "SPTooltip.h" #import "SPGeometryDataView.h" @@ -164,8 +161,8 @@ #ifndef SP_CODA // On Mac OSX 10.6 QuickLook runs non-modal thus order out the panel // if still visible - if ([[NSClassFromString(@"QLPreviewPanel") sharedPreviewPanel] isVisible]) { - [[NSClassFromString(@"QLPreviewPanel") sharedPreviewPanel] orderOut:nil]; + if ([[QLPreviewPanel sharedPreviewPanel] isVisible]) { + [[QLPreviewPanel sharedPreviewPanel] orderOut:nil]; } #endif @@ -882,89 +879,34 @@ - (void)invokeQuickLookOfType:(NSString *)type treatAsText:(BOOL)isText { #ifndef SP_CODA - // Load QL via private framework (SDK 10.5) - if([[NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/QuickLookUI.framework"] load]) { - - [editSheetProgressBar startAnimation:self]; - - [self createTemporaryQuickLookFileOfType:type treatAsText:isText]; - - counter++; - - // Init QuickLook - id ql = [NSClassFromString(@"QLPreviewPanel") sharedPreviewPanel]; - - [[ql delegate] setDelegate:self]; - [ql setURLs:@[[NSURL fileURLWithPath:tmpFileName]] currentIndex:0 preservingDisplayState:YES]; - - // TODO: No interaction with iChat and iPhoto due to .scriptSuite warning: - // unknown image format - [ql setShowsAddToiPhotoButton:NO]; - [ql setShowsiChatTheaterButton:NO]; - // Since we are inside of editSheet we have to avoid full-screen zooming - // otherwise QuickLook hangs - [ql setShowsFullscreenButton:NO]; - [ql setEnableDragNDrop:NO]; - // Order out QuickLook with animation effect according to self:previewPanel:frameForURL: - [ql makeKeyAndOrderFrontWithEffect:2]; // 1 = fade in - - // quickLookCloseMarker == 1 break the modal session - quickLookCloseMarker = 0; - - [editSheetProgressBar stopAnimation:self]; - - // Run QuickLook in its own modal seesion for event handling - NSModalSession session = [NSApp beginModalSessionForWindow:ql]; - for (;;) { - // Conditions for closing QuickLook - if ([NSApp runModalSession:session] != NSRunContinuesResponse - || quickLookCloseMarker == 1 - || ![ql isVisible]) - break; - [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode - beforeDate:[NSDate distantFuture]]; - - } - [NSApp endModalSession:session]; - - // set ql's delegate to nil for dealloc - [[ql windowController] setDelegate:nil]; - - } - // Load QL via framework (SDK 10.5 but SP runs on 10.6) - // TODO: This is an hack in order to be able to support QuickLook on Mac OS X 10.5 and 10.6 - // as long as SP will be compiled against SDK 10.5. - // If SP will be compiled against SDK 10.6 we can use the standard way by using - // the QuickLookUI which is part of the Quartz.framework. See Developer example "QuickLookDownloader" + // See Developer example "QuickLookDownloader" // file:///Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/Contents/Resources/Documents/samplecode/QuickLookDownloader/index.html#//apple_ref/doc/uid/DTS40009082 - else if([[NSBundle bundleWithPath:@"/System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework"] load]) { - [editSheetProgressBar startAnimation:self]; + [editSheetProgressBar startAnimation:self]; - [self createTemporaryQuickLookFileOfType:type treatAsText:isText]; + [self createTemporaryQuickLookFileOfType:type treatAsText:isText]; - counter++; + counter++; - // TODO: If QL is visible reload it - but how? - // Up to now QL will close and the user has to redo it. - if([[NSClassFromString(@"QLPreviewPanel") sharedPreviewPanel] isVisible]) { - [[NSClassFromString(@"QLPreviewPanel") sharedPreviewPanel] orderOut:nil]; - } + // TODO: If QL is visible reload it - but how? + // Up to now QL will close and the user has to redo it. + if([[QLPreviewPanel sharedPreviewPanel] isVisible]) { + [[QLPreviewPanel sharedPreviewPanel] orderOut:nil]; + } - [[NSClassFromString(@"QLPreviewPanel") sharedPreviewPanel] makeKeyAndOrderFront:nil]; + [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil]; - [editSheetProgressBar stopAnimation:self]; + [editSheetProgressBar stopAnimation:self]; - } else { - [SPTooltip showWithObject:[NSString stringWithFormat:@"QuickLook is not available on that platform."]]; - } #endif } +#pragma mark - QLPreviewPanelController methods + /** * QuickLook delegate for SDK 10.6. Set the Quicklook delegate to self and suppress setShowsAddToiPhotoButton since the format is unknow. */ -- (void)beginPreviewPanelControl:(id)panel +- (void)beginPreviewPanelControl:(QLPreviewPanel *)panel { #ifndef SP_CODA @@ -972,15 +914,13 @@ [panel setDelegate:self]; [panel setDataSource:self]; - // Due to the unknown image format disable image sharing - [panel setShowsAddToiPhotoButton:NO]; #endif } /** * QuickLook delegate for SDK 10.6 - not in usage. */ -- (void)endPreviewPanelControl:(id)panel +- (void)endPreviewPanelControl:(QLPreviewPanel *)panel { // This document loses its responsisibility on the preview panel // Until the next call to -beginPreviewPanelControl: it must not @@ -990,22 +930,19 @@ /** * QuickLook delegate for SDK 10.6 */ -- (BOOL)acceptsPreviewPanelControl:(id)panel; +- (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel *)panel; { return YES; } -// QuickLook delegates for SDK 10.6 -// - (BOOL)previewPanel:(QLPreviewPanel *)panel handleEvent:(NSEvent *)event -// { -// } +#pragma mark - QLPreviewPanelDataSource methods /** * QuickLook delegate for SDK 10.6. * * @return It always returns 1. */ -- (NSInteger)numberOfPreviewItemsInPreviewPanel:(id)panel +- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel *)panel { return 1; } @@ -1015,7 +952,7 @@ * * @return It returns as NSURL the temporarily created file. */ -- (id)previewPanel:(id)panel previewItemAtIndex:(NSInteger)anIndex +- (id)previewPanel:(QLPreviewPanel *)panel previewItemAtIndex:(NSInteger)anIndex { if(tmpFileName) return [NSURL fileURLWithPath:tmpFileName]; @@ -1023,33 +960,19 @@ return nil; } -/** - * QuickLook delegate for SDK 10.5. - * - * @return It returns the frame of the application's middle. If an empty frame is returned then the panel will fade in/out instead. - */ -- (NSRect)previewPanel:(NSPanel*)panel frameForURL:(NSURL*)URL -{ - - // Close modal session defined in invokeQuickLookOfType: - // if user closes the QuickLook view - quickLookCloseMarker = 1; +#pragma mark - QLPreviewPanelDelegate methods - // Return the App's middle point - NSRect mwf = [[NSApp mainWindow] frame]; - return NSMakeRect( - mwf.origin.x+mwf.size.width/2, - mwf.origin.y+mwf.size.height/2, - 5, 5); - -} +// QuickLook delegates for SDK 10.6 +// - (BOOL)previewPanel:(QLPreviewPanel *)panel handleEvent:(NSEvent *)event +// { +// } /** * QuickLook delegate for SDK 10.6. * * @return It returns the frame of the application's middle. If an empty frame is returned then the panel will fade in/out instead. */ -- (NSRect)previewPanel:(id)panel sourceFrameOnScreenForPreviewItem:(id)item +- (NSRect)previewPanel:(QLPreviewPanel *)panel sourceFrameOnScreenForPreviewItem:(id)item { // Return the App's middle point NSRect mwf = [[NSApp mainWindow] frame]; @@ -1065,6 +988,8 @@ // return [NSImage imageNamed:@"database"]; // } +#pragma mark - + /** * Called by (SPImageView) if an image was pasted into the editSheet */ diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 9295c858..45add266 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -43,7 +43,6 @@ #import "SPQueryDocumentsController.h" #import "SPTextAndLinkCell.h" #ifndef SP_CODA -#import "QLPreviewPanel.h" #import "SPSplitView.h" #endif #import "SPFieldEditorController.h" |