Move app open routing into document helper
This commit is contained in:
11
src/app.cpp
11
src/app.cpp
@@ -35,16 +35,7 @@ void App::create()
|
||||
|
||||
void App::open_document(std::string path)
|
||||
{
|
||||
const auto route = pp::app::classify_document_open_path(path);
|
||||
if (!route)
|
||||
return;
|
||||
|
||||
const bool has_unsaved_project =
|
||||
route.value().kind == pp::app::DocumentOpenKind::open_project && Canvas::I->m_unsaved;
|
||||
const auto open_plan = pp::app::plan_document_open(route.value().kind, has_unsaved_project);
|
||||
const auto status = pp::panopainter::execute_legacy_document_open_plan(*this, open_plan, route.value());
|
||||
if (!status.ok())
|
||||
LOG("Document open action failed: %s", status.message);
|
||||
pp::panopainter::execute_legacy_document_open(*this, std::move(path));
|
||||
}
|
||||
|
||||
bool App::request_close()
|
||||
|
||||
@@ -163,6 +163,22 @@ pp::foundation::Status execute_legacy_document_open_plan(
|
||||
return pp::app::execute_document_open_plan(action, route, services);
|
||||
}
|
||||
|
||||
pp::foundation::Status execute_legacy_document_open(App& app, std::string path)
|
||||
{
|
||||
const auto route = pp::app::classify_document_open_path(path);
|
||||
if (!route)
|
||||
return route.status();
|
||||
|
||||
const bool has_unsaved_project =
|
||||
route.value().kind == pp::app::DocumentOpenKind::open_project && Canvas::I->m_unsaved;
|
||||
const auto open_plan = pp::app::plan_document_open(route.value().kind, has_unsaved_project);
|
||||
const auto status = execute_legacy_document_open_plan(app, open_plan, route.value());
|
||||
if (!status.ok())
|
||||
LOG("Document open action failed: %s", status.message);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void execute_legacy_downloaded_project_open(
|
||||
App& app,
|
||||
std::string_view path,
|
||||
|
||||
@@ -3,12 +3,17 @@
|
||||
#include "app_core/document_session.h"
|
||||
#include "foundation/result.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
class App;
|
||||
|
||||
namespace pp::panopainter {
|
||||
|
||||
[[nodiscard]] pp::foundation::Status execute_legacy_document_open(
|
||||
App& app,
|
||||
std::string path);
|
||||
|
||||
[[nodiscard]] pp::foundation::Status execute_legacy_document_open_plan(
|
||||
App& app,
|
||||
pp::app::DocumentOpenPlanAction action,
|
||||
|
||||
Reference in New Issue
Block a user