débogage et modifications suite perte de code :-( )

This commit is contained in:
Daniel Tartavel 2023-01-31 00:45:53 +01:00
parent fe74ab906f
commit 4dbfa8fa97
6 changed files with 81 additions and 68 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-01-28T00:30:34. --> <!-- Written by QtCreator 4.14.2, 2023-01-30T17:56:05. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -59,7 +59,7 @@ void downloadFile::download(MainWindow *mw)
} }
argv[2] = "--port=" + to_string(mw->connexion.port); argv[2] = "--port=" + to_string(mw->connexion.port);
argv[3] = "-P"; 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[5] = mw->downloading.savePath + "/";
argv[6].clear(); argv[6].clear();

Binary file not shown.

View File

@ -131,24 +131,12 @@
<source>Menu</source> <source>Menu</source>
<translation>Menu</translation> <translation>Menu</translation>
</message> </message>
<message>
<source>help</source>
<translation type="vanished">Aide</translation>
</message>
<message> <message>
<location filename="../../mainwindow.ui" line="409"/> <location filename="../../mainwindow.ui" line="409"/>
<location filename="../../mainwindow.ui" line="412"/> <location filename="../../mainwindow.ui" line="412"/>
<source>Change save folder</source> <source>Change save folder</source>
<translation>Changer le dossier de destination</translation> <translation>Changer le dossier de destination</translation>
</message> </message>
<message>
<source>Default save folder</source>
<translation type="vanished">Dossier d&apos;enregistrement</translation>
</message>
<message>
<source>Bandwidth limit</source>
<translation type="vanished">Limite de bande passante</translation>
</message>
<message> <message>
<location filename="../../mainwindow.ui" line="420"/> <location filename="../../mainwindow.ui" line="420"/>
<source>About</source> <source>About</source>
@ -164,10 +152,6 @@
<source>Settings</source> <source>Settings</source>
<translation>Paramètres</translation> <translation>Paramètres</translation>
</message> </message>
<message>
<source>debug</source>
<translation type="vanished">debug</translation>
</message>
<message> <message>
<location filename="../../mainwindow.cpp" line="23"/> <location filename="../../mainwindow.cpp" line="23"/>
<source>Byte</source> <source>Byte</source>
@ -195,7 +179,7 @@
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="23"/> <location filename="../../mainwindow.cpp" line="23"/>
<location filename="../../mainwindow.cpp" line="614"/> <location filename="../../mainwindow.cpp" line="634"/>
<source>PB</source> <source>PB</source>
<translation>Po</translation> <translation>Po</translation>
</message> </message>
@ -209,86 +193,81 @@ You click on file to enqueue it, and RyncUI Download one file a time</source>
Cliquez sur un fichier pour l&apos;ajouter dans la file de téléchargement</translation> Cliquez sur un fichier pour l&apos;ajouter dans la file de téléchargement</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="38"/> <location filename="../../mainwindow.cpp" line="37"/>
<source>Path</source> <source>Path</source>
<translation>Chemin</translation> <translation>Chemin</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="38"/> <location filename="../../mainwindow.cpp" line="37"/>
<source>Size</source> <source>Size</source>
<translation>Taille</translation> <translation>Taille</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="38"/> <location filename="../../mainwindow.cpp" line="37"/>
<source>Type</source> <source>Type</source>
<translation>Type</translation> <translation>Type</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="80"/> <location filename="../../mainwindow.cpp" line="79"/>
<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>Soritr stoppera le téléchargement et effacera la file des téléchargements. <translation>Cela stoppera le téléchargement et effacera la file des téléchargements.
Voulez-vous vraiment sortir du programme ?</translation> Voulez-vous vraiment arrêter le programme ?</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="328"/> <location filename="../../mainwindow.cpp" line="329"/>
<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="355"/> <location filename="../../mainwindow.cpp" line="356"/>
<location filename="../../mainwindow.cpp" line="375"/> <location filename="../../mainwindow.cpp" line="376"/>
<source>Dir</source> <source>Dir</source>
<translation>Dossier</translation> <translation>Dir</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="358"/> <location filename="../../mainwindow.cpp" line="359"/>
<location filename="../../mainwindow.cpp" line="378"/>
<location filename="../../mainwindow.cpp" line="424"/> <location filename="../../mainwindow.cpp" line="424"/>
<source>File</source> <source>File</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="564"/> <location filename="../../mainwindow.cpp" line="582"/>
<source>Version</source> <source>Version</source>
<translation>Version</translation> <translation>Version</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="565"/> <location filename="../../mainwindow.cpp" line="583"/>
<source>Licence</source> <source>Licence</source>
<translation>License</translation> <translation>License</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="566"/> <location filename="../../mainwindow.cpp" line="584"/>
<source>Author</source> <source>Author</source>
<translation>Auteur</translation> <translation>Auteur</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="567"/> <location filename="../../mainwindow.cpp" line="585"/>
<source>EMail</source> <source>EMail</source>
<translation>Courriel</translation> <translation>Courriel</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="568"/> <location filename="../../mainwindow.cpp" line="586"/>
<source>Source code</source> <source>Source code</source>
<translation>Code source</translation> <translation>Code source</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="590"/> <location filename="../../mainwindow.cpp" line="603"/>
<source>Choose directory to save file</source> <source>Choose directory to save file</source>
<translation>Choisissez le dossier enregistrer</translation> <translation>Choisissez le dossier enregistrer</translation>
</message> </message>
<message> <message>
<location filename="../../mainwindow.cpp" line="497"/> <location filename="../../mainwindow.cpp" line="512"/>
<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>
<source>Client for rsync server</source> <location filename="../../mainwindow.cpp" line="524"/>
<translation type="vanished">Client pour serveur rsync</translation>
</message>
<message>
<location filename="../../mainwindow.cpp" line="509"/>
<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>

View File

@ -30,12 +30,11 @@ MainWindow::MainWindow(QWidget *parent)
connect(&downloadO, &downloadFile::finishedSignal, this, &MainWindow::downloadFinished); connect(&downloadO, &downloadFile::finishedSignal, this, &MainWindow::downloadFinished);
connect(this, &MainWindow::stopDownloading, &downloadO, &downloadFile::cancelled); connect(this, &MainWindow::stopDownloading, &downloadO, &downloadFile::cancelled);
connect(config.buttonBox, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted())); connect(config.buttonBox, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted()));
connect(config.comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MainWindow::on_comboBox_currentIndexChanged);
// init of widgets // init of widgets
ui->ktreewidgetsearchline->setTreeWidget(ui->treeWidget); ui->ktreewidgetsearchline->setTreeWidget(ui->treeWidget);
ui->ktreewidgetsearchline->setCaseSensitivity(Qt::CaseInsensitive); 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()); config.comboBox->setCurrentIndex(ui->toolBar->toolButtonStyle());
if (this->settings.contains("connexion/lastServer")) if (this->settings.contains("connexion/lastServer"))
{ {
@ -150,13 +149,13 @@ void MainWindow::populateList()
{ {
if (validateServer(server.toStdString())) if (validateServer(server.toStdString()))
{ {
if (!this->settings.contains(server)) if (!this->settings.contains(server))
{ {
cout << server.toStdString() << endl; cout << server.toStdString() << endl;
// storing serverURL and port in settings // storing serverURL and port in settings
this->settings.setValue(server, port); this->settings.setValue(server, port);
this->settings.sync(); this->settings.sync();
this->downloading.server = server.toStdString();
// storing in history of combobox // storing in history of combobox
ui->khistorycombobox->addToHistory(server); ui->khistorycombobox->addToHistory(server);
@ -354,12 +353,12 @@ QTreeWidgetItem * MainWindow::addTreeRoot(QString name, QString fileSize, bool i
// QTreeWidgetItem::setText(int column, const QString & text) // QTreeWidgetItem::setText(int column, const QString & text)
if (isDir == true) if (isDir == true)
{ {
treeItem->setText(0, "Dir"); treeItem->setText(1, tr("Dir"));
}else }else
{ {
treeItem->setText(0,"File"); treeItem->setText(1,tr("File"));
} }
treeItem->setText(1, name); treeItem->setText(0, name);
treeItem->setText(2, fileSize); treeItem->setText(2, fileSize);
return treeItem; return treeItem;
@ -374,12 +373,12 @@ QTreeWidgetItem * MainWindow::addTreeChild(QTreeWidgetItem *parent, QString name
// QTreeWidgetItem::setText(int column, const QString & text) // QTreeWidgetItem::setText(int column, const QString & text)
if (isDir == true) if (isDir == true)
{ {
treeItem->setText(0, "Dir"); treeItem->setText(1, tr("Dir"));
}else }else
{ {
treeItem->setText(0,"File"); treeItem->setText(1,("File"));
} }
treeItem->setText(1, name); treeItem->setText(0, name);
treeItem->setText(2, fileSize); treeItem->setText(2, fileSize);
// QTreeWidgetItem::addChild(QTreeWidgetItem * child) // QTreeWidgetItem::addChild(QTreeWidgetItem * child)
@ -391,8 +390,15 @@ QTreeWidgetItem * MainWindow::addTreeChild(QTreeWidgetItem *parent, QString name
void MainWindow::on_listWidget_clicked() void MainWindow::on_listWidget_clicked()
{ {
vector<string> v; vector<string> v;
QString str;
v = explode(ui->listWidget->currentItem()->text().toStdString(), '\n', 2); v = explode(ui->listWidget->currentItem()->text().toStdString(), '\n', 2);
this->downloading.service = v[0]; 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); populateTree(NULL);
} }
@ -403,18 +409,19 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item)
QFileDialog dialog; QFileDialog dialog;
QTreeWidgetItem * itemR; QTreeWidgetItem * itemR;
string path; string path;
QString str;
//item = ui->treeWidget->currentItem(); //item = ui->treeWidget->currentItem();
itemR = item; itemR = item;
path = item->text(1).toStdString(); path = item->text(0).toStdString();
while(itemR->parent() != NULL) while(itemR->parent() != NULL)
{ {
itemR = itemR->parent(); 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 // Item is a file
this->downloading.path = path; this->downloading.path = path;
@ -423,11 +430,19 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item)
on_DefaultSaveFolder_triggered(); on_DefaultSaveFolder_triggered();
}else if (this->downloading.pid == 0) }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(); startDownloading();
sleep(1); 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 }else
{ {
//Item is a Directory //Item is a Directory
@ -456,12 +471,28 @@ void MainWindow::stoppingDownload()
// when download is finished, launch download of next file in queue // when download is finished, launch download of next file in queue
void MainWindow::downloadFinished() void MainWindow::downloadFinished()
{ {
string path;
int pos;
string str;
ui->progressBar->hide(); ui->progressBar->hide();
delete ui->listDownload->takeItem(0); delete ui->listDownload->takeItem(0);
this->downloading.pid = 0; this->downloading.pid = 0;
if (ui->listDownload->count() != 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(); startDownloading();
} }
} }
@ -566,10 +597,20 @@ void MainWindow::on_actionAbout_Qt_triggered()
void MainWindow::on_DefaultSaveFolder_triggered() void MainWindow::on_DefaultSaveFolder_triggered()
{ {
QFileDialog dialog; 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(); path = 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()); 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(); this->settings.sync();
}
}
} }
// Activated when menu "settings" is clicked // Activated when menu "settings" is clicked
@ -601,8 +642,3 @@ void MainWindow::on_buttonBox_accepted()
this->settings.sync(); this->settings.sync();
Configuration.hide(); Configuration.hide();
} }
void MainWindow::on_comboBox_currentIndexChanged(int index)
{
ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)index);
}

View File

@ -50,9 +50,9 @@ class Connexion
class Downloading class Downloading
{ {
public: public:
std::string server;
std::string service; std::string service;
std::string path; std::string path;
std::string defaultSavePath;
std::string savePath; std::string savePath;
int pid = 0; int pid = 0;
}; };
@ -132,8 +132,6 @@ class MainWindow : public QMainWindow
void on_action_Settings_triggered(); void on_action_Settings_triggered();
void on_comboBox_currentIndexChanged(int index);
public slots: public slots:
void on_buttonBox_accepted(); void on_buttonBox_accepted();