diff --git a/RsyncUI.pro.user b/RsyncUI.pro.user index 798c730..c282129 100644 --- a/RsyncUI.pro.user +++ b/RsyncUI.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/RsyncUI_fr_FR.ts b/RsyncUI_fr_FR.ts index 33ea27f..30279ea 100644 --- a/RsyncUI_fr_FR.ts +++ b/RsyncUI_fr_FR.ts @@ -183,27 +183,27 @@ Paramètres - + KB Ko - + MB Mo - + GB Go - + TB To - + PB Po @@ -245,17 +245,17 @@ Cliquez sur un fichier pour le supprimer de la file et une fenêtre de confirmat <h2>Client pour serveur rsync<2><br><br>éaa - + Path Chemin - + Size Taille - + Type Type @@ -265,85 +265,85 @@ Cliquez sur un fichier pour le supprimer de la file et une fenêtre de confirmat Une liste de téléchargement existe, voulez-vous utiliser cette liste ? si non, elle sera effacée - + &Quit &Quitter - + Clicking Save button, You can save the list of downloads Vous pouvez enregistrer la liste des téléchargements en cliquant sur "enregister" - + Exiting will stop downloading, and will clear the download queue. Do you want to exit ? Si vous sortez, les téléchargements seront arrêter. Voulez-vous vraiment sortir ? - + The program will keep running in the system tray. To terminate the program, choose <b>Quit</b> in the context menu of the system tray entry. Le programme continue dans la boîte à miniatures. Pour quitter le programme cliquez sur l'icône <b>Quitter</b> ou dans les menu contextuel. - + server does not exists Le serveur n'existe pas - - + + Dir dossier - - + + File Doc - + File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory 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 - + File is already downloaded. Do you want to reload it ? The old file will be deleted Le document est déjà téléchargé. Voulez-vous le télécharger à nouveau ? L'ancien fichier sera effacé - + File is already downloading Le document est déjà en téléchargement - + Starting downloading Démarrage du téléchargement - + finished Terminé - + Rsync process crashed Le processus rsync à planté - + stopped by user stoppé par l'utilisateur - + Download Téléchargement @@ -378,52 +378,52 @@ Voulez-vous vraiment sortir ? Code source - + Since the save path is linked to service, you need to select a service before you can select a folder Vous devez sélectionnez un service pour pouvoir sélectionnez un dossier par défaut - + Choose folder where to save file Choisissez un dossier où enregistrer le document - + Do you want to stop downloading and delete this file from download queue ? Voulez-vous arrêter le téléchargement et enlever ce fichier de la file de téléchargement ? - + Do you want to delete this file from download queue ? Voulez-vous enlever ce fichier de la file de téléchargement ? - + The process failed to start. Either the invoked program is missing, or you may have insufficient permissions or resources to invoke the program. Le processus échoué, soit le programme est manquant, soit vous n'avez pas l'autorisation de l'exécuter. - + The process crashed some time after starting successfully. Le processus à planté après avoir démarré avec succès. - + The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again. La fonction waitFor...() a dépassé la limite de temps, you pouvez essayer de la relancer. - + 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. Une erreur est survenue lors de l'envoi des données vers le processus. Le processus est peut être arrté ou il a fermé son canal d'entrée. - + An error occurred when attempting to read from the process. For example, the process may not be running. Une erreur est survenue lors de la lecturee de données, le processus est probablement arrêté. - + An unknown error occurred. This is the default return value of error(). Une erreur inconnue est survenue. C'est la valeur de retour par défaut de error(). diff --git a/downloadfile.cpp b/downloadfile.cpp index 43cba48..1bbd803 100644 --- a/downloadfile.cpp +++ b/downloadfile.cpp @@ -49,7 +49,7 @@ void MainWindow::download() { 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 << this->downloading.server + "::" + this->downloading.service + "/" + this->downloading.path << this->downloading.savePath + "/"; @@ -69,32 +69,50 @@ void MainWindow::readRsyncOutput() bool flag = false; int value; int pos; + static QString dlSpeed; + QStringList list; + static QString filename; + int i; + int listSize; while(!flag) { + list.clear(); line = QString::fromUtf8(this->downloading.process->readLine()); if (line.isEmpty()) { flag = true; break; - } - pos = line.indexOf("%"); - if (pos != -1) - { - line.resize(pos); - pos = line.lastIndexOf(' '); - if (pos != -1) - { - line.remove(0, pos); - value = line.toInt(); - // sending progress to Main window - emit progressSignal(value); - } }else { - if (!line.contains("receiving")) + pos = line.indexOf("%"); + if (pos != -1) { - emit fileName(line.remove(QChar('\n'), Qt::CaseInsensitive) + " %p%"); + 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(' '); + if (pos != -1) + { + line.remove(0, pos); + value = line.toInt();*/ + // sending progress to Main window + emit progressSignal(value); + emit fileName(filename + " %p%" + "\t " + dlSpeed); + } + }else + { + if (!line.contains("receiving")) + { + filename = line.remove(QChar('\n'), Qt::CaseInsensitive); + emit fileName(filename + " %p%\t " + dlSpeed); + } } } } diff --git a/mainwindow.cpp b/mainwindow.cpp index 98257c9..7fe1a91 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -61,6 +61,7 @@ MainWindow::MainWindow(QWidget *parent) // connectors connect(this, &MainWindow::fileName, ui->progressBar, &QProgressBar::setFormat); 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::stopDownloading, this, &MainWindow::cancelled); 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->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 ui->treeWidget->setCursor(Qt::ArrowCursor); @@ -93,6 +83,18 @@ MainWindow::MainWindow(QWidget *parent) 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 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 this->downloading.path = path; this->downloading.server = this->connexion.server; + this->downloading.port = this->connexion.port; this->downloading.service = this->connexion.service; startDownloading(); // wait 1 second to process start @@ -1048,6 +1051,7 @@ void MainWindow::loadDownloadList() path.resize(pos); pos = path.lastIndexOf(" => "); this->downloading.server = path.midRef(pos+4).toString(); + this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).toInt(); path.resize(pos); this->downloading.path = path; str = "Folder/" + this->downloading.server + "/" + this->downloading.service; @@ -1097,3 +1101,8 @@ void MainWindow::on_actionExit_triggered() { quitApp(); } + +void MainWindow::setDlSpeed(QString speed) +{ + speed.squeeze(); +} diff --git a/mainwindow.h b/mainwindow.h index dde7341..a5031b1 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,7 @@ class Downloading QString service; QString path; QString savePath; + int port; QProcess * process = nullptr; bool quit = false; void clear(); @@ -198,9 +200,12 @@ class MainWindow : public QMainWindow void on_actionExit_triggered(); + void setDlSpeed(QString speed); + signals: void stopDownloading(QProcess *); void progressSignal(int); + void speed(QString); void finishedSignal(bool = true); void fileName(QString); //void errorSignal(QString);