Adding initial stuff for install stage.
This commit is contained in:
@@ -0,0 +1,181 @@
|
|||||||
|
// <Kira Installer - universal Linux installer.>
|
||||||
|
// Copyright (C) <2026> <Kira Foundation>
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/*
|
||||||
|
Actual installation script.
|
||||||
|
*/
|
||||||
|
|
||||||
|
///
|
||||||
|
/// So. I am goind to make dir structure lile this
|
||||||
|
/// /bzz/root
|
||||||
|
/// /bzz/home
|
||||||
|
/// Mount root from it and binmount home
|
||||||
|
///
|
||||||
|
|
||||||
|
use log;
|
||||||
|
use crate::{
|
||||||
|
kira_theming,
|
||||||
|
stage::{KiraConfig, StageAction, StageResult},
|
||||||
|
};
|
||||||
|
use iced::{Alignment, Task, futures, widget};
|
||||||
|
use rust_i18n::t;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
enum InstallationState {
|
||||||
|
UserConfirmDialog,
|
||||||
|
Partitionning,
|
||||||
|
CopyFiles,
|
||||||
|
Configuring,
|
||||||
|
Finish,
|
||||||
|
Error,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub struct InstallStage {
|
||||||
|
state: InstallationState,
|
||||||
|
progress: f32,
|
||||||
|
progress_message: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum Message {
|
||||||
|
UserConfirms,
|
||||||
|
UserDenies,
|
||||||
|
StartPartitioning,
|
||||||
|
UpdateProgress(Result<(f32, String), String>),
|
||||||
|
PartitioningFinish(Result<(), String>),
|
||||||
|
Back,
|
||||||
|
Cancel,
|
||||||
|
Finish,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Update {
|
||||||
|
StgAct(StageAction),
|
||||||
|
Task(Task<Message>),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
impl InstallStage {
|
||||||
|
pub fn new(config: &KiraConfig) -> Self {
|
||||||
|
Self {
|
||||||
|
state: InstallationState::UserConfirmDialog,
|
||||||
|
progress: 0.0,
|
||||||
|
progress_message: String::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gen_result(&self) -> StageResult {
|
||||||
|
StageResult::new("install")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update(&mut self, message: Message) -> Update {
|
||||||
|
match message {
|
||||||
|
Message::UserDenies => Update::StgAct(StageAction::Back),
|
||||||
|
Message::UserConfirms => {
|
||||||
|
// starting installation process here
|
||||||
|
self.state = InstallationState::Partitionning;
|
||||||
|
Update::Task(Task::run(disk_part::check_connected(), Message::UpdateProgress))
|
||||||
|
//Update::Task(Task::perform(, Message::PartitioningFinish))
|
||||||
|
}
|
||||||
|
Message::StartPartitioning => Update::StgAct(StageAction::None),
|
||||||
|
Message::PartitioningFinish(res) => Update::StgAct(StageAction::None),
|
||||||
|
Message::UpdateProgress(maybe_msg) => {
|
||||||
|
match maybe_msg {
|
||||||
|
Ok((progress, msg))=> {
|
||||||
|
self.progress = progress;
|
||||||
|
self.progress_message = msg;
|
||||||
|
Update::StgAct(StageAction::None)
|
||||||
|
}
|
||||||
|
Err(ex) => {
|
||||||
|
log::error!("{}", &ex);
|
||||||
|
self.state = InstallationState::Error;
|
||||||
|
Update::StgAct(StageAction::None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Update::StgAct(StageAction::None)
|
||||||
|
|
||||||
|
},
|
||||||
|
Message::Cancel => Update::StgAct(StageAction::Abort),
|
||||||
|
Message::Back => Update::StgAct(StageAction::Back),
|
||||||
|
Message::Finish => Update::StgAct(StageAction::None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn view(&self) -> iced::Element<'_, Message> {
|
||||||
|
let action_button = if self.state == InstallationState::Finish {
|
||||||
|
widget::button(widget::text(t!("button.finish"))).on_press(Message::Finish)
|
||||||
|
} else {
|
||||||
|
widget::button(widget::text(t!("button.cancel"))).on_press(Message::Cancel)
|
||||||
|
};
|
||||||
|
|
||||||
|
// Embed the image bytes into the executable
|
||||||
|
let welcom_logo_handle = widget::image::Handle::from_bytes(kira_theming::get_logo_bytes());
|
||||||
|
|
||||||
|
let main_content = widget::column![
|
||||||
|
widget::container(
|
||||||
|
widget::column![
|
||||||
|
widget::image(welcom_logo_handle)
|
||||||
|
.width(iced::Pixels(128.0))
|
||||||
|
.height(iced::Pixels(128.0)),
|
||||||
|
widget::text(t!("install.caption")),
|
||||||
|
widget::progress_bar(0.0..=100.0, self.progress),
|
||||||
|
widget::text(self.progress_message.clone()),
|
||||||
|
]
|
||||||
|
.padding(10)
|
||||||
|
.spacing(10)
|
||||||
|
.align_x(Alignment::Center)
|
||||||
|
)
|
||||||
|
.height(iced::Length::Fill)
|
||||||
|
.width(iced::Length::Fill)
|
||||||
|
.align_x(Alignment::Center)
|
||||||
|
.align_y(Alignment::Center),
|
||||||
|
widget::container(action_button)
|
||||||
|
.width(iced::Length::Fill)
|
||||||
|
.align_y(Alignment::End)
|
||||||
|
.padding(10),
|
||||||
|
]
|
||||||
|
.align_x(Alignment::Center)
|
||||||
|
.spacing(10);
|
||||||
|
|
||||||
|
let page_stack = widget::Stack::with_capacity(2).push(main_content);
|
||||||
|
|
||||||
|
if self.state == InstallationState::UserConfirmDialog {
|
||||||
|
page_stack
|
||||||
|
.push(
|
||||||
|
widget::column![
|
||||||
|
widget::text(t!("install.warning")),
|
||||||
|
widget::row![
|
||||||
|
widget::button(widget::text(t!("button.no")))
|
||||||
|
.on_press(Message::UserDenies),
|
||||||
|
widget::space::horizontal(), // Pushes the right button to the far right
|
||||||
|
widget::button(widget::text(t!("button.yes")))
|
||||||
|
.on_press(Message::UserConfirms)
|
||||||
|
]
|
||||||
|
.width(iced::Length::Fill)
|
||||||
|
.align_y(Alignment::End)
|
||||||
|
.padding(10)
|
||||||
|
]
|
||||||
|
.align_x(Alignment::Center),
|
||||||
|
)
|
||||||
|
.into()
|
||||||
|
} else {
|
||||||
|
page_stack.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -22,4 +22,5 @@ pub mod timezone;
|
|||||||
pub mod locale;
|
pub mod locale;
|
||||||
pub mod keyboard;
|
pub mod keyboard;
|
||||||
pub mod partition;
|
pub mod partition;
|
||||||
pub mod security;
|
pub mod security;
|
||||||
|
pub mod install;
|
||||||
Reference in New Issue
Block a user