mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07:00
Dynamically show 'Start' and 'Pause' menu items
This commit is contained in:
parent
2a712a81ea
commit
76e30ecf78
1 changed files with 55 additions and 2 deletions
|
@ -129,29 +129,82 @@ var ContextMenu = new Class({
|
||||||
|
|
||||||
updateMenuItems: function () {
|
updateMenuItems: function () {
|
||||||
all_are_seq_dl = true;
|
all_are_seq_dl = true;
|
||||||
|
there_are_seq_dl = false;
|
||||||
all_are_f_l_piece_prio = true;
|
all_are_f_l_piece_prio = true;
|
||||||
|
there_are_f_l_piece_prio = false;
|
||||||
all_are_downloaded = true;
|
all_are_downloaded = true;
|
||||||
|
all_are_paused = true;
|
||||||
|
there_are_paused = false;
|
||||||
|
|
||||||
var h = myTable.selectedIds();
|
var h = myTable.selectedIds();
|
||||||
h.each(function(item, index){
|
h.each(function(item, index){
|
||||||
tr = myTable.rows.get(item);
|
tr = myTable.rows.get(item);
|
||||||
|
|
||||||
if (tr.getAttribute('seq_dl') != 'true')
|
if (tr.getAttribute('seq_dl') != 'true')
|
||||||
all_are_seq_dl = false;
|
all_are_seq_dl = false;
|
||||||
|
else
|
||||||
|
there_are_seq_dl = true;
|
||||||
|
|
||||||
if (tr.getAttribute('f_l_piece_prio') != 'true')
|
if (tr.getAttribute('f_l_piece_prio') != 'true')
|
||||||
all_are_f_l_piece_prio = false;
|
all_are_f_l_piece_prio = false;
|
||||||
|
else
|
||||||
|
there_are_f_l_piece_prio = true;
|
||||||
|
|
||||||
if (tr.getAttribute('downloaded') != 'true')
|
if (tr.getAttribute('downloaded') != 'true')
|
||||||
all_are_downloaded = false;
|
all_are_downloaded = false;
|
||||||
|
|
||||||
|
state = tr.getAttribute('state');
|
||||||
|
if ((state != 'pausedUP') && (state != 'pausedDL'))
|
||||||
|
all_are_paused = false;
|
||||||
|
else
|
||||||
|
there_are_paused = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
show_seq_dl = true;
|
||||||
|
|
||||||
|
if (!all_are_seq_dl && there_are_seq_dl)
|
||||||
|
show_seq_dl = false;
|
||||||
|
|
||||||
|
show_f_l_piece_prio = true;
|
||||||
|
|
||||||
|
if (!all_are_f_l_piece_prio && there_are_f_l_piece_prio)
|
||||||
|
show_f_l_piece_prio = false;
|
||||||
|
|
||||||
if (all_are_downloaded) {
|
if (all_are_downloaded) {
|
||||||
this.hideItem('SequentialDownload');
|
this.hideItem('SequentialDownload');
|
||||||
this.hideItem('FirstLastPiecePrio');
|
this.hideItem('FirstLastPiecePrio');
|
||||||
} else {
|
} else {
|
||||||
|
if (!show_seq_dl && show_f_l_piece_prio)
|
||||||
|
this.menu.getElement('a[href$=FirstLastPiecePrio]').parentNode.addClass('separator');
|
||||||
|
else
|
||||||
|
this.menu.getElement('a[href$=FirstLastPiecePrio]').parentNode.removeClass('separator');
|
||||||
|
|
||||||
|
if (show_seq_dl)
|
||||||
this.showItem('SequentialDownload');
|
this.showItem('SequentialDownload');
|
||||||
|
else
|
||||||
|
this.hideItem('SequentialDownload');
|
||||||
|
|
||||||
|
if (show_f_l_piece_prio)
|
||||||
this.showItem('FirstLastPiecePrio');
|
this.showItem('FirstLastPiecePrio');
|
||||||
|
else
|
||||||
|
this.hideItem('FirstLastPiecePrio');
|
||||||
|
|
||||||
this.setItemChecked('SequentialDownload', all_are_seq_dl);
|
this.setItemChecked('SequentialDownload', all_are_seq_dl);
|
||||||
this.setItemChecked('FirstLastPiecePrio', all_are_f_l_piece_prio);
|
this.setItemChecked('FirstLastPiecePrio', all_are_f_l_piece_prio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (all_are_paused) {
|
||||||
|
this.showItem('Start');
|
||||||
|
this.hideItem('Pause');
|
||||||
|
} else {
|
||||||
|
if (there_are_paused) {
|
||||||
|
this.showItem('Start');
|
||||||
|
this.showItem('Pause');
|
||||||
|
} else {
|
||||||
|
this.hideItem('Start');
|
||||||
|
this.showItem('Pause');
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//show menu
|
//show menu
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue