mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-01 17:03:19 +00:00
Add default path when creating new source
This commit is contained in:
parent
14d04f6a77
commit
d6c781faa2
7 changed files with 24 additions and 6 deletions
|
@ -26,6 +26,7 @@ set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
|
|||
add_subdirectory(external/slint)
|
||||
add_subdirectory(external/selenite/cpp)
|
||||
add_subdirectory(external/mirai-core)
|
||||
add_subdirectory(external/evalyte-cpp-common)
|
||||
|
||||
add_executable(mirai
|
||||
src/main.cpp
|
||||
|
@ -41,6 +42,7 @@ set_property(TARGET mirai PROPERTY SLINT_EMBED_RESOURCES embed-files)
|
|||
|
||||
target_link_libraries(mirai PRIVATE Slint::Slint)
|
||||
target_link_libraries(mirai PRIVATE selenite)
|
||||
target_link_libraries(mirai PRIVATE evalyte-cpp-common)
|
||||
|
||||
target_include_directories(mirai PRIVATE "external")
|
||||
target_link_libraries(mirai PRIVATE mirai-core)
|
||||
|
|
2
external/evalyte-cpp-common
vendored
2
external/evalyte-cpp-common
vendored
|
@ -1 +1 @@
|
|||
Subproject commit b154a3351b89a5962a2bed2feae683b3a8009857
|
||||
Subproject commit 20e766badc8f400ac7db8487486b5e8990cefbbe
|
8
external/mirai-core/src/Mirai.cpp
vendored
8
external/mirai-core/src/Mirai.cpp
vendored
|
@ -136,10 +136,14 @@ std::vector<std::unique_ptr<Source>> &Mirai::getSources()
|
|||
|
||||
Source *Mirai::getSourceById(int id)
|
||||
{
|
||||
if (id >= sources_.size()) {
|
||||
auto source = std::ranges::find_if(sources_, [&](const std::unique_ptr<Source> &source) {
|
||||
return source->id == id;
|
||||
});
|
||||
assert(source != sources_.end()); // This should not happen
|
||||
if (source == sources_.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return sources_.at(id).get();
|
||||
return source->get();
|
||||
}
|
||||
|
||||
} // namespace mirai
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "AppWindow.h"
|
||||
#include "SeleniteSetup.h"
|
||||
#include "Utils.h"
|
||||
#include "evalyte-cpp-common/evalyte.h"
|
||||
#include "mirai-core/DataProvider.h"
|
||||
#include "mirai-core/DateTime.h"
|
||||
#include "mirai-core/Day.h"
|
||||
|
@ -48,6 +49,10 @@ AppWindowBackend::AppWindowBackend(mirai::Mirai *miraiInstance)
|
|||
}
|
||||
);
|
||||
|
||||
addSourceWindow_->set_default_source_path(
|
||||
slint::SharedString(evalyte::dataDirectoryPath("mirai") + "/")
|
||||
);
|
||||
|
||||
const auto palettePath = std::string(getenv("HOME")) + "/.config/evalyte/theme.json";
|
||||
const auto palette = selenite::parseJson(palettePath);
|
||||
if (palette.has_value()) {
|
||||
|
@ -138,6 +143,8 @@ void AppWindowBackend::setupCallbacks()
|
|||
std::string(params.name), std::string(params.type), std::move(file)
|
||||
);
|
||||
addSourceWindow_->hide();
|
||||
view_.setAllSources();
|
||||
view_.update();
|
||||
reloadSources();
|
||||
reloadTasks();
|
||||
});
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
*/
|
||||
|
||||
#include "AppWindowBackend.h"
|
||||
#include "evalyte-cpp-common/config.h"
|
||||
#include "evalyte-cpp-common/evalyte.h"
|
||||
#include "mirai-core/Mirai.h"
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const auto configFilePath = evalyte::createConfigDirectoryPath("mirai") + "/config.json";
|
||||
evalyte::createRequiredDirectories("mirai");
|
||||
const auto configFilePath = evalyte::configDirectoryPath("mirai") + "/config.json";
|
||||
mirai::Mirai mirai{configFilePath};
|
||||
AppWindowBackend appWindow{&mirai};
|
||||
appWindow.run();
|
||||
|
|
|
@ -41,7 +41,7 @@ export component SideBar inherits Rectangle {
|
|||
text: item.name;
|
||||
text-alignment: left;
|
||||
active: item.selected;
|
||||
clicked => { Backend.source-clicked(index) }
|
||||
clicked => { Backend.source-clicked(item.id) }
|
||||
VActionButton {
|
||||
visible: parent.active;
|
||||
icon-svg: Svg.cog;
|
||||
|
|
|
@ -12,14 +12,18 @@ export component AddSourceWindow inherits Window {
|
|||
default-font-size: 16px;
|
||||
background: Palette.background;
|
||||
|
||||
in-out property <string> default-source-path;
|
||||
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
nameInput := VTextInput {
|
||||
label: "Name";
|
||||
text: "todo";
|
||||
}
|
||||
pathInput := VTextInput {
|
||||
label: "Path";
|
||||
text: root.default-source-path + nameInput.text + ".md";
|
||||
}
|
||||
VButton {
|
||||
text: "Create";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue