fix: use btreemap to preserve order
This commit is contained in:
parent
183005da53
commit
711cb1fd9e
2 changed files with 29 additions and 21 deletions
|
|
@ -48,6 +48,7 @@ pub mod message {
|
||||||
}
|
}
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
pub use self::command::Task;
|
pub use self::command::Task;
|
||||||
pub use self::core::Core;
|
pub use self::core::Core;
|
||||||
|
|
@ -58,9 +59,11 @@ use crate::widget::{
|
||||||
};
|
};
|
||||||
use crate::{prelude::*, widget};
|
use crate::{prelude::*, widget};
|
||||||
use apply::Apply;
|
use apply::Apply;
|
||||||
|
use iced::alignment::Vertical;
|
||||||
use iced::{window, Alignment};
|
use iced::{window, Alignment};
|
||||||
use iced::{Length, Subscription};
|
use iced::{Length, Subscription};
|
||||||
pub use message::Message;
|
pub use message::Message;
|
||||||
|
use taffy::AlignContent;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
#[cfg(feature = "single-instance")]
|
#[cfg(feature = "single-instance")]
|
||||||
use {
|
use {
|
||||||
|
|
@ -610,7 +613,7 @@ where
|
||||||
.application_icon
|
.application_icon
|
||||||
.map(|icon| crate::desktop::IconSource::Name(icon).as_cosmic_icon());
|
.map(|icon| crate::desktop::IconSource::Name(icon).as_cosmic_icon());
|
||||||
|
|
||||||
let mut links: HashMap<String, String> = HashMap::new();
|
let mut links: BTreeMap<String, String> = BTreeMap::new();
|
||||||
|
|
||||||
if let Some(website) = about.website {
|
if let Some(website) = about.website {
|
||||||
links.insert("Website".into(), website);
|
links.insert("Website".into(), website);
|
||||||
|
|
@ -645,7 +648,7 @@ where
|
||||||
widget::row()
|
widget::row()
|
||||||
.push_maybe(version)
|
.push_maybe(version)
|
||||||
.push_maybe(license)
|
.push_maybe(license)
|
||||||
.spacing(spacing.space_xxs),
|
.spacing(spacing.space_xs),
|
||||||
)
|
)
|
||||||
.push_maybe(links_section)
|
.push_maybe(links_section)
|
||||||
.push_maybe(developers_section)
|
.push_maybe(developers_section)
|
||||||
|
|
@ -656,7 +659,7 @@ where
|
||||||
.push_maybe(comments)
|
.push_maybe(comments)
|
||||||
.push_maybe(copyright)
|
.push_maybe(copyright)
|
||||||
.align_x(Alignment::Center)
|
.align_x(Alignment::Center)
|
||||||
.spacing(spacing.space_xxs)
|
.spacing(spacing.space_xs)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.into()
|
.into()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -666,26 +669,33 @@ where
|
||||||
|
|
||||||
fn maintainer_section<'a>(
|
fn maintainer_section<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
list: HashMap<String, String>,
|
list: BTreeMap<String, String>,
|
||||||
title: &'a str,
|
title: &'a str,
|
||||||
) -> Option<widget::settings::Section<'a, crate::app::cosmic::Message>> {
|
) -> Option<widget::settings::Section<'a, crate::app::cosmic::Message>> {
|
||||||
|
let spacing = crate::theme::active().cosmic().spacing;
|
||||||
let developers_section = if list.is_empty() {
|
let developers_section = if list.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let developers: Vec<Element<crate::app::cosmic::Message>> = list
|
let developers: Vec<Element<crate::app::cosmic::Message>> = list
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(name, email)| {
|
.map(|(name, email)| {
|
||||||
widget::button::link(name)
|
widget::button::custom(
|
||||||
.on_press(crate::app::cosmic::Message::OpenUrl(format!(
|
widget::row()
|
||||||
"mailto:{email}"
|
.push(widget::text(name))
|
||||||
)))
|
.push(horizontal_space())
|
||||||
.into()
|
.push(crate::widget::icon::from_name("link-symbolic").icon())
|
||||||
|
.padding(spacing.space_xxs)
|
||||||
|
.align_y(Vertical::Center),
|
||||||
|
)
|
||||||
|
.class(crate::theme::Button::Text)
|
||||||
|
.on_press(crate::app::cosmic::Message::OpenUrl(format!(
|
||||||
|
"mailto:{email}"
|
||||||
|
)))
|
||||||
|
.width(Length::Fill)
|
||||||
|
.into()
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let mut developers_section = widget::settings::section().title(title);
|
let developers_section = widget::settings::section().title(title).extend(developers);
|
||||||
for developer in developers {
|
|
||||||
developers_section = developers_section.add(developer);
|
|
||||||
}
|
|
||||||
Some(developers_section)
|
Some(developers_section)
|
||||||
};
|
};
|
||||||
developers_section
|
developers_section
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::{widget, Element};
|
|
||||||
|
|
||||||
#[cfg(feature = "desktop")]
|
#[cfg(feature = "desktop")]
|
||||||
use std::collections::HashMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
#[cfg(feature = "desktop")]
|
#[cfg(feature = "desktop")]
|
||||||
#[derive(Debug, Default, Clone, derive_setters::Setters)]
|
#[derive(Debug, Default, Clone, derive_setters::Setters)]
|
||||||
|
|
@ -12,19 +10,19 @@ pub struct About {
|
||||||
/// The application's icon name.
|
/// The application's icon name.
|
||||||
pub application_icon: Option<String>,
|
pub application_icon: Option<String>,
|
||||||
/// Artists who contributed to the application.
|
/// Artists who contributed to the application.
|
||||||
pub artists: HashMap<String, String>,
|
pub artists: BTreeMap<String, String>,
|
||||||
/// Comments about the application.
|
/// Comments about the application.
|
||||||
pub comments: Option<String>,
|
pub comments: Option<String>,
|
||||||
/// The application's copyright.
|
/// The application's copyright.
|
||||||
pub copyright: Option<String>,
|
pub copyright: Option<String>,
|
||||||
/// Designers who contributed to the application.
|
/// Designers who contributed to the application.
|
||||||
pub designers: HashMap<String, String>,
|
pub designers: BTreeMap<String, String>,
|
||||||
/// Name of the application's developer.
|
/// Name of the application's developer.
|
||||||
pub developer_name: Option<String>,
|
pub developer_name: Option<String>,
|
||||||
/// Developers who contributed to the application.
|
/// Developers who contributed to the application.
|
||||||
pub developers: HashMap<String, String>,
|
pub developers: BTreeMap<String, String>,
|
||||||
/// Documenters who contributed to the application.
|
/// Documenters who contributed to the application.
|
||||||
pub documenters: HashMap<String, String>,
|
pub documenters: BTreeMap<String, String>,
|
||||||
/// The license text.
|
/// The license text.
|
||||||
pub license: Option<String>,
|
pub license: Option<String>,
|
||||||
/// The license from a list of known licenses.
|
/// The license from a list of known licenses.
|
||||||
|
|
@ -34,7 +32,7 @@ pub struct About {
|
||||||
/// The URL of the application’s repository.
|
/// The URL of the application’s repository.
|
||||||
pub repository_url: Option<String>,
|
pub repository_url: Option<String>,
|
||||||
/// Translators who contributed to the application.
|
/// Translators who contributed to the application.
|
||||||
pub translators: HashMap<String, String>,
|
pub translators: BTreeMap<String, String>,
|
||||||
/// The application’s version.
|
/// The application’s version.
|
||||||
pub version: Option<String>,
|
pub version: Option<String>,
|
||||||
/// The application’s website.
|
/// The application’s website.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue