USe libcosmic for replace dialog
This commit is contained in:
parent
5778d64e8c
commit
e9da2bfb90
4 changed files with 51 additions and 71 deletions
48
Cargo.lock
generated
48
Cargo.lock
generated
|
|
@ -1121,7 +1121,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"atomicwrites",
|
||||
"cosmic-config-derive",
|
||||
|
|
@ -1138,7 +1138,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config-derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
|
|
@ -1198,7 +1198,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"almost",
|
||||
"cosmic-config",
|
||||
|
|
@ -1678,9 +1678,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "error-code"
|
||||
version = "3.1.0"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26a147e1a6641a55d994b3e4e9fa4d9b180c8d652c09b363af8c9bf1b8e04139"
|
||||
checksum = "a0474425d51df81997e2f90a21591180b38eccf27292d755f3e30750225c175b"
|
||||
|
||||
[[package]]
|
||||
name = "etagere"
|
||||
|
|
@ -2580,7 +2580,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"iced_accessibility",
|
||||
"iced_core",
|
||||
|
|
@ -2595,7 +2595,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_accessibility"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"accesskit_winit",
|
||||
|
|
@ -2604,7 +2604,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_core"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"log",
|
||||
|
|
@ -2621,7 +2621,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_futures"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"iced_core",
|
||||
|
|
@ -2634,7 +2634,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_graphics"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bytemuck",
|
||||
|
|
@ -2658,7 +2658,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_renderer"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"iced_graphics",
|
||||
"iced_tiny_skia",
|
||||
|
|
@ -2670,7 +2670,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_runtime"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"iced_core",
|
||||
"iced_futures",
|
||||
|
|
@ -2680,7 +2680,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_style"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"iced_core",
|
||||
"once_cell",
|
||||
|
|
@ -2690,7 +2690,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_tiny_skia"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cosmic-text",
|
||||
|
|
@ -2707,7 +2707,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_wgpu"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bytemuck",
|
||||
|
|
@ -2726,7 +2726,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_widget"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"iced_renderer",
|
||||
"iced_runtime",
|
||||
|
|
@ -2740,7 +2740,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_winit"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"iced_graphics",
|
||||
"iced_runtime",
|
||||
|
|
@ -3059,7 +3059,7 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
|||
[[package]]
|
||||
name = "libcosmic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#a0340aac268bf61529025c02bff10fb4c21dc6fc"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#7abfef4eed01af0eda1a0bd8775e49e31a789a57"
|
||||
dependencies = [
|
||||
"apply",
|
||||
"ashpd",
|
||||
|
|
@ -4283,9 +4283,9 @@ checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab"
|
|||
|
||||
[[package]]
|
||||
name = "rangemap"
|
||||
version = "1.5.0"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "795915a3930a5d6bafd9053d37602fea3e61be2e5d4d788983a8ba9654c1c6f2"
|
||||
checksum = "f60fcc7d6849342eff22c4350c8b9a989ee8ceabc4b481253e8946b9fe83d684"
|
||||
|
||||
[[package]]
|
||||
name = "raw-window-handle"
|
||||
|
|
@ -4346,9 +4346,9 @@ checksum = "3b42e27ef78c35d3998403c1d26f3efd9e135d3e5121b0a4845cc5cc27547f4f"
|
|||
|
||||
[[package]]
|
||||
name = "read-fonts"
|
||||
version = "0.15.5"
|
||||
version = "0.15.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c044ab88c43e2eae05b34a17fc13598736679fdb03d71b49fcfe114443ec8a86"
|
||||
checksum = "17ea23eedb4d938031b6d4343222444608727a6aa68ec355e13588d9947ffe92"
|
||||
dependencies = [
|
||||
"font-types",
|
||||
]
|
||||
|
|
@ -5045,9 +5045,9 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f"
|
|||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.10.0"
|
||||
version = "3.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67"
|
||||
checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"fastrand 2.0.1",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ open-file = Open file
|
|||
open-folder = Open folder
|
||||
open-multiple-files = Open multiple files
|
||||
open-multiple-folders = Open multiple folders
|
||||
replace = Replace file
|
||||
replace = Replace
|
||||
replace-title = {$filename} already exists in this location.
|
||||
replace-warning = Do you want to replace it with the one you are saving? Replacing it will overwrite its content.
|
||||
save = Save
|
||||
save-file = Save file
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use cosmic::{
|
|||
subscription::{self, Subscription},
|
||||
window, Event, Length, Size,
|
||||
},
|
||||
style,
|
||||
widget::{self, segmented_button},
|
||||
Application, ApplicationExt, Element,
|
||||
};
|
||||
|
|
@ -365,6 +366,22 @@ impl Application for App {
|
|||
self.flags.window_id
|
||||
}
|
||||
|
||||
fn dialog(&self) -> Option<Element<Message>> {
|
||||
if self.replace_dialog {
|
||||
if let DialogKind::SaveFile { filename } = &self.flags.kind {
|
||||
return Some(
|
||||
widget::dialog(fl!("replace-title", filename = filename.as_str()))
|
||||
.icon(widget::icon::from_name("dialog-question").size(64))
|
||||
.body(fl!("replace-warning"))
|
||||
.primary_action(fl!("replace"), Message::Save(true))
|
||||
.secondary_action(fl!("cancel"), Message::Cancel)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
// The default nav_bar widget needs to have its width reduced for cosmic-files
|
||||
fn nav_bar(&self) -> Option<Element<message::Message<Message>>> {
|
||||
if !self.core().nav_bar_active() {
|
||||
|
|
@ -612,9 +629,9 @@ impl Application for App {
|
|||
.on_press(Message::Cancel)
|
||||
.into(),
|
||||
if self.flags.kind.save() {
|
||||
widget::button::standard(fl!("save")).on_press(Message::Save(false))
|
||||
widget::button::suggested(fl!("save")).on_press(Message::Save(false))
|
||||
} else {
|
||||
widget::button::standard(fl!("open")).on_press(Message::Open)
|
||||
widget::button::suggested(fl!("open")).on_press(Message::Open)
|
||||
}
|
||||
.into(),
|
||||
])
|
||||
|
|
@ -622,41 +639,7 @@ impl Application for App {
|
|||
.spacing(space_xxs),
|
||||
);
|
||||
|
||||
//TODO: what is the best empty widget?
|
||||
let mut overlay: Element<_> = widget::horizontal_space(Length::Shrink).into();
|
||||
let mut show_popup = false;
|
||||
if self.replace_dialog {
|
||||
if let DialogKind::SaveFile { filename } = &self.flags.kind {
|
||||
overlay = widget::cosmic_container::container(
|
||||
widget::column::with_children(vec![
|
||||
widget::text::title3(fl!("replace")).into(),
|
||||
//TODO: translate
|
||||
widget::text(format!("Do you want to replace \"{}\"?", filename)).into(),
|
||||
widget::row::with_children(vec![
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::button::standard(fl!("cancel"))
|
||||
.on_press(Message::Cancel)
|
||||
.into(),
|
||||
widget::button::destructive(fl!("replace"))
|
||||
.on_press(Message::Save(true))
|
||||
.into(),
|
||||
])
|
||||
.spacing(space_xxs)
|
||||
.into(),
|
||||
])
|
||||
.spacing(space_s),
|
||||
)
|
||||
.layer(cosmic_theme::Layer::Primary)
|
||||
.padding(space_m)
|
||||
.width(Length::Fixed(480.0))
|
||||
.into();
|
||||
show_popup = true;
|
||||
}
|
||||
}
|
||||
|
||||
let content: Element<_> = widget::popover(tab_column, overlay)
|
||||
.show_popup(show_popup)
|
||||
.into();
|
||||
let content: Element<_> = tab_column.into();
|
||||
|
||||
// Uncomment to debug layout:
|
||||
//content.explain(cosmic::iced::Color::WHITE)
|
||||
|
|
|
|||
13
src/tab.rs
13
src/tab.rs
|
|
@ -1135,15 +1135,10 @@ impl Tab {
|
|||
mouse_area =
|
||||
mouse_area.on_right_press(move |point_opt| Message::ContextMenu(point_opt));
|
||||
}
|
||||
let mut popover = widget::popover(mouse_area, menu::context_menu(&self));
|
||||
match self.context_menu {
|
||||
Some(point) => {
|
||||
let rounded = Point::new(point.x.round(), point.y.round());
|
||||
popover = popover.position(rounded);
|
||||
}
|
||||
None => {
|
||||
popover = popover.show_popup(false);
|
||||
}
|
||||
let mut popover = widget::popover(mouse_area);
|
||||
if let Some(point) = self.context_menu {
|
||||
let rounded = Point::new(point.x.round(), point.y.round());
|
||||
popover = popover.popup(menu::context_menu(&self)).position(rounded);
|
||||
}
|
||||
widget::container(widget::column::with_children(vec![
|
||||
location_view,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue