First try in implementing sheet edit dialog

This commit is contained in:
Julian Mutter 2024-05-25 23:10:47 +02:00
parent 58901dae37
commit 2ffd0bbbc3
3 changed files with 13 additions and 4 deletions

View File

@ -2,7 +2,6 @@ use std::{path::PathBuf, sync::Arc};
use chrono::Utc; use chrono::Utc;
use gtk::prelude::*; use gtk::prelude::*;
use log::debug;
use relm4::{ use relm4::{
component::{AsyncComponent, AsyncComponentParts}, component::{AsyncComponent, AsyncComponentParts},
gtk::Adjustment, gtk::Adjustment,
@ -19,6 +18,7 @@ use crate::{
use super::{ use super::{
mcdu::McduModel, mcdu::McduModel,
sheet_edit_dialog::{SheetEditDialogInput, SheetEditDialogModel},
sheet_listing::{SheetListingInput, SheetListingModel, SheetListingOutput}, sheet_listing::{SheetListingInput, SheetListingModel, SheetListingOutput},
}; };
@ -29,6 +29,7 @@ pub struct AppModel {
sheets_listing: Controller<SheetListingModel>, sheets_listing: Controller<SheetListingModel>,
edit_mode: bool, edit_mode: bool,
scroll_adjustment: Adjustment, scroll_adjustment: Adjustment,
sheet_edit_dialog: Controller<SheetEditDialogModel>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -131,6 +132,11 @@ impl AsyncComponent for AppModel {
}, },
); );
let sheet_edit_dialog = SheetEditDialogModel::builder()
.transient_for(&window)
.launch(())
.forward(sender.input_sender(), |_| todo!());
let model = AppModel { let model = AppModel {
database: Arc::new(init_data.database), database: Arc::new(init_data.database),
directory: Arc::new(init_data.directory), directory: Arc::new(init_data.directory),
@ -138,6 +144,7 @@ impl AsyncComponent for AppModel {
sheets_listing, sheets_listing,
edit_mode: false, edit_mode: false,
scroll_adjustment: Adjustment::builder().build(), scroll_adjustment: Adjustment::builder().build(),
sheet_edit_dialog,
}; };
let widgets = view_output!(); let widgets = view_output!();
@ -158,7 +165,10 @@ impl AsyncComponent for AppModel {
} }
AppInput::SheetPressed(sheet) => { AppInput::SheetPressed(sheet) => {
if self.edit_mode { if self.edit_mode {
debug!("Sheet pressed, but we are in edit mode!"); self.sheet_edit_dialog
.sender()
.send(SheetEditDialogInput::Show(sheet))
.unwrap();
} else { } else {
sheet.open_file(); sheet.open_file();
let mut sheet = sheet; let mut sheet = sheet;

View File

@ -1,4 +1,5 @@
pub mod app; pub mod app;
pub mod mcdu; pub mod mcdu;
pub mod sheet_edit_dialog;
pub mod sheet_listing; pub mod sheet_listing;
pub mod sheet_model; pub mod sheet_model;

View File

@ -1,5 +1,3 @@
use gtk::prelude::*; use gtk::prelude::*;
use relm4::prelude::*; use relm4::prelude::*;