From 73dfc2b2cb22a3c856d3a8dc166d51be443464fe Mon Sep 17 00:00:00 2001 From: parg Date: Thu, 24 Feb 2022 12:10:09 +0100 Subject: [PATCH] Support multiple selection for download completion masking --- .../com/biglybt/ui/swt/TorrentMenuFancy.java | 27 +++++++++---------- uis/src/com/biglybt/ui/swt/TorrentUtil.java | 13 ++++++--- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/uis/src/com/biglybt/ui/swt/TorrentMenuFancy.java b/uis/src/com/biglybt/ui/swt/TorrentMenuFancy.java index 727031acaf8..f1d1bf2b406 100644 --- a/uis/src/com/biglybt/ui/swt/TorrentMenuFancy.java +++ b/uis/src/com/biglybt/ui/swt/TorrentMenuFancy.java @@ -1264,15 +1264,16 @@ public void buildMenu(Menu menu) { @Override public void buildMenu(Menu menu) { - boolean allStopped = true; - boolean allScanSelected = true; - boolean allScanNotSelected = true; - boolean fileMove = true; + boolean allStopped = true; + boolean allScanSelected = true; + boolean allScanNotSelected = true; + boolean fileMove = true; boolean allResumeIncomplete = true; - boolean hasClearableLinks = false; + boolean hasClearableLinks = false; boolean hasRevertableFiles = false; boolean lrrecheck = false; boolean allAllocatable = true; + boolean allMaskDC = true; for (DownloadManager dm : dms) { boolean stopped = ManagerUtils.isStopped(dm); @@ -1311,7 +1312,9 @@ public void buildMenu(Menu menu) { lrrecheck = lrrecheck || ManagerUtils.canLowResourceRecheck(dm); - allAllocatable &= stopped && !dm.isDataAlreadyAllocated() && !dm.isDownloadComplete( false ); + allAllocatable &= stopped && !dm.isDataAlreadyAllocated() && !dm.isDownloadComplete( false ); + + allMaskDC = allMaskDC && dms.getBooleanAttribute( DownloadManagerState.AT_MASK_DL_COMP ); } boolean fileRescan = allScanSelected || allScanNotSelected; @@ -1462,14 +1465,11 @@ public void run(DownloadManager dm) { MenuItem itemMaskDLComp = new MenuItem(menu, SWT.CHECK); - if ( dms.length == 1 ){ - itemMaskDLComp.setSelection( - globalMask || - dms[0].getDownloadState().getBooleanAttribute( DownloadManagerState.AT_MASK_DL_COMP )); + if ( dms.length > 0 ){ + itemMaskDLComp.setSelection( globalMask || allMaskDC ); } - Messages.setLanguageText(itemMaskDLComp, - "ConfigView.label.hap"); + Messages.setLanguageText(itemMaskDLComp,"ConfigView.label.hap"); itemMaskDLComp.addListener(SWT.Selection, new ListenerDMTask(dms) { @Override public void run(DownloadManager dm) { @@ -1477,8 +1477,7 @@ public void run(DownloadManager dm) { } }); - itemMaskDLComp.setEnabled( dms.length == 1 && !globalMask ); - + itemMaskDLComp.setEnabled( dms.length > 0 && !globalMask ); if (userMode > 1 && isSeedingView) { diff --git a/uis/src/com/biglybt/ui/swt/TorrentUtil.java b/uis/src/com/biglybt/ui/swt/TorrentUtil.java index 0db27688ffe..94ade6cf3ea 100644 --- a/uis/src/com/biglybt/ui/swt/TorrentUtil.java +++ b/uis/src/com/biglybt/ui/swt/TorrentUtil.java @@ -425,6 +425,8 @@ public static void fillTorrentMenu(final Menu menu, boolean hasClearableLinks = false; boolean hasRevertableFiles = false; + boolean allMaskDC = true; + if (hasSelection) { for (int i = 0; i < dms.length; i++) { DownloadManager dm = (DownloadManager) dms[i]; @@ -578,6 +580,8 @@ public static void fillTorrentMenu(final Menu menu, hasRevertableFiles = true; } + + allMaskDC = allMaskDC && dm_state.getBooleanAttribute( DownloadManagerState.AT_MASK_DL_COMP ); } fileRescan = allScanSelected || allScanNotSelected; @@ -598,6 +602,7 @@ public static void fillTorrentMenu(final Menu menu, changeUrl = false; recheck = false; manualUpdate = false; + allMaskDC = false; } // === Root Menu === @@ -1063,10 +1068,8 @@ public void run(DownloadManager dm) { MenuItem itemMaskDLComp = new MenuItem(menuFiles, SWT.CHECK); - if ( dms.length == 1 ){ - itemMaskDLComp.setSelection( - globalMask || - dms[0].getDownloadState().getBooleanAttribute( DownloadManagerState.AT_MASK_DL_COMP )); + if ( dms.length> 0 ){ + itemMaskDLComp.setSelection( globalMask || allMaskDC ); } Messages.setLanguageText(itemMaskDLComp, @@ -1078,6 +1081,8 @@ public void run(DownloadManager dm) { } }); + itemMaskDLComp.setEnabled( dms.length > 0 && !globalMask ); + // Advanced -> archive final List ar_dms = new ArrayList<>();