Skip to content

Commit

Permalink
Support multiple selection for download completion masking
Browse files Browse the repository at this point in the history
  • Loading branch information
parg committed Feb 24, 2022
1 parent 96b7919 commit 73dfc2b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
27 changes: 13 additions & 14 deletions uis/src/com/biglybt/ui/swt/TorrentMenuFancy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1462,23 +1465,19 @@ 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) {
dm.getDownloadState().setBooleanAttribute( DownloadManagerState.AT_MASK_DL_COMP, itemMaskDLComp.getSelection());
}
});

itemMaskDLComp.setEnabled( dms.length == 1 && !globalMask );

itemMaskDLComp.setEnabled( dms.length > 0 && !globalMask );

if (userMode > 1 && isSeedingView) {

Expand Down
13 changes: 9 additions & 4 deletions uis/src/com/biglybt/ui/swt/TorrentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand All @@ -598,6 +602,7 @@ public static void fillTorrentMenu(final Menu menu,
changeUrl = false;
recheck = false;
manualUpdate = false;
allMaskDC = false;
}

// === Root Menu ===
Expand Down Expand Up @@ -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,
Expand All @@ -1078,6 +1081,8 @@ public void run(DownloadManager dm) {
}
});

itemMaskDLComp.setEnabled( dms.length > 0 && !globalMask );

// Advanced -> archive

final List<Download> ar_dms = new ArrayList<>();
Expand Down

0 comments on commit 73dfc2b

Please sign in to comment.