1
0
mirror of https://github.com/pcvolkmer/cert-tools.git synced 2025-12-14 06:03:20 +00:00

feat: update ui to use iced 0.14

This commit is contained in:
2025-12-13 22:07:44 +01:00
parent a150b73c5f
commit aaf649cb05
3 changed files with 22 additions and 28 deletions

View File

@@ -2,7 +2,7 @@
name = "cert-tools" name = "cert-tools"
description = "Application to show, check and cleanup content of PEM files" description = "Application to show, check and cleanup content of PEM files"
version = "0.4.1" version = "0.4.1"
edition = "2021" edition = "2024"
license = "GPL-3.0-or-later" license = "GPL-3.0-or-later"
authors = ["Paul-Christian Volkmer"] authors = ["Paul-Christian Volkmer"]

View File

@@ -1,20 +1,13 @@
[package] [package]
name = "cert-tools-ui" name = "cert-tools-ui"
version = "0.4.1" version = "0.4.1"
edition = "2021" edition = "2024"
[dependencies] [dependencies]
cert-tools = { path = ".." } cert-tools = { path = ".." }
iced = { version = "0.13", features = ["wgpu", "tiny-skia", "tokio", "web-colors", "image"], default-features = false } iced = { version = "0.14", features = ["wayland", "x11", "wgpu", "tiny-skia", "tokio", "web-colors", "image", "advanced"], default-features = false }
rfd = "0.15" rfd = "0.16"
itertools = "0.14" itertools = "0.14"
[build-dependencies] [build-dependencies]
winresource = "0.1" winresource = "0.1"
[profile.release]
opt-level = "z"
codegen-units = 1
lto = true
strip = true
panic = "abort"

View File

@@ -23,7 +23,7 @@ use cert_tools::{read_p12_file, save_p12_file, Chain, PrivateKey};
use iced::border::Radius; use iced::border::Radius;
use iced::widget::text_editor::{default, Content, Status}; use iced::widget::text_editor::{default, Content, Status};
use iced::widget::{ use iced::widget::{
self, button, column, container, horizontal_rule, horizontal_space, row, text, text_editor, self, button, column, container, rule, space, row, text, text_editor,
text_input, Container, Scrollable, text_input, Container, Scrollable,
}; };
use iced::{alignment, application, clipboard, color, window, Background, Border, Color, Element, Font, Length, Padding, Pixels, Settings, Size, Task}; use iced::{alignment, application, clipboard, color, window, Background, Border, Color, Element, Font, Length, Padding, Pixels, Settings, Size, Task};
@@ -33,7 +33,8 @@ use std::time::SystemTime;
use iced::window::settings::PlatformSpecific; use iced::window::settings::PlatformSpecific;
fn main() -> iced::Result { fn main() -> iced::Result {
application(Ui::title, Ui::update, Ui::view) application(Ui::new, Ui::update, Ui::view)
.title(Ui::title)
.settings(Settings { .settings(Settings {
default_text_size: Pixels::from(13), default_text_size: Pixels::from(13),
..Settings::default() ..Settings::default()
@@ -54,7 +55,7 @@ fn main() -> iced::Result {
}) })
.resizable(false) .resizable(false)
.window_size(Size::new(1020.0, 800.0)) .window_size(Size::new(1020.0, 800.0))
.run_with(Ui::new) .run()
} }
enum File { enum File {
@@ -294,7 +295,7 @@ impl Ui {
}; };
match &self.chain { match &self.chain {
None => {} None => {}
Some(ref chain) => match file { Some(chain) => match file {
Ok(file) => { Ok(file) => {
match save_p12_file(&file, &self.password_1, chain.certs(), private_key) match save_p12_file(&file, &self.password_1, chain.certs(), private_key)
{ {
@@ -338,9 +339,9 @@ impl Ui {
file: &'a File, file: &'a File,
) -> text_input::TextInput<'a, Message> { ) -> text_input::TextInput<'a, Message> {
let text = match file { let text = match file {
File::Invalid(ref file) File::Invalid(file)
| File::Certificates(ref file, _) | File::Certificates(file, _)
| File::PrivateKey(ref file, _) => file.display().to_string(), | File::PrivateKey(file, _) => file.display().to_string(),
_ => String::new(), _ => String::new(),
}; };
@@ -474,7 +475,7 @@ impl Ui {
text(" "), text(" "),
clip_button, clip_button,
cleanup_button, cleanup_button,
horizontal_space(), space::horizontal(),
] ]
} else { } else {
row![ row![
@@ -485,7 +486,7 @@ impl Ui {
text(" "), text(" "),
clip_button, clip_button,
cleanup_button, cleanup_button,
horizontal_space(), space::horizontal(),
] ]
} }
.spacing(2); .spacing(2);
@@ -539,7 +540,7 @@ impl Ui {
container(text("")) container(text(""))
} }
], ],
horizontal_rule(1), rule::horizontal(1),
row![text("Issuer: ").width(160), text(cert.issuer().to_string())], row![text("Issuer: ").width(160), text(cert.issuer().to_string())],
row![ row![
text("Gültigkeit: ").width(160), text("Gültigkeit: ").width(160),
@@ -559,7 +560,7 @@ impl Ui {
row![ row![
text("SHA-1-Fingerprint: ").width(160), text("SHA-1-Fingerprint: ").width(160),
monospace_text(cert.fingerprint().sha1.to_string()), monospace_text(cert.fingerprint().sha1.to_string()),
horizontal_space(), space::horizontal(),
button("Copy to Clipboard") button("Copy to Clipboard")
.style(button::secondary) .style(button::secondary)
.padding(1) .padding(1)
@@ -571,7 +572,7 @@ impl Ui {
row![ row![
text("SHA-256-Fingerprint: ").width(160), text("SHA-256-Fingerprint: ").width(160),
monospace_text(cert.fingerprint().sha256.to_string()), monospace_text(cert.fingerprint().sha256.to_string()),
horizontal_space(), space::horizontal(),
button("Copy to Clipboard") button("Copy to Clipboard")
.style(button::secondary) .style(button::secondary)
.padding(1) .padding(1)
@@ -863,19 +864,19 @@ impl Ui {
indicator.center_y(96), indicator.center_y(96),
] ]
.spacing(40), .spacing(40),
horizontal_rule(1), rule::horizontal(1),
buttons, buttons,
horizontal_rule(1), rule::horizontal(1),
match self.mode { match self.mode {
UiMode::CertList => column![certs, chain_info], UiMode::CertList => column![certs, chain_info],
UiMode::Output => column![output], UiMode::Output => column![output],
UiMode::ImportPassphrase => column![ask_for_import_password], UiMode::ImportPassphrase => column![ask_for_import_password],
UiMode::ExportPassphrase => column![ask_for_export_password], UiMode::ExportPassphrase => column![ask_for_export_password],
}, },
horizontal_rule(1), rule::horizontal(1),
row![ row![
text(&self.status), text(&self.status),
horizontal_space(), space::horizontal(),
text(format!("Version {}", env!("CARGO_PKG_VERSION"))).style(|_| text::Style { text(format!("Version {}", env!("CARGO_PKG_VERSION"))).style(|_| text::Style {
color: Some(color!(0x888888)) color: Some(color!(0x888888))
}), }),