S016: R1-15/17/18 one protection flyout, QR sized to content, flyout polish
The shield flyout holds the ad blocker, privacy mode and the VPN as separate groups; the VPN toolbar button only shows its state and opens it. Flyout action rows no longer wrap, which stretched the QR flyout to the window's bottom. Panel flyouts get the original's look: title with icon actions, accent group labels, two-line entries and designed empty states. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7aef048172
commit
7e6c70128c
6 changed files with 206 additions and 115 deletions
|
|
@ -306,6 +306,12 @@ Flyouts keep the last one drawn so it animates out; switching flyouts closes one
|
|||
`menu_item(ui, icon, label, trailing, selected)` (34 high, icon column, label cut with an ellipsis, shortcut or
|
||||
detail on the right), `divider`, `empty`, `one_line` (text cut to a width). egui popups (`Popup::menu`, submenus)
|
||||
use the same `surface` frame. Areas need `default_size` set or egui caps them at 600×400.
|
||||
Panel flyouts (R1-18, after the original's): `header(ui, title, |ui| ..)` (Title, actions as icon buttons on the
|
||||
right, no leading icon), `group(ui, title, |ui| ..)` (accent label over a group, its actions on the right),
|
||||
`entry(ui, icon, title, subtitle, time)` (48 high, icon in the menu rows' column, two lines, time on the right),
|
||||
`empty_state(ui, icon, title, body)`, `line` (label + control), `text`, `actions` (one right-aligned row of
|
||||
buttons). Text starts at `INSET` (12, the menu icons' edge). Never use a wrapping layout in a flyout: inside the
|
||||
full-window `default_size` it centres itself in the whole height and stretches the surface (R1-17).
|
||||
|
||||
## Feature checklist
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,6 @@ impl App {
|
|||
"main" => Some(Flyout::Main),
|
||||
"downloads" => Some(Flyout::Downloads),
|
||||
"shield" => Some(Flyout::Shield),
|
||||
"vpn" => Some(Flyout::Vpn),
|
||||
"media" => Some(Flyout::Media),
|
||||
"siteinfo" => Some(Flyout::SiteInfo),
|
||||
"profiles" => Some(Flyout::Profiles),
|
||||
|
|
|
|||
|
|
@ -453,12 +453,14 @@ fn right_button(ui: &mut Ui, f: &mut Frame, settings: &crate::store::settings::S
|
|||
VpnStatus::On(how) => (Some(p.success), format!("VPN on: {how}")),
|
||||
VpnStatus::Failed(why) => (Some(p.error), format!("VPN: {why}")),
|
||||
};
|
||||
let r = icon_toggle(ui, glyph("vpn"), &tip, open(f, &Flyout::Vpn));
|
||||
// The VPN lives in the shield flyout with the ad blocker and privacy mode (R1-15); this button only
|
||||
// shows its state.
|
||||
let r = icon_toggle(ui, glyph("vpn"), &tip, open(f, &Flyout::Shield));
|
||||
if let Some(color) = dot {
|
||||
badge(ui, r.rect, "", color, color);
|
||||
}
|
||||
if r.clicked() {
|
||||
f.ui.toggle(Flyout::Vpn, Some(r.rect));
|
||||
f.ui.toggle(Flyout::Shield, Some(r.rect));
|
||||
}
|
||||
},
|
||||
"media" => {
|
||||
|
|
|
|||
307
src/ui/menus.rs
307
src/ui/menus.rs
|
|
@ -236,18 +236,37 @@ pub fn empty(ui: &mut Ui, text: &str) {
|
|||
});
|
||||
}
|
||||
|
||||
/// The top of a panel-like flyout: an icon, the title, and controls on the right.
|
||||
fn header(ui: &mut Ui, glyph: Option<&str>, title: &str, right: impl FnOnce(&mut Ui)) {
|
||||
/// Where a flyout's text starts: in line with the icons of its menu rows.
|
||||
const INSET: f32 = theme::GAP_M;
|
||||
|
||||
/// The top of a panel-like flyout: the title, and its actions as icon buttons on the right (the first one added
|
||||
/// sits rightmost).
|
||||
fn header(ui: &mut Ui, title: &str, right: impl FnOnce(&mut Ui)) {
|
||||
let p = theme::palette(ui.ctx());
|
||||
ui.horizontal(|ui| {
|
||||
ui.set_min_height(theme::CONTROL);
|
||||
ui.add_space(theme::GAP_XS);
|
||||
if let Some(glyph) = glyph {
|
||||
let (rect, _) = ui.allocate_exact_size(Vec2::splat(theme::ICON + theme::GAP_XS), Sense::hover());
|
||||
icon(ui, rect.center(), glyph, theme::ICON, false, p.primary);
|
||||
}
|
||||
ui.label(RichText::new(title).font(theme::font(theme::TITLE, Weight::Medium)).color(p.on_surface));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), right);
|
||||
ui.add_space(INSET);
|
||||
let width = ui.available_width() - 2.0 * theme::CONTROL;
|
||||
ui.label(one_line(ui, title, theme::font(theme::TITLE, Weight::Medium), p.on_surface, width));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.spacing_mut().item_spacing.x = 0.0;
|
||||
right(ui);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// An accent label over a group of a flyout's rows, with that group's actions on its right.
|
||||
fn group(ui: &mut Ui, title: &str, right: impl FnOnce(&mut Ui)) {
|
||||
let p = theme::palette(ui.ctx());
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.horizontal(|ui| {
|
||||
ui.set_min_height(theme::CONTROL_SMALL);
|
||||
ui.add_space(INSET);
|
||||
ui.label(RichText::new(title).font(theme::font(theme::BODY, Weight::Medium)).color(p.primary));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.spacing_mut().item_spacing.x = 0.0;
|
||||
right(ui);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +274,7 @@ fn header(ui: &mut Ui, glyph: Option<&str>, title: &str, right: impl FnOnce(&mut
|
|||
fn text(ui: &mut Ui, text: impl Into<String>, caption: bool) {
|
||||
let p = theme::palette(ui.ctx());
|
||||
let (size, color) = if caption { (theme::SMALL, p.on_surface_variant) } else { (theme::BODY, p.on_surface) };
|
||||
egui::Frame::NONE.inner_margin(egui::Margin::symmetric(theme::GAP_XS as i8, 0)).show(ui, |ui| {
|
||||
egui::Frame::NONE.inner_margin(egui::Margin::symmetric(INSET as i8, 0)).show(ui, |ui| {
|
||||
ui.label(RichText::new(text).font(theme::font(size, Weight::Regular)).color(color));
|
||||
});
|
||||
}
|
||||
|
|
@ -265,22 +284,88 @@ fn line<R>(ui: &mut Ui, label: &str, control: impl FnOnce(&mut Ui) -> R) -> R {
|
|||
let p = theme::palette(ui.ctx());
|
||||
ui.horizontal(|ui| {
|
||||
ui.set_min_height(theme::CONTROL);
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.add_space(INSET);
|
||||
ui.label(RichText::new(label).font(theme::font(theme::BODY, Weight::Regular)).color(p.on_surface));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), control).inner
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.add_space(theme::GAP_XS);
|
||||
control(ui)
|
||||
})
|
||||
.inner
|
||||
})
|
||||
.inner
|
||||
}
|
||||
|
||||
/// A row of buttons at the bottom of a flyout, aligned right.
|
||||
/// A row of buttons at the bottom of a flyout, aligned right. One row: a wrapping layout here would centre itself
|
||||
/// in the whole height the flyout may take and stretch the surface to the bottom of the window (R1-17).
|
||||
fn actions(ui: &mut Ui, contents: impl FnOnce(&mut Ui)) {
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center).with_main_wrap(true), |ui| {
|
||||
ui.spacing_mut().item_spacing = vec2(theme::GAP_XS, theme::GAP_XS);
|
||||
contents(ui);
|
||||
ui.horizontal(|ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.spacing_mut().item_spacing.x = theme::GAP_XS;
|
||||
ui.add_space(theme::GAP_XS);
|
||||
contents(ui);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// What a flyout shows when it has nothing to list: a round icon, what will appear here and how.
|
||||
fn empty_state(ui: &mut Ui, glyph: &str, title: &str, body: &str) {
|
||||
let p = theme::palette(ui.ctx());
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.add_space(theme::GAP_L);
|
||||
let (rect, _) = ui.allocate_exact_size(Vec2::splat(theme::ICON_LARGE + theme::GAP_L), Sense::hover());
|
||||
ui.painter().circle_filled(rect.center(), rect.width() / 2.0, p.surface_container_highest);
|
||||
icon(ui, rect.center(), glyph, theme::ICON, false, p.on_surface_variant);
|
||||
ui.add_space(theme::GAP_S);
|
||||
ui.label(RichText::new(title).font(theme::font(theme::BODY, Weight::Medium)).color(p.on_surface));
|
||||
ui.scope(|ui| {
|
||||
ui.set_max_width(ui.available_width() - 2.0 * theme::GAP_L);
|
||||
ui.label(RichText::new(body).font(theme::font(theme::SMALL, Weight::Regular)).color(p.on_surface_variant));
|
||||
});
|
||||
ui.add_space(theme::GAP_L);
|
||||
});
|
||||
}
|
||||
|
||||
/// Height of an `entry`.
|
||||
const ENTRY: f32 = 48.0;
|
||||
|
||||
/// A list row in a flyout: an icon in the menu rows' icon column, a title over a quieter line, and a time or
|
||||
/// detail at the right end, each cut with an ellipsis. The whole row is the button.
|
||||
fn entry(ui: &mut Ui, glyph: &str, title: &str, subtitle: &str, trailing: &str) -> Response {
|
||||
let p = theme::palette(ui.ctx());
|
||||
let width = ui.available_width().max(160.0);
|
||||
let (rect, response) = ui.allocate_exact_size(vec2(width, ENTRY), Sense::click());
|
||||
if ui.is_rect_visible(rect) {
|
||||
let s = interaction(ui, &response);
|
||||
let radius = theme::radius(ui.ctx(), theme::S);
|
||||
if s.amount() > 0.0 {
|
||||
ui.painter().rect_filled(rect, theme::corner_radius(radius), s.layer(p.surface_container_high, p.on_surface));
|
||||
}
|
||||
let cy = rect.center().y;
|
||||
icon(ui, pos2(rect.left() + theme::GAP_M + 10.0, cy), glyph, theme::ICON, false, p.on_surface_variant);
|
||||
let left = rect.left() + theme::GAP_M + 20.0 + theme::GAP_M;
|
||||
let small = theme::font(theme::SMALL, Weight::Regular);
|
||||
let time = (!trailing.is_empty()).then(|| one_line(ui, trailing, small.clone(), p.on_surface_variant, width * 0.3));
|
||||
let right = rect.right() - theme::GAP_M - time.as_ref().map_or(0.0, |g| g.size().x + theme::GAP_M);
|
||||
let title = one_line(ui, title, theme::font(theme::BODY, Weight::Regular), p.on_surface, (right - left).max(8.0));
|
||||
let subtitle = (!subtitle.is_empty()).then(|| one_line(ui, subtitle, small, p.on_surface_variant, (right - left).max(8.0)));
|
||||
let height = title.size().y + subtitle.as_ref().map_or(0.0, |g| g.size().y);
|
||||
let top = cy - height / 2.0;
|
||||
let title_height = title.size().y;
|
||||
ui.painter().galley(pos2(left, top), title, p.on_surface);
|
||||
if let Some(g) = subtitle {
|
||||
ui.painter().galley(pos2(left, top + title_height), g, p.on_surface_variant);
|
||||
}
|
||||
if let Some(g) = time {
|
||||
ui.painter().galley(pos2(rect.right() - theme::GAP_M - g.size().x, cy - g.size().y / 2.0), g, p.on_surface_variant);
|
||||
}
|
||||
if s.focus {
|
||||
focus_ring(ui, rect.shrink(2.0), radius, &p);
|
||||
}
|
||||
}
|
||||
response
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
// The page's right-click menu
|
||||
|
||||
|
|
@ -404,7 +489,6 @@ fn flyout_id(flyout: &Flyout) -> Id {
|
|||
Flyout::Main => "main",
|
||||
Flyout::Downloads => "downloads",
|
||||
Flyout::Shield => "shield",
|
||||
Flyout::Vpn => "vpn",
|
||||
Flyout::Media => "media",
|
||||
Flyout::SiteInfo => "siteinfo",
|
||||
Flyout::Profiles => "profiles",
|
||||
|
|
@ -464,7 +548,6 @@ fn flyout_body(ui: &mut Ui, f: &mut Frame, flyout: &Flyout) {
|
|||
Flyout::Main => main_menu(ui, f),
|
||||
Flyout::Downloads => downloads(ui, f),
|
||||
Flyout::Shield => shield(ui, f),
|
||||
Flyout::Vpn => vpn(ui, f),
|
||||
Flyout::Media => media(ui, f),
|
||||
Flyout::SiteInfo => site_info(ui, f),
|
||||
Flyout::Profiles => profiles(ui, f),
|
||||
|
|
@ -572,8 +655,8 @@ fn main_menu(ui: &mut Ui, f: &mut Frame) {
|
|||
|
||||
fn downloads(ui: &mut Ui, f: &mut Frame) {
|
||||
ui.set_width(380.0);
|
||||
header(ui, Some(icons::DOWNLOAD), "Downloads", |ui| {
|
||||
if button(ui, ButtonKind::Text, None, "All downloads").clicked() {
|
||||
header(ui, "Downloads", |ui| {
|
||||
if icon_button(ui, icons::OPEN_IN_NEW, "All downloads").clicked() {
|
||||
f.send(Command::ShowPage(Page::Downloads));
|
||||
f.ui.flyout = None;
|
||||
}
|
||||
|
|
@ -598,17 +681,7 @@ fn downloads(ui: &mut Ui, f: &mut Frame) {
|
|||
drop(settings);
|
||||
let items: Vec<crate::store::downloads::Download> = f.shared.downloads.borrow().items.iter().take(8).cloned().collect();
|
||||
if items.is_empty() {
|
||||
let p = theme::palette(ui.ctx());
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.add_space(theme::GAP_L);
|
||||
let (rect, _) = ui.allocate_exact_size(Vec2::splat(theme::ICON_LARGE + theme::GAP_L), Sense::hover());
|
||||
ui.painter().circle_filled(rect.center(), rect.width() / 2.0, p.surface_container_highest);
|
||||
icon(ui, rect.center(), icons::DOWNLOAD, theme::ICON, false, p.on_surface_variant);
|
||||
ui.add_space(theme::GAP_S);
|
||||
ui.label(RichText::new("Nothing downloaded yet").font(theme::font(theme::BODY, Weight::Medium)).color(p.on_surface));
|
||||
ui.label(RichText::new("Files you download show up here").font(theme::font(theme::SMALL, Weight::Regular)).color(p.on_surface_variant));
|
||||
ui.add_space(theme::GAP_L);
|
||||
});
|
||||
empty_state(ui, icons::DOWNLOAD, "Nothing downloaded yet", "Files you download show up here");
|
||||
}
|
||||
for d in items {
|
||||
download_row(ui, f, &d);
|
||||
|
|
@ -707,17 +780,31 @@ pub fn download_row(ui: &mut Ui, f: &mut Frame, d: &crate::store::downloads::Dow
|
|||
});
|
||||
}
|
||||
|
||||
/// Protection for this window, in three groups: the ad blocker (global and for this site), privacy mode and the VPN.
|
||||
fn shield(ui: &mut Ui, f: &mut Frame) {
|
||||
ui.set_width(340.0);
|
||||
let max_height = (ui.ctx().content_rect().bottom() - ui.max_rect().top() - 3.0 * theme::GAP_L).max(200.0);
|
||||
egui::ScrollArea::vertical().max_height(max_height).show(ui, |ui| shield_body(ui, f));
|
||||
}
|
||||
|
||||
fn shield_body(ui: &mut Ui, f: &mut Frame) {
|
||||
ui.set_width(360.0);
|
||||
let p = theme::palette(ui.ctx());
|
||||
let (host, blocked, hidden) = f.tab().map(|t| (t.host(), t.blocked, t.hidden_elements)).unwrap_or_default();
|
||||
let incognito = f.incognito();
|
||||
let vpn_status = f.shared.vpn_status.borrow().clone();
|
||||
let mut settings_page = None;
|
||||
let mut settings = f.shared.settings.borrow_mut();
|
||||
header(ui, Some(icons::SHIELD), "Ad blocker", |ui| {
|
||||
switch(ui, &mut settings.adblock.enabled);
|
||||
header(ui, "Protection", |_| {});
|
||||
|
||||
group(ui, "Ad blocker", |ui| {
|
||||
if icon_button(ui, icons::TUNE, "Ad blocker settings").clicked() {
|
||||
settings_page = Some("adblock");
|
||||
}
|
||||
});
|
||||
if !host.is_empty() {
|
||||
line(ui, "Block ads and trackers", |ui| switch(ui, &mut settings.adblock.enabled));
|
||||
if !host.is_empty() && settings.adblock.enabled {
|
||||
let mut on_here = !settings.adblock_paused_on(&host);
|
||||
line(ui, &format!("On {host}"), |ui| {
|
||||
line(ui, &format!("On {}", util::ellipsize(&host, 30)), |ui| {
|
||||
if switch(ui, &mut on_here) {
|
||||
if on_here {
|
||||
settings.adblock.allow.retain(|h| !util::host_matches(&host, h));
|
||||
|
|
@ -728,10 +815,10 @@ fn shield(ui: &mut Ui, f: &mut Frame) {
|
|||
});
|
||||
text(ui, "Changes for this site apply when the page reloads", true);
|
||||
}
|
||||
ui.add_space(theme::GAP_S);
|
||||
ui.add_space(theme::GAP_XS);
|
||||
// The count for this page, large, then the rest.
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.add_space(INSET);
|
||||
ui.label(RichText::new(blocked.to_string()).font(theme::font(theme::HEADLINE * 1.5, Weight::Light)).color(p.primary));
|
||||
ui.vertical(|ui| {
|
||||
ui.add_space(theme::GAP_S);
|
||||
|
|
@ -743,50 +830,49 @@ fn shield(ui: &mut Ui, f: &mut Frame) {
|
|||
ui.label(RichText::new(more).font(theme::font(theme::SMALL, Weight::Regular)).color(p.on_surface_variant));
|
||||
});
|
||||
});
|
||||
drop(settings);
|
||||
let status = f.shared.adblock_status.borrow().clone();
|
||||
if !status.is_empty() {
|
||||
text(ui, status, true);
|
||||
}
|
||||
actions(ui, |ui| {
|
||||
if button(ui, ButtonKind::Text, None, "Settings").clicked() {
|
||||
f.send(Command::ShowPage(Page::Settings("adblock".into())));
|
||||
f.ui.flyout = None;
|
||||
if button(ui, ButtonKind::Tonal, Some(icons::SYNC), "Update lists").clicked() {
|
||||
f.send(Command::UpdateFilterLists);
|
||||
}
|
||||
if button(ui, ButtonKind::Text, None, "Reload page").clicked() {
|
||||
f.send(Command::Reload { hard: false });
|
||||
}
|
||||
if button(ui, ButtonKind::Tonal, Some(icons::SYNC), "Update lists").clicked() {
|
||||
f.send(Command::UpdateFilterLists);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn vpn(ui: &mut Ui, f: &mut Frame) {
|
||||
ui.set_width(340.0);
|
||||
let p = theme::palette(ui.ctx());
|
||||
let status = f.shared.vpn_status.borrow().clone();
|
||||
let mut settings = f.shared.settings.borrow_mut();
|
||||
header(ui, Some(icons::VPN_LOCK), "VPN", |ui| {
|
||||
switch(ui, &mut settings.vpn.enabled);
|
||||
});
|
||||
text(ui, "Covers Nacre only: pages, downloads and list updates. Other apps keep using your normal connection.", true);
|
||||
ui.add_space(theme::GAP_S);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(theme::GAP_XS);
|
||||
segmented(ui, &mut settings.vpn.provider, VpnProvider::ALL);
|
||||
});
|
||||
ui.add_space(theme::GAP_XS);
|
||||
divider(ui);
|
||||
|
||||
// Privacy mode: in an incognito window the switch is the incognito setting, as in the original.
|
||||
group(ui, "Privacy mode", |ui| {
|
||||
if icon_button(ui, icons::TUNE, "Privacy settings").clicked() {
|
||||
settings_page = Some("privacy");
|
||||
}
|
||||
});
|
||||
let on = if incognito { &mut settings.privacy.mode_incognito } else { &mut settings.privacy.mode };
|
||||
line(ui, "Hide this browser's fingerprint", |ui| switch(ui, on));
|
||||
text(ui, if incognito { "Incognito windows: canvas, WebGL, screen and hardware details, from the next page load" } else { "Canvas, WebGL, screen and hardware details, from the next page load" }, true);
|
||||
ui.add_space(theme::GAP_S);
|
||||
divider(ui);
|
||||
|
||||
group(ui, "VPN", |ui| {
|
||||
if icon_button(ui, icons::TUNE, "VPN settings").clicked() {
|
||||
settings_page = Some("privacy");
|
||||
}
|
||||
});
|
||||
line(ui, "Use the VPN", |ui| switch(ui, &mut settings.vpn.enabled));
|
||||
line(ui, "Through", |ui| segmented(ui, &mut settings.vpn.provider, VpnProvider::ALL));
|
||||
if settings.vpn.provider == VpnProvider::Custom {
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(theme::GAP_XS);
|
||||
text_field(ui, &mut settings.vpn.custom, "socks5://host:port or http://host:port", 316.0);
|
||||
ui.add_space(INSET);
|
||||
text_field(ui, &mut settings.vpn.custom, "socks5://host:port or http://host:port", 360.0 - 2.0 * INSET);
|
||||
});
|
||||
} else {
|
||||
text(ui, "Uses a Tor that is already running (system tor, Tor Browser) or starts the installed tor program.", true);
|
||||
}
|
||||
drop(settings);
|
||||
let (label, color) = match status {
|
||||
let (label, color) = match vpn_status {
|
||||
VpnStatus::Off => ("Off".to_owned(), p.outline),
|
||||
VpnStatus::Connecting(why) => (why, p.warning),
|
||||
VpnStatus::On(how) => (format!("Connected: {how}"), p.success),
|
||||
|
|
@ -794,12 +880,18 @@ fn vpn(ui: &mut Ui, f: &mut Frame) {
|
|||
};
|
||||
ui.add_space(theme::GAP_S);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.add_space(INSET);
|
||||
let (rect, _) = ui.allocate_exact_size(Vec2::splat(12.0), Sense::hover());
|
||||
ui.painter().circle_filled(rect.center(), 5.0, color);
|
||||
ui.label(RichText::new(label).font(theme::font(theme::BODY, Weight::Medium)).color(p.on_surface));
|
||||
ui.add(egui::Label::new(RichText::new(label).font(theme::font(theme::BODY, Weight::Medium)).color(p.on_surface)).wrap());
|
||||
});
|
||||
ui.add_space(theme::GAP_XS);
|
||||
text(ui, "Covers Nacre only: pages, downloads and list updates. Other apps keep your normal connection", true);
|
||||
ui.add_space(theme::GAP_XS);
|
||||
if let Some(section) = settings_page {
|
||||
f.send(Command::ShowPage(Page::Settings(section.into())));
|
||||
f.ui.flyout = None;
|
||||
}
|
||||
}
|
||||
|
||||
fn media(ui: &mut Ui, f: &mut Frame) {
|
||||
|
|
@ -1022,9 +1114,9 @@ fn site_info(ui: &mut Ui, f: &mut Frame) {
|
|||
let url = tab.url.clone();
|
||||
let secure = url.starts_with("https://");
|
||||
let file = url.starts_with("file:");
|
||||
header(ui, None, if file { "File on this computer" } else { &host }, |_| {});
|
||||
header(ui, if file { "File on this computer" } else { &host }, |_| {});
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.add_space(INSET);
|
||||
let (glyph, color, line) = if file {
|
||||
(icons::FOLDER, p.on_surface_variant, "This page is a file on your computer; nothing goes over the network")
|
||||
} else if secure {
|
||||
|
|
@ -1036,11 +1128,8 @@ fn site_info(ui: &mut Ui, f: &mut Frame) {
|
|||
icon(ui, rect.center(), glyph, 18.0, false, color);
|
||||
ui.add(egui::Label::new(RichText::new(line).font(theme::font(theme::BODY, Weight::Regular)).color(if secure || file { p.on_surface } else { p.error })).wrap());
|
||||
});
|
||||
ui.add_space(theme::GAP_M);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.label(RichText::new("Permissions").font(theme::font(theme::BODY, Weight::Medium)).color(p.primary));
|
||||
});
|
||||
ui.add_space(theme::GAP_S);
|
||||
group(ui, "Permissions", |_| {});
|
||||
let decisions = f.shared.permissions.borrow().for_host(&host);
|
||||
if decisions.is_empty() {
|
||||
text(ui, "This site hasn't asked for anything", true);
|
||||
|
|
@ -1075,13 +1164,13 @@ fn profiles(ui: &mut Ui, f: &mut Frame) {
|
|||
ui.set_width(280.0);
|
||||
let list = f.shared.paths.profile_list();
|
||||
let current = f.shared.paths.profile.clone();
|
||||
header(ui, Some(if f.incognito() { icons::DOMINO_MASK } else { icons::ACCOUNT_CIRCLE }), ¤t, |_| {});
|
||||
header(ui, ¤t, |_| {});
|
||||
if f.incognito() {
|
||||
text(ui, "Incognito: nothing from this window is saved", true);
|
||||
}
|
||||
let others: Vec<String> = list.profiles.into_iter().filter(|n| *n != current).collect();
|
||||
if !others.is_empty() {
|
||||
divider(ui);
|
||||
group(ui, "Other profiles", |_| {});
|
||||
}
|
||||
for name in others {
|
||||
if menu_item(ui, Some(icons::PERSON), &format!("Open {name}"), "", false).clicked() {
|
||||
|
|
@ -1102,12 +1191,12 @@ fn edit_bookmark(ui: &mut Ui, f: &mut Frame, url: &str) {
|
|||
f.ui.flyout = None;
|
||||
return;
|
||||
};
|
||||
header(ui, Some(icons::STAR), "Bookmark", |_| {});
|
||||
header(ui, "Bookmark", |_| {});
|
||||
let id = Id::new(("bookmark-title", node.id));
|
||||
let mut title = ui.data_mut(|d| d.get_temp::<String>(id)).unwrap_or_else(|| node.title.clone());
|
||||
let field = 340.0 - 2.0 * theme::GAP_XS;
|
||||
let field = 340.0 - 2.0 * INSET;
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.add_space(INSET);
|
||||
text_field(ui, &mut title, "Name", field);
|
||||
});
|
||||
ui.data_mut(|d| d.insert_temp(id, title.clone()));
|
||||
|
|
@ -1117,7 +1206,7 @@ fn edit_bookmark(ui: &mut Ui, f: &mut Frame, url: &str) {
|
|||
let mut parent = current_parent;
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.add_space(INSET);
|
||||
egui::ComboBox::from_id_salt("bookmark-folder").width(field).selected_text(format!("{} {}", icons::FOLDER, folders.iter().find(|(id, _)| *id == parent).map(|(_, n)| n.clone()).unwrap_or_default())).show_ui(ui, |ui| {
|
||||
for (id, name) in &folders {
|
||||
ui.selectable_value(&mut parent, *id, name);
|
||||
|
|
@ -1168,7 +1257,7 @@ pub fn parent_of(b: &crate::store::bookmarks::Bookmarks, id: u64) -> u64 {
|
|||
}
|
||||
|
||||
fn qr(ui: &mut Ui, f: &mut Frame, url: &str) {
|
||||
ui.set_width(280.0);
|
||||
ui.set_width(300.0);
|
||||
let p = theme::palette(ui.ctx());
|
||||
let key = format!("qr:{url}");
|
||||
let texture = match &f.ui.qr_texture {
|
||||
|
|
@ -1179,7 +1268,12 @@ fn qr(ui: &mut Ui, f: &mut Frame, url: &str) {
|
|||
t
|
||||
}),
|
||||
};
|
||||
header(ui, Some(icons::QR_CODE_2), "Scan to open this page", |_| {});
|
||||
let mut copy = false;
|
||||
let mut save = false;
|
||||
header(ui, "QR code", |ui| {
|
||||
save = icon_button(ui, icons::DOWNLOAD, "Save as PNG").clicked();
|
||||
copy = icon_button(ui, icons::CONTENT_COPY, "Copy address").clicked();
|
||||
});
|
||||
ui.vertical_centered(|ui| {
|
||||
match texture {
|
||||
Some(texture) => {
|
||||
|
|
@ -1192,23 +1286,21 @@ fn qr(ui: &mut Ui, f: &mut Frame, url: &str) {
|
|||
ui.label(RichText::new("This address is too long for a QR code").font(theme::font(theme::BODY, Weight::Regular)).color(p.on_surface));
|
||||
},
|
||||
}
|
||||
ui.add_space(theme::GAP_S);
|
||||
ui.label(RichText::new("Scan it with a phone to open this page").font(theme::font(theme::BODY, Weight::Regular)).color(p.on_surface));
|
||||
ui.label(one_line(ui, url, theme::font(theme::SMALL, Weight::Regular), p.on_surface_variant, ui.available_width() - 2.0 * INSET));
|
||||
ui.add_space(theme::GAP_XS);
|
||||
ui.label(RichText::new(util::ellipsize(url, 44)).font(theme::font(theme::SMALL, Weight::Regular)).color(p.on_surface_variant));
|
||||
});
|
||||
actions(ui, |ui| {
|
||||
if button(ui, ButtonKind::Text, Some(icons::DOWNLOAD), "Save as PNG").clicked()
|
||||
&& let Some(png) = qr_png(url)
|
||||
{
|
||||
std::thread::spawn(move || {
|
||||
if let Some(path) = rfd::FileDialog::new().set_file_name("qr-code.png").save_file() {
|
||||
let _ = std::fs::write(path, png);
|
||||
}
|
||||
});
|
||||
}
|
||||
if button(ui, ButtonKind::Tonal, Some(icons::CONTENT_COPY), "Copy address").clicked() {
|
||||
ui.ctx().copy_text(url.to_owned());
|
||||
}
|
||||
});
|
||||
if save && let Some(png) = qr_png(url) {
|
||||
std::thread::spawn(move || {
|
||||
if let Some(path) = rfd::FileDialog::new().set_file_name("qr-code.png").save_file() {
|
||||
let _ = std::fs::write(path, png);
|
||||
}
|
||||
});
|
||||
}
|
||||
if copy {
|
||||
ui.ctx().copy_text(url.to_owned());
|
||||
}
|
||||
}
|
||||
|
||||
fn qr_modules(url: &str) -> Option<(usize, Vec<bool>)> {
|
||||
|
|
@ -1326,7 +1418,7 @@ fn back_history(ui: &mut Ui, f: &mut Frame) {
|
|||
}
|
||||
for (i, url) in entries {
|
||||
let title = f.shared.history.borrow().search(&url, 1).first().map(|v| v.title.clone()).filter(|t| !t.is_empty()).unwrap_or_else(|| url.clone());
|
||||
if menu_item(ui, Some(icons::PUBLIC), &title, &util::host_of_str(&url), false).clicked() {
|
||||
if entry(ui, icons::PUBLIC, &title, &util::host_of_str(&url), "").on_hover_text(&url).clicked() {
|
||||
f.send(Command::HistoryJump(i));
|
||||
f.ui.flyout = None;
|
||||
}
|
||||
|
|
@ -1341,20 +1433,19 @@ fn back_history(ui: &mut Ui, f: &mut Frame) {
|
|||
fn apps(ui: &mut Ui, f: &mut Frame) {
|
||||
ui.set_width(300.0);
|
||||
let apps = f.shared.apps.borrow().items.clone();
|
||||
header(ui, Some(icons::APPS), "Apps", |_| {});
|
||||
header(ui, "Apps", |ui| {
|
||||
if icon_button(ui, icons::OPEN_IN_NEW, "Manage apps and scripts").clicked() {
|
||||
f.send(Command::ShowPage(Page::Apps));
|
||||
f.ui.flyout = None;
|
||||
}
|
||||
});
|
||||
if apps.is_empty() {
|
||||
text(ui, "No apps yet. Open a site, then choose Install this site as an app in the menu.", true);
|
||||
ui.add_space(theme::GAP_XS);
|
||||
empty_state(ui, icons::APPS, "No apps yet", "Open a site, then choose Install this site as an app in the menu");
|
||||
}
|
||||
for app in apps {
|
||||
if menu_item(ui, Some(icons::WEB), &app.name, &util::host_of_str(&app.scope), false).on_hover_text(&app.scope).clicked() {
|
||||
if entry(ui, icons::WEB, &app.name, &util::host_of_str(&app.scope), "").on_hover_text(&app.scope).clicked() {
|
||||
f.send(Command::OpenApp(app.id.clone()));
|
||||
f.ui.flyout = None;
|
||||
}
|
||||
}
|
||||
divider(ui);
|
||||
if menu_item(ui, Some(icons::TUNE), "Manage apps and scripts", "", false).clicked() {
|
||||
f.send(Command::ShowPage(Page::Apps));
|
||||
f.ui.flyout = None;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ pub enum Flyout {
|
|||
Main,
|
||||
Downloads,
|
||||
Shield,
|
||||
Vpn,
|
||||
Media,
|
||||
SiteInfo,
|
||||
Profiles,
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@ shot downloads-dark
|
|||
flyout shield
|
||||
wait 1
|
||||
shot shield-dark
|
||||
flyout vpn
|
||||
wait 1
|
||||
shot vpn-dark
|
||||
flyout media
|
||||
wait 1
|
||||
shot media-dark
|
||||
|
|
@ -109,9 +106,6 @@ shot downloads-light
|
|||
flyout shield
|
||||
wait 1
|
||||
shot shield-light
|
||||
flyout vpn
|
||||
wait 1
|
||||
shot vpn-light
|
||||
flyout siteinfo
|
||||
wait 1
|
||||
shot siteinfo-light
|
||||
|
|
|
|||
Loading…
Reference in a new issue