mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 18:23:19 +00:00
Add color for events and source tags
This commit is contained in:
parent
d208fc6ca4
commit
4bca7fac3e
12 changed files with 95 additions and 39 deletions
13
external/mirai-core/src/Mirai.cpp
vendored
13
external/mirai-core/src/Mirai.cpp
vendored
|
@ -41,14 +41,15 @@ void Mirai::loadConfig(const std::string &path)
|
|||
auto &filePath = jsonSources[i];
|
||||
assert(filePath.isObject());
|
||||
const auto name = filePath.asObject().getString("name");
|
||||
const auto color = filePath.asObject().getString("color");
|
||||
const auto path = filePath.asObject().getString("path");
|
||||
std::unique_ptr<DataProvider> file = std::make_unique<MarkdownDataProvider>(path);
|
||||
DataProvider *sourceDataProvider = file.release();
|
||||
sourceDataProvider->load();
|
||||
sources_.push_back(
|
||||
std::make_unique<Source>(
|
||||
SourceConstructor{.name = name, .sourceDataProvider = sourceDataProvider}
|
||||
)
|
||||
std::make_unique<Source>(SourceConstructor{
|
||||
.name = name, .color = color, .sourceDataProvider = sourceDataProvider
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +68,7 @@ void Mirai::saveConfig()
|
|||
|
||||
rei::json::JsonObject jsonSource;
|
||||
jsonSource.set("name", source->name());
|
||||
jsonSource.set("color", source->color());
|
||||
auto dataProvider = dynamic_cast<MarkdownDataProvider *>(source->dataProvider());
|
||||
jsonSource.set("path", dataProvider->path());
|
||||
jsonSource.set("type", "FileSystemMarkdown");
|
||||
|
@ -96,10 +98,13 @@ void Mirai::addSource(
|
|||
sourceAdded.emit(nullptr);
|
||||
};
|
||||
|
||||
void Mirai::editSource(int id, const std::string &name, const std::string &path)
|
||||
void Mirai::editSource(
|
||||
int id, const std::string &name, const std::string &color, const std::string &path
|
||||
)
|
||||
{
|
||||
auto source = getSourceById(id);
|
||||
source->setName(name);
|
||||
source->setColor(color);
|
||||
|
||||
DataProvider *sourceDataProvider = source->dataProvider();
|
||||
saveConfig();
|
||||
|
|
13
external/mirai-core/src/Source.cpp
vendored
13
external/mirai-core/src/Source.cpp
vendored
|
@ -52,8 +52,7 @@ std::vector<Day> Source::getDays()
|
|||
auto daysData = data->getDays();
|
||||
std::vector<Day> days;
|
||||
std::transform(
|
||||
daysData.begin(), daysData.end(), std::back_inserter(days),
|
||||
[&](const DayData &dayData) {
|
||||
daysData.begin(), daysData.end(), std::back_inserter(days), [&](const DayData &dayData) {
|
||||
return Day{data, dayData};
|
||||
}
|
||||
);
|
||||
|
@ -148,11 +147,21 @@ std::string Source::name() const
|
|||
return name_;
|
||||
}
|
||||
|
||||
std::string Source::color() const
|
||||
{
|
||||
return color_;
|
||||
}
|
||||
|
||||
void Source::setName(const std::string &name)
|
||||
{
|
||||
name_ = name;
|
||||
}
|
||||
|
||||
void Source::setColor(const std::string &color)
|
||||
{
|
||||
color_ = color;
|
||||
}
|
||||
|
||||
std::string Source::type() const
|
||||
{
|
||||
// There is only 1 type for now
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue