From 4dbfa8fa97abe326567153275c4af716f226c8fe Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Tue, 31 Jan 2023 00:45:53 +0100 Subject: [PATCH] =?UTF-8?q?=20d=C3=A9bogage=20et=20modifications=20suite?= =?UTF-8?q?=20perte=20de=20code=20:-(=20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RsyncUI.pro.user | 2 +- downloadfile.cpp | 2 +- languages/fr_FR/RsyncUI_fr_FR.qm | Bin 5268 -> 5258 bytes languages/fr_FR/RsyncUI_fr_FR.ts | 61 ++++++++--------------- mainwindow.cpp | 80 ++++++++++++++++++++++--------- mainwindow.h | 4 +- 6 files changed, 81 insertions(+), 68 deletions(-) diff --git a/RsyncUI.pro.user b/RsyncUI.pro.user index 4ff0db9..b35dcef 100644 --- a/RsyncUI.pro.user +++ b/RsyncUI.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/downloadfile.cpp b/downloadfile.cpp index 9cae1bc..e0f00f6 100644 --- a/downloadfile.cpp +++ b/downloadfile.cpp @@ -59,7 +59,7 @@ void downloadFile::download(MainWindow *mw) } argv[2] = "--port=" + to_string(mw->connexion.port); argv[3] = "-P"; - argv[4] = mw->connexion.server + "::" + mw->downloading.service + "/" + mw->downloading.path; + argv[4] = mw->downloading.server + "::" + mw->downloading.service + "/" + mw->downloading.path; argv[5] = mw->downloading.savePath + "/"; argv[6].clear(); diff --git a/languages/fr_FR/RsyncUI_fr_FR.qm b/languages/fr_FR/RsyncUI_fr_FR.qm index 8d7dd482e78ad67a1c9907181b8e067720ca96a5..9a35396d28dab5a509d3b9e116b341aa50723edc 100644 GIT binary patch delta 346 zcmWNMJxD@v6vfZ;`F|hye5OGSg=SEo6hRIy5mwxJVf8Q5?;n(m} zydm==-YE?Ne2RaH&CtG>F0=-!%+ndBYaSL?ZUMo~R`P2=(iK%FTeyE!08{03k6yR|AwqDgRytq*1w7CcSl9>*E~0RZ}DROw)?emJ3ppta8r9 z$hEGNwpCJnnICig6s2K)E6~5PR|PTkMlS%?F?)0A?kYiG6@& ziMRl$`*FAC^?>yZljs8*+ad0O%_fOYU|Wn#F0j)e@fPm2A_e*|*!=^T@9_J10vNsx zU&RXwKQ`LMUceYLKI)_NUyT>)y%pwc3eYqso0Bd9zLhQKSAg1WmP(xyZ`cvn3Menu Menu - - help - Aide - Change save folder Changer le dossier de destination - - Default save folder - Dossier d'enregistrement - - - Bandwidth limit - Limite de bande passante - About @@ -164,10 +152,6 @@ Settings Paramètres - - debug - debug - Byte @@ -195,7 +179,7 @@ - + PB Po @@ -209,86 +193,81 @@ You click on file to enqueue it, and RyncUI Download one file a time Cliquez sur un fichier pour l'ajouter dans la file de téléchargement - + Path Chemin - + Size Taille - + Type Type - + Exiting will stop downloading, and will clear the download queue. Do you want to exit ? - Soritr stoppera le téléchargement et effacera la file des téléchargements. -Voulez-vous vraiment sortir du programme ? + Cela stoppera le téléchargement et effacera la file des téléchargements. +Voulez-vous vraiment arrêter le programme ? - + server does not exists Le serveur n'existe pas - - + + Dir - Dossier + Dir - - + File - + Version Version - + Licence License - + Author Auteur - + EMail Courriel - + Source code Code source - + Choose directory to save file Choisissez le dossier où enregistrer - + 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 ? - Client for rsync server - Client pour serveur rsync - - - + Do you want to delete this file from download queue ? Voulez-vous enlever ce fichier de la file de téléchargement ? diff --git a/mainwindow.cpp b/mainwindow.cpp index c8362a5..151850a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -30,12 +30,11 @@ MainWindow::MainWindow(QWidget *parent) connect(&downloadO, &downloadFile::finishedSignal, this, &MainWindow::downloadFinished); connect(this, &MainWindow::stopDownloading, &downloadO, &downloadFile::cancelled); connect(config.buttonBox, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted())); - connect(config.comboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &MainWindow::on_comboBox_currentIndexChanged); // init of widgets ui->ktreewidgetsearchline->setTreeWidget(ui->treeWidget); ui->ktreewidgetsearchline->setCaseSensitivity(Qt::CaseInsensitive); - ui->treeWidget->setHeaderLabels({tr("Type"), tr("Path"), tr("Size")} ); + ui->treeWidget->setHeaderLabels({tr("Path"), tr("Type"), tr("Size")} ); config.comboBox->setCurrentIndex(ui->toolBar->toolButtonStyle()); if (this->settings.contains("connexion/lastServer")) { @@ -150,13 +149,13 @@ void MainWindow::populateList() { if (validateServer(server.toStdString())) { - if (!this->settings.contains(server)) { cout << server.toStdString() << endl; // storing serverURL and port in settings this->settings.setValue(server, port); this->settings.sync(); + this->downloading.server = server.toStdString(); // storing in history of combobox ui->khistorycombobox->addToHistory(server); @@ -354,12 +353,12 @@ QTreeWidgetItem * MainWindow::addTreeRoot(QString name, QString fileSize, bool i // QTreeWidgetItem::setText(int column, const QString & text) if (isDir == true) { - treeItem->setText(0, "Dir"); + treeItem->setText(1, tr("Dir")); }else { - treeItem->setText(0,"File"); + treeItem->setText(1,tr("File")); } - treeItem->setText(1, name); + treeItem->setText(0, name); treeItem->setText(2, fileSize); return treeItem; @@ -374,12 +373,12 @@ QTreeWidgetItem * MainWindow::addTreeChild(QTreeWidgetItem *parent, QString name // QTreeWidgetItem::setText(int column, const QString & text) if (isDir == true) { - treeItem->setText(0, "Dir"); + treeItem->setText(1, tr("Dir")); }else { - treeItem->setText(0,"File"); + treeItem->setText(1,("File")); } - treeItem->setText(1, name); + treeItem->setText(0, name); treeItem->setText(2, fileSize); // QTreeWidgetItem::addChild(QTreeWidgetItem * child) @@ -391,8 +390,15 @@ QTreeWidgetItem * MainWindow::addTreeChild(QTreeWidgetItem *parent, QString name void MainWindow::on_listWidget_clicked() { vector v; + QString str; + v = explode(ui->listWidget->currentItem()->text().toStdString(), '\n', 2); this->downloading.service = v[0]; + str = QString::fromStdString("Folder/" + this->connexion.server + "/" + this->downloading.service); + if (this->settings.contains(str)) + { + this->downloading.savePath = this->settings.value(str).toString().toStdString(); + } populateTree(NULL); } @@ -403,18 +409,19 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item) QFileDialog dialog; QTreeWidgetItem * itemR; string path; + QString str; //item = ui->treeWidget->currentItem(); itemR = item; - path = item->text(1).toStdString(); + path = item->text(0).toStdString(); while(itemR->parent() != NULL) { itemR = itemR->parent(); - path = itemR->text(1).toStdString() + "/" + path; + path = itemR->text(0).toStdString() + "/" + path; }; - if (item->text(0) == "File") + if (item->text(1) == tr("File")) { // Item is a file this->downloading.path = path; @@ -423,11 +430,19 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item) on_DefaultSaveFolder_triggered(); }else if (this->downloading.pid == 0) { + str = QString::fromStdString("Folder/" + this->connexion.server + "/" + this->downloading.service); + if(this->settings.value(str).toString().isEmpty() and !this->downloading.savePath.empty()) + { + this->settings.setValue(str, this->downloading.savePath.c_str()); + this->settings.sync(); + } + this->downloading.server = this->connexion.server; startDownloading(); sleep(1); } - ui->listDownload->addItem(QString::fromStdString(this->downloading.path)); + str = QString::fromStdString(this->downloading.path + " => " + this->connexion.server + "/" + this->downloading.service); + ui->listDownload->addItem(str); }else { //Item is a Directory @@ -456,12 +471,28 @@ void MainWindow::stoppingDownload() // when download is finished, launch download of next file in queue void MainWindow::downloadFinished() { + string path; + int pos; + string str; + ui->progressBar->hide(); delete ui->listDownload->takeItem(0); this->downloading.pid = 0; if (ui->listDownload->count() != 0) { - this->downloading.path = ui->listDownload->item(0)->text().toStdString(); + path = ui->listDownload->item(0)->text().toStdString(); + pos = path.rfind("/"); + this->downloading.service = path.substr(pos+1); + path.resize(pos); + pos = path.rfind(" => "); + this->downloading.server = path.substr(pos+4); + path.resize(pos); + this->downloading.path = path; + str = "Folder/" + this->downloading.server + "/" + this->downloading.service; + if (this->settings.contains(str.c_str())) + { + this->downloading.savePath = this->settings.value(str.c_str()).toString().toStdString(); + } startDownloading(); } } @@ -566,10 +597,20 @@ void MainWindow::on_actionAbout_Qt_triggered() void MainWindow::on_DefaultSaveFolder_triggered() { QFileDialog dialog; + string folder; + string path; - this->downloading.savePath = dialog.getExistingDirectory(this, tr("Choose directory to save file"), QString::fromStdString(this->downloading.savePath), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks).toStdString(); - this->settings.setValue("Folder/", this->downloading.savePath.c_str()); - this->settings.sync(); + path = dialog.getExistingDirectory(this, tr("Choose directory to save file"), QString::fromStdString(this->downloading.savePath), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks).toStdString(); + if (!path.empty()) + { + this->downloading.savePath = path; + if (!this->downloading.service.empty() and !this->connexion.server.empty()) + { + folder = "Folder/" + this->connexion.server + "/" + this->downloading.service; + this->settings.setValue(folder.c_str(), this->downloading.savePath.c_str()); + this->settings.sync(); + } + } } // Activated when menu "settings" is clicked @@ -601,8 +642,3 @@ void MainWindow::on_buttonBox_accepted() this->settings.sync(); Configuration.hide(); } - -void MainWindow::on_comboBox_currentIndexChanged(int index) -{ - ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)index); -} diff --git a/mainwindow.h b/mainwindow.h index fc0c3df..82131af 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -50,9 +50,9 @@ class Connexion class Downloading { public: + std::string server; std::string service; std::string path; - std::string defaultSavePath; std::string savePath; int pid = 0; }; @@ -132,8 +132,6 @@ class MainWindow : public QMainWindow void on_action_Settings_triggered(); - void on_comboBox_currentIndexChanged(int index); - public slots: void on_buttonBox_accepted();