added 'suspend' button

This commit is contained in:
2024-10-18 22:39:09 +02:00
parent fe3e68d205
commit 029be91dc8
3 changed files with 90 additions and 25 deletions
+53 -8
View File
@@ -7,12 +7,8 @@
#include "tools.h"
#include "password.h"
#include <kcombobox.h>
/*
#include <klineedit.h>
#include <khistorycombobox.h>
#include <kcompletion.h>
*/
#include <signal.h>
#include <QTextStream>
using namespace std;
@@ -1622,12 +1618,61 @@ void MainWindow::on_actionHiddenService_triggered()
void MainWindow::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
void();
(void) item;
(void) column;
}
void MainWindow::on_treeWidget_doubleClicked(const QModelIndex &index)
{
void();
(void) index;
}
void MainWindow::on_actionPause_downloads_triggered()
{
quint64 processID = this->downloading.process->processId();
QString fileStr = "/proc/" + QString::number(processID) + "/task/" + QString::number(processID) + "/children";
static QMessageBox *msgBox;
info (DEBUGMACRO, "downloading state : " + QString::fromUtf8((this->downloading.paused==0)?"running":"paused"));
info (DEBUGMACRO, "Downloading process ID : " + QString::number(processID));
info (DEBUGMACRO, fileStr);
QFile file(fileStr);
if(!file.open(QIODevice::ReadOnly))
{
QMessageBox::information(0, "error", file.errorString());
}
QTextStream in(&file);
QString children = in.readLine();
info (DEBUGMACRO, "Child process is : " + children);
if (this->downloading.paused)
{
info(DEBUGMACRO, "resuming Download");
if (kill(children.toLongLong(), SIGCONT))
{
info(DEBUGMACRO, "resuming failed : " + QString::number(errno));
}
msgBox->close();
this->downloading.paused = false;
}else
{
info(DEBUGMACRO, "pausing Download");
if (kill(children.toLongLong(), SIGTSTP))
{
info(DEBUGMACRO, "resuming failed : " + QString::number(errno));
}
msgBox = new QMessageBox(this);
msgBox->setIcon( QMessageBox::Warning );
msgBox->setText("Download suspended");
//QPushButton *btnCancel = msgBox->addButton( "Cancel", QMessageBox::RejectRole );
msgBox->setAttribute(Qt::WA_DeleteOnClose); // delete pointer after close
msgBox->setModal(false);
msgBox->show();
this->downloading.paused = true;
}
}