corrected regression: resuming downloadlist download did not start\n added downloading speed in progress bar

This commit is contained in:
Daniel Tartavel 2023-02-22 00:48:16 +01:00
parent e8743ff802
commit a8e888e20d
5 changed files with 95 additions and 63 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.14.2, 2023-02-16T21:27:43. --> <!-- Written by QtCreator 4.14.2, 2023-02-22T00:23:04. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -183,27 +183,27 @@
<translation>Paramètres</translation> <translation>Paramètres</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="100"/> <location filename="mainwindow.cpp" line="102"/>
<source>KB</source> <source>KB</source>
<translation>Ko</translation> <translation>Ko</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="100"/> <location filename="mainwindow.cpp" line="102"/>
<source>MB</source> <source>MB</source>
<translation>Mo</translation> <translation>Mo</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="100"/> <location filename="mainwindow.cpp" line="102"/>
<source>GB</source> <source>GB</source>
<translation>Go</translation> <translation>Go</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="100"/> <location filename="mainwindow.cpp" line="102"/>
<source>TB</source> <source>TB</source>
<translation>To</translation> <translation>To</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="100"/> <location filename="mainwindow.cpp" line="102"/>
<source>PB</source> <source>PB</source>
<translation>Po</translation> <translation>Po</translation>
</message> </message>
@ -245,17 +245,17 @@ Cliquez sur un fichier pour le supprimer de la file et une fenêtre de confirmat
<translation type="vanished">&lt;h2&gt;Client pour serveur rsync&lt;2&gt;&lt;br&gt;&lt;br&gt;éaa</translation> <translation type="vanished">&lt;h2&gt;Client pour serveur rsync&lt;2&gt;&lt;br&gt;&lt;br&gt;éaa</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="72"/> <location filename="mainwindow.cpp" line="73"/>
<source>Path</source> <source>Path</source>
<translation>Chemin</translation> <translation>Chemin</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="72"/> <location filename="mainwindow.cpp" line="73"/>
<source>Size</source> <source>Size</source>
<translation>Taille</translation> <translation>Taille</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="72"/> <location filename="mainwindow.cpp" line="73"/>
<source>Type</source> <source>Type</source>
<translation>Type</translation> <translation>Type</translation>
</message> </message>
@ -265,85 +265,85 @@ Cliquez sur un fichier pour le supprimer de la file et une fenêtre de confirmat
<translation>Une liste de téléchargement existe, voulez-vous utiliser cette liste ? si non, elle sera effacée</translation> <translation>Une liste de téléchargement existe, voulez-vous utiliser cette liste ? si non, elle sera effacée</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="144"/> <location filename="mainwindow.cpp" line="146"/>
<source>&amp;Quit</source> <source>&amp;Quit</source>
<translation>&amp;Quitter</translation> <translation>&amp;Quitter</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="201"/> <location filename="mainwindow.cpp" line="203"/>
<source>Clicking Save button, You can save the list of downloads <source>Clicking Save button, You can save the list of downloads
</source> </source>
<translation>Vous pouvez enregistrer la liste des téléchargements en cliquant sur &quot;enregister&quot; <translation>Vous pouvez enregistrer la liste des téléchargements en cliquant sur &quot;enregister&quot;
</translation> </translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="207"/> <location filename="mainwindow.cpp" line="209"/>
<source>Exiting will stop downloading, and will clear the download queue. <source>Exiting will stop downloading, and will clear the download queue.
Do you want to exit ?</source> Do you want to exit ?</source>
<translation>Si vous sortez, les téléchargements seront arrêter. <translation>Si vous sortez, les téléchargements seront arrêter.
Voulez-vous vraiment sortir ?</translation> Voulez-vous vraiment sortir ?</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="245"/> <location filename="mainwindow.cpp" line="247"/>
<source>The program will keep running in the system tray. To terminate the program, choose &lt;b&gt;Quit&lt;/b&gt; in the context menu of the system tray entry.</source> <source>The program will keep running in the system tray. To terminate the program, choose &lt;b&gt;Quit&lt;/b&gt; in the context menu of the system tray entry.</source>
<translation>Le programme continue dans la boîte à miniatures. Pour quitter le programme cliquez sur l&apos;icône &lt;b&gt;Quitter&lt;/b&gt; ou dans les menu contextuel.</translation> <translation>Le programme continue dans la boîte à miniatures. Pour quitter le programme cliquez sur l&apos;icône &lt;b&gt;Quitter&lt;/b&gt; ou dans les menu contextuel.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="538"/> <location filename="mainwindow.cpp" line="540"/>
<source>server does not exists</source> <source>server does not exists</source>
<translation>Le serveur n&apos;existe pas</translation> <translation>Le serveur n&apos;existe pas</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="565"/> <location filename="mainwindow.cpp" line="567"/>
<location filename="mainwindow.cpp" line="585"/> <location filename="mainwindow.cpp" line="587"/>
<source>Dir</source> <source>Dir</source>
<translation>dossier</translation> <translation>dossier</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="569"/> <location filename="mainwindow.cpp" line="571"/>
<location filename="mainwindow.cpp" line="655"/> <location filename="mainwindow.cpp" line="657"/>
<source>File</source> <source>File</source>
<translation>Doc</translation> <translation>Doc</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="666"/> <location filename="mainwindow.cpp" line="668"/>
<source>File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory</source> <source>File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory</source>
<translation>Le document est déjà partiellement téléchargé. Voulez vous continuer le téléchargemnt ? Si non, il sera supprimer du dossier de destination</translation> <translation>Le document est déjà partiellement téléchargé. Voulez vous continuer le téléchargemnt ? Si non, il sera supprimer du dossier de destination</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="683"/> <location filename="mainwindow.cpp" line="685"/>
<source>File is already downloaded. Do you want to reload it ? The old file will be deleted</source> <source>File is already downloaded. Do you want to reload it ? The old file will be deleted</source>
<translation>Le document est déjà téléchargé. Voulez-vous le télécharger à nouveau ? L&apos;ancien fichier sera effacé</translation> <translation>Le document est déjà téléchargé. Voulez-vous le télécharger à nouveau ? L&apos;ancien fichier sera effacé</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="719"/> <location filename="mainwindow.cpp" line="722"/>
<source>File is already downloading</source> <source>File is already downloading</source>
<translation>Le document est déjà en téléchargement</translation> <translation>Le document est déjà en téléchargement</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="742"/> <location filename="mainwindow.cpp" line="745"/>
<source>Starting downloading <source>Starting downloading
</source> </source>
<translation>Démarrage du téléchargement <translation>Démarrage du téléchargement
</translation> </translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="757"/> <location filename="mainwindow.cpp" line="760"/>
<source>finished</source> <source>finished</source>
<translation>Terminé</translation> <translation>Terminé</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="765"/> <location filename="mainwindow.cpp" line="768"/>
<source>Rsync process crashed</source> <source>Rsync process crashed</source>
<translation>Le processus rsync à planté</translation> <translation>Le processus rsync à planté</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="777"/> <location filename="mainwindow.cpp" line="780"/>
<source>stopped by user</source> <source>stopped by user</source>
<translation>stoppé par l&apos;utilisateur</translation> <translation>stoppé par l&apos;utilisateur</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="781"/> <location filename="mainwindow.cpp" line="784"/>
<source>Download </source> <source>Download </source>
<translation>Téléchargement </translation> <translation>Téléchargement </translation>
</message> </message>
@ -378,52 +378,52 @@ Voulez-vous vraiment sortir ?</translation>
<translation>Code source</translation> <translation>Code source</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="952"/> <location filename="mainwindow.cpp" line="955"/>
<source>Since the save path is linked to service, you need to select a service before you can select a folder</source> <source>Since the save path is linked to service, you need to select a service before you can select a folder</source>
<translation>Vous devez sélectionnez un service pour pouvoir sélectionnez un dossier par défaut</translation> <translation>Vous devez sélectionnez un service pour pouvoir sélectionnez un dossier par défaut</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="957"/> <location filename="mainwindow.cpp" line="960"/>
<source>Choose folder where to save file</source> <source>Choose folder where to save file</source>
<translation>Choisissez un dossier enregistrer le document</translation> <translation>Choisissez un dossier enregistrer le document</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="848"/> <location filename="mainwindow.cpp" line="851"/>
<source>Do you want to stop downloading and delete this file from download queue ?</source> <source>Do you want to stop downloading and delete this file from download queue ?</source>
<translation>Voulez-vous arrêter le téléchargement et enlever ce fichier de la file de téléchargement ?</translation> <translation>Voulez-vous arrêter le téléchargement et enlever ce fichier de la file de téléchargement ?</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="862"/> <location filename="mainwindow.cpp" line="865"/>
<source>Do you want to delete this file from download queue ?</source> <source>Do you want to delete this file from download queue ?</source>
<translation>Voulez-vous enlever ce fichier de la file de téléchargement ?</translation> <translation>Voulez-vous enlever ce fichier de la file de téléchargement ?</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="125"/> <location filename="mainwindow.h" line="128"/>
<source>The process failed to start. Either the invoked program is missing, or you may have insufficient permissions or resources to invoke the program.</source> <source>The process failed to start. Either the invoked program is missing, or you may have insufficient permissions or resources to invoke the program.</source>
<translation>Le processus échoué, soit le programme est manquant, soit vous n&apos;avez pas l&apos;autorisation de l&apos;exécuter.</translation> <translation>Le processus échoué, soit le programme est manquant, soit vous n&apos;avez pas l&apos;autorisation de l&apos;exécuter.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="126"/> <location filename="mainwindow.h" line="129"/>
<source>The process crashed some time after starting successfully.</source> <source>The process crashed some time after starting successfully.</source>
<translation>Le processus à planté après avoir démarré avec succès.</translation> <translation>Le processus à planté après avoir démarré avec succès.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="127"/> <location filename="mainwindow.h" line="130"/>
<source>The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again.</source> <source>The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again.</source>
<translation>La fonction waitFor...() a dépassé la limite de temps, you pouvez essayer de la relancer.</translation> <translation>La fonction waitFor...() a dépassé la limite de temps, you pouvez essayer de la relancer.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="128"/> <location filename="mainwindow.h" line="131"/>
<source>An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.</source> <source>An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.</source>
<translation>Une erreur est survenue lors de l&apos;envoi des données vers le processus. Le processus est peut être arrté ou il a fermé son canal d&apos;entrée.</translation> <translation>Une erreur est survenue lors de l&apos;envoi des données vers le processus. Le processus est peut être arrté ou il a fermé son canal d&apos;entrée.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="129"/> <location filename="mainwindow.h" line="132"/>
<source>An error occurred when attempting to read from the process. For example, the process may not be running.</source> <source>An error occurred when attempting to read from the process. For example, the process may not be running.</source>
<translation>Une erreur est survenue lors de la lecturee de données, le processus est probablement arrêté.</translation> <translation>Une erreur est survenue lors de la lecturee de données, le processus est probablement arrêté.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="130"/> <location filename="mainwindow.h" line="133"/>
<source>An unknown error occurred. This is the default return value of error().</source> <source>An unknown error occurred. This is the default return value of error().</source>
<translation>Une erreur inconnue est survenue. C&apos;est la valeur de retour par défaut de error().</translation> <translation>Une erreur inconnue est survenue. C&apos;est la valeur de retour par défaut de error().</translation>
</message> </message>

View File

@ -49,7 +49,7 @@ void MainWindow::download()
{ {
param << "--bwlimit=" + QString::number(this->connexion.bandwidthLimit) + bwUnitChar[this->connexion.bandwidthLimitUnit]; param << "--bwlimit=" + QString::number(this->connexion.bandwidthLimit) + bwUnitChar[this->connexion.bandwidthLimitUnit];
} }
param << "--port=" + QString::number(this->connexion.port); param << "--port=" + QString::number(this->downloading.port);
param << "-aXP"; param << "-aXP";
param << this->downloading.server + "::" + this->downloading.service + "/" + this->downloading.path << this->downloading.savePath + "/"; param << this->downloading.server + "::" + this->downloading.service + "/" + this->downloading.path << this->downloading.savePath + "/";
@ -69,32 +69,50 @@ void MainWindow::readRsyncOutput()
bool flag = false; bool flag = false;
int value; int value;
int pos; int pos;
static QString dlSpeed;
QStringList list;
static QString filename;
int i;
int listSize;
while(!flag) while(!flag)
{ {
list.clear();
line = QString::fromUtf8(this->downloading.process->readLine()); line = QString::fromUtf8(this->downloading.process->readLine());
if (line.isEmpty()) if (line.isEmpty())
{ {
flag = true; flag = true;
break; break;
} }else
{
pos = line.indexOf("%"); pos = line.indexOf("%");
if (pos != -1) if (pos != -1)
{ {
line.resize(pos); line = line.simplified();
list = line.split(" ");
listSize = list.count() / 4;
for (i = 0; i < listSize; i++)
{
value = list.at(i *4 + 1).chopped(1).toInt();
dlSpeed = list.at(i * 4 + 2);
/*line.resize(pos);
pos = line.lastIndexOf(' '); pos = line.lastIndexOf(' ');
if (pos != -1) if (pos != -1)
{ {
line.remove(0, pos); line.remove(0, pos);
value = line.toInt(); value = line.toInt();*/
// sending progress to Main window // sending progress to Main window
emit progressSignal(value); emit progressSignal(value);
emit fileName(filename + " %p%" + "\t " + dlSpeed);
} }
}else }else
{ {
if (!line.contains("receiving")) if (!line.contains("receiving"))
{ {
emit fileName(line.remove(QChar('\n'), Qt::CaseInsensitive) + " %p%"); filename = line.remove(QChar('\n'), Qt::CaseInsensitive);
emit fileName(filename + " %p%\t " + dlSpeed);
}
} }
} }
} }

View File

@ -61,6 +61,7 @@ MainWindow::MainWindow(QWidget *parent)
// connectors // connectors
connect(this, &MainWindow::fileName, ui->progressBar, &QProgressBar::setFormat); connect(this, &MainWindow::fileName, ui->progressBar, &QProgressBar::setFormat);
connect(this, &MainWindow::progressSignal, ui->progressBar, &QProgressBar::setValue); connect(this, &MainWindow::progressSignal, ui->progressBar, &QProgressBar::setValue);
//connect(this, &MainWindow::speed, ui->progressBar, &MainWindow::setDlSpeed);
//connect(this, &MainWindow::errorSignal, this, &MainWindow::downloadingErrorSlot); //connect(this, &MainWindow::errorSignal, this, &MainWindow::downloadingErrorSlot);
connect(this, &MainWindow::stopDownloading, this, &MainWindow::cancelled); connect(this, &MainWindow::stopDownloading, this, &MainWindow::cancelled);
connect(config.buttonBox, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted())); connect(config.buttonBox, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted()));
@ -71,17 +72,6 @@ MainWindow::MainWindow(QWidget *parent)
ui->ktreewidgetsearchline->setCaseSensitivity(Qt::CaseInsensitive); // and set it case insensitive ui->ktreewidgetsearchline->setCaseSensitivity(Qt::CaseInsensitive); // and set it case insensitive
ui->treeWidget->setHeaderLabels({tr("Path"), tr("Type"), tr("Size")} ); // set header of columns of tree widget ui->treeWidget->setHeaderLabels({tr("Path"), tr("Type"), tr("Size")} ); // set header of columns of tree widget
// if last server exists in settings
if (this->settings.contains("connexion/lastServer"))
{
// set window to precedent server/port configuration
ui->portEdit->setText(this->settings.value("connexion/port").toString());
ui->khistorycombobox->setCurrentText(this->settings.value("connexion/lastServer").toString());
}else
{
ui->portEdit->text() = QString::number(this->connexion.port);
ui->khistorycombobox->clear();
}
// setting arrowcursor for treeWidget, listWidget and listDownload to arrow // setting arrowcursor for treeWidget, listWidget and listDownload to arrow
ui->treeWidget->setCursor(Qt::ArrowCursor); ui->treeWidget->setCursor(Qt::ArrowCursor);
@ -93,6 +83,18 @@ MainWindow::MainWindow(QWidget *parent)
loadSettings(); loadSettings();
// if last server exists in settings
if (this->settings.contains("connexion/lastServer"))
{
// set window to precedent server/port configuration
ui->portEdit->setText(this->settings.value("connexion/port").toString());
ui->khistorycombobox->setCurrentText(this->settings.value("connexion/lastServer").toString());
}else
{
ui->portEdit->setText(QString::number(this->connexion.port));
ui->khistorycombobox->clear();
}
//setting configuration window //setting configuration window
config.comboBox->setCurrentIndex(ui->toolBar->toolButtonStyle()); // setting combobox to saved settings config.comboBox->setCurrentIndex(ui->toolBar->toolButtonStyle()); // setting combobox to saved settings
@ -702,6 +704,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
// no downloading process launching it // no downloading process launching it
this->downloading.path = path; this->downloading.path = path;
this->downloading.server = this->connexion.server; this->downloading.server = this->connexion.server;
this->downloading.port = this->connexion.port;
this->downloading.service = this->connexion.service; this->downloading.service = this->connexion.service;
startDownloading(); startDownloading();
// wait 1 second to process start // wait 1 second to process start
@ -1048,6 +1051,7 @@ void MainWindow::loadDownloadList()
path.resize(pos); path.resize(pos);
pos = path.lastIndexOf(" => "); pos = path.lastIndexOf(" => ");
this->downloading.server = path.midRef(pos+4).toString(); this->downloading.server = path.midRef(pos+4).toString();
this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).toInt();
path.resize(pos); path.resize(pos);
this->downloading.path = path; this->downloading.path = path;
str = "Folder/" + this->downloading.server + "/" + this->downloading.service; str = "Folder/" + this->downloading.server + "/" + this->downloading.service;
@ -1097,3 +1101,8 @@ void MainWindow::on_actionExit_triggered()
{ {
quitApp(); quitApp();
} }
void MainWindow::setDlSpeed(QString speed)
{
speed.squeeze();
}

View File

@ -10,6 +10,7 @@
#include <QMainWindow> #include <QMainWindow>
#include <string> #include <string>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QList>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QProgressDialog> #include <QProgressDialog>
#include <QSettings> #include <QSettings>
@ -68,6 +69,7 @@ class Downloading
QString service; QString service;
QString path; QString path;
QString savePath; QString savePath;
int port;
QProcess * process = nullptr; QProcess * process = nullptr;
bool quit = false; bool quit = false;
void clear(); void clear();
@ -198,9 +200,12 @@ class MainWindow : public QMainWindow
void on_actionExit_triggered(); void on_actionExit_triggered();
void setDlSpeed(QString speed);
signals: signals:
void stopDownloading(QProcess *); void stopDownloading(QProcess *);
void progressSignal(int); void progressSignal(int);
void speed(QString);
void finishedSignal(bool = true); void finishedSignal(bool = true);
void fileName(QString); void fileName(QString);
//void errorSignal(QString); //void errorSignal(QString);