mirror of
https://github.com/obsqrbtz/clrsync.git
synced 2026-04-09 04:29:04 +03:00
chore: structured src/gui, run clang-format
This commit is contained in:
64
src/gui/controllers/template_controller.cpp
Normal file
64
src/gui/controllers/template_controller.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "gui/controllers/template_controller.hpp"
|
||||
#include "core/config/config.hpp"
|
||||
|
||||
template_controller::template_controller()
|
||||
{
|
||||
m_templates = m_template_manager.templates();
|
||||
}
|
||||
|
||||
void template_controller::set_template_enabled(const std::string &key, bool enabled)
|
||||
{
|
||||
auto it = m_templates.find(key);
|
||||
if (it != m_templates.end())
|
||||
{
|
||||
it->second.set_enabled(enabled);
|
||||
(void)clrsync::core::config::instance().update_template(key, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
void template_controller::set_template_input_path(const std::string &key, const std::string &path)
|
||||
{
|
||||
auto it = m_templates.find(key);
|
||||
if (it != m_templates.end())
|
||||
{
|
||||
it->second.set_template_path(path);
|
||||
(void)clrsync::core::config::instance().update_template(key, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
void template_controller::set_template_output_path(const std::string &key, const std::string &path)
|
||||
{
|
||||
auto it = m_templates.find(key);
|
||||
if (it != m_templates.end())
|
||||
{
|
||||
it->second.set_output_path(path);
|
||||
(void)clrsync::core::config::instance().update_template(key, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
void template_controller::set_template_reload_command(const std::string &key,
|
||||
const std::string &cmd)
|
||||
{
|
||||
auto it = m_templates.find(key);
|
||||
if (it != m_templates.end())
|
||||
{
|
||||
it->second.set_reload_command(cmd);
|
||||
(void)clrsync::core::config::instance().update_template(key, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
bool template_controller::remove_template(const std::string &key)
|
||||
{
|
||||
auto result = clrsync::core::config::instance().remove_template(key);
|
||||
if (result)
|
||||
{
|
||||
m_templates.erase(key);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void template_controller::refresh()
|
||||
{
|
||||
m_templates = m_template_manager.templates();
|
||||
}
|
||||
Reference in New Issue
Block a user