Route file actions through platform services
This commit is contained in:
@@ -120,6 +120,36 @@ public:
|
||||
displayKeyboard(visible);
|
||||
#else
|
||||
(void)visible;
|
||||
#endif
|
||||
}
|
||||
|
||||
void display_file(std::string_view path) override
|
||||
{
|
||||
const std::string value(path);
|
||||
#ifdef __IOS__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[App::I->ios_view display_file:value];
|
||||
});
|
||||
#elif __OSX__
|
||||
[[NSWorkspace sharedWorkspace] openFile:[NSString stringWithUTF8String:value.c_str()]];
|
||||
#else
|
||||
(void)value;
|
||||
#endif
|
||||
}
|
||||
|
||||
void share_file(std::string_view path) override
|
||||
{
|
||||
const std::string value(path);
|
||||
#ifdef __IOS__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[App::I->ios_view share_file:[NSString stringWithUTF8String:value.c_str()]];
|
||||
});
|
||||
#elif __OSX__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[App::I->osx_view share_file:[NSString stringWithUTF8String:value.c_str()]];
|
||||
});
|
||||
#else
|
||||
(void)value;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
@@ -398,24 +428,7 @@ void App::display_file(std::string path)
|
||||
if (pp::app::plan_display_file(path) == pp::app::DisplayFileAction::ignore_empty_path)
|
||||
return;
|
||||
|
||||
#ifdef __IOS__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view display_file:path];
|
||||
});
|
||||
#elif __OSX__
|
||||
[[NSWorkspace sharedWorkspace] openFile:[NSString stringWithUTF8String:path.c_str()]];
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// std::string path = [osx_view pick_file];
|
||||
// if (!path.empty())
|
||||
// callback(path);
|
||||
// });
|
||||
#elif __ANDROID__
|
||||
//displayKeyboard(and_app, false);
|
||||
#elif _WIN32
|
||||
// std::string path = win32_open_file();
|
||||
// if (!path.empty())
|
||||
// callback(path);
|
||||
#endif
|
||||
legacy_platform_services().display_file(path);
|
||||
}
|
||||
|
||||
void App::share_file(std::string path)
|
||||
@@ -426,18 +439,7 @@ void App::share_file(std::string path)
|
||||
message_box("Sharing failed", "Please save the document before sharing it.");
|
||||
return;
|
||||
}
|
||||
#ifdef __IOS__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view share_file:[NSString stringWithUTF8String:path.c_str()]];
|
||||
});
|
||||
#elif __OSX__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[osx_view share_file:[NSString stringWithUTF8String:path.c_str()]];
|
||||
});
|
||||
#elif __ANDROID__
|
||||
#elif _WIN32
|
||||
// not implemented
|
||||
#endif
|
||||
legacy_platform_services().share_file(path);
|
||||
}
|
||||
|
||||
bool App::mouse_down(int button, float x, float y, float pressure, kEventSource source, bool eraser)
|
||||
|
||||
@@ -13,6 +13,8 @@ public:
|
||||
[[nodiscard]] virtual bool set_clipboard_text(std::string_view text) = 0;
|
||||
virtual void set_cursor_visible(bool visible) = 0;
|
||||
virtual void set_virtual_keyboard_visible(bool visible) = 0;
|
||||
virtual void display_file(std::string_view path) = 0;
|
||||
virtual void share_file(std::string_view path) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user