added 'suspend' button
This commit is contained in:
parent
fe3e68d205
commit
029be91dc8
@ -7,12 +7,8 @@
|
|||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "password.h"
|
#include "password.h"
|
||||||
#include <kcombobox.h>
|
#include <kcombobox.h>
|
||||||
|
#include <signal.h>
|
||||||
/*
|
#include <QTextStream>
|
||||||
#include <klineedit.h>
|
|
||||||
#include <khistorycombobox.h>
|
|
||||||
#include <kcompletion.h>
|
|
||||||
*/
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -1622,12 +1618,61 @@ void MainWindow::on_actionHiddenService_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
void MainWindow::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||||
{
|
{
|
||||||
void();
|
(void) item;
|
||||||
|
(void) column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_treeWidget_doubleClicked(const QModelIndex &index)
|
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 bandwidthLimitUnit;
|
||||||
int contimeout = 20;
|
int contimeout = 20;
|
||||||
QString server;
|
QString server;
|
||||||
QString service;
|
QString service;
|
||||||
QString path;
|
QString path;
|
||||||
QString savePath;
|
QString savePath;
|
||||||
QString user;
|
QString user;
|
||||||
QString password;
|
QString password;
|
||||||
QProcess * process = nullptr;
|
QProcess * process = nullptr;
|
||||||
int ipversion = 4;
|
int ipversion = 4;
|
||||||
uint port = 873;
|
uint port = 873;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
void clear();
|
void clear();
|
||||||
|
bool paused = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Downloading
|
class Downloading
|
||||||
@ -75,13 +76,15 @@ class Downloading
|
|||||||
QString service;
|
QString service;
|
||||||
QString path;
|
QString path;
|
||||||
QString savePath;
|
QString savePath;
|
||||||
QString user;
|
QString user;
|
||||||
QString password;
|
QString password;
|
||||||
int ipversion = 4;
|
int ipversion = 4;
|
||||||
int port = 873;
|
int port = 873;
|
||||||
QProcess * process = nullptr;
|
QProcess * process = nullptr;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
void clear();
|
bool paused = false;
|
||||||
|
|
||||||
|
void clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
class About
|
class About
|
||||||
@ -223,6 +226,8 @@ class MainWindow : public QMainWindow
|
|||||||
|
|
||||||
void on_treeWidget_doubleClicked(const QModelIndex &index);
|
void on_treeWidget_doubleClicked(const QModelIndex &index);
|
||||||
|
|
||||||
|
void on_actionPause_downloads_triggered();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stopDownloading(QProcess *);
|
void stopDownloading(QProcess *);
|
||||||
void progressSignal(int);
|
void progressSignal(int);
|
||||||
|
@ -407,6 +407,7 @@
|
|||||||
<addaction name="actionAbout"/>
|
<addaction name="actionAbout"/>
|
||||||
<addaction name="actionAbout_Qt"/>
|
<addaction name="actionAbout_Qt"/>
|
||||||
<addaction name="actionExit"/>
|
<addaction name="actionExit"/>
|
||||||
|
<addaction name="actionPause_downloads"/>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="DefaultSaveFolder">
|
<action name="DefaultSaveFolder">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
@ -479,6 +480,20 @@
|
|||||||
<string>hidden service</string>
|
<string>hidden service</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</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>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
Loading…
Reference in New Issue
Block a user