associate abr files to panopainter on iOS and fix import menu

This commit is contained in:
2019-02-27 16:43:57 +01:00
parent c33fcdf932
commit f8987e2236
3 changed files with 77 additions and 30 deletions

View File

@@ -18,6 +18,16 @@
<string>com.panopainter.image</string> <string>com.panopainter.image</string>
</array> </array>
</dict> </dict>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>ABR</string>
<key>LSItemContentTypes</key>
<array>
<string>com.panopainter.abr</string>
</array>
</dict>
</array> </array>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
@@ -69,6 +79,7 @@
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>UTExportedTypeDeclarations</key> <key>UTExportedTypeDeclarations</key>
<array>
<array> <array>
<dict> <dict>
<key>UTTypeConformsTo</key> <key>UTTypeConformsTo</key>
@@ -93,5 +104,28 @@
</dict> </dict>
</dict> </dict>
</array> </array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
<string>public.content</string>
</array>
<key>UTTypeDescription</key>
<string>ABR</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>com.panopainter.abr</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>abr</string>
</array>
<key>public.mime-type</key>
<string>preset/abr</string>
</dict>
</dict>
</array>
</dict> </dict>
</plist> </plist>

View File

@@ -31,9 +31,20 @@ void App::create()
void App::open_document(std::string path) void App::open_document(std::string path)
{ {
auto start = path.rfind('/') + 1; std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)$)");
doc_name = path.substr(start, path.length() - start - strlen(".ppi")); std::smatch m;
doc_dir = path.substr(0, start - 1); if (!std::regex_search(path, m, r))
return;
std::string ext = m[3].str();
if (str_iequals(m[3].str(), "abr"))
{
std::thread(&NodePanelStroke::import_abr, stroke, path).detach();
}
else
{
doc_name = m[2].str();
doc_dir = m[1].str();
doc_path = path; doc_path = path;
canvas->reset_camera(); canvas->reset_camera();
layers->clear(); layers->clear();
@@ -58,6 +69,7 @@ void App::open_document(std::string path)
} }
}); });
ActionManager::clear(); ActionManager::clear();
}
} }
bool App::request_close() bool App::request_close()

View File

@@ -86,7 +86,8 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
redraw = true; redraw = true;
#ifdef __IOS__ #ifdef __IOS__
// not implemented on ios // not implemented on ios
//[ios_view pick_photo:callback]; // fallback to pick_image
[ios_view pick_photo:callback];
#elif __OSX__ #elif __OSX__
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
//NSArray* fileTypes = [NSArray arrayWithObjects:@"ppi", @"PPI", nil]; //NSArray* fileTypes = [NSArray arrayWithObjects:@"ppi", @"PPI", nil];