From fb444f646b19ee4e2c4715fe5ae3e654b4af9664 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Tue, 11 Oct 2016 18:08:01 -0700 Subject: [PATCH 01/18] default template for PreviewFile --- atom/browser/api/atom_api_window.cc | 5 +++++ atom/browser/api/atom_api_window.h | 1 + atom/browser/native_window.cc | 3 +++ atom/browser/native_window.h | 1 + atom/browser/native_window_mac.h | 1 + atom/browser/native_window_mac.mm | 12 ++++++++++++ 6 files changed, 23 insertions(+) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index d5f1964517..dccf6a77ce 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -729,6 +729,10 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) { window_->SetAspectRatio(aspect_ratio, extra_size); } +void Window::PreviewFile(const base::string16& filepath) { + window_->PreviewFile(filepath); +} + void Window::SetParentWindow(v8::Local value, mate::Arguments* args) { if (IsModal()) { @@ -825,6 +829,7 @@ void Window::BuildPrototype(v8::Isolate* isolate, .SetMethod("setFullScreen", &Window::SetFullScreen) .SetMethod("isFullScreen", &Window::IsFullscreen) .SetMethod("setAspectRatio", &Window::SetAspectRatio) + .SetMethod("previewFile", &Window::PreviewFile) #if !defined(OS_WIN) .SetMethod("setParentWindow", &Window::SetParentWindow) #endif diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 317f5b51ec..abd19f9d5b 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -170,6 +170,7 @@ class Window : public mate::TrackableObject, void SetMenuBarVisibility(bool visible); bool IsMenuBarVisible(); void SetAspectRatio(double aspect_ratio, mate::Arguments* args); + void PreviewFile(const base::string16& filepath); void SetParentWindow(v8::Local value, mate::Arguments* args); v8::Local GetParentWindow() const; std::vector> GetChildWindows() const; diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 1cf5a23b6e..b6ea285159 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -374,6 +374,9 @@ void NativeWindow::SetAspectRatio(double aspect_ratio, aspect_ratio_extraSize_ = extra_size; } +void NativeWindow::PreviewFile(const base::string16& filepath) { +} + void NativeWindow::RequestToClosePage() { bool prevent_default = false; FOR_EACH_OBSERVER(NativeWindowObserver, diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index d8c022d606..c15868c5f4 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -176,6 +176,7 @@ class NativeWindow : public base::SupportsUserData, double GetAspectRatio(); gfx::Size GetAspectRatioExtraSize(); virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size); + virtual void PreviewFile(const base::string16& filepath); base::WeakPtr GetWeakPtr() { return weak_factory_.GetWeakPtr(); diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 4fd7bcc3c2..35649ae7d3 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -55,6 +55,7 @@ class NativeWindowMac : public NativeWindow, void SetMovable(bool movable) override; void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size) override; + void PreviewFile(const base::string16& filepath) override; bool IsMovable() override; void SetMinimizable(bool minimizable) override; bool IsMinimizable() override; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 98e8d4b656..1e18efcc71 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -10,6 +10,8 @@ #include "atom/common/color_util.h" #include "atom/common/draggable_region.h" #include "atom/common/options_switches.h" +#include "atom/common/native_mate_converters/string16_converter.h" +#include "base/strings/utf_string_conversions.h" #include "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" #include "base/strings/sys_string_conversions.h" @@ -25,6 +27,7 @@ #include "third_party/skia/include/core/SkRegion.h" #include "ui/gfx/skia_util.h" + namespace { // Prevents window from resizing during the scope. @@ -899,6 +902,15 @@ void NativeWindowMac::SetAspectRatio(double aspect_ratio, [window_ setResizeIncrements:NSMakeSize(1.0, 1.0)]; } +void NativeWindowMac::PreviewFile(const base::string16& filepath) { + std::string rtf = base::UTF16ToUTF8(filepath); + + NSString *path = [NSString stringWithCString:rtf.c_str() + encoding:[NSString defaultCStringEncoding]]; + NSAlert *alert = [NSAlert alertWithMessageText:path defaultButton:@"Close anyway" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@""]; + [alert runModal]; +} + void NativeWindowMac::SetMovable(bool movable) { [window_ setMovable:movable]; } From 526debb5ab5bdf6d72a71a0fc4c6f7f7f53ba5b7 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Wed, 12 Oct 2016 17:21:56 -0700 Subject: [PATCH 02/18] Adding easy way to preview files --- atom/browser/api/atom_api_window.cc | 4 +- atom/browser/api/atom_api_window.h | 2 +- atom/browser/native_window.cc | 2 +- atom/browser/native_window.h | 2 +- atom/browser/native_window_mac.h | 3 +- atom/browser/native_window_mac.mm | 72 ++++++++++++++++++++++++++--- electron.gyp | 1 + 7 files changed, 73 insertions(+), 13 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index dccf6a77ce..408f738c4b 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -729,8 +729,8 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) { window_->SetAspectRatio(aspect_ratio, extra_size); } -void Window::PreviewFile(const base::string16& filepath) { - window_->PreviewFile(filepath); +void Window::PreviewFile(const base::string16& filepath, const base::string16& filename) { + window_->PreviewFile(filepath, filename); } void Window::SetParentWindow(v8::Local value, diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index abd19f9d5b..e92960f339 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -170,7 +170,7 @@ class Window : public mate::TrackableObject, void SetMenuBarVisibility(bool visible); bool IsMenuBarVisible(); void SetAspectRatio(double aspect_ratio, mate::Arguments* args); - void PreviewFile(const base::string16& filepath); + void PreviewFile(const base::string16& filepath, const base::string16& filename); void SetParentWindow(v8::Local value, mate::Arguments* args); v8::Local GetParentWindow() const; std::vector> GetChildWindows() const; diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index b6ea285159..f9b762f544 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -374,7 +374,7 @@ void NativeWindow::SetAspectRatio(double aspect_ratio, aspect_ratio_extraSize_ = extra_size; } -void NativeWindow::PreviewFile(const base::string16& filepath) { +void NativeWindow::PreviewFile(const base::string16& filepath, const base::string16& filename) { } void NativeWindow::RequestToClosePage() { diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index c15868c5f4..c10cb90725 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -176,7 +176,7 @@ class NativeWindow : public base::SupportsUserData, double GetAspectRatio(); gfx::Size GetAspectRatioExtraSize(); virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size); - virtual void PreviewFile(const base::string16& filepath); + virtual void PreviewFile(const base::string16& filepath, const base::string16& filename); base::WeakPtr GetWeakPtr() { return weak_factory_.GetWeakPtr(); diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 35649ae7d3..6e3f586703 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -9,6 +9,7 @@ #include #include +#include #include "atom/browser/native_window.h" #include "base/mac/scoped_nsobject.h" @@ -55,7 +56,7 @@ class NativeWindowMac : public NativeWindow, void SetMovable(bool movable) override; void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size) override; - void PreviewFile(const base::string16& filepath) override; + void PreviewFile(const base::string16& filepath, const base::string16& filename) override; bool IsMovable() override; void SetMinimizable(bool minimizable) override; bool IsMinimizable() override; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 1e18efcc71..cf9e863b86 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -5,6 +5,7 @@ #include "atom/browser/native_window_mac.h" #include +#include #include "atom/browser/window_list.h" #include "atom/common/color_util.h" @@ -280,7 +281,29 @@ bool ScopedDisableResize::disable_resize_ = false; @end -@interface AtomNSWindow : EventDispatchingWindow { +@interface AtomPreviewItem : NSObject + +@property (nonatomic, retain) NSURL *previewItemURL; +@property (nonatomic, retain) NSString *previewItemTitle; + +- (id)initWithURL:(NSURL *)anURL title:(NSString *)aTitle; + +@end + +@implementation AtomPreviewItem + +- (id)initWithURL:(NSURL *)url title:(NSString *)title { + self = [super init]; + if (self) { + self.previewItemURL = url; + self.previewItemTitle = title; + } + return self; +} + +@end + +@interface AtomNSWindow : EventDispatchingWindow { @private atom::NativeWindowMac* shell_; bool enable_larger_than_screen_; @@ -290,6 +313,7 @@ bool ScopedDisableResize::disable_resize_ = false; @property BOOL disableAutoHideCursor; @property BOOL disableKeyOrMainWindow; @property NSPoint windowButtonsOffset; +@property (nonatomic, retain) AtomPreviewItem* quickLookItem; - (void)setShell:(atom::NativeWindowMac*)shell; - (void)setEnableLargerThanScreen:(bool)enable; @@ -447,6 +471,36 @@ bool ScopedDisableResize::disable_resize_ = false; return [[self contentView] superview]; } +// Quicklook methods + +- (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel *)panel { + return YES; +} + +- (void)beginPreviewPanelControl:(QLPreviewPanel *)panel { + panel.delegate = self; + panel.dataSource = self; +} + +- (void)endPreviewPanelControl:(QLPreviewPanel *)panel { + panel.delegate = nil; + panel.dataSource = nil; +} + +- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel *)panel { + return 1; +} + +- (id )previewPanel:(QLPreviewPanel *)panel previewItemAtIndex:(NSInteger)index { + return [self quickLookItem]; +} + +- (void)previewFileAtPath:(NSString *)filepath withName:(NSString *) name { + NSURL * url = [[NSURL alloc] initFileURLWithPath:filepath]; + [self setQuickLookItem:[[AtomPreviewItem alloc] initWithURL:url title:name]]; + [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil]; +} + @end @interface ControlRegionView : NSView @@ -902,13 +956,17 @@ void NativeWindowMac::SetAspectRatio(double aspect_ratio, [window_ setResizeIncrements:NSMakeSize(1.0, 1.0)]; } -void NativeWindowMac::PreviewFile(const base::string16& filepath) { - std::string rtf = base::UTF16ToUTF8(filepath); +void NativeWindowMac::PreviewFile(const base::string16& filepath, const base::string16& filename) { + std::string pathStr = base::UTF16ToUTF8(filepath); + std::string nameStr = base::UTF16ToUTF8(filename); - NSString *path = [NSString stringWithCString:rtf.c_str() - encoding:[NSString defaultCStringEncoding]]; - NSAlert *alert = [NSAlert alertWithMessageText:path defaultButton:@"Close anyway" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@""]; - [alert runModal]; + NSString *path = [NSString stringWithCString:pathStr.c_str() + encoding:[NSString defaultCStringEncoding]]; + + NSString *name = [NSString stringWithCString:nameStr.c_str() + encoding:[NSString defaultCStringEncoding]]; + + [window_ previewFileAtPath:path withName:name]; } void NativeWindowMac::SetMovable(bool movable) { diff --git a/electron.gyp b/electron.gyp index 413d6c5580..0552006e69 100644 --- a/electron.gyp +++ b/electron.gyp @@ -509,6 +509,7 @@ 'libraries': [ '$(SDKROOT)/System/Library/Frameworks/Carbon.framework', '$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework', + '$(SDKROOT)/System/Library/Frameworks/Quartz.framework', ], }, 'mac_bundle': 1, From 9673cee4d71c6856c0f76b802d079bb3dc167592 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Wed, 12 Oct 2016 17:25:31 -0700 Subject: [PATCH 03/18] Using string from the std --- atom/browser/api/atom_api_window.cc | 2 +- atom/browser/api/atom_api_window.h | 2 +- atom/browser/native_window.cc | 2 +- atom/browser/native_window.h | 2 +- atom/browser/native_window_mac.h | 4 ++-- atom/browser/native_window_mac.mm | 9 +++------ 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 408f738c4b..516d322b3a 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -729,7 +729,7 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) { window_->SetAspectRatio(aspect_ratio, extra_size); } -void Window::PreviewFile(const base::string16& filepath, const base::string16& filename) { +void Window::PreviewFile(const std::string& filepath, const std::string& filename) { window_->PreviewFile(filepath, filename); } diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index e92960f339..966b85cdb5 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -170,7 +170,7 @@ class Window : public mate::TrackableObject, void SetMenuBarVisibility(bool visible); bool IsMenuBarVisible(); void SetAspectRatio(double aspect_ratio, mate::Arguments* args); - void PreviewFile(const base::string16& filepath, const base::string16& filename); + void PreviewFile(const std::string& filepath, const std::string& filename); void SetParentWindow(v8::Local value, mate::Arguments* args); v8::Local GetParentWindow() const; std::vector> GetChildWindows() const; diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index f9b762f544..d01e6fbb21 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -374,7 +374,7 @@ void NativeWindow::SetAspectRatio(double aspect_ratio, aspect_ratio_extraSize_ = extra_size; } -void NativeWindow::PreviewFile(const base::string16& filepath, const base::string16& filename) { +void NativeWindow::PreviewFile(const std::string& filepath, const std::string& filename) { } void NativeWindow::RequestToClosePage() { diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index c10cb90725..9c4116a68b 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -176,7 +176,7 @@ class NativeWindow : public base::SupportsUserData, double GetAspectRatio(); gfx::Size GetAspectRatioExtraSize(); virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size); - virtual void PreviewFile(const base::string16& filepath, const base::string16& filename); + virtual void PreviewFile(const std::string& filepath, const std::string& filename); base::WeakPtr GetWeakPtr() { return weak_factory_.GetWeakPtr(); diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 6e3f586703..9fc2627a0c 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -9,7 +9,6 @@ #include #include -#include #include "atom/browser/native_window.h" #include "base/mac/scoped_nsobject.h" @@ -56,7 +55,8 @@ class NativeWindowMac : public NativeWindow, void SetMovable(bool movable) override; void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size) override; - void PreviewFile(const base::string16& filepath, const base::string16& filename) override; + void PreviewFile(const std::string& filepath, const std::string& filename) + override; bool IsMovable() override; void SetMinimizable(bool minimizable) override; bool IsMinimizable() override; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index cf9e863b86..3be1e14de7 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -956,14 +956,11 @@ void NativeWindowMac::SetAspectRatio(double aspect_ratio, [window_ setResizeIncrements:NSMakeSize(1.0, 1.0)]; } -void NativeWindowMac::PreviewFile(const base::string16& filepath, const base::string16& filename) { - std::string pathStr = base::UTF16ToUTF8(filepath); - std::string nameStr = base::UTF16ToUTF8(filename); - - NSString *path = [NSString stringWithCString:pathStr.c_str() +void NativeWindowMac::PreviewFile(const std::string& filepath, const std::string& filename) { + NSString *path = [NSString stringWithCString:filepath.c_str() encoding:[NSString defaultCStringEncoding]]; - NSString *name = [NSString stringWithCString:nameStr.c_str() + NSString *name = [NSString stringWithCString:filename.c_str() encoding:[NSString defaultCStringEncoding]]; [window_ previewFileAtPath:path withName:name]; From 4d305b06d1c2824e76e1dbebcb3b19b168730b8b Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Wed, 12 Oct 2016 20:46:42 -0700 Subject: [PATCH 04/18] Adding documentation --- docs/api/browser-window.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 345419eed2..56478039e2 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -664,6 +664,11 @@ the player itself we would call this function with arguments of 16/9 and are within the content view--only that they exist. Just sum any extra width and height areas you have within the overall content view. +#### `win.previewFile(pathname, filename)` + +* `pathname` String - The absolute path to the file to preview with QuickLook. This is important as Quicklook uses the file name and file extension on the path to determine the content_type of the file to open. +* `filename` String - The name of the file to display on QuickLook modal view. This is purely visual and does not affect the content_type of the file. + #### `win.setBounds(bounds[, animate])` * `bounds` [Rectangle](structures/rectangle.md) From 002462ce7b4d3f0c49bceb3e94ec3c7a6cfc1dd1 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Wed, 12 Oct 2016 20:48:40 -0700 Subject: [PATCH 05/18] Removing unused header dependencies --- atom/browser/native_window_mac.mm | 2 -- 1 file changed, 2 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 3be1e14de7..cae346a330 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -11,8 +11,6 @@ #include "atom/common/color_util.h" #include "atom/common/draggable_region.h" #include "atom/common/options_switches.h" -#include "atom/common/native_mate_converters/string16_converter.h" -#include "base/strings/utf_string_conversions.h" #include "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" #include "base/strings/sys_string_conversions.h" From 2f7cceb11cdfaf9bea8d93ce1532ae1a8469f412 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Wed, 12 Oct 2016 20:49:11 -0700 Subject: [PATCH 06/18] Removing extra line break --- atom/browser/native_window_mac.mm | 1 - 1 file changed, 1 deletion(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index cae346a330..7415ce76e4 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -26,7 +26,6 @@ #include "third_party/skia/include/core/SkRegion.h" #include "ui/gfx/skia_util.h" - namespace { // Prevents window from resizing during the scope. From 18ac4178fee758c90121c8c284688724c9b401fb Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Wed, 12 Oct 2016 21:07:14 -0700 Subject: [PATCH 07/18] Validation with linter --- atom/browser/api/atom_api_window.cc | 3 ++- atom/browser/native_window.cc | 3 ++- atom/browser/native_window.h | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 516d322b3a..aa9c9cca68 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -729,7 +729,8 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) { window_->SetAspectRatio(aspect_ratio, extra_size); } -void Window::PreviewFile(const std::string& filepath, const std::string& filename) { +void Window::PreviewFile(const std::string& filepath, + const std::string& filename) { window_->PreviewFile(filepath, filename); } diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index d01e6fbb21..140dd1e3b6 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -374,7 +374,8 @@ void NativeWindow::SetAspectRatio(double aspect_ratio, aspect_ratio_extraSize_ = extra_size; } -void NativeWindow::PreviewFile(const std::string& filepath, const std::string& filename) { +void NativeWindow::PreviewFile(const std::string& filepath, + const std::string& filename) { } void NativeWindow::RequestToClosePage() { diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 9c4116a68b..e3b9fe563e 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -176,7 +176,8 @@ class NativeWindow : public base::SupportsUserData, double GetAspectRatio(); gfx::Size GetAspectRatioExtraSize(); virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size); - virtual void PreviewFile(const std::string& filepath, const std::string& filename); + virtual void PreviewFile(const std::string& filepath, + const std::string& filename); base::WeakPtr GetWeakPtr() { return weak_factory_.GetWeakPtr(); From 9736dc31156fc44c2da2264f16af6a8b64470b8b Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Wed, 12 Oct 2016 21:12:50 -0700 Subject: [PATCH 08/18] Specifying macOS only method --- docs/api/browser-window.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 56478039e2..b031fd47a6 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -664,7 +664,7 @@ the player itself we would call this function with arguments of 16/9 and are within the content view--only that they exist. Just sum any extra width and height areas you have within the overall content view. -#### `win.previewFile(pathname, filename)` +#### `win.previewFile(pathname, filename)` _macOS_ * `pathname` String - The absolute path to the file to preview with QuickLook. This is important as Quicklook uses the file name and file extension on the path to determine the content_type of the file to open. * `filename` String - The name of the file to display on QuickLook modal view. This is purely visual and does not affect the content_type of the file. From b44371f4bf6a30f507ae784d973ef3fa3a556c00 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Thu, 13 Oct 2016 08:20:47 -0700 Subject: [PATCH 09/18] filename as Optional argument --- atom/browser/api/atom_api_window.cc | 7 +++++-- atom/browser/api/atom_api_window.h | 2 +- docs/api/browser-window.md | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index aa9c9cca68..12a987fe7f 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -729,8 +729,11 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) { window_->SetAspectRatio(aspect_ratio, extra_size); } -void Window::PreviewFile(const std::string& filepath, - const std::string& filename) { +void Window::PreviewFile(const std::string& filepath, mate::Arguments* args) { + std::string filename; + if (!args->GetNext(&filename)) { + filename = filepath; + } window_->PreviewFile(filepath, filename); } diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 966b85cdb5..a340b2c5e1 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -170,7 +170,7 @@ class Window : public mate::TrackableObject, void SetMenuBarVisibility(bool visible); bool IsMenuBarVisible(); void SetAspectRatio(double aspect_ratio, mate::Arguments* args); - void PreviewFile(const std::string& filepath, const std::string& filename); + void PreviewFile(const std::string& filepath, mate::Arguments* args); void SetParentWindow(v8::Local value, mate::Arguments* args); v8::Local GetParentWindow() const; std::vector> GetChildWindows() const; diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index b031fd47a6..fccedae527 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -664,10 +664,12 @@ the player itself we would call this function with arguments of 16/9 and are within the content view--only that they exist. Just sum any extra width and height areas you have within the overall content view. -#### `win.previewFile(pathname, filename)` _macOS_ +#### `win.previewFile(pathname[, filename])` _macOS_ * `pathname` String - The absolute path to the file to preview with QuickLook. This is important as Quicklook uses the file name and file extension on the path to determine the content_type of the file to open. -* `filename` String - The name of the file to display on QuickLook modal view. This is purely visual and does not affect the content_type of the file. +* `filename` String (Optional) - The name of the file to display on the QuickLook modal view. This is purely visual and does not affect the content_type of the file. Defaults to filepath. + +Uses QuickLook to preview a file at a given path. #### `win.setBounds(bounds[, animate])` From e759ce72b55503e4003ceed3e92f2d5f13de5b49 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Thu, 13 Oct 2016 09:20:55 -0700 Subject: [PATCH 10/18] Using UTF8 String for filepath and filename --- atom/browser/native_window_mac.mm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 7415ce76e4..1a51f68a93 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -954,11 +954,8 @@ void NativeWindowMac::SetAspectRatio(double aspect_ratio, } void NativeWindowMac::PreviewFile(const std::string& filepath, const std::string& filename) { - NSString *path = [NSString stringWithCString:filepath.c_str() - encoding:[NSString defaultCStringEncoding]]; - - NSString *name = [NSString stringWithCString:filename.c_str() - encoding:[NSString defaultCStringEncoding]]; + NSString *path = [NSString stringWithUTF8String:filepath.c_str()]; + NSString *name = [NSString stringWithUTF8String:filename.c_str()]; [window_ previewFileAtPath:path withName:name]; } From 6bac17fb9a521882b07b0492e42b66529864ea92 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Thu, 13 Oct 2016 15:01:48 -0700 Subject: [PATCH 11/18] Linter --- atom/browser/api/atom_api_window.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 12a987fe7f..564c5392da 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -733,7 +733,7 @@ void Window::PreviewFile(const std::string& filepath, mate::Arguments* args) { std::string filename; if (!args->GetNext(&filename)) { filename = filepath; - } + } window_->PreviewFile(filepath, filename); } From 9b19e6ee3895a6aa7b805d4b5f1cd8b733f092ac Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Fri, 14 Oct 2016 09:42:50 -0700 Subject: [PATCH 12/18] Changing names and memory leak fix --- atom/browser/api/atom_api_window.cc | 10 +++++----- atom/browser/api/atom_api_window.h | 2 +- atom/browser/native_window.cc | 4 ++-- atom/browser/native_window.h | 4 ++-- atom/browser/native_window_mac.h | 2 +- atom/browser/native_window_mac.mm | 14 +++++++------- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 564c5392da..a0391985d7 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -729,12 +729,12 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) { window_->SetAspectRatio(aspect_ratio, extra_size); } -void Window::PreviewFile(const std::string& filepath, mate::Arguments* args) { - std::string filename; - if (!args->GetNext(&filename)) { - filename = filepath; +void Window::PreviewFile(const std::string& path, mate::Arguments* args) { + std::string fileName; + if (!args->GetNext(&fileName)) { + fileName = path; } - window_->PreviewFile(filepath, filename); + window_->PreviewFile(path, fileName); } void Window::SetParentWindow(v8::Local value, diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index a340b2c5e1..ba1a999b2b 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -170,7 +170,7 @@ class Window : public mate::TrackableObject, void SetMenuBarVisibility(bool visible); bool IsMenuBarVisible(); void SetAspectRatio(double aspect_ratio, mate::Arguments* args); - void PreviewFile(const std::string& filepath, mate::Arguments* args); + void PreviewFile(const std::string& path, mate::Arguments* args); void SetParentWindow(v8::Local value, mate::Arguments* args); v8::Local GetParentWindow() const; std::vector> GetChildWindows() const; diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 140dd1e3b6..9d56615e6b 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -374,8 +374,8 @@ void NativeWindow::SetAspectRatio(double aspect_ratio, aspect_ratio_extraSize_ = extra_size; } -void NativeWindow::PreviewFile(const std::string& filepath, - const std::string& filename) { +void NativeWindow::PreviewFile(const std::string& path, + const std::string& fileName) { } void NativeWindow::RequestToClosePage() { diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index e3b9fe563e..e3d1558cfa 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -176,8 +176,8 @@ class NativeWindow : public base::SupportsUserData, double GetAspectRatio(); gfx::Size GetAspectRatioExtraSize(); virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size); - virtual void PreviewFile(const std::string& filepath, - const std::string& filename); + virtual void PreviewFile(const std::string& path, + const std::string& fileName); base::WeakPtr GetWeakPtr() { return weak_factory_.GetWeakPtr(); diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 9fc2627a0c..1a6d2d382c 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -55,7 +55,7 @@ class NativeWindowMac : public NativeWindow, void SetMovable(bool movable) override; void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size) override; - void PreviewFile(const std::string& filepath, const std::string& filename) + void PreviewFile(const std::string& path, const std::string& fileName) override; bool IsMovable() override; void SetMinimizable(bool minimizable) override; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 1a51f68a93..52e2111da3 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -492,9 +492,9 @@ bool ScopedDisableResize::disable_resize_ = false; return [self quickLookItem]; } -- (void)previewFileAtPath:(NSString *)filepath withName:(NSString *) name { - NSURL * url = [[NSURL alloc] initFileURLWithPath:filepath]; - [self setQuickLookItem:[[AtomPreviewItem alloc] initWithURL:url title:name]]; +- (void)previewFileAtPath:(NSString *)path withName:(NSString *) fileName { + NSURL * url = [[[NSURL alloc] initFileURLWithPath:path] autorelease]; + [self setQuickLookItem:[[[AtomPreviewItem alloc] initWithURL:url title:fileName] autorelease]]; [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil]; } @@ -953,11 +953,11 @@ void NativeWindowMac::SetAspectRatio(double aspect_ratio, [window_ setResizeIncrements:NSMakeSize(1.0, 1.0)]; } -void NativeWindowMac::PreviewFile(const std::string& filepath, const std::string& filename) { - NSString *path = [NSString stringWithUTF8String:filepath.c_str()]; - NSString *name = [NSString stringWithUTF8String:filename.c_str()]; +void NativeWindowMac::PreviewFile(const std::string& path, const std::string& fileName) { + NSString *pathStr = [NSString stringWithUTF8String:path.c_str()]; + NSString *nameStr = [NSString stringWithUTF8String:fileName.c_str()]; - [window_ previewFileAtPath:path withName:name]; + [window_ previewFileAtPath:pathStr withName:nameStr]; } void NativeWindowMac::SetMovable(bool movable) { From 1f60aff73d765e82c5f27c37b27df321f063c3d3 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Mon, 24 Oct 2016 11:49:30 -0700 Subject: [PATCH 13/18] linter --- atom/browser/native_window_mac.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 52e2111da3..0981aa5cdb 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -280,16 +280,16 @@ bool ScopedDisableResize::disable_resize_ = false; @interface AtomPreviewItem : NSObject -@property (nonatomic, retain) NSURL *previewItemURL; -@property (nonatomic, retain) NSString *previewItemTitle; +@property (nonatomic, retain) NSURL* previewItemURL; +@property (nonatomic, retain) NSString* previewItemTitle; -- (id)initWithURL:(NSURL *)anURL title:(NSString *)aTitle; +- (id)initWithURL:(NSURL*)url title:(NSString*)title; @end @implementation AtomPreviewItem -- (id)initWithURL:(NSURL *)url title:(NSString *)title { +- (id)initWithURL:(NSURL*)url title:(NSString*)title { self = [super init]; if (self) { self.previewItemURL = url; From cf5fc3f92225abe397cfe527e552c11383231824 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Mon, 24 Oct 2016 11:54:22 -0700 Subject: [PATCH 14/18] more linter --- atom/browser/native_window_mac.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 0981aa5cdb..d20618b96a 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -470,21 +470,21 @@ bool ScopedDisableResize::disable_resize_ = false; // Quicklook methods -- (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel *)panel { +- (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel*)panel { return YES; } -- (void)beginPreviewPanelControl:(QLPreviewPanel *)panel { +- (void)beginPreviewPanelControl:(QLPreviewPanel*)panel { panel.delegate = self; panel.dataSource = self; } -- (void)endPreviewPanelControl:(QLPreviewPanel *)panel { +- (void)endPreviewPanelControl:(QLPreviewPanel*)panel { panel.delegate = nil; panel.dataSource = nil; } -- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel *)panel { +- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel*)panel { return 1; } From 0ec57cca325b6a59f6460a53d2bb52356b5c3760 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Mon, 24 Oct 2016 11:55:48 -0700 Subject: [PATCH 15/18] last linter commit --- atom/browser/native_window_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index d20618b96a..89378f2307 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -488,11 +488,11 @@ bool ScopedDisableResize::disable_resize_ = false; return 1; } -- (id )previewPanel:(QLPreviewPanel *)panel previewItemAtIndex:(NSInteger)index { +- (id )previewPanel:(QLPreviewPanel*)panel previewItemAtIndex:(NSInteger)index { return [self quickLookItem]; } -- (void)previewFileAtPath:(NSString *)path withName:(NSString *) fileName { +- (void)previewFileAtPath:(NSString*)path withName:(NSString*) fileName { NSURL * url = [[[NSURL alloc] initFileURLWithPath:path] autorelease]; [self setQuickLookItem:[[[AtomPreviewItem alloc] initWithURL:url title:fileName] autorelease]]; [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil]; From d26601f695a9f7d65a0f56712b6836e25c91f166 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Tue, 25 Oct 2016 07:52:56 -0700 Subject: [PATCH 16/18] Convention naming --- atom/browser/native_window_mac.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 89378f2307..98fc2c8695 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -493,7 +493,7 @@ bool ScopedDisableResize::disable_resize_ = false; } - (void)previewFileAtPath:(NSString*)path withName:(NSString*) fileName { - NSURL * url = [[[NSURL alloc] initFileURLWithPath:path] autorelease]; + NSURL* url = [[[NSURL alloc] initFileURLWithPath:path] autorelease]; [self setQuickLookItem:[[[AtomPreviewItem alloc] initWithURL:url title:fileName] autorelease]]; [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil]; } @@ -954,8 +954,8 @@ void NativeWindowMac::SetAspectRatio(double aspect_ratio, } void NativeWindowMac::PreviewFile(const std::string& path, const std::string& fileName) { - NSString *pathStr = [NSString stringWithUTF8String:path.c_str()]; - NSString *nameStr = [NSString stringWithUTF8String:fileName.c_str()]; + NSString* pathStr = [NSString stringWithUTF8String:path.c_str()]; + NSString* nameStr = [NSString stringWithUTF8String:fileName.c_str()]; [window_ previewFileAtPath:pathStr withName:nameStr]; } From d982376fc4a1a98f01ad3665ade218f947bc66a6 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 26 Oct 2016 09:47:22 +0900 Subject: [PATCH 17/18] filename -> displayName --- atom/browser/api/atom_api_window.cc | 8 ++++---- atom/browser/native_window.cc | 2 +- atom/browser/native_window.h | 2 +- atom/browser/native_window_mac.h | 2 +- atom/browser/native_window_mac.mm | 14 +++++++------- docs/api/browser-window.md | 13 +++++++++---- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index a0391985d7..ae37f504ca 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -730,11 +730,11 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) { } void Window::PreviewFile(const std::string& path, mate::Arguments* args) { - std::string fileName; - if (!args->GetNext(&fileName)) { - fileName = path; + std::string display_name; + if (!args->GetNext(&display_name)) { + display_name = path; } - window_->PreviewFile(path, fileName); + window_->PreviewFile(path, display_name); } void Window::SetParentWindow(v8::Local value, diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 9d56615e6b..6c32e79e19 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -375,7 +375,7 @@ void NativeWindow::SetAspectRatio(double aspect_ratio, } void NativeWindow::PreviewFile(const std::string& path, - const std::string& fileName) { + const std::string& display_name) { } void NativeWindow::RequestToClosePage() { diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index e3d1558cfa..3d190ba7d9 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -177,7 +177,7 @@ class NativeWindow : public base::SupportsUserData, gfx::Size GetAspectRatioExtraSize(); virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size); virtual void PreviewFile(const std::string& path, - const std::string& fileName); + const std::string& display_name); base::WeakPtr GetWeakPtr() { return weak_factory_.GetWeakPtr(); diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 1a6d2d382c..979d69d1a2 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -55,7 +55,7 @@ class NativeWindowMac : public NativeWindow, void SetMovable(bool movable) override; void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size) override; - void PreviewFile(const std::string& path, const std::string& fileName) + void PreviewFile(const std::string& path, const std::string& display_name) override; bool IsMovable() override; void SetMinimizable(bool minimizable) override; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 98fc2c8695..d9de9bd3ca 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -290,11 +290,11 @@ bool ScopedDisableResize::disable_resize_ = false; @implementation AtomPreviewItem - (id)initWithURL:(NSURL*)url title:(NSString*)title { - self = [super init]; + self = [super init]; if (self) { self.previewItemURL = url; self.previewItemTitle = title; - } + } return self; } @@ -953,11 +953,11 @@ void NativeWindowMac::SetAspectRatio(double aspect_ratio, [window_ setResizeIncrements:NSMakeSize(1.0, 1.0)]; } -void NativeWindowMac::PreviewFile(const std::string& path, const std::string& fileName) { - NSString* pathStr = [NSString stringWithUTF8String:path.c_str()]; - NSString* nameStr = [NSString stringWithUTF8String:fileName.c_str()]; - - [window_ previewFileAtPath:pathStr withName:nameStr]; +void NativeWindowMac::PreviewFile(const std::string& path, + const std::string& display_name) { + NSString* path_ns = [NSString stringWithUTF8String:path.c_str()]; + NSString* name_ns = [NSString stringWithUTF8String:display_name.c_str()]; + [window_ previewFileAtPath:path_ns withName:name_ns]; } void NativeWindowMac::SetMovable(bool movable) { diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index fccedae527..b891396dba 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -664,12 +664,16 @@ the player itself we would call this function with arguments of 16/9 and are within the content view--only that they exist. Just sum any extra width and height areas you have within the overall content view. -#### `win.previewFile(pathname[, filename])` _macOS_ +#### `win.previewFile(pathname[, displayName])` _macOS_ -* `pathname` String - The absolute path to the file to preview with QuickLook. This is important as Quicklook uses the file name and file extension on the path to determine the content_type of the file to open. -* `filename` String (Optional) - The name of the file to display on the QuickLook modal view. This is purely visual and does not affect the content_type of the file. Defaults to filepath. +* `path` String - The absolute path to the file to preview with QuickLook. This + is important as Quick Look uses the file name and file extension on the path to + determine the content type of the file to open. +* `displayName` String (Optional) - The name of the file to display on the + Quick Look modal view. This is purely visual and does not affect the content + type of the file. Defaults to `path`. -Uses QuickLook to preview a file at a given path. +Uses [Quick Look][quick-look] to preview a file at a given path. #### `win.setBounds(bounds[, animate])` @@ -1189,3 +1193,4 @@ Returns `BrowserWindow` - The parent window. Returns `BrowserWindow[]` - All child windows. [window-levels]: https://developer.apple.com/reference/appkit/nswindow/1664726-window_levels +[quick-look]: https://en.wikipedia.org/wiki/Quick_Look From d85c4da11b7e577a0b96bfef1e576962044c3daa Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 26 Oct 2016 09:55:34 +0900 Subject: [PATCH 18/18] Minor formatting tweaks --- atom/browser/api/atom_api_window.cc | 3 +-- atom/browser/native_window_mac.mm | 2 +- docs/api/browser-window.md | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index ae37f504ca..88b0459c26 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -731,9 +731,8 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) { void Window::PreviewFile(const std::string& path, mate::Arguments* args) { std::string display_name; - if (!args->GetNext(&display_name)) { + if (!args->GetNext(&display_name)) display_name = path; - } window_->PreviewFile(path, display_name); } diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index d9de9bd3ca..95423e0851 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -4,8 +4,8 @@ #include "atom/browser/native_window_mac.h" -#include #include +#include #include "atom/browser/window_list.h" #include "atom/common/color_util.h" diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index b891396dba..059c9f152d 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -664,11 +664,11 @@ the player itself we would call this function with arguments of 16/9 and are within the content view--only that they exist. Just sum any extra width and height areas you have within the overall content view. -#### `win.previewFile(pathname[, displayName])` _macOS_ +#### `win.previewFile(path[, displayName])` _macOS_ * `path` String - The absolute path to the file to preview with QuickLook. This - is important as Quick Look uses the file name and file extension on the path to - determine the content type of the file to open. + is important as Quick Look uses the file name and file extension on the path + to determine the content type of the file to open. * `displayName` String (Optional) - The name of the file to display on the Quick Look modal view. This is purely visual and does not affect the content type of the file. Defaults to `path`.