Use dash icon if column not sorted
This commit is contained in:
parent
91060cf22e
commit
ea93c7df32
1 changed files with 9 additions and 9 deletions
18
src/tab.rs
18
src/tab.rs
|
|
@ -514,7 +514,7 @@ pub enum View {
|
||||||
List,
|
List,
|
||||||
}
|
}
|
||||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, PartialOrd, Ord, Eq)]
|
#[derive(Clone, Copy, Debug, Hash, PartialEq, PartialOrd, Ord, Eq)]
|
||||||
enum HeadingOptions {
|
pub enum HeadingOptions {
|
||||||
Name,
|
Name,
|
||||||
Modified,
|
Modified,
|
||||||
Size,
|
Size,
|
||||||
|
|
@ -533,6 +533,7 @@ pub struct Tab {
|
||||||
pub history_i: usize,
|
pub history_i: usize,
|
||||||
pub history: Vec<Location>,
|
pub history: Vec<Location>,
|
||||||
pub config: TabConfig,
|
pub config: TabConfig,
|
||||||
|
//TODO: this no longer needs to be a map
|
||||||
sort_map: HashMap<HeadingOptions, bool>,
|
sort_map: HashMap<HeadingOptions, bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -540,10 +541,7 @@ impl Tab {
|
||||||
pub fn new(location: Location, config: TabConfig) -> Self {
|
pub fn new(location: Location, config: TabConfig) -> Self {
|
||||||
let history = vec![location.clone()];
|
let history = vec![location.clone()];
|
||||||
let mut sort_map = HashMap::new();
|
let mut sort_map = HashMap::new();
|
||||||
|
|
||||||
sort_map.insert(HeadingOptions::Name, true);
|
sort_map.insert(HeadingOptions::Name, true);
|
||||||
sort_map.insert(HeadingOptions::Modified, true);
|
|
||||||
sort_map.insert(HeadingOptions::Size, true);
|
|
||||||
Self {
|
Self {
|
||||||
location,
|
location,
|
||||||
context_menu: None,
|
context_menu: None,
|
||||||
|
|
@ -758,7 +756,8 @@ impl Tab {
|
||||||
self.view = view;
|
self.view = view;
|
||||||
}
|
}
|
||||||
Message::ToggleSort(heading_option) => {
|
Message::ToggleSort(heading_option) => {
|
||||||
let heading_sort = !self.sort_map[&heading_option];
|
let heading_sort = !self.sort_map.get(&heading_option).unwrap_or(&false);
|
||||||
|
self.sort_map.clear();
|
||||||
self.sort_map.insert(heading_option, heading_sort);
|
self.sort_map.insert(heading_option, heading_sort);
|
||||||
let check_reverse = |ord: Ordering, sort: bool| {
|
let check_reverse = |ord: Ordering, sort: bool| {
|
||||||
if sort {
|
if sort {
|
||||||
|
|
@ -1084,15 +1083,16 @@ impl Tab {
|
||||||
($name: literal, $width: expr, $msg: expr) => {
|
($name: literal, $width: expr, $msg: expr) => {
|
||||||
widget::row::with_children(vec![
|
widget::row::with_children(vec![
|
||||||
widget::text::heading(fl!($name)).into(),
|
widget::text::heading(fl!($name)).into(),
|
||||||
widget::button(widget::icon::from_name(if self.sort_map[&$msg] {
|
widget::button(widget::icon::from_name(match self.sort_map.get(&$msg) {
|
||||||
"go-down-symbolic"
|
Some(true) => "go-down-symbolic",
|
||||||
} else {
|
Some(false) => "go-up-symbolic",
|
||||||
"go-up-symbolic"
|
None => "list-remove-symbolic",
|
||||||
}))
|
}))
|
||||||
.on_press(Message::ToggleSort($msg))
|
.on_press(Message::ToggleSort($msg))
|
||||||
.style(cosmic::style::Button::Icon)
|
.style(cosmic::style::Button::Icon)
|
||||||
.into(),
|
.into(),
|
||||||
])
|
])
|
||||||
|
.spacing(space_xxs)
|
||||||
.width($width)
|
.width($width)
|
||||||
.align_items(Alignment::Center)
|
.align_items(Alignment::Center)
|
||||||
.into()
|
.into()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue