added 'suspend' button
This commit is contained in:
parent
fe3e68d205
commit
029be91dc8
@ -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;
|
||||
}
|
||||
}
|
||||
|
39
mainwindow.h
39
mainwindow.h
@ -56,16 +56,17 @@ class Connexion
|
||||
int bandwidthLimitUnit;
|
||||
int contimeout = 20;
|
||||
QString server;
|
||||
QString service;
|
||||
QString path;
|
||||
QString savePath;
|
||||
QString user;
|
||||
QString password;
|
||||
QProcess * process = nullptr;
|
||||
int ipversion = 4;
|
||||
uint port = 873;
|
||||
bool quit = false;
|
||||
void clear();
|
||||
QString service;
|
||||
QString path;
|
||||
QString savePath;
|
||||
QString user;
|
||||
QString password;
|
||||
QProcess * process = nullptr;
|
||||
int ipversion = 4;
|
||||
uint port = 873;
|
||||
bool quit = false;
|
||||
void clear();
|
||||
bool paused = false;
|
||||
};
|
||||
|
||||
class Downloading
|
||||
@ -75,13 +76,15 @@ class Downloading
|
||||
QString service;
|
||||
QString path;
|
||||
QString savePath;
|
||||
QString user;
|
||||
QString password;
|
||||
int ipversion = 4;
|
||||
int port = 873;
|
||||
QProcess * process = nullptr;
|
||||
bool quit = false;
|
||||
void clear();
|
||||
QString user;
|
||||
QString password;
|
||||
int ipversion = 4;
|
||||
int port = 873;
|
||||
QProcess * process = nullptr;
|
||||
bool quit = false;
|
||||
bool paused = false;
|
||||
|
||||
void clear();
|
||||
};
|
||||
|
||||
class About
|
||||
@ -223,6 +226,8 @@ class MainWindow : public QMainWindow
|
||||
|
||||
void on_treeWidget_doubleClicked(const QModelIndex &index);
|
||||
|
||||
void on_actionPause_downloads_triggered();
|
||||
|
||||
signals:
|
||||
void stopDownloading(QProcess *);
|
||||
void progressSignal(int);
|
||||
|
@ -407,6 +407,7 @@
|
||||
<addaction name="actionAbout"/>
|
||||
<addaction name="actionAbout_Qt"/>
|
||||
<addaction name="actionExit"/>
|
||||
<addaction name="actionPause_downloads"/>
|
||||
</widget>
|
||||
<action name="DefaultSaveFolder">
|
||||
<property name="icon">
|
||||
@ -479,6 +480,20 @@
|
||||
<string>hidden service</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPause_downloads">
|
||||
<property name="icon">
|
||||
<iconset theme="media-playback-pause"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop/resume downloads</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Stop/resume downloading </string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>P</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
Reference in New Issue
Block a user