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"]
|
[submodule "external/selenite"]
|
||||||
path = external/selenite
|
path = external/selenite
|
||||||
url = https://codeberg.org/vyn/selenite.git
|
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)
|
cmake_minimum_required(VERSION 3.21)
|
||||||
project(focus LANGUAGES CXX)
|
project(focus LANGUAGES CXX)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set(SLINT_FEATURE_RENDERER_SKIA ON)
|
set(SLINT_FEATURE_RENDERER_SKIA ON)
|
||||||
set(SLINT_FEATURE_RENDERER_SOFTWARE ON)
|
set(SLINT_FEATURE_RENDERER_SOFTWARE ON)
|
||||||
|
@ -27,9 +27,17 @@ target_link_libraries(focus PRIVATE Slint::Slint)
|
||||||
slint_target_sources(
|
slint_target_sources(
|
||||||
focus ui/app-window.slint
|
focus ui/app-window.slint
|
||||||
NAMESPACE ui
|
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.
|
# On Windows, copy the Slint DLL next to the application binary so that it's found.
|
||||||
if (WIN32)
|
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)
|
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 "app-window.h"
|
||||||
|
#include "rei-json/Object.h"
|
||||||
|
#include "rei-json/json.h"
|
||||||
|
#include "selenite/selenite.h"
|
||||||
#include "slint_string.h"
|
#include "slint_string.h"
|
||||||
#include "slint_timer.h"
|
#include "slint_timer.h"
|
||||||
#include "slint.h"
|
#include "slint.h"
|
||||||
#include "nlohmann/json.hpp"
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
#include <print>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CountdownState {
|
class CountdownState {
|
||||||
public:
|
public:
|
||||||
CountdownState(slint::ComponentHandle<ui::AppWindow> ui) : ui_(ui) {
|
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;
|
std::cerr << "Cant open config file: " << configPath << std::endl;
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
auto jsonConfig = nlohmann::json::parse(file);
|
std::stringstream buffer;
|
||||||
|
buffer << file.rdbuf();
|
||||||
|
auto jsonStr = buffer.str();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
if (!jsonConfig.is_object()) {
|
auto jsonConfig = std::get<rei::json::JsonObject>(rei::json::parse(jsonStr));
|
||||||
std::cerr << "Config file malformated: " << configPath << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonConfig["timerEndingScript"].is_string()) {
|
if (jsonConfig["timerEndingScript"].isString()) {
|
||||||
config.timerEndingScript = jsonConfig["timerEndingScript"].get<std::string>();
|
config.timerEndingScript = jsonConfig["timerEndingScript"].asString();
|
||||||
}
|
}
|
||||||
if (jsonConfig["focusDuration"].is_number_integer()) {
|
if (jsonConfig["focusDuration"].isNumber()) {
|
||||||
config.focusDuration = jsonConfig["focusDuration"].get<int>();
|
config.focusDuration = jsonConfig["focusDuration"].asNumber();
|
||||||
}
|
}
|
||||||
if (jsonConfig["breakDuration"].is_number_integer()) {
|
if (jsonConfig["breakDuration"].isNumber()) {
|
||||||
config.breakDuration = jsonConfig["breakDuration"].get<int>();
|
config.breakDuration = jsonConfig["breakDuration"].asNumber();
|
||||||
}
|
}
|
||||||
if (jsonConfig["sessionCount"].is_number_integer()) {
|
if (jsonConfig["sessionCount"].isNumber()) {
|
||||||
config.sessionCount = jsonConfig["sessionCount"].get<int>();
|
config.sessionCount = jsonConfig["sessionCount"].asNumber();
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -183,12 +184,12 @@ void saveJsonConfig(const std::string& configPath, const Config& config) {
|
||||||
std::cerr << "Cant open config file: " << configPath << std::endl;
|
std::cerr << "Cant open config file: " << configPath << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nlohmann::json jsonConfig;
|
rei::json::JsonObject jsonConfig;
|
||||||
jsonConfig["timerEndingScript"] = config.timerEndingScript;
|
jsonConfig.set("timerEndingScript", config.timerEndingScript);
|
||||||
jsonConfig["focusDuration"] = config.focusDuration;
|
jsonConfig.set("focusDuration", config.focusDuration);
|
||||||
jsonConfig["breakDuration"] = config.breakDuration;
|
jsonConfig.set("breakDuration", config.breakDuration);
|
||||||
jsonConfig["sessionCount"] = config.sessionCount;
|
jsonConfig.set("sessionCount", config.sessionCount);
|
||||||
file << jsonConfig.dump(4);
|
file << rei::json::toString(jsonConfig);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,6 +210,12 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
CountdownState countdown(ui);
|
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([&] {
|
ui->global<ui::State>().on_config_changed([&] {
|
||||||
countdown.reset();
|
countdown.reset();
|
||||||
config.timerEndingScript = ui->global<ui::State>().get_timer_ending_script();
|
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