mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-12 05:43:18 +00:00
Move all UI code into new 'ui' directory
This commit is contained in:
parent
00d9cbe7ef
commit
0046cb9bbb
21 changed files with 94 additions and 93 deletions
|
@ -12,11 +12,11 @@
|
|||
#include "mirai-core/source.h"
|
||||
#include "selenite/palette.h"
|
||||
#include "selenite/selenite.h"
|
||||
#include "shared/Utils.h"
|
||||
#include "slint_color.h"
|
||||
#include "slint_models.h"
|
||||
#include "slint_string.h"
|
||||
#include "ui.h"
|
||||
#include "ui/utils.h"
|
||||
#include <algorithm>
|
||||
#include <bits/chrono.h>
|
||||
#include <cassert>
|
||||
|
@ -52,7 +52,7 @@ app_logic::app_logic(mirai::core *miraiInstance) : _mirai_core(miraiInstance)
|
|||
);
|
||||
}
|
||||
|
||||
bindSlintUtils(_main_window->global<ui::Utils>());
|
||||
bind_slint_utils(_main_window->global<ui::Utils>());
|
||||
|
||||
models().set_sidebar_view(_sidebar_view);
|
||||
models().set_calendar_view(_calendar_view);
|
||||
|
@ -193,7 +193,7 @@ void app_logic::setupCallbacks()
|
|||
assert(source);
|
||||
auto task = source->get_task_by_id(newTaskData.id);
|
||||
assert(task.has_value());
|
||||
const mirai::date &date = SlintDateToMiraiDate(newTaskData.date);
|
||||
const mirai::date &date = slint_date_to_mirai_date(newTaskData.date);
|
||||
// const auto dayOpt = source->get_day_by_date(date);
|
||||
task->set_title(std::string(newTaskData.title));
|
||||
|
||||
|
@ -206,7 +206,7 @@ void app_logic::setupCallbacks()
|
|||
actions().on_create_task([&](ui::NewTaskData newTaskData) {
|
||||
std::optional<mirai::date> date = std::nullopt;
|
||||
if (newTaskData.date.year != 0) {
|
||||
date = SlintDateToMiraiDate(newTaskData.date);
|
||||
date = slint_date_to_mirai_date(newTaskData.date);
|
||||
}
|
||||
auto source = _mirai_core->getSourceById(newTaskData.sourceId);
|
||||
|
||||
|
@ -240,14 +240,14 @@ void app_logic::setupCallbacks()
|
|||
|
||||
actions().on_create_event([&](ui::CreateEventParams newEventParams) {
|
||||
const ui::Date &date = newEventParams.date;
|
||||
const std::string dateStr = SlintDateToStdString(date);
|
||||
const std::string dateStr = slint_date_to_std_string(date);
|
||||
auto source = _mirai_core->getSourceById(newEventParams.source_id);
|
||||
|
||||
source->create_event({
|
||||
.title = std::string(newEventParams.title),
|
||||
.date = SlintDateToMiraiDate(newEventParams.date),
|
||||
.starts_at = SlintTimeToMiraiTime(newEventParams.starts_at),
|
||||
.ends_at = SlintTimeToMiraiTime(newEventParams.ends_at),
|
||||
.date = slint_date_to_mirai_date(newEventParams.date),
|
||||
.starts_at = slint_time_to_mirai_time(newEventParams.starts_at),
|
||||
.ends_at = slint_time_to_mirai_time(newEventParams.ends_at),
|
||||
});
|
||||
_mirai_core->save();
|
||||
update_views();
|
||||
|
@ -527,17 +527,17 @@ void app_logic::update_calendar_view()
|
|||
.source_id = current_event.source_id(),
|
||||
.id = current_event.id(),
|
||||
.title = slint::SharedString(current_event.title()),
|
||||
.starts_at = MiraiTimeToSlintTime(current_event.starts_at()),
|
||||
.ends_at = MiraiTimeToSlintTime(current_event.ends_at()),
|
||||
.starts_at = mirai_time_to_slint_time(current_event.starts_at()),
|
||||
.ends_at = mirai_time_to_slint_time(current_event.ends_at()),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
auto new_slint_date = ui::CalendarViewDate{
|
||||
.events = new_slint_events,
|
||||
.date = MiraiDateToSlintDate(current_date),
|
||||
.date = mirai_date_to_slint_date(current_date),
|
||||
.header = slint::SharedString(
|
||||
capitalize(formatDateRelative(MiraiDateToSlintDate(current_date)))
|
||||
capitalize(format_date_relative(mirai_date_to_slint_date(current_date)))
|
||||
)
|
||||
};
|
||||
new_slint_dates->push_back(new_slint_date);
|
||||
|
@ -667,7 +667,7 @@ void app_logic::update_tasks_view()
|
|||
};
|
||||
|
||||
if (current_date.has_value()) {
|
||||
new_slint_date.due_date = MiraiDateToSlintDate(current_date.value());
|
||||
new_slint_date.due_date = mirai_date_to_slint_date(current_date.value());
|
||||
new_slint_date.is_late = current_date.value() < today;
|
||||
} else {
|
||||
new_slint_date.no_date = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue