misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux
Rust bittorrent-clientdebriddownload-acceleratordownload-managerdownloadmanagereguifile-downloadergallery-dlidmidm-alternativeinternet-download-managerm3u8-downloadermagnetplaylist-downloaderreal-debridrusttorrent-clientvideo-downloaderyoutube-downloaderyt-dlp
Fix “Hide tab” in the download window and add Show hidden tabs (#326) (#445)
Anirudh1e4ae5881bdd
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 15bc2eee..0962379e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -34,6 +34,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see- A download refused by a site's bot check (Cloudflare's challenge) says so and how to get the file, instead of "the server answered 403 Forbidden" ([#376](https://github.com/anefzaoui/misterdownloadmanager/issues/376)).- **Open folder** works on a torrent that is still downloading ([#354](https://github.com/anefzaoui/misterdownloadmanager/issues/354)).- **Alt** and **F10** open the menu bar while a button or the list has the keyboard focus, not only when nothing does ([#328](https://github.com/anefzaoui/misterdownloadmanager/issues/328)).+- **Hide tab** in a download's window takes the Speed Limiter or Options on completion tab off its tab row, instead of only going back to Download status. Right-click the tab row and choose **Show hidden tabs** to bring them back ([#326](https://github.com/anefzaoui/misterdownloadmanager/issues/326)).- Windows: no more crash on a computer where Direct3D can't start, when a window opened during the switch to OpenGL ([#337](https://github.com/anefzaoui/misterdownloadmanager/issues/337)).- Windows: no more crash when a screen is unplugged, turned off or rearranged while MDM runs ([#335](https://github.com/anefzaoui/misterdownloadmanager/issues/335)).### Addeddiff --git a/ROADMAP.md b/ROADMAP.mdindex 23fd08b2..3c26c2eb 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -525,6 +525,8 @@ These ship in a later version, when they're ready.[#345](https://github.com/anefzaoui/misterdownloadmanager/issues/345)): fix in review- 🔄 A page that starts a download by script being saved instead of the file([#374](https://github.com/anefzaoui/misterdownloadmanager/issues/374)): fix in review+- 🔄 "Hide tab" in a download's window only going back to Download status, the tab still+ there ([#326](https://github.com/anefzaoui/misterdownloadmanager/issues/326)): fix in review- 🔍 A site's bot check refusing MDM's request (testfile.org, a Cloudflare challenge): the\n message now says so ([#376](https://github.com/anefzaoui/misterdownloadmanager/issues/376)); a way to hand the download back to the browser is still to decide- 🔄 A download starting again by itself after Stop, when it is in a running queue\n ([#341](https://github.com/anefzaoui/misterdownloadmanager/issues/341)): fix in review- 🔄 A crash when removing the last feed in the RSS feeds windowdiff --git a/crates/app/src/progress.rs b/crates/app/src/progress.rsindex 4626e8c9..b5151c6b 100644--- a/crates/app/src/progress.rs+++ b/crates/app/src/progress.rs@@ -75,7 +75,7 @@ fn seg_rows() -> impl Iterator<Item = (Color32, Color32, Color32)> {(0..13).map(|i| (s.missing[i], s.done[i], s.start[i]))}-#[derive(Clone, Copy, PartialEq, Eq)]+#[derive(Clone, Copy, Debug, PartialEq, Eq)]enum Tab {Status,Limiter,@@ -85,7 +85,7 @@ enum Tab {impl Progress {/// Open on a tab by its English name in lower case: a top tab ("status", "limit", "done") or/// a torrent's details tab ("peers"; /show progress:peers, for the docs' screenshots and the- /// fit audit); any other name leaves it as it is.+ /// fit audit); any other name leaves it as it is. A top tab hidden with "Hide tab" comes back.pub fn show_tab(&mut self, name: &str) {let top = match name {"status" => Some(Tab::Status),@@ -94,6 +94,7 @@ impl Progress {_ => None,};if let Some(t) = top {+ self.hidden_tabs.retain(|h| *h != t);self.tab = t;return;}@@ -127,6 +128,8 @@ pub struct Progress {pub id: u64,details: bool,tab: Tab,+ /// Tabs taken off the strip with their "Hide tab" button (#326), for this window.+ hidden_tabs: Vec<Tab>,ttab: TTab,limiter: bool,/// KBytes/sec typed on the Speed Limiter tab.@@ -195,6 +198,7 @@ impl Progress {id,details: true,tab: Tab::Status,+ hidden_tabs: Vec::new(),ttab: TTab::Files,limiter: false,limit_kb: "10".into(),@@ -397,18 +401,21 @@ impl Progress {) -> Action {let p = ui.painter().clone();let hide = self.tabs(ui, o);- match self.tab {- Tab::Status => status_page(ui, o, item, snap, frac),- Tab::Limiter => {- if self.limiter_page(ui, o, item) {- self.tab = Tab::Status;- }- }- Tab::Completion => {- if self.completion_page(ui, o, item) {- self.tab = Tab::Status;- }+ let hide_tab = match self.tab {+ Tab::Status => {+ status_page(ui, o, item, snap, frac);+ false}+ Tab::Limiter => self.limiter_page(ui, o, item),+ Tab::Completion => self.completion_page(ui, o, item),+ };+ if hide_tab {+ self.hide(self.tab);+ // The strip above was drawn with the tab still on it: draw the window again at once,+ // without showing this pass, so the tab goes in one step. A download's window+ // otherwise waits for its next timed repaint (250 ms while it downloads) on the old page.+ ui.ctx().request_discard("Hide tab");+ ui.ctx().request_repaint();}// The progress bar: IDM's green on the shared, themed track.@@ -520,14 +527,17 @@ impl Progress {fn tabs(&mut self, ui: &mut Ui, o: Pos2) -> bool {// The shared tab strip (the torrent tabs' too): one look in both themes, one Tab stop with// the arrows, sized to the translated labels. It had two of its own (classic 3-D in dark).- let tabs = [+ let tabs: Vec<(Tab, &str)> = [// i18n: tab title: how the download is going(Tab::Status, crate::i18n::mark("Download status")),// i18n: tab title: the tool that limits the download speed(Tab::Limiter, crate::i18n::mark("Speed Limiter")),// i18n: tab title: what happens when the download finishes(Tab::Completion, crate::i18n::mark("Options on completion")),- ];+ ]+ .into_iter()+ .filter(|t| !self.hidden_tabs.contains(&t.0))+ .collect();let p = ui.painter().clone();let english: Vec<&str> = tabs.iter().map(|t| t.1).collect();// The hide button sits here where the system draws the title bar (Linux, macOS; on@@ -548,6 +558,7 @@ impl Progress {if let Some(i) = winui::tabs_light(ui, o, r(o, 18.0, 8.0, 514.0, 165.0), &light, current) {self.tab = tabs[i].0;}+ self.tab_row_menu(ui, r(o, 18.0, 6.0, 514.0, 22.0));// MDM's (#63): IDM puts this in its title bar, which here is the system's own (it takes// no buttons of ours), so it sits at the tab row's end, over the page's corner.tab_button@@ -561,6 +572,78 @@ impl Progress {.clicked()}+ /// The tab row's right-click menu (#326): "Show hidden tabs" puts back the tabs hidden in+ /// this window, greyed while none is. From the keyboard too, on the focused tab: Shift+F10+ /// or the Menu key.+ fn tab_row_menu(&mut self, ui: &Ui, row: egui::Rect) {+ use crate::chrome::{MenuEntry, MenuKind, PopupResult};+ let ctx = ui.ctx();+ let key = egui::Id::unique(("progress-tab-menu", self.id));+ let by_pointer = ui.input(|i| {+ i.pointer+ .secondary_clicked()+ .then(|| i.pointer.interact_pos())+ .flatten()+ .filter(|p| row.contains(*p))+ });+ let by_keys = || {+ let tab = ctx+ .memory(|m| m.focused())+ .and_then(|f| ctx.read_response(f))+ .map(|r| r.rect)+ .filter(|r| row.contains(r.center()))?;+ ui.input_mut(|i| {+ i.consume_key(egui::Modifiers::SHIFT, egui::Key::F10)+ || i.consume_key(egui::Modifiers::NONE, egui::Key::Menu)+ })+ // Under the tab, from its leading edge (a menu's top-right in right to left).+ .then(|| {+ if winui::rtl() {+ tab.right_bottom()+ } else {+ tab.left_bottom()+ }+ })+ };+ if let Some(at) = by_pointer.or_else(by_keys) {+ ctx.data_mut(|d| d.insert_temp(key, at));+ }+ let Some(at) = ctx.data(|d| d.get_temp::<Pos2>(key)) else {+ return;+ };+ let entries = [MenuEntry::Item(+ // i18n: right-click menu of a download window's tab row: bring back the tabs taken off with "Hide tab"+ "&Show hidden tabs",+ (),+ !self.hidden_tabs.is_empty(),+ false,+ )];+ let id = format!("progress-tab-menu-{}", self.id);+ match crate::chrome::popup(ctx, MenuKind::Context, &id, at, &entries, &|_| None) {+ PopupResult::Open | PopupResult::Neighbor(_) => return,+ PopupResult::Chosen(()) => {+ self.show_hidden_tabs();+ ctx.request_repaint();+ }+ PopupResult::Dismissed => {}+ }+ ctx.data_mut(|d| d.remove::<Pos2>(key));+ }++ /// Puts every tab hidden with "Hide tab" back on the strip, in its own place.+ fn show_hidden_tabs(&mut self) {+ self.hidden_tabs.clear();+ }++ /// Takes `tab` off the strip (its "Hide tab" button, #326) and shows Download status, which+ /// has no such button and so always stays.+ fn hide(&mut self, tab: Tab) {+ if tab != Tab::Status && !self.hidden_tabs.contains(&tab) {+ self.hidden_tabs.push(tab);+ }+ self.tab = Tab::Status;+ }+/// The Speed Limiter tab, live for this download. Returns true when "Hide tab" is pressed.fn limiter_page(&mut self, ui: &mut Ui, o: Pos2, item: &Item) -> bool {let p = ui.painter().clone();@@ -1713,3 +1796,39 @@ fn connections(ui: &mut Ui, p: &egui::Painter, o: Pos2, snap: Option<&Snapshot>)}}}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn hide_tab_takes_the_tab_off_the_strip() {+ let mut p = Progress::new(1, true);+ p.tab = Tab::Limiter;+ p.hide(Tab::Limiter);+ assert_eq!(p.tab, Tab::Status, "back on Download status");+ assert_eq!(p.hidden_tabs, [Tab::Limiter], "Speed Limiter off the strip");+ p.hide(Tab::Limiter);+ p.hide(Tab::Status);+ assert_eq!(+ p.hidden_tabs,+ [Tab::Limiter],+ "once each, never Download status"+ );+ p.hide(Tab::Completion);+ assert_eq!(p.hidden_tabs, [Tab::Limiter, Tab::Completion]);+ p.show_tab("limit");+ assert_eq!(p.tab, Tab::Limiter, "asked for, it comes back");+ assert_eq!(p.hidden_tabs, [Tab::Completion], "the other stays hidden");+ }++ #[test]+ fn show_hidden_tabs_brings_them_all_back() {+ let mut p = Progress::new(1, true);+ p.hide(Tab::Limiter);+ p.hide(Tab::Completion);+ p.show_hidden_tabs();+ assert!(p.hidden_tabs.is_empty(), "every tab back on the strip");+ assert_eq!(p.tab, Tab::Status, "the page shown stays as it was");+ }+}diff --git a/docs/connections-and-speed.md b/docs/connections-and-speed.mdindex 6d994dfc..36f2e1c8 100644--- a/docs/connections-and-speed.md+++ b/docs/connections-and-speed.md@@ -56,7 +56,7 @@ Two more tabs:- **Speed Limiter** — a limit for this download only. See below.- **Options on completion** — shows where the file will be saved. Untick **Show download complete dialog** to skip the **Download complete** box for this file only.-**Hide tab** goes back to **Download status**.+**Hide tab** takes a tab off this download's window and goes back to **Download status**. To bring the tabs back, right-click the tab row and choose **Show hidden tabs**; closing the window and opening it again brings them back too.## When a download finishesdiff --git a/i18n/en.tsv b/i18n/en.tsvindex 95b0984e..f7c729e2 100644--- a/i18n/en.tsv+++ b/i18n/en.tsv@@ -4476,6 +4476,10 @@ menu &RSS feeds... &RSS feeds...#. menu command in the main window#. & marks the keyboard shortcut letter: keep one & before a letter of the translationmenu &Scheduler and queues &Scheduler and queues+#. menu command in a download's progress window+#. right-click menu of a download window's tab row: bring back the tabs taken off with "Hide tab"+#. & marks the keyboard shortcut letter: keep one & before a letter of the translation+menu &Show hidden tabs &Show hidden tabs#. menu command in the main window#. & marks the keyboard shortcut letter: keep one & before a letter of the translationmenu &Stop All &Stop All