mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-01 08:53:20 +00:00
Replace 'add event window' with popup
This commit is contained in:
parent
c804ce1c7b
commit
2e1e5db5ea
10 changed files with 50 additions and 204 deletions
|
@ -32,7 +32,6 @@ add_executable(mirai
|
|||
src/main.cpp
|
||||
src/windows/AppWindow/AppWindow.cpp
|
||||
src/windows/SettingsWindow/SettingsWindow.cpp
|
||||
src/windows/EditEventWindow/EditEventWindow.cpp
|
||||
src/SeleniteSetup.cpp
|
||||
src/shared/Utils.cpp
|
||||
)
|
||||
|
|
2
external/selenite
vendored
2
external/selenite
vendored
|
@ -1 +1 @@
|
|||
Subproject commit fa86c85483725f269ee06001dba8c4c2a438194d
|
||||
Subproject commit 810607c01fa659f31bd11bd41a9ee5611e5db8ea
|
43
src/modals/AddEventModal.slint
Normal file
43
src/modals/AddEventModal.slint
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { Palette } from "@selenite";
|
||||
import { VTextInput } from "../../external/selenite/components/TextInput.slint";
|
||||
import { VButton, VText, VDatePicker } from "../../external/selenite/components/index.slint";
|
||||
import { AppWindowActions } from "../windows/AppWindow/Actions.slint";
|
||||
import { Modal } from "../../external/selenite/components/Modal.slint";
|
||||
import { VTimePicker } from "../../external/selenite/components/TimePicker.slint";
|
||||
|
||||
export component AddEventModal inherits Modal {
|
||||
public function open() {
|
||||
root.show();
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
titleInput := VTextInput {
|
||||
label: "title";
|
||||
}
|
||||
VText { text: "on"; vertical-alignment: bottom;}
|
||||
dateInput := VDatePicker {
|
||||
enabled: true;
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
VText { text: "between"; vertical-alignment: bottom; }
|
||||
startTimeInput := VTimePicker { }
|
||||
VText { text: "and"; vertical-alignment: bottom; }
|
||||
endTimeInput := VTimePicker { }
|
||||
}
|
||||
VButton {
|
||||
text: "Create";
|
||||
clicked => {
|
||||
AppWindowActions.create-event({
|
||||
title: titleInput.text,
|
||||
date: dateInput.date,
|
||||
startsAt: startTimeInput.time,
|
||||
endsAt: endTimeInput.time
|
||||
});
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,7 @@ import { AppWindowModels } from "windows/AppWindow/Models.slint";
|
|||
import { AppWindowActions } from "windows/AppWindow/Actions.slint";
|
||||
import { AppWindow } from "windows/AppWindow/AppWindow.slint";
|
||||
import { SettingsWindow } from "windows/SettingsWindow/SettingsWindow.slint";
|
||||
import { EditEventWindow } from "windows/EditEventWindow/EditEventWindow.slint";
|
||||
import { Utils } from "shared/Utils.slint";
|
||||
import { Palette } from "@selenite";
|
||||
|
||||
export { Utils, Palette, AppWindow, AppWindowModels, AppWindowActions, SettingsWindow, EditEventWindow }
|
||||
export { Utils, Palette, AppWindow, AppWindowModels, AppWindowActions, SettingsWindow }
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
#include <vector>
|
||||
|
||||
AppWindow::AppWindow(mirai::Mirai *miraiInstance)
|
||||
: miraiInstance_(miraiInstance), settingsWindow_(miraiInstance),
|
||||
editEventWindow_(miraiInstance), view_(miraiInstance)
|
||||
: miraiInstance_(miraiInstance), settingsWindow_(miraiInstance), view_(miraiInstance)
|
||||
{
|
||||
sources_ = std::make_shared<slint::VectorModel<ui::Source>>();
|
||||
days_ = std::make_shared<slint::VectorModel<ui::Day>>();
|
||||
|
@ -133,7 +132,7 @@ void AppWindow::setupCallbacks()
|
|||
/*editSourceWindow_.open(source);*/
|
||||
/*});*/
|
||||
actions().on_open_add_event_window([&]() {
|
||||
editEventWindow_.open();
|
||||
// editEventWindow_.open();
|
||||
});
|
||||
|
||||
actions().on_task_clicked([&](int sourceId, int taskId) {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "../EditEventWindow/EditEventWindow.h"
|
||||
#include "../SettingsWindow/SettingsWindow.h"
|
||||
#include "mirai-core/Mirai.h"
|
||||
#include "mirai-core/View.h"
|
||||
|
@ -37,7 +36,6 @@ class AppWindow
|
|||
|
||||
slint::ComponentHandle<ui::AppWindow> mainWindow_ = ui::AppWindow::create();
|
||||
SettingsWindow settingsWindow_;
|
||||
EditEventWindow editEventWindow_;
|
||||
|
||||
mirai::Mirai *miraiInstance_;
|
||||
mirai::View view_;
|
||||
|
|
|
@ -4,10 +4,11 @@ import { Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets
|
|||
import { TaskLine } from "../../../components/TaskLine.slint";
|
||||
import { EventGroup } from "../../../components/EventGroup.slint";
|
||||
import { Calendar } from "../../../components/Calendar.slint";
|
||||
import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Svg, Palette } from "@selenite";
|
||||
import { VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Svg, Palette } from "@selenite";
|
||||
import { CreateTaskOrEvent } from "../../../components/CreateTaskOrEvent.slint";
|
||||
import { Utils } from "../../../shared/Utils.slint";
|
||||
import { VActionButton } from "../../../../external/selenite/components/index.slint";
|
||||
import { AddEventModal } from "../../../modals/AddEventModal.slint";
|
||||
|
||||
export component CalendarView inherits Rectangle {
|
||||
|
||||
|
@ -15,49 +16,7 @@ export component CalendarView inherits Rectangle {
|
|||
private property<string> icon-not-visible: Svg.not-visible;
|
||||
private property<bool> completed-tasks-visible: false;
|
||||
|
||||
createEventPopup := PopupWindow {
|
||||
x: parent.width / 2 - 200px;
|
||||
y: parent.height / 2 - 300px;
|
||||
close-policy: close-on-click-outside;
|
||||
background := Rectangle {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background: Palette.background1;
|
||||
border-color: Palette.popup-border;
|
||||
border-width: 1px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
titleInput := VTextInput {
|
||||
label: "title";
|
||||
}
|
||||
VText { text: "on"; vertical-alignment: bottom;}
|
||||
dateInput := VDatePicker {
|
||||
enabled: true;
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
VText { text: "between"; vertical-alignment: bottom; }
|
||||
startTimeInput := VTimePicker { }
|
||||
VText { text: "and"; vertical-alignment: bottom; }
|
||||
endTimeInput := VTimePicker { }
|
||||
}
|
||||
VButton {
|
||||
text: "Create";
|
||||
clicked => {
|
||||
AppWindowActions.create-event({
|
||||
title: titleInput.text,
|
||||
date: dateInput.date,
|
||||
startsAt: startTimeInput.time,
|
||||
endsAt: endTimeInput.time
|
||||
});
|
||||
createEventPopup.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
createEventPopup := AddEventModal {}
|
||||
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Mirai. Copyright (C) 2024 Vyn
|
||||
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
|
||||
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
|
||||
#include "EditEventWindow.h"
|
||||
#include "../../SeleniteSetup.h"
|
||||
#include "evalyte-cpp-common/evalyte.h"
|
||||
#include "mirai-core/DataProvider.h"
|
||||
#include "mirai-core/MarkdownDataProvider.h"
|
||||
#include "mirai-core/Mirai.h"
|
||||
#include "slint.h"
|
||||
#include "slint_string.h"
|
||||
#include <bits/chrono.h>
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <print>
|
||||
#include <string>
|
||||
|
||||
EditEventWindow::EditEventWindow(mirai::Mirai *miraiInstance) : miraiInstance_(miraiInstance)
|
||||
{
|
||||
|
||||
const auto palettePath = std::string(getenv("HOME")) + "/.config/evalyte/theme.json";
|
||||
const auto palette = selenite::parseJson(palettePath);
|
||||
|
||||
if (palette.has_value()) {
|
||||
setSelenitePalette(window_->global<ui::Palette>(), palette.value());
|
||||
}
|
||||
|
||||
setupCallbacks();
|
||||
}
|
||||
|
||||
void EditEventWindow::setupCallbacks()
|
||||
{
|
||||
}
|
||||
|
||||
void EditEventWindow::open()
|
||||
{
|
||||
window_->show();
|
||||
}
|
||||
|
||||
void EditEventWindow::close()
|
||||
{
|
||||
window_->hide();
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Mirai. Copyright (C) 2024 Vyn
|
||||
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
|
||||
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mirai-core/Mirai.h"
|
||||
#include "slint.h"
|
||||
#include "ui.h"
|
||||
|
||||
class EditEventWindow
|
||||
{
|
||||
|
||||
public:
|
||||
EditEventWindow(mirai::Mirai *mirai);
|
||||
|
||||
void open();
|
||||
void close();
|
||||
|
||||
auto getHandle()
|
||||
{
|
||||
return this->window_;
|
||||
}
|
||||
|
||||
private:
|
||||
void setupCallbacks();
|
||||
|
||||
std::shared_ptr<slint::VectorModel<ui::Source>> sources_;
|
||||
slint::ComponentHandle<ui::EditEventWindow> window_ = ui::EditEventWindow::create();
|
||||
mirai::Mirai *miraiInstance_;
|
||||
};
|
|
@ -1,68 +0,0 @@
|
|||
import { AppWindowModels } from "../AppWindow/Models.slint";
|
||||
import { Button, VerticalBox, CheckBox } from "std-widgets.slint";
|
||||
import { VText, VTextInput, Palette } from "@selenite";
|
||||
import { VButton } from "../../../external/selenite/components/index.slint";
|
||||
import { Date, Time, Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
|
||||
import { VDatePicker } from "../../../external/selenite/components/DatePicker.slint";
|
||||
import { VTimePicker } from "../../../external/selenite/components/TimePicker.slint";
|
||||
|
||||
export struct CreateEventParams {
|
||||
title: string,
|
||||
date: Date,
|
||||
startsAt: Time,
|
||||
endsAt: Time
|
||||
}
|
||||
|
||||
export component EditEventWindow inherits Window {
|
||||
|
||||
title: "Mirai - Event";
|
||||
min-height: 100px;
|
||||
max-height: 500px; // needed, otherwise the window wants to fit the content (on Swaywm)
|
||||
max-width: 500px; // needed, otherwise the window wants to fit the content (on Swaywm)
|
||||
background: Palette.background;
|
||||
in-out property <int> sourceId;
|
||||
|
||||
callback create-event(CreateEventParams);
|
||||
callback delete-event(int);
|
||||
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
titleInput := VTextInput {
|
||||
label: "title";
|
||||
}
|
||||
VText { text: "on"; vertical-alignment: bottom;}
|
||||
dateInput := VDatePicker {
|
||||
enabled: true;
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
VText { text: "between"; vertical-alignment: bottom; }
|
||||
startTimeInput := VTimePicker { }
|
||||
VText { text: "and"; vertical-alignment: bottom; }
|
||||
endTimeInput := VTimePicker { }
|
||||
}
|
||||
VButton {
|
||||
text: "Create";
|
||||
clicked => {
|
||||
debug("clicked");
|
||||
root.create-event({
|
||||
title: titleInput.text,
|
||||
date: dateInput.date,
|
||||
startsAt: startTimeInput.time,
|
||||
endsAt: endTimeInput.time
|
||||
})
|
||||
}
|
||||
}
|
||||
VButton {
|
||||
text: "Delete";
|
||||
background-color: Palette.red;
|
||||
double-clicked => {
|
||||
//root.delete-event(root.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { AppWindowModels, Palette } // Export to make it visible to the C++ backend
|
Loading…
Add table
Add a link
Reference in a new issue