Update dependencies
This commit is contained in:
parent
da32449075
commit
f2e21d1bc7
7 changed files with 44 additions and 24792 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +1,6 @@
|
|||
[submodule "external/selenite"]
|
||||
path = external/selenite
|
||||
url = https://codeberg.org/vyn/selenite.git
|
||||
[submodule "external/rei-json"]
|
||||
path = external/rei-json
|
||||
url = https://codeberg.org/vyn/rei-json.git
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.21)
|
||||
project(focus LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(SLINT_FEATURE_RENDERER_SKIA ON)
|
||||
set(SLINT_FEATURE_RENDERER_SOFTWARE ON)
|
||||
|
@ -27,9 +27,17 @@ target_link_libraries(focus PRIVATE Slint::Slint)
|
|||
slint_target_sources(
|
||||
focus ui/app-window.slint
|
||||
NAMESPACE ui
|
||||
LIBRARY_PATHS selenite=${CMAKE_CURRENT_SOURCE_DIR}/external/selenite/index.slint
|
||||
LIBRARY_PATHS selenite=${CMAKE_CURRENT_SOURCE_DIR}/external/selenite/components/index.slint
|
||||
)
|
||||
|
||||
add_subdirectory(external/selenite/cpp)
|
||||
target_include_directories(focus PRIVATE "external/selenite/cpp/include")
|
||||
target_link_libraries(focus PRIVATE selenite)
|
||||
|
||||
add_subdirectory(external/rei-json)
|
||||
target_include_directories(focus PRIVATE "external/rei-json/include")
|
||||
target_link_libraries(focus PRIVATE rei-json)
|
||||
|
||||
# On Windows, copy the Slint DLL next to the application binary so that it's found.
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET focus POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:focus> $<TARGET_FILE_DIR:focus> COMMAND_EXPAND_LISTS)
|
||||
|
|
24767
external/nlohmann/json.hpp
vendored
24767
external/nlohmann/json.hpp
vendored
File diff suppressed because it is too large
Load diff
1
external/rei-json
vendored
Submodule
1
external/rei-json
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 2041a0aafe85085dcf35a37437db493898f1be3c
|
2
external/selenite
vendored
2
external/selenite
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 1774720377afc932cb92303516e049f66d8bf7a0
|
||||
Subproject commit 482980b29aca92dd3282bd3c81e78c520f30a233
|
49
src/main.cpp
49
src/main.cpp
|
@ -1,17 +1,18 @@
|
|||
#include "app-window.h"
|
||||
#include "rei-json/Object.h"
|
||||
#include "rei-json/json.h"
|
||||
#include "selenite/selenite.h"
|
||||
#include "slint_string.h"
|
||||
#include "slint_timer.h"
|
||||
#include "slint.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <print>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
class CountdownState {
|
||||
public:
|
||||
CountdownState(slint::ComponentHandle<ui::AppWindow> ui) : ui_(ui) {
|
||||
|
@ -154,24 +155,24 @@ Config loadJsonConfig(const std::string& configPath) {
|
|||
std::cerr << "Cant open config file: " << configPath << std::endl;
|
||||
return config;
|
||||
}
|
||||
auto jsonConfig = nlohmann::json::parse(file);
|
||||
std::stringstream buffer;
|
||||
buffer << file.rdbuf();
|
||||
auto jsonStr = buffer.str();
|
||||
file.close();
|
||||
|
||||
if (!jsonConfig.is_object()) {
|
||||
std::cerr << "Config file malformated: " << configPath << std::endl;
|
||||
}
|
||||
auto jsonConfig = std::get<rei::json::JsonObject>(rei::json::parse(jsonStr));
|
||||
|
||||
if (jsonConfig["timerEndingScript"].is_string()) {
|
||||
config.timerEndingScript = jsonConfig["timerEndingScript"].get<std::string>();
|
||||
if (jsonConfig["timerEndingScript"].isString()) {
|
||||
config.timerEndingScript = jsonConfig["timerEndingScript"].asString();
|
||||
}
|
||||
if (jsonConfig["focusDuration"].is_number_integer()) {
|
||||
config.focusDuration = jsonConfig["focusDuration"].get<int>();
|
||||
if (jsonConfig["focusDuration"].isNumber()) {
|
||||
config.focusDuration = jsonConfig["focusDuration"].asNumber();
|
||||
}
|
||||
if (jsonConfig["breakDuration"].is_number_integer()) {
|
||||
config.breakDuration = jsonConfig["breakDuration"].get<int>();
|
||||
if (jsonConfig["breakDuration"].isNumber()) {
|
||||
config.breakDuration = jsonConfig["breakDuration"].asNumber();
|
||||
}
|
||||
if (jsonConfig["sessionCount"].is_number_integer()) {
|
||||
config.sessionCount = jsonConfig["sessionCount"].get<int>();
|
||||
if (jsonConfig["sessionCount"].isNumber()) {
|
||||
config.sessionCount = jsonConfig["sessionCount"].asNumber();
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
@ -183,12 +184,12 @@ void saveJsonConfig(const std::string& configPath, const Config& config) {
|
|||
std::cerr << "Cant open config file: " << configPath << std::endl;
|
||||
return;
|
||||
}
|
||||
nlohmann::json jsonConfig;
|
||||
jsonConfig["timerEndingScript"] = config.timerEndingScript;
|
||||
jsonConfig["focusDuration"] = config.focusDuration;
|
||||
jsonConfig["breakDuration"] = config.breakDuration;
|
||||
jsonConfig["sessionCount"] = config.sessionCount;
|
||||
file << jsonConfig.dump(4);
|
||||
rei::json::JsonObject jsonConfig;
|
||||
jsonConfig.set("timerEndingScript", config.timerEndingScript);
|
||||
jsonConfig.set("focusDuration", config.focusDuration);
|
||||
jsonConfig.set("breakDuration", config.breakDuration);
|
||||
jsonConfig.set("sessionCount", config.sessionCount);
|
||||
file << rei::json::toString(jsonConfig);
|
||||
file.close();
|
||||
}
|
||||
|
||||
|
@ -209,6 +210,12 @@ int main(int argc, char **argv)
|
|||
|
||||
CountdownState countdown(ui);
|
||||
|
||||
const auto palettePath = std::string(getenv("HOME")) + "/.config/evalyte/theme.json";
|
||||
const auto palette = selenite::parseJson(palettePath);
|
||||
if (palette.has_value()) {
|
||||
setSelenitePalette<slint::Color, selenite::Color>(ui->global<ui::Palette>(), palette.value());
|
||||
}
|
||||
|
||||
ui->global<ui::State>().on_config_changed([&] {
|
||||
countdown.reset();
|
||||
config.timerEndingScript = ui->global<ui::State>().get_timer_ending_script();
|
||||
|
|
|
@ -51,4 +51,4 @@ export component AppWindow inherits Window {
|
|||
|
||||
}
|
||||
|
||||
export { State }
|
||||
export { State, Palette }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue