Plan app dialog factories

This commit is contained in:
2026-06-05 07:36:56 +02:00
parent a79ef4cda8
commit 062fdaa982
9 changed files with 374 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
#include "pch.h"
#include "app.h"
#include "app_core/app_dialog.h"
#include "app_core/document_layer.h"
#include "app_core/document_resize.h"
#include "app_core/document_export.h"
@@ -108,30 +109,32 @@ void start_document_export_collection(
std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title, int total /*= 0*/)
{
const auto plan = pp::app::plan_app_progress_dialog(title, total);
auto pb = std::make_shared<NodeProgressBar>();
pb->set_manager(&layout);
pb->init();
pb->create();
pb->loaded();
pb->m_progress->SetWidthP(0);
pb->m_title->set_text(title.c_str());
pb->m_total = total;
pb->m_count = 0;
pb->m_progress->SetWidthP(plan.progress_fraction);
pb->m_title->set_text(plan.title.c_str());
pb->m_total = plan.total;
pb->m_count = plan.count;
layout[main_id]->add_child(pb);
return pb;
}
std::shared_ptr<NodeMessageBox> App::message_box(const std::string &title, const std::string& text, bool cancel_button)
{
const auto plan = pp::app::plan_app_message_dialog(title, text, cancel_button);
auto m = std::make_shared<NodeMessageBox>();
m->set_manager(&layout);
m->init();
m->create();
m->loaded();
m->m_title->set_text(title.c_str());
m->m_message->set_text(text.c_str());
m->btn_ok->m_text->set_text("Ok");
if (!cancel_button)
m->m_title->set_text(plan.title.c_str());
m->m_message->set_text(plan.message.c_str());
m->btn_ok->m_text->set_text(plan.ok_caption.c_str());
if (!plan.show_cancel)
m->btn_cancel->destroy();
layout[main_id]->add_child(m);
return m;
@@ -140,14 +143,20 @@ std::shared_ptr<NodeMessageBox> App::message_box(const std::string &title, const
std::shared_ptr<NodeInputBox> App::input_box(const std::string& title,
const std::string& field_name, const std::string& ok_caption /*= "Ok"*/)
{
const auto plan_result = pp::app::plan_app_input_dialog(title, field_name, ok_caption);
if (!plan_result) {
LOG("input dialog skipped: %s", plan_result.status().message);
return nullptr;
}
const auto& plan = plan_result.value();
auto m = std::make_shared<NodeInputBox>();
m->set_manager(&layout);
m->init();
m->create();
m->loaded();
m->m_title->set_text(title.c_str());
m->m_field_name->set_text(field_name.c_str());
m->btn_ok->m_text->set_text(ok_caption.c_str());
m->m_title->set_text(plan.title.c_str());
m->m_field_name->set_text(plan.field_name.c_str());
m->btn_ok->m_text->set_text(plan.ok_caption.c_str());
layout[main_id]->add_child(m);
return m;
}