mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-12 05:43:18 +00:00
Add 'remove source' feature
This commit is contained in:
parent
0046cb9bbb
commit
e608a4afcc
11 changed files with 126 additions and 286 deletions
|
@ -37,11 +37,6 @@ app_logic::app_logic(mirai::core *miraiInstance) : _mirai_core(miraiInstance)
|
|||
_sidebar_view = ui::SidebarView();
|
||||
_calendar_view = ui::CalendarView();
|
||||
_tasks_view = ui::TasksView();
|
||||
/*auto sourcesNames = std::make_shared<slint::MapModel<ui::Source, slint::SharedString>>(*/
|
||||
/*sources_, [&](const ui::Source &a) {*/
|
||||
/*return a.name;*/
|
||||
/*}*/
|
||||
/*);*/
|
||||
|
||||
const auto palettePath = std::string(getenv("HOME")) + "/.config/evalyte/theme.json";
|
||||
const auto palette = selenite::parseJson(palettePath);
|
||||
|
@ -60,13 +55,8 @@ app_logic::app_logic(mirai::core *miraiInstance) : _mirai_core(miraiInstance)
|
|||
|
||||
show_all_sources();
|
||||
update_views();
|
||||
/*view_.setAllSources();*/
|
||||
/*view_.update();*/
|
||||
|
||||
reloadSources();
|
||||
reloadTasks();
|
||||
|
||||
setupCallbacks();
|
||||
setup_callbacks();
|
||||
}
|
||||
|
||||
std::optional<ui::Date> stringToDate(const std::string &dateStr)
|
||||
|
@ -90,59 +80,57 @@ std::optional<ui::Date> stringToDate(const std::string &dateStr)
|
|||
return ui::Date{.year = year, .month = month, .day = day};
|
||||
}
|
||||
|
||||
void app_logic::setupCallbacks()
|
||||
void app_logic::setup_callbacks()
|
||||
{
|
||||
models().on_get_source_id_from_name([&](slint::SharedString name) {
|
||||
auto source = _mirai_core->getSourceByName(std::string(name));
|
||||
auto source = _mirai_core->get_source_by_name(std::string(name));
|
||||
assert(source);
|
||||
return source->id;
|
||||
});
|
||||
|
||||
models().on_get_source_name_from_id([&](int sourceId) {
|
||||
auto source = _mirai_core->getSourceById(sourceId);
|
||||
auto source = _mirai_core->get_source_by_id(sourceId);
|
||||
assert(source);
|
||||
return slint::SharedString(source->name());
|
||||
});
|
||||
|
||||
models().on_get_source_color_from_id_as_hex([&](int sourceId) {
|
||||
auto source = _mirai_core->getSourceById(sourceId);
|
||||
auto source = _mirai_core->get_source_by_id(sourceId);
|
||||
assert(source);
|
||||
return slint::SharedString(source->color());
|
||||
});
|
||||
|
||||
models().on_get_source_color_from_id_as_color([&](int sourceId) {
|
||||
auto source = _mirai_core->getSourceById(sourceId);
|
||||
auto source = _mirai_core->get_source_by_id(sourceId);
|
||||
assert(source);
|
||||
auto color = selenite::hexStringToColor(source->color());
|
||||
return slint::Color::from_rgb_uint8(color.r, color.g, color.b);
|
||||
});
|
||||
|
||||
models().on_get_source_path_from_id([&](int sourceId) {
|
||||
auto source = _mirai_core->getSourceById(sourceId);
|
||||
auto source = _mirai_core->get_source_by_id(sourceId);
|
||||
assert(source);
|
||||
mirai::markdown_data_provider *sourceProvider =
|
||||
dynamic_cast<mirai::markdown_data_provider *>(source->data_provider());
|
||||
return slint::SharedString(sourceProvider->path());
|
||||
});
|
||||
|
||||
_mirai_core->onSourceAdded([&](mirai::source *source) { refreshModels(); });
|
||||
_mirai_core->onSourceEdited([&](mirai::source *source) { refreshModels(); });
|
||||
_mirai_core->onSourceDeleted([&](int id) { refreshModels(); });
|
||||
_mirai_core->on_source_added([&](mirai::source *source) { update_views(); });
|
||||
_mirai_core->on_source_edited([&](mirai::source *source) { update_views(); });
|
||||
_mirai_core->on_source_removed([&](int id) { update_views(); });
|
||||
|
||||
actions().on_task_clicked([&](int sourceId, int taskId) {
|
||||
auto source = _mirai_core->getSourceById(sourceId);
|
||||
auto source = _mirai_core->get_source_by_id(sourceId);
|
||||
assert(source);
|
||||
auto task = source->get_task_by_id(taskId);
|
||||
assert(task);
|
||||
task->set_checked(!task->checked());
|
||||
_mirai_core->save();
|
||||
update_views();
|
||||
// view_.update();
|
||||
reloadTasks();
|
||||
});
|
||||
|
||||
actions().on_source_clicked([&](int index) {
|
||||
const mirai::source *const source = _mirai_core->getSourceById(index);
|
||||
const mirai::source *const source = _mirai_core->get_source_by_id(index);
|
||||
assert(source != nullptr);
|
||||
if (should_show_source(*source)) {
|
||||
hide_source(*source);
|
||||
|
@ -153,43 +141,45 @@ void app_logic::setupCallbacks()
|
|||
update_views();
|
||||
});
|
||||
|
||||
actions().on_add_source([&](slint::SharedString name, slint::SharedString path) {
|
||||
actions().on_add_source([&](slint::SharedString name, slint::SharedString color,
|
||||
slint::SharedString path) {
|
||||
std::unique_ptr<mirai::data_provider> file =
|
||||
std::make_unique<mirai::markdown_data_provider>(std::string(path));
|
||||
_mirai_core->addSource(std::string(name), "FileSystemMarkdown", std::move(file));
|
||||
_mirai_core->add_source(
|
||||
std::string(name), std::string(color), "FileSystemMarkdown", std::move(file)
|
||||
);
|
||||
});
|
||||
|
||||
actions().on_edit_source([&](int sourceId, slint::SharedString name, slint::SharedString color,
|
||||
slint::SharedString path) {
|
||||
_mirai_core->editSource(sourceId, std::string(name), std::string(color), std::string(path));
|
||||
_mirai_core->edit_source(
|
||||
sourceId, std::string(name), std::string(color), std::string(path)
|
||||
);
|
||||
});
|
||||
|
||||
actions().on_remove_source([&](int source_id) { _mirai_core->remove_source(source_id); });
|
||||
|
||||
actions().on_delete_task_clicked([&](int sourceId, int taskId) {
|
||||
auto source = _mirai_core->getSourceById(sourceId);
|
||||
auto source = _mirai_core->get_source_by_id(sourceId);
|
||||
assert(source);
|
||||
auto task = source->get_task_by_id(taskId);
|
||||
assert(task);
|
||||
source->remove_task(*task);
|
||||
_mirai_core->save();
|
||||
// view_.update();
|
||||
update_views();
|
||||
reloadTasks();
|
||||
});
|
||||
|
||||
actions().on_toggle_show_completed_tasks([&] {
|
||||
// view_.hideCompletedTasks(!view_.shouldHideCompletedTasks());
|
||||
if (should_hide_completed_tasks()) {
|
||||
show_completed_tasks();
|
||||
} else {
|
||||
hide_completed_tasks();
|
||||
}
|
||||
// view_.update();
|
||||
update_views();
|
||||
reloadTasks();
|
||||
});
|
||||
|
||||
actions().on_save_task([&](ui::SaveTaskData newTaskData) {
|
||||
auto source = _mirai_core->getSourceById(newTaskData.sourceId);
|
||||
auto source = _mirai_core->get_source_by_id(newTaskData.sourceId);
|
||||
assert(source);
|
||||
auto task = source->get_task_by_id(newTaskData.id);
|
||||
assert(task.has_value());
|
||||
|
@ -198,9 +188,7 @@ void app_logic::setupCallbacks()
|
|||
task->set_title(std::string(newTaskData.title));
|
||||
|
||||
_mirai_core->save();
|
||||
// view_.update();
|
||||
update_views();
|
||||
reloadTasks();
|
||||
});
|
||||
|
||||
actions().on_create_task([&](ui::NewTaskData newTaskData) {
|
||||
|
@ -208,7 +196,7 @@ void app_logic::setupCallbacks()
|
|||
if (newTaskData.date.year != 0) {
|
||||
date = slint_date_to_mirai_date(newTaskData.date);
|
||||
}
|
||||
auto source = _mirai_core->getSourceById(newTaskData.sourceId);
|
||||
auto source = _mirai_core->get_source_by_id(newTaskData.sourceId);
|
||||
|
||||
std::optional<mirai::event> event = std::nullopt;
|
||||
if (newTaskData.eventId >= 0) {
|
||||
|
@ -221,13 +209,11 @@ void app_logic::setupCallbacks()
|
|||
});
|
||||
|
||||
_mirai_core->save();
|
||||
// view_.update();
|
||||
update_views();
|
||||
reloadTasks();
|
||||
});
|
||||
|
||||
actions().on_delete_event([&](int sourceId, int eventId) {
|
||||
auto source = _mirai_core->getSourceById(sourceId);
|
||||
auto source = _mirai_core->get_source_by_id(sourceId);
|
||||
assert(source);
|
||||
auto event = source->get_event_by_id(eventId);
|
||||
assert(event.has_value());
|
||||
|
@ -235,13 +221,12 @@ void app_logic::setupCallbacks()
|
|||
_mirai_core->save();
|
||||
// view_.update();
|
||||
update_views();
|
||||
reloadTasks();
|
||||
});
|
||||
|
||||
actions().on_create_event([&](ui::CreateEventParams newEventParams) {
|
||||
const ui::Date &date = newEventParams.date;
|
||||
const std::string dateStr = slint_date_to_std_string(date);
|
||||
auto source = _mirai_core->getSourceById(newEventParams.source_id);
|
||||
auto source = _mirai_core->get_source_by_id(newEventParams.source_id);
|
||||
|
||||
source->create_event({
|
||||
.title = std::string(newEventParams.title),
|
||||
|
@ -264,159 +249,6 @@ stdToSlintStringVector(const std::vector<std::string> &stdVector)
|
|||
return slintVector;
|
||||
}
|
||||
|
||||
void app_logic::reloadTasks()
|
||||
{
|
||||
/* days_->clear();*/
|
||||
/*if (miraiInstance_->getSources().size() == 0) {*/
|
||||
/*return;*/
|
||||
/*}*/
|
||||
/*auto todayDate = mirai::Date(std::chrono::system_clock::now());*/
|
||||
/*auto dates = view_.getDates();*/
|
||||
/*auto slintDays = std::make_shared<slint::VectorModel<ui::Day>>();*/
|
||||
/*for (int dayIndex = 0; dayIndex < dates.size(); ++dayIndex) {*/
|
||||
/*auto ¤tDate = dates.at(dayIndex);*/
|
||||
/*auto slintEvents = std::make_shared<slint::VectorModel<ui::Event>>();*/
|
||||
/*auto slintDayTasks = std::make_shared<slint::VectorModel<ui::TaskData>>();*/
|
||||
/*auto relativeDaysDiff = std::chrono::duration_cast<std::chrono::days>(*/
|
||||
/*std::chrono::sys_days(currentDate.toStdChrono()) -*/
|
||||
/*std::chrono::sys_days(todayDate.toStdChrono())*/
|
||||
/*)*/
|
||||
/*.count();*/
|
||||
/*slintDays->push_back(*/
|
||||
/*ui::Day{*/
|
||||
/*.date = MiraiDateToSlintDate(currentDate),*/
|
||||
/*.events = slintEvents,*/
|
||||
/*.tasks = slintDayTasks,*/
|
||||
/*.isLate = currentDate < todayDate,*/
|
||||
/*.isToday = currentDate == todayDate,*/
|
||||
/*.relativeDaysDiff = static_cast<int>(relativeDaysDiff)*/
|
||||
/*}*/
|
||||
/*);*/
|
||||
/*Day's tasks*/
|
||||
/*const std::vector<mirai::Task> tasksForDate = view_.getTasksForDate(currentDate);*/
|
||||
/*for (int taskIndex = 0; taskIndex < tasksForDate.size(); ++taskIndex) {*/
|
||||
/*auto &task = tasksForDate.at(taskIndex);*/
|
||||
/*slintDayTasks->push_back({*/
|
||||
/*.sourceId = task.sourceId(),*/
|
||||
/*.eventId = -1,*/
|
||||
/*.id = task.id(),*/
|
||||
/*.title = slint::SharedString(task.title()),*/
|
||||
/*.checked = task.checked(),*/
|
||||
/*});*/
|
||||
/*}*/
|
||||
|
||||
/*Day's events*/
|
||||
/*const std::vector<mirai::Event> eventsForDate = view_.getEventsForDate(currentDate);*/
|
||||
/*for (int eventIndex = 0; eventIndex < eventsForDate.size(); ++eventIndex) {*/
|
||||
/*auto ¤tEvent = eventsForDate.at(eventIndex);*/
|
||||
/*auto slintTasks = std::make_shared<slint::VectorModel<ui::TaskData>>();*/
|
||||
/*slintEvents->push_back(*/
|
||||
/*ui::Event{*/
|
||||
/*.sourceId = currentEvent.source_id(),*/
|
||||
/*.id = currentEvent.id(),*/
|
||||
/*.title = slint::SharedString(currentEvent.title()),*/
|
||||
/*.startsAt = MiraiTimeToSlintTime(currentEvent.startsAt()),*/
|
||||
/*.endsAt = MiraiTimeToSlintTime(currentEvent.endsAt()),*/
|
||||
/*.tasks = slintTasks,*/
|
||||
/*}*/
|
||||
/*);*/
|
||||
/*auto eventTasks = currentEvent.queryTasks();*/
|
||||
/*for (int taskIndex = 0; taskIndex < eventTasks.size(); ++taskIndex) {*/
|
||||
/*auto &task = eventTasks.at(taskIndex);*/
|
||||
/*slintTasks->push_back({*/
|
||||
/*.sourceId = task.sourceId(),*/
|
||||
/*.eventId = currentEvent.id(),*/
|
||||
/*.id = task.id(),*/
|
||||
/*.title = slint::SharedString(task.title()),*/
|
||||
/*.checked = task.checked(),*/
|
||||
/*});*/
|
||||
/*}*/
|
||||
/*}*/
|
||||
/*}*/
|
||||
/*days_ = slintDays;*/
|
||||
/*models().set_days(days_);*/
|
||||
|
||||
/*auto unscheduledTasksView = view_.getUnscheduledTasks();*/
|
||||
/*unscheduledTasks_->clear();*/
|
||||
/*for (int taskIndex = 0; taskIndex < unscheduledTasksView.size(); ++taskIndex) {*/
|
||||
/*auto &task = unscheduledTasksView.at(taskIndex);*/
|
||||
/*const auto &source = miraiInstance_->getSourceById(task.sourceId());*/
|
||||
/*std::println("request name for source id {} : {}", task.sourceId(), source->name());*/
|
||||
/*unscheduledTasks_->push_back({*/
|
||||
/*.sourceId = task.sourceId(),*/
|
||||
/*.eventId = -1,*/
|
||||
/*.id = task.id(),*/
|
||||
/*.title = slint::SharedString(task.title()),*/
|
||||
/*.checked = task.checked(),*/
|
||||
/*});*/
|
||||
/*}*/
|
||||
/*models().set_unscheduled_tasks(unscheduledTasks_);*/
|
||||
|
||||
/*calendar_->clear();*/
|
||||
/*for (int dayIndex = 0; dayIndex < 7; ++dayIndex) {*/
|
||||
/*std::chrono::year_month_day nextDate =*/
|
||||
/*std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now()) +*/
|
||||
/*std::chrono::days{dayIndex};*/
|
||||
/*auto currentDate = mirai::Date{nextDate};*/
|
||||
/*auto events = view_.getEventsForDate(currentDate);*/
|
||||
/*auto slintEvents = std::make_shared<slint::VectorModel<ui::CalendarDayEvent>>();*/
|
||||
/*auto relativeDaysDiff = std::chrono::duration_cast<std::chrono::days>(*/
|
||||
/*std::chrono::sys_days(currentDate.toStdChrono()) -*/
|
||||
/*std::chrono::sys_days(todayDate.toStdChrono())*/
|
||||
/*)*/
|
||||
/*.count();*/
|
||||
/*if (relativeDaysDiff < 0 || relativeDaysDiff >= 7) {*/
|
||||
/*continue;*/
|
||||
/*}*/
|
||||
/*const std::vector<mirai::Event> eventsForDate = view_.getEventsForDate(currentDate);*/
|
||||
/*for (int eventIndex = 0; eventIndex < eventsForDate.size(); ++eventIndex) {*/
|
||||
/*auto ¤tEvent = eventsForDate.at(eventIndex);*/
|
||||
/*slintEvents->push_back(*/
|
||||
/*ui::CalendarDayEvent{*/
|
||||
/*.sourceId = currentEvent.source_id(),*/
|
||||
/*.id = currentEvent.id(),*/
|
||||
/*.title = slint::SharedString(currentEvent.title()),*/
|
||||
/*.startsAt = MiraiTimeToSlintTime(currentEvent.startsAt()),*/
|
||||
/*.endsAt = MiraiTimeToSlintTime(currentEvent.endsAt()),*/
|
||||
/*}*/
|
||||
/*);*/
|
||||
/*}*/
|
||||
|
||||
/*auto calendarDay = ui::CalendarDay{*/
|
||||
/*.events = slintEvents,*/
|
||||
/*.date = MiraiDateToSlintDate(currentDate),*/
|
||||
/*.header = slint::SharedString(*/
|
||||
/*capitalize(formatDateRelative(MiraiDateToSlintDate(currentDate)))*/
|
||||
/*)*/
|
||||
/*};*/
|
||||
/*calendar_->push_back(calendarDay);*/
|
||||
/*}*/
|
||||
}
|
||||
|
||||
void app_logic::reloadSources()
|
||||
{
|
||||
/*sources_->clear();*/
|
||||
/*bool noSourceSelected = miraiInstance_->getSources().size() == view_.activeSourceCount();*/
|
||||
/*for (const auto &source : miraiInstance_->getSources()) {*/
|
||||
/*bool isSourceSelected = view_.isSourceSelected(*source);*/
|
||||
/*mirai::markdown_data_provider *sourceProvider =*/
|
||||
/*dynamic_cast<mirai::markdown_data_provider *>(source->data_provider());*/
|
||||
/*sources_->push_back(*/
|
||||
/*{.id = source->id,*/
|
||||
/*.name = slint::SharedString(source->name()),*/
|
||||
/*.selected = isSourceSelected && !noSourceSelected,*/
|
||||
/*.path = slint::SharedString(sourceProvider->path())}*/
|
||||
/*);*/
|
||||
/*}*/
|
||||
/*models().set_no_source_selected(noSourceSelected);*/
|
||||
}
|
||||
|
||||
void app_logic::refreshModels()
|
||||
{
|
||||
show_all_sources();
|
||||
update_views();
|
||||
}
|
||||
|
||||
void app_logic::update_views()
|
||||
{
|
||||
update_sidebar_view();
|
||||
|
@ -427,14 +259,14 @@ void app_logic::update_views()
|
|||
|
||||
void app_logic::update_available_sources()
|
||||
{
|
||||
const auto &sources = _mirai_core->getSources();
|
||||
const auto &sources = _mirai_core->get_sources();
|
||||
auto available_sources = std::make_shared<slint::VectorModel<ui::AvailableSource>>();
|
||||
auto available_sources_strings = std::make_shared<slint::VectorModel<slint::SharedString>>();
|
||||
for (auto &source : sources) {
|
||||
mirai::markdown_data_provider *sourceProvider =
|
||||
dynamic_cast<mirai::markdown_data_provider *>(source->data_provider());
|
||||
const auto color =
|
||||
selenite::hexStringToColor(_mirai_core->getSourceById(source->id)->color());
|
||||
selenite::hexStringToColor(_mirai_core->get_source_by_id(source->id)->color());
|
||||
auto source_color = slint::Color::from_rgb_uint8(color.r, color.g, color.b);
|
||||
|
||||
available_sources->push_back(
|
||||
|
@ -449,14 +281,14 @@ void app_logic::update_available_sources()
|
|||
|
||||
void app_logic::update_sidebar_view()
|
||||
{
|
||||
const auto &sources = _mirai_core->getSources();
|
||||
const auto &sources = _mirai_core->get_sources();
|
||||
|
||||
auto new_sources = std::make_shared<slint::VectorModel<ui::SidebarViewSources>>();
|
||||
for (auto &source : sources) {
|
||||
mirai::markdown_data_provider *sourceProvider =
|
||||
dynamic_cast<mirai::markdown_data_provider *>(source->data_provider());
|
||||
const auto color =
|
||||
selenite::hexStringToColor(_mirai_core->getSourceById(source->id)->color());
|
||||
selenite::hexStringToColor(_mirai_core->get_source_by_id(source->id)->color());
|
||||
auto source_color = slint::Color::from_rgb_uint8(color.r, color.g, color.b);
|
||||
new_sources->push_back({
|
||||
.id = source->id,
|
||||
|
@ -497,7 +329,7 @@ void app_logic::update_calendar_view()
|
|||
auto today = mirai::date(std::chrono::system_clock::now());
|
||||
auto new_slint_dates = std::make_shared<slint::VectorModel<ui::CalendarViewDate>>();
|
||||
|
||||
auto &sources = _mirai_core->getSources();
|
||||
auto &sources = _mirai_core->get_sources();
|
||||
auto all_events = merge_all_events_from_sources(sources);
|
||||
|
||||
for (int day_index = 0; day_index < 7; ++day_index) {
|
||||
|
@ -518,7 +350,7 @@ void app_logic::update_calendar_view()
|
|||
for (int event_index = 0; event_index < events_for_date.size(); ++event_index) {
|
||||
auto ¤t_event = events_for_date.at(event_index);
|
||||
// TODO directly remove the source instead of this workaround after data layer refacto
|
||||
auto source = _mirai_core->getSourceById(current_event.source_id());
|
||||
auto source = _mirai_core->get_source_by_id(current_event.source_id());
|
||||
if (!should_show_source(*source)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -618,7 +450,7 @@ void app_logic::update_tasks_view()
|
|||
auto today = mirai::date(std::chrono::system_clock::now());
|
||||
auto new_slint_dates = std::make_shared<slint::VectorModel<ui::TasksViewDate>>();
|
||||
|
||||
auto &sources = _mirai_core->getSources();
|
||||
auto &sources = _mirai_core->get_sources();
|
||||
auto all_tasks_dates = group_tasks_by_date(get_all_tasks_from_sources(sources));
|
||||
|
||||
for (int date_index = 0; date_index < all_tasks_dates.size(); ++date_index) {
|
||||
|
@ -637,7 +469,7 @@ void app_logic::update_tasks_view()
|
|||
for (auto &source_group : current_date_group.sources) {
|
||||
auto new_slint_source = ui::TasksViewSource();
|
||||
auto new_slint_tasks = std::make_shared<slint::VectorModel<ui::TasksViewTask>>();
|
||||
auto source = _mirai_core->getSourceById(source_group.id);
|
||||
auto source = _mirai_core->get_source_by_id(source_group.id);
|
||||
if (!should_show_source(*source)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -655,7 +487,7 @@ void app_logic::update_tasks_view()
|
|||
new_slint_source.tasks = new_slint_tasks;
|
||||
new_slint_source.id = source_group.id;
|
||||
new_slint_source.name =
|
||||
slint::SharedString(_mirai_core->getSourceById(source_group.id)->name());
|
||||
slint::SharedString(_mirai_core->get_source_by_id(source_group.id)->name());
|
||||
const auto color = selenite::hexStringToColor(source->color());
|
||||
new_slint_source.color = slint::Color::from_rgb_uint8(color.r, color.g, color.b);
|
||||
if (new_slint_source.tasks->row_count() > 0) {
|
||||
|
@ -699,7 +531,7 @@ bool app_logic::should_show_source(const mirai::source &source) const
|
|||
|
||||
void app_logic::show_all_sources()
|
||||
{
|
||||
auto &sources = _mirai_core->getSources();
|
||||
auto &sources = _mirai_core->get_sources();
|
||||
for (auto &source : sources) {
|
||||
show_source(*source);
|
||||
}
|
||||
|
|
|
@ -21,10 +21,6 @@ class app_logic
|
|||
|
||||
void run();
|
||||
|
||||
void reloadSources();
|
||||
void reloadTasks();
|
||||
void refreshModels();
|
||||
|
||||
void update_views();
|
||||
void update_sidebar_view();
|
||||
void update_calendar_view();
|
||||
|
@ -42,7 +38,7 @@ class app_logic
|
|||
bool should_hide_completed_tasks() const;
|
||||
|
||||
private:
|
||||
void setupCallbacks();
|
||||
void setup_callbacks();
|
||||
const ui::AppModels &models();
|
||||
const ui::AppActions &actions();
|
||||
|
||||
|
|
|
@ -32,8 +32,9 @@ export struct CreateEventParams {
|
|||
export global AppActions {
|
||||
callback task-clicked(int, int);
|
||||
callback source-clicked(int);
|
||||
callback add-source(name: string, path: string);
|
||||
callback add-source(name: string, color: string, path: string);
|
||||
callback edit-source(sourceId: int, name: string, color: string, path: string);
|
||||
callback remove-source(sourceId: int);
|
||||
|
||||
callback toggle-show-completed-tasks();
|
||||
callback delete-task-clicked(int, int);
|
||||
|
|
|
@ -9,6 +9,7 @@ export component AddSourceModal inherits Modal {
|
|||
private property <int> source-id-to-edit: -1;
|
||||
private property <string> name: "";
|
||||
private property <string> path: "";
|
||||
private property <string> color_: "#ffffff";
|
||||
|
||||
public function open() {
|
||||
root.show();
|
||||
|
@ -21,6 +22,10 @@ export component AddSourceModal inherits Modal {
|
|||
label: "Name";
|
||||
text <=> root.name;
|
||||
}
|
||||
colorInput := VTextInput {
|
||||
label: "Color";
|
||||
text <=> root.color_;
|
||||
}
|
||||
pathInput := VTextInput {
|
||||
label: "Path";
|
||||
text <=> root.path;
|
||||
|
@ -28,7 +33,7 @@ export component AddSourceModal inherits Modal {
|
|||
VButton {
|
||||
text: "Add";
|
||||
clicked => {
|
||||
AppActions.add-source(name, path);
|
||||
AppActions.add-source(name, color_, path);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ export component EditSourceModal inherits Modal {
|
|||
label: "Color";
|
||||
text <=> root.color_;
|
||||
}
|
||||
pathInput := VTextInput {
|
||||
label: "Path";
|
||||
text <=> root.path;
|
||||
}
|
||||
//pathInput := VTextInput {
|
||||
//label: "Path";
|
||||
//text <=> root.path;
|
||||
//}
|
||||
VButton {
|
||||
text: "Save";
|
||||
clicked => {
|
||||
|
@ -45,7 +45,8 @@ export component EditSourceModal inherits Modal {
|
|||
text: "Delete";
|
||||
background-color: Palette.red;
|
||||
double-clicked => {
|
||||
//root.delete-source(root.id)
|
||||
AppActions.remove-source(source-id-to-edit);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,11 @@ export component SideBar inherits Rectangle {
|
|||
|
||||
TouchArea {
|
||||
clicked => { AppActions.source-clicked(source.id) }
|
||||
//right-clicked => { editSourcePopup.edit(source.id) }
|
||||
pointer-event(e) => {
|
||||
if (e.button == PointerEventButton.right && e.kind == PointerEventKind.up) {
|
||||
editSourcePopup.edit(source.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue