-corrected bug

- added  warning when selecting a file which is already in download
  queue
This commit is contained in:
Daniel Tartavel 2023-02-11 13:40:46 +01:00
parent 0b60543ff3
commit f73174216a
3 changed files with 50 additions and 31 deletions

View File

@ -248,62 +248,67 @@ Voulez-vous vraiment sortir ?</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="456"/>
<location filename="mainwindow.cpp" line="553"/>
<location filename="mainwindow.cpp" line="540"/>
<source>File</source>
<translation>Doc</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="534"/>
<location filename="mainwindow.cpp" line="549"/>
<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>
</message>
<message>
<location filename="mainwindow.cpp" line="615"/>
<location filename="mainwindow.cpp" line="584"/>
<source>File is already downloading</source>
<translation>Le document est déjà en téléchargement</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="628"/>
<source>Rsync process crashed</source>
<translation>Le processus rsync à planté</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="770"/>
<location filename="mainwindow.cpp" line="784"/>
<source>Version</source>
<translation>Version</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="771"/>
<location filename="mainwindow.cpp" line="785"/>
<source>Licence</source>
<translation>License</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="772"/>
<location filename="mainwindow.cpp" line="786"/>
<source>Author</source>
<translation>Auteur</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="773"/>
<location filename="mainwindow.cpp" line="787"/>
<source>EMail</source>
<translation>Courriel</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="774"/>
<location filename="mainwindow.cpp" line="788"/>
<source>Source code</source>
<translation>Code source</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="797"/>
<location filename="mainwindow.cpp" line="811"/>
<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>
</message>
<message>
<location filename="mainwindow.cpp" line="802"/>
<location filename="mainwindow.cpp" line="816"/>
<source>Choose folder where to save file</source>
<translation>Choisissez un dossier enregistrer le document</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="688"/>
<location filename="mainwindow.cpp" line="702"/>
<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>
</message>
<message>
<location filename="mainwindow.cpp" line="702"/>
<location filename="mainwindow.cpp" line="716"/>
<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>
</message>

Binary file not shown.

View File

@ -524,25 +524,12 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
cout << "no directory selectioned, ignoring download request";
return;
}
}
if (QFile::exists(this->downloading.savePath + "/" + path))
}else
{
reply = QMessageBox::question(
this,
"RsyncUI",
tr("File is already downloaded. Do you want to reload it ? The old file will be deleted"),
QMessageBox::Yes|QMessageBox::No,
QMessageBox::No);
if (reply == QMessageBox::No)
{
return;
}else
{
QFile::remove(this->downloading.savePath + "/" + path);
}
this->downloading.savePath = this->settings.value(str).toString();
}
while(itemR->parent() != NULL)
{
itemR = itemR->parent();
@ -553,6 +540,25 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
if (item->text(1) == tr("File") or downloadDir == true)
{
// Item is a file
// searching if file exists in savepath
if (QFile::exists(this->downloading.savePath + "/" + path))
{
reply = QMessageBox::question(
this,
"RsyncUI",
tr("File is already downloaded. Do you want to reload it ? The old file will be deleted"),
QMessageBox::Yes|QMessageBox::No,
QMessageBox::No);
if (reply == QMessageBox::No)
{
return;
}else
{
QFile::remove(this->downloading.savePath + "/" + path);
}
}
if(ui->listDownload->findItems(path, Qt::MatchStartsWith).empty())
{
// is there a downloading process ?
@ -570,6 +576,13 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
// Adding download in download list
str = path + " => " + this->connexion.server + "/" + this->connexion.service;
ui->listDownload->addItem(str);
}else
{
QMessageBox::warning(
this,
"RsyncUI",
tr("File is already downloading" )
);
}
}else
{
@ -628,7 +641,7 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
disconnect(this->downloading.process, 0, 0, 0);
// reset variables and window
this->downloading.process= nullptr;
this->downloading.process = nullptr;
ui->progressBar->hide();
delete ui->listDownload->takeItem(0);
this->downloading.clear();
@ -653,7 +666,7 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
path.resize(pos);
this->downloading.path = path;
// save path exists in settings ?
// savepath exists in settings ?
str = "Folder/" + this->downloading.server + "/" + this->downloading.service;
if (this->settings.contains(str))
{
@ -671,6 +684,7 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
}
}
}
saveDownloadList();
}