Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/cordiale-ui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8204,7 +8204,7 @@ fn link_refused(ui: &slint::Weak<AppWindow>, refusal: cordiale_core::media::Link
ui.set_media_error(reason.into());
ui.set_media_kind("failed".into());
ui.set_media_zoom(false);
ui.set_screen("media".into());
ui.set_media_open(true);
});
}

Expand Down Expand Up @@ -8237,7 +8237,7 @@ fn open_link(state: &WorkerState, ui: &slint::Weak<AppWindow>, href: String) {
ui.set_media_title(title.into());
ui.set_media_kind("loading".into());
ui.set_media_zoom(false);
ui.set_screen("media".into());
ui.set_media_open(true);
});
let ui = ui.clone();
tokio::spawn(async move {
Expand Down
44 changes: 41 additions & 3 deletions crates/cordiale-ui/ui/appwindow.slint
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,8 @@ export component AppWindow inherits Window {
chat-resume = false;
}
} else {
chat-resume = screen == "media" || screen == "settings" || screen == "links" || screen == "archive" || screen == "reply" || screen == "umodes" || screen == "radio" || screen == "debug";
media-open = false;
chat-resume = screen == "settings" || screen == "links" || screen == "archive" || screen == "reply" || screen == "umodes" || screen == "radio" || screen == "debug";
}
}
// Set once by Rust before the window is shown: where the splash
Expand Down Expand Up @@ -1579,6 +1580,8 @@ export component AppWindow inherits Window {
in property <string> media-text: "";
in property <bool> media-truncated: false;
in-out property <bool> media-zoom: false;
// The viewer is a popup over the connected screen, not a screen of its own.
in-out property <bool> media-open: false;
// The integrated radio. `radio-status` is "", "connecting", "playing",
// "failed" or "ended"; the custom stations live in Settings > Radio.
in property <[RadioRow]> radio-stations: [];
Expand Down Expand Up @@ -7274,7 +7277,39 @@ export component AppWindow inherits Window {
}
}

if screen == "media" : VerticalBox {
// The media viewer: a popup over the chat, which stays where it is
// behind it. Escape or Close dismisses it.
if media-open : Rectangle {
width: parent.width;
height: parent.height;
background: #00000099;

TouchArea {
width: parent.width;
height: parent.height;
}

Rectangle {
width: min(900px, parent.width - 32px);
height: parent.height - 32px;
x: (parent.width - self.width) / 2;
y: 16px;
border-width: 1px;
border-radius: 8px;
border-color: #8080806a;
background: theme == "dark" ? #242424 : white;

FocusScope {
init => { self.focus(); }
key-pressed(event) => {
if event.text == Key.Escape {
media-open = false;
return accept;
}
return reject;
}

VerticalBox {
padding: 16px;
spacing: 8px;

Expand All @@ -7299,7 +7334,7 @@ export component AppWindow inherits Window {
}
CompactButton {
text: "✕ " + @tr("Close");
clicked => { screen = "connected"; }
clicked => { media-open = false; }
}
}

Expand Down Expand Up @@ -7360,6 +7395,9 @@ export component AppWindow inherits Window {
}
}
}
}
}
}

if screen == "archive" : VerticalBox {
padding: 16px;
Expand Down
Loading