Skip to content

Commit e1fc347

Browse files
committed
chore: update libcosmic/about page
1 parent 98a37b3 commit e1fc347

File tree

4 files changed

+67
-36
lines changed

4 files changed

+67
-36
lines changed

Cargo.lock

Lines changed: 38 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ calculator-rs = "0.1.2"
99
i18n-embed-fl = "0.8"
1010
log = "0.4.22"
1111
once_cell = "1.19.0"
12+
open = "5.3.0"
1213
paste = "1.0.15"
1314
pretty_env_logger = "0.5.0"
1415
rust-embed = "8.3.0"

i18n/en/cosmic_ext_calculator.ftl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ view = View
44
delete = Delete
55
clear-history = Clear history
66
malformed-expression = Malformed expression
7+
8+
## About
9+
repository = Repository
10+
support = Support
11+
website = Website

src/app.rs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::config;
88
use crate::config::CONFIG_VERSION;
99
use crate::fl;
1010
use crate::operator::Operator;
11-
use cosmic::app::about::About;
1211
use cosmic::app::{self, Core, Message as CosmicMessage, Task};
1312
use cosmic::cosmic_config::Update;
1413
use cosmic::cosmic_theme::ThemeMode;
@@ -18,6 +17,7 @@ use cosmic::iced::{
1817
keyboard::{Key, Modifiers},
1918
Alignment, Event, Length, Subscription,
2019
};
20+
use cosmic::widget::about::About;
2121
use cosmic::widget::menu::Action;
2222
use cosmic::widget::{self, menu, nav_bar, ToastId};
2323
use cosmic::{cosmic_config, cosmic_theme, theme, Application, ApplicationExt, Element};
@@ -48,7 +48,7 @@ pub enum Message {
4848
CleanHistory,
4949
ShowToast(String),
5050
CloseToast(ToastId),
51-
Cosmic(cosmic::app::cosmic::Message),
51+
Open(String),
5252
}
5353

5454
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
@@ -144,14 +144,22 @@ impl Application for Calculator {
144144
}
145145

146146
let about = About::default()
147-
.set_application_name(fl!("app-title"))
148-
.set_application_icon(Self::APP_ID)
149-
.set_developer_name("Eduardo Flores")
150-
.set_license_type("GPL-3.0")
151-
.set_version("0.1.1")
152-
.set_support_url("https://github.com/cosmic-utils/calculator/issues")
153-
.set_repository_url("https://github.com/cosmic-utils/calculator")
154-
.set_developers([("Eduardo Flores".into(), "[email protected]".into())]);
147+
.name(fl!("app-title"))
148+
.icon(Self::APP_ID)
149+
.version("0.1.1")
150+
.author("Eduardo Flores")
151+
.license("GPL-3.0-only")
152+
.links([
153+
(
154+
fl!("support"),
155+
"https://github.com/cosmic-utils/calculator/issues",
156+
),
157+
(
158+
fl!("repository"),
159+
"https://github.com/cosmic-utils/calculator",
160+
),
161+
])
162+
.developers([("Eduardo Flores".into(), "[email protected]".into())]);
155163

156164
let mut app = Calculator {
157165
core,
@@ -175,10 +183,6 @@ impl Application for Calculator {
175183
(app, Task::batch(tasks))
176184
}
177185

178-
fn about(&self) -> Option<&About> {
179-
Some(&self.about)
180-
}
181-
182186
fn header_start(&self) -> Vec<Element<Self::Message>> {
183187
let menu_bar = menu::bar(vec![menu::Tree::with_children(
184188
menu::root(fl!("view")),
@@ -373,10 +377,10 @@ impl Application for Calculator {
373377
}
374378

375379
match message {
376-
Message::Cosmic(message) => {
377-
commands.push(cosmic::app::command::message(cosmic::app::message::cosmic(
378-
message,
379-
)));
380+
Message::Open(url) => {
381+
if let Err(err) = open::that_detached(url) {
382+
log::error!("{err}")
383+
}
380384
}
381385
Message::ShowToast(message) => {
382386
commands.push(
@@ -453,7 +457,7 @@ impl Application for Calculator {
453457
}
454458

455459
Some(match self.context_page {
456-
ContextPage::About => self.about_view()?.map(Message::Cosmic),
460+
ContextPage::About => widget::about(&self.about, Message::Open),
457461
})
458462
}
459463

0 commit comments

Comments
 (0)