fix: better popup size
This commit is contained in:
parent
fd074db283
commit
ae89afcc5f
2 changed files with 56 additions and 40 deletions
|
|
@ -4,8 +4,8 @@ mod window;
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
iced::{sctk_settings::InitialSurface, Application},
|
iced::{sctk_settings::InitialSurface, Application},
|
||||||
iced_native::window::Settings,
|
|
||||||
iced_native::command::platform_specific::wayland::window::SctkWindowSettings,
|
iced_native::command::platform_specific::wayland::window::SctkWindowSettings,
|
||||||
|
iced_native::window::Settings,
|
||||||
settings,
|
settings,
|
||||||
};
|
};
|
||||||
use cosmic_panel_config::PanelSize;
|
use cosmic_panel_config::PanelSize;
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,18 @@ use iced_sctk::alignment::Horizontal;
|
||||||
use iced_sctk::commands::popup::{destroy_popup, get_popup};
|
use iced_sctk::commands::popup::{destroy_popup, get_popup};
|
||||||
use zbus::Connection;
|
use zbus::Connection;
|
||||||
|
|
||||||
#[derive(Default, Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
enum State {
|
enum State {
|
||||||
#[default]
|
SelectGraphicsMode(bool),
|
||||||
SelectGraphicsMode,
|
|
||||||
SettingGraphicsMode(Graphics),
|
SettingGraphicsMode(Graphics),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for State {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::SelectGraphicsMode(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
popup: Option<window::Id>,
|
popup: Option<window::Id>,
|
||||||
|
|
@ -96,7 +101,7 @@ impl Application for Window {
|
||||||
Message::AppliedGraphicsMode(g) => {
|
Message::AppliedGraphicsMode(g) => {
|
||||||
if let Some(g) = g {
|
if let Some(g) = g {
|
||||||
self.graphics_mode.replace(g);
|
self.graphics_mode.replace(g);
|
||||||
self.state = State::SelectGraphicsMode;
|
self.state = State::SelectGraphicsMode(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::TogglePopup => {
|
Message::TogglePopup => {
|
||||||
|
|
@ -113,7 +118,9 @@ impl Application for Window {
|
||||||
|cur_graphics| Message::CurrentGraphics(cur_graphics.ok()),
|
|cur_graphics| Message::CurrentGraphics(cur_graphics.ok()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let popup_settings = get_popup_settings(window::Id::new(0), new_id, None, None);
|
let mut popup_settings =
|
||||||
|
get_popup_settings(window::Id::new(0), new_id, None, None);
|
||||||
|
popup_settings.positioner.size = (200, 240);
|
||||||
commands.push(get_popup(popup_settings));
|
commands.push(get_popup(popup_settings));
|
||||||
return Command::batch(commands);
|
return Command::batch(commands);
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +141,6 @@ impl Application for Window {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Message::CurrentGraphics(g) => {
|
Message::CurrentGraphics(g) => {
|
||||||
dbg!(g);
|
|
||||||
if let Some(g) = g {
|
if let Some(g) = g {
|
||||||
self.graphics_mode.replace(g);
|
self.graphics_mode.replace(g);
|
||||||
}
|
}
|
||||||
|
|
@ -145,39 +151,49 @@ impl Application for Window {
|
||||||
|
|
||||||
fn view_popup(&self, _: window::Id) -> Element<Message> {
|
fn view_popup(&self, _: window::Id) -> Element<Message> {
|
||||||
let content = match self.state {
|
let content = match self.state {
|
||||||
State::SelectGraphicsMode => column(vec![
|
State::SelectGraphicsMode(pending_restart) => {
|
||||||
radio(
|
let mut content_list = vec![
|
||||||
"Integrated Graphics",
|
radio(
|
||||||
Graphics::Integrated,
|
"Integrated Graphics",
|
||||||
self.graphics_mode,
|
Graphics::Integrated,
|
||||||
|g| Message::SelectGraphicsMode(g),
|
self.graphics_mode,
|
||||||
)
|
|g| Message::SelectGraphicsMode(g),
|
||||||
.into(),
|
)
|
||||||
radio(
|
.into(),
|
||||||
"Nvidia Graphics",
|
radio(
|
||||||
Graphics::Nvidia,
|
"Nvidia Graphics",
|
||||||
self.graphics_mode,
|
Graphics::Nvidia,
|
||||||
|g| Message::SelectGraphicsMode(g),
|
self.graphics_mode,
|
||||||
)
|
|g| Message::SelectGraphicsMode(g),
|
||||||
.into(),
|
)
|
||||||
radio(
|
.into(),
|
||||||
"Hybrid Graphics",
|
radio(
|
||||||
Graphics::Hybrid,
|
"Hybrid Graphics",
|
||||||
self.graphics_mode,
|
Graphics::Hybrid,
|
||||||
|g| Message::SelectGraphicsMode(g),
|
self.graphics_mode,
|
||||||
)
|
|g| Message::SelectGraphicsMode(g),
|
||||||
.into(),
|
)
|
||||||
radio(
|
.into(),
|
||||||
"Compute Graphics",
|
radio(
|
||||||
Graphics::Compute,
|
"Compute Graphics",
|
||||||
self.graphics_mode,
|
Graphics::Compute,
|
||||||
|g| Message::SelectGraphicsMode(g),
|
self.graphics_mode,
|
||||||
)
|
|g| Message::SelectGraphicsMode(g),
|
||||||
.into(),
|
)
|
||||||
])
|
.into(),
|
||||||
.padding([8, 0])
|
];
|
||||||
.spacing(8)
|
if pending_restart {
|
||||||
.into(),
|
content_list.insert(
|
||||||
|
0,
|
||||||
|
text("Restart to apply changes")
|
||||||
|
.width(Length::Fill)
|
||||||
|
.horizontal_alignment(Horizontal::Center)
|
||||||
|
.size(16)
|
||||||
|
.into(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
column(content_list).padding([8, 0]).spacing(8).into()
|
||||||
|
}
|
||||||
State::SettingGraphicsMode(graphics) => {
|
State::SettingGraphicsMode(graphics) => {
|
||||||
let graphics_str = match graphics {
|
let graphics_str = match graphics {
|
||||||
Graphics::Integrated => "integrated",
|
Graphics::Integrated => "integrated",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue