mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-13 08:43:08 -07:00
- Pause / resume in Web UI now updates the GUI
- Code cleanup
This commit is contained in:
parent
b58046b1fc
commit
a848538d66
8 changed files with 37 additions and 42 deletions
|
@ -289,13 +289,6 @@ void FinishedTorrents::pauseTorrent(QString hash) {
|
||||||
setRowColor(row, QString::fromUtf8("red"));
|
setRowColor(row, QString::fromUtf8("red"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinishedTorrents::resumeTorrent(QString hash) {
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
Q_ASSERT(row != -1);
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("orange"));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString FinishedTorrents::getHashFromRow(unsigned int row) const {
|
QString FinishedTorrents::getHashFromRow(unsigned int row) const {
|
||||||
Q_ASSERT(row < (unsigned int)finishedListModel->rowCount());
|
Q_ASSERT(row < (unsigned int)finishedListModel->rowCount());
|
||||||
return finishedListModel->data(finishedListModel->index(row, F_HASH)).toString();
|
return finishedListModel->data(finishedListModel->index(row, F_HASH)).toString();
|
||||||
|
|
|
@ -78,7 +78,6 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
|
||||||
void addTorrent(QString hash);
|
void addTorrent(QString hash);
|
||||||
void updateTorrent(QTorrentHandle h);
|
void updateTorrent(QTorrentHandle h);
|
||||||
void pauseTorrent(QString hash);
|
void pauseTorrent(QString hash);
|
||||||
void resumeTorrent(QString hash);
|
|
||||||
void propertiesSelection();
|
void propertiesSelection();
|
||||||
void deleteTorrent(QString hash);
|
void deleteTorrent(QString hash);
|
||||||
void showPropertiesFromHash(QString hash);
|
void showPropertiesFromHash(QString hash);
|
||||||
|
|
46
src/GUI.cpp
46
src/GUI.cpp
|
@ -122,6 +122,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
|
||||||
connect(BTSession, SIGNAL(fullDiskError(QTorrentHandle&)), this, SLOT(fullDiskError(QTorrentHandle&)));
|
connect(BTSession, SIGNAL(fullDiskError(QTorrentHandle&)), this, SLOT(fullDiskError(QTorrentHandle&)));
|
||||||
connect(BTSession, SIGNAL(finishedTorrent(QTorrentHandle&)), this, SLOT(finishedTorrent(QTorrentHandle&)));
|
connect(BTSession, SIGNAL(finishedTorrent(QTorrentHandle&)), this, SLOT(finishedTorrent(QTorrentHandle&)));
|
||||||
connect(BTSession, SIGNAL(addedTorrent(QTorrentHandle&)), this, SLOT(addedTorrent(QTorrentHandle&)));
|
connect(BTSession, SIGNAL(addedTorrent(QTorrentHandle&)), this, SLOT(addedTorrent(QTorrentHandle&)));
|
||||||
|
connect(BTSession, SIGNAL(pausedTorrent(QTorrentHandle&)), this, SLOT(pausedTorrent(QTorrentHandle&)));
|
||||||
|
connect(BTSession, SIGNAL(resumedTorrent(QTorrentHandle&)), this, SLOT(resumedTorrent(QTorrentHandle&)));
|
||||||
connect(BTSession, SIGNAL(torrentFinishedChecking(QTorrentHandle&)), this, SLOT(checkedTorrent(QTorrentHandle&)));
|
connect(BTSession, SIGNAL(torrentFinishedChecking(QTorrentHandle&)), this, SLOT(checkedTorrent(QTorrentHandle&)));
|
||||||
connect(BTSession, SIGNAL(trackerAuthenticationRequired(QTorrentHandle&)), this, SLOT(trackerAuthenticationRequired(QTorrentHandle&)));
|
connect(BTSession, SIGNAL(trackerAuthenticationRequired(QTorrentHandle&)), this, SLOT(trackerAuthenticationRequired(QTorrentHandle&)));
|
||||||
connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString)));
|
connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString)));
|
||||||
|
@ -371,6 +373,22 @@ void GUI::addedTorrent(QTorrentHandle& h) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::pausedTorrent(QTorrentHandle& h) const {
|
||||||
|
if(h.is_seed()) {
|
||||||
|
finishedTorrentTab->pauseTorrent(h.hash());
|
||||||
|
} else {
|
||||||
|
downloadingTorrentTab->pauseTorrent(h.hash());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUI::resumedTorrent(QTorrentHandle& h) const {
|
||||||
|
if(h.is_seed()) {
|
||||||
|
finishedTorrentTab->updateTorrent(h);
|
||||||
|
} else {
|
||||||
|
downloadingTorrentTab->updateTorrent(h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::checkedTorrent(QTorrentHandle& h) const {
|
void GUI::checkedTorrent(QTorrentHandle& h) const {
|
||||||
if(h.is_seed()) {
|
if(h.is_seed()) {
|
||||||
// Move torrent to finished tab
|
// Move torrent to finished tab
|
||||||
|
@ -1193,20 +1211,18 @@ void GUI::togglePausedState(QString hash) {
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
if(h.is_paused()) {
|
if(h.is_paused()) {
|
||||||
h.resume();
|
h.resume();
|
||||||
|
resumedTorrent(h);
|
||||||
if(inDownloadList) {
|
if(inDownloadList) {
|
||||||
downloadingTorrentTab->resumeTorrent(hash);
|
|
||||||
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
||||||
}else{
|
}else{
|
||||||
finishedTorrentTab->resumeTorrent(hash);
|
|
||||||
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
|
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
h.pause();
|
h.pause();
|
||||||
|
pausedTorrent(h);
|
||||||
if(inDownloadList) {
|
if(inDownloadList) {
|
||||||
downloadingTorrentTab->pauseTorrent(hash);
|
|
||||||
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
||||||
}else{
|
}else{
|
||||||
finishedTorrentTab->pauseTorrent(hash);
|
|
||||||
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
|
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1222,13 +1238,7 @@ void GUI::on_actionPause_All_triggered() {
|
||||||
if(!h.is_valid() || h.is_paused()) continue;
|
if(!h.is_valid() || h.is_paused()) continue;
|
||||||
change = true;
|
change = true;
|
||||||
h.pause();
|
h.pause();
|
||||||
if(h.is_seed()) {
|
pausedTorrent(h);
|
||||||
// Update in finished list
|
|
||||||
finishedTorrentTab->pauseTorrent(h.hash());
|
|
||||||
} else {
|
|
||||||
// Update in download list
|
|
||||||
downloadingTorrentTab->pauseTorrent(h.hash());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(change) {
|
if(change) {
|
||||||
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
||||||
|
@ -1271,11 +1281,10 @@ void GUI::on_actionPause_triggered() {
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
if(!h.is_paused()){
|
if(!h.is_paused()){
|
||||||
h.pause();
|
h.pause();
|
||||||
|
pausedTorrent(h);
|
||||||
if(inDownloadList) {
|
if(inDownloadList) {
|
||||||
downloadingTorrentTab->pauseTorrent(hash);
|
|
||||||
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
||||||
} else {
|
} else {
|
||||||
finishedTorrentTab->pauseTorrent(hash);
|
|
||||||
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
|
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1299,13 +1308,7 @@ void GUI::on_actionStart_All_triggered() {
|
||||||
if(!h.is_valid() || !h.is_paused()) continue;
|
if(!h.is_valid() || !h.is_paused()) continue;
|
||||||
change = true;
|
change = true;
|
||||||
h.resume();
|
h.resume();
|
||||||
if(h.is_seed()) {
|
resumedTorrent(h);
|
||||||
// Update in finished list
|
|
||||||
finishedTorrentTab->resumeTorrent(h.hash());
|
|
||||||
} else {
|
|
||||||
// Update in download list
|
|
||||||
downloadingTorrentTab->resumeTorrent(h.hash());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(change) {
|
if(change) {
|
||||||
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
||||||
|
@ -1330,11 +1333,10 @@ void GUI::on_actionStart_triggered() {
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
if(h.is_paused()){
|
if(h.is_paused()){
|
||||||
h.resume();
|
h.resume();
|
||||||
|
resumedTorrent(h);
|
||||||
if(inDownloadList) {
|
if(inDownloadList) {
|
||||||
downloadingTorrentTab->resumeTorrent(hash);
|
|
||||||
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
||||||
} else {
|
} else {
|
||||||
finishedTorrentTab->resumeTorrent(hash);
|
|
||||||
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
|
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
||||||
void finishedTorrent(QTorrentHandle& h) const;
|
void finishedTorrent(QTorrentHandle& h) const;
|
||||||
void addedTorrent(QTorrentHandle& h) const;
|
void addedTorrent(QTorrentHandle& h) const;
|
||||||
void checkedTorrent(QTorrentHandle& h) const;
|
void checkedTorrent(QTorrentHandle& h) const;
|
||||||
|
void pausedTorrent(QTorrentHandle& h) const;
|
||||||
|
void resumedTorrent(QTorrentHandle& h) const;
|
||||||
void updateLists(bool force=false);
|
void updateLists(bool force=false);
|
||||||
bool initWebUi(QString username, QString password, int port);
|
bool initWebUi(QString username, QString password, int port);
|
||||||
void pauseTorrent(QString hash);
|
void pauseTorrent(QString hash);
|
||||||
|
|
|
@ -287,6 +287,7 @@ void bittorrent::pauseAllTorrents() {
|
||||||
if(!h.is_valid()) continue;
|
if(!h.is_valid()) continue;
|
||||||
if(!h.is_paused()) {
|
if(!h.is_paused()) {
|
||||||
h.pause();
|
h.pause();
|
||||||
|
emit pausedTorrent(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,20 +300,25 @@ void bittorrent::resumeAllTorrents() {
|
||||||
if(!h.is_valid()) continue;
|
if(!h.is_valid()) continue;
|
||||||
if(h.is_paused()) {
|
if(h.is_paused()) {
|
||||||
h.resume();
|
h.resume();
|
||||||
|
emit resumedTorrent(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bittorrent::pauseTorrent(QString hash) {
|
void bittorrent::pauseTorrent(QString hash) {
|
||||||
QTorrentHandle h = getTorrentHandle(hash);
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
if(!h.is_paused())
|
if(!h.is_paused()) {
|
||||||
h.pause();
|
h.pause();
|
||||||
|
emit pausedTorrent(h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bittorrent::resumeTorrent(QString hash) {
|
void bittorrent::resumeTorrent(QString hash) {
|
||||||
QTorrentHandle h = getTorrentHandle(hash);
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
if(h.is_paused())
|
if(h.is_paused()) {
|
||||||
h.resume();
|
h.resume();
|
||||||
|
emit resumedTorrent(h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bittorrent::loadWebSeeds(QString hash) {
|
void bittorrent::loadWebSeeds(QString hash) {
|
||||||
|
@ -502,18 +508,17 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
|
||||||
}
|
}
|
||||||
// Send torrent addition signal
|
// Send torrent addition signal
|
||||||
if(!from_url.isNull()) {
|
if(!from_url.isNull()) {
|
||||||
emit addedTorrent(h);
|
|
||||||
if(fastResume)
|
if(fastResume)
|
||||||
addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(from_url));
|
addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(from_url));
|
||||||
else
|
else
|
||||||
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(from_url));
|
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(from_url));
|
||||||
}else{
|
}else{
|
||||||
emit addedTorrent(h);
|
|
||||||
if(fastResume)
|
if(fastResume)
|
||||||
addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(file));
|
addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(file));
|
||||||
else
|
else
|
||||||
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(file));
|
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(file));
|
||||||
}
|
}
|
||||||
|
emit addedTorrent(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check in .priorities file if the user filtered files
|
// Check in .priorities file if the user filtered files
|
||||||
|
|
|
@ -165,6 +165,8 @@ class bittorrent : public QObject {
|
||||||
signals:
|
signals:
|
||||||
void addedTorrent(QTorrentHandle& h);
|
void addedTorrent(QTorrentHandle& h);
|
||||||
void deletedTorrent(QString hash);
|
void deletedTorrent(QString hash);
|
||||||
|
void pausedTorrent(QTorrentHandle& h);
|
||||||
|
void resumedTorrent(QTorrentHandle& h);
|
||||||
void finishedTorrent(QTorrentHandle& h);
|
void finishedTorrent(QTorrentHandle& h);
|
||||||
void fullDiskError(QTorrentHandle& h);
|
void fullDiskError(QTorrentHandle& h);
|
||||||
void trackerError(QString hash, QString time, QString msg);
|
void trackerError(QString hash, QString time, QString msg);
|
||||||
|
|
|
@ -168,13 +168,6 @@ void DownloadingTorrents::showPropertiesFromHash(QString hash) {
|
||||||
prop->show();
|
prop->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadingTorrents::resumeTorrent(QString hash){
|
|
||||||
int row = getRowFromHash(hash);
|
|
||||||
Q_ASSERT(row != -1);
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/stalled.png"))), Qt::DecorationRole);
|
|
||||||
setRowColor(row, QString::fromUtf8("grey"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove a torrent from the download list but NOT from the BT Session
|
// Remove a torrent from the download list but NOT from the BT Session
|
||||||
void DownloadingTorrents::deleteTorrent(QString hash) {
|
void DownloadingTorrents::deleteTorrent(QString hash) {
|
||||||
int row = getRowFromHash(hash);
|
int row = getRowFromHash(hash);
|
||||||
|
|
|
@ -86,7 +86,6 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
|
||||||
public slots:
|
public slots:
|
||||||
bool updateTorrent(QTorrentHandle h);
|
bool updateTorrent(QTorrentHandle h);
|
||||||
void pauseTorrent(QString hash);
|
void pauseTorrent(QString hash);
|
||||||
void resumeTorrent(QString hash);
|
|
||||||
void deleteTorrent(QString hash);
|
void deleteTorrent(QString hash);
|
||||||
void propertiesSelection();
|
void propertiesSelection();
|
||||||
void updateFileSizeAndProgress(QString hash);
|
void updateFileSizeAndProgress(QString hash);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue