Skip to content

Commit

Permalink
fixup! feat(Workspace): add missing settings and update design
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombier committed Nov 7, 2024
1 parent 0608b3e commit 0227032
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 64 deletions.
80 changes: 51 additions & 29 deletions cosmic-settings/src/pages/desktop/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ pub struct Page {
enum Asset {
WorkspaceSpanDisplay,
WorkspaceSeparateDisplay,
WorkspaceOrientationVertical,
WorkspaceOrientationHorizontal,
WorkspaceOrientationLeft,
WorkspaceOrientationRight,
WorkspaceOrientationTop,
WorkspaceOrientationBottom,
TrackpadGestureSwipeVertical,
TrackpadGestureSwipeHorizontal,
TrackpadGestureSwipeLeft,
Expand All @@ -60,8 +62,10 @@ impl Asset {
match self {
Asset::WorkspaceSpanDisplay => "assets/workspace-span-display",
Asset::WorkspaceSeparateDisplay => "assets/workspace-separate-display",
Asset::WorkspaceOrientationVertical => "assets/workspace-orientation-vertical",
Asset::WorkspaceOrientationHorizontal => "assets/workspace-orientation-horizontal",
Asset::WorkspaceOrientationLeft => "assets/workspace-orientation-left",
Asset::WorkspaceOrientationRight => "assets/workspace-orientation-right",
Asset::WorkspaceOrientationTop => "assets/workspace-orientation-top",
Asset::WorkspaceOrientationBottom => "assets/workspace-orientation-bottom",
Asset::TrackpadGestureSwipeVertical => "assets/trackpad-gesture-swipe-vertical",
Asset::TrackpadGestureSwipeHorizontal => "assets/trackpad-gesture-swipe-horizontal",
Asset::TrackpadGestureSwipeLeft => "assets/trackpad-gesture-swipe-left",
Expand Down Expand Up @@ -211,19 +215,36 @@ impl Page {
fl!("workspaces-orientation", "right"),
],
};
self.comp_workspace_config.workspace_thumbnail_placement =
match self.comp_workspace_config.workspace_layout {
WorkspaceLayout::Vertical => {
if self.selected_workspace_thumbnail_placement == 0 {
WorkspaceThumbnailPlacement::Left
} else {
WorkspaceThumbnailPlacement::Right
}
}
WorkspaceLayout::Horizontal => {
if self.selected_workspace_thumbnail_placement == 0 {
WorkspaceThumbnailPlacement::Top
} else {
WorkspaceThumbnailPlacement::Bottom
}
}
};
self.save_comp_config();
}
Message::SetWorkspaceThumbnailPlacement(value) => {
self.comp_workspace_config.workspace_thumbnail_placement =
match self.comp_workspace_config.workspace_layout {
WorkspaceLayout::Horizontal => {
WorkspaceLayout::Vertical => {
if value == 0 {
WorkspaceThumbnailPlacement::Left
} else {
WorkspaceThumbnailPlacement::Right
}
}
WorkspaceLayout::Vertical => {
WorkspaceLayout::Horizontal => {
if value == 0 {
WorkspaceThumbnailPlacement::Top
} else {
Expand All @@ -232,10 +253,7 @@ impl Page {
}
};
self.selected_workspace_thumbnail_placement = value;
// TODO apply the setting
// if let Err(err) = self.config.set("show_workspace_number", value) {
// error!(?err, "Failed to set config 'show_workspace_number'");
// }
self.save_comp_config();
}
Message::SetShowName(value) => {
self.show_workspace_name = value;
Expand Down Expand Up @@ -271,7 +289,7 @@ fn multi_behavior() -> Section<crate::pages::Message> {
ListColumn::default()
.add(
cosmic::iced::widget::column!(
widget::vertical_space(1),
widget::vertical_space().height(1),
settings::item_row(vec![radio(
text::body(&descriptions[span]),
WorkspaceMode::Global,
Expand All @@ -283,11 +301,11 @@ fn multi_behavior() -> Section<crate::pages::Message> {
cosmic::iced::widget::svg(asset_handle(Asset::WorkspaceSpanDisplay))
)
.spacing(cosmic::theme::active().cosmic().space_s())
.align_items(Alignment::Center),
.align_x(Alignment::Center),
)
.add(
cosmic::iced::widget::column!(
widget::vertical_space(1),
widget::vertical_space().height(1),
settings::item_row(vec![radio(
text::body(&descriptions[separate]),
WorkspaceMode::OutputBound,
Expand All @@ -299,7 +317,7 @@ fn multi_behavior() -> Section<crate::pages::Message> {
cosmic::iced::widget::svg(asset_handle(Asset::WorkspaceSeparateDisplay))
)
.spacing(cosmic::theme::active().cosmic().space_s())
.align_items(Alignment::Center),
.align_x(Alignment::Center),
)
.spacing(0))
.title(&section.title)
Expand Down Expand Up @@ -342,11 +360,15 @@ fn workspace_orientation() -> Section<crate::pages::Message> {
.add(
cosmic::iced::widget::column!(
cosmic::iced::widget::svg(
match page.comp_workspace_config.workspace_layout {
WorkspaceLayout::Vertical =>
asset_handle(Asset::WorkspaceOrientationVertical),
WorkspaceLayout::Horizontal =>
asset_handle(Asset::WorkspaceOrientationHorizontal),
match page.comp_workspace_config.workspace_thumbnail_placement {
WorkspaceThumbnailPlacement::Left =>
asset_handle(Asset::WorkspaceOrientationLeft),
WorkspaceThumbnailPlacement::Right =>
asset_handle(Asset::WorkspaceOrientationRight),
WorkspaceThumbnailPlacement::Top =>
asset_handle(Asset::WorkspaceOrientationTop),
WorkspaceThumbnailPlacement::Bottom =>
asset_handle(Asset::WorkspaceOrientationBottom),
}
),
cosmic::iced::widget::container(
Expand All @@ -360,7 +382,7 @@ fn workspace_orientation() -> Section<crate::pages::Message> {
.height(32.0),
)
.spacing(cosmic::theme::active().cosmic().space_m())
.align_items(Alignment::Center),
.align_x(Alignment::Center),
)
.add(settings::item(
&descriptions[thumbnail_placement_label],
Expand Down Expand Up @@ -408,49 +430,49 @@ fn workspace_orientation() -> Section<crate::pages::Message> {
.add(
cosmic::iced::widget::row!(
text(&descriptions[switch_workspace]),
cosmic::iced::widget::horizontal_space(2),
cosmic::iced::widget::horizontal_space().width(2),
text(&descriptions[switch_ws_label]).font(cosmic::font::bold()),
cosmic::iced::widget::horizontal_space(Length::Fill),
cosmic::iced::widget::horizontal_space().width(Length::Fill),
cosmic::iced::widget::container(cosmic::iced::widget::svg(
switch_ws
))
.width(115)
.height(92)
)
.width(Length::Fill)
.align_items(Alignment::Center)
.align_y(Alignment::Center)
.padding([0, 16]),
)
.add(
cosmic::iced::widget::row!(
text(&descriptions[open_workspaces]),
cosmic::iced::widget::horizontal_space(2),
cosmic::iced::widget::horizontal_space().width(2),
text(&descriptions[open_ws_label]).font(cosmic::font::bold()),
cosmic::iced::widget::horizontal_space(Length::Fill),
cosmic::iced::widget::horizontal_space().width(Length::Fill),
cosmic::iced::widget::container(cosmic::iced::widget::svg(open_ws))
.width(115)
.height(92)
)
.width(Length::Fill)
.align_items(Alignment::Center)
.align_y(Alignment::Center)
.padding([0, 16]),
)
.add(
cosmic::widget::list_column().add(
cosmic::iced::widget::row!(
text(&descriptions[open_applications]),
cosmic::iced::widget::horizontal_space(2),
cosmic::iced::widget::horizontal_space().width(2),
text(&descriptions[open_app_label])
.font(cosmic::font::bold()),
cosmic::iced::widget::horizontal_space(Length::Fill),
cosmic::iced::widget::horizontal_space().width(Length::Fill),
cosmic::iced::widget::container(cosmic::iced::widget::svg(
open_app
))
.width(115)
.height(92)
)
.width(Length::Fill)
.align_items(Alignment::Center)
.align_y(Alignment::Center)
.padding([0, 16]),
),
),
Expand Down
11 changes: 11 additions & 0 deletions resources/assets/workspace-orientation-bottom-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions resources/assets/workspace-orientation-bottom-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 0 additions & 12 deletions resources/assets/workspace-orientation-horizontal-light.svg

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions resources/assets/workspace-orientation-right-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0227032

Please sign in to comment.