mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-18 18:35:14 +08:00
Dynamically show 'Start' and 'Pause' menu items
This commit is contained in:
parent
2a712a81ea
commit
76e30ecf78
@ -129,29 +129,82 @@ var ContextMenu = new Class({
|
||||
|
||||
updateMenuItems: function () {
|
||||
all_are_seq_dl = true;
|
||||
there_are_seq_dl = false;
|
||||
all_are_f_l_piece_prio = true;
|
||||
there_are_f_l_piece_prio = false;
|
||||
all_are_downloaded = true;
|
||||
all_are_paused = true;
|
||||
there_are_paused = false;
|
||||
|
||||
var h = myTable.selectedIds();
|
||||
h.each(function(item, index){
|
||||
tr = myTable.rows.get(item);
|
||||
|
||||
if (tr.getAttribute('seq_dl') != 'true')
|
||||
all_are_seq_dl = false;
|
||||
else
|
||||
there_are_seq_dl = true;
|
||||
|
||||
if (tr.getAttribute('f_l_piece_prio') != 'true')
|
||||
all_are_f_l_piece_prio = false;
|
||||
else
|
||||
there_are_f_l_piece_prio = true;
|
||||
|
||||
if (tr.getAttribute('downloaded') != 'true')
|
||||
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) {
|
||||
this.hideItem('SequentialDownload');
|
||||
this.hideItem('FirstLastPiecePrio');
|
||||
} else {
|
||||
this.showItem('SequentialDownload');
|
||||
this.showItem('FirstLastPiecePrio');
|
||||
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');
|
||||
else
|
||||
this.hideItem('SequentialDownload');
|
||||
|
||||
if (show_f_l_piece_prio)
|
||||
this.showItem('FirstLastPiecePrio');
|
||||
else
|
||||
this.hideItem('FirstLastPiecePrio');
|
||||
|
||||
this.setItemChecked('SequentialDownload', all_are_seq_dl);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user