From b44371f4bf6a30f507ae784d973ef3fa3a556c00 Mon Sep 17 00:00:00 2001 From: Pierre Laurac Date: Thu, 13 Oct 2016 08:20:47 -0700 Subject: [PATCH] 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])`