From 5804e43d1ff0a8ee90de416cc75fbaa83e1b68fd Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Thu, 2 Feb 2023 17:14:04 +0100 Subject: [PATCH] added context menu to download folders --- RsyncUI.pro.user | 2 +- downloadfile.cpp | 2 +- mainwindow.cpp | 15 +++++++++++++-- mainwindow.h | 4 +++- mainwindow.ui | 27 +++++++++++++++++---------- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/RsyncUI.pro.user b/RsyncUI.pro.user index b3262d3..c9c9e30 100644 --- a/RsyncUI.pro.user +++ b/RsyncUI.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/downloadfile.cpp b/downloadfile.cpp index 6b3e393..b2055a0 100644 --- a/downloadfile.cpp +++ b/downloadfile.cpp @@ -61,7 +61,7 @@ void downloadFile::download(MainWindow *mw) argv[1] = "--bwlimit=" + to_string(mw->connexion.bandwidthLimit) + mw->connexion.bandwidthLimitUnit; } argv[2] = "--port=" + to_string(mw->connexion.port); - argv[3] = "-P"; + argv[3] = "-aP"; argv[4] = d.server + "::" + d.service + "/" + d.path; argv[5] = d.savePath + "/"; argv[6].clear(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 4edadbb..8cf01b7 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -19,6 +19,9 @@ MainWindow::MainWindow(QWidget *parent) QCoreApplication::setOrganizationName("RsyncUI"); QCoreApplication::setApplicationName("RsyncUI"); + ui->treeWidget->addAction(ui->actionDownload); + + // init shortcut loadSettings(); config.setupUi(&Configuration); @@ -432,7 +435,7 @@ void MainWindow::on_listWidget_clicked() } //Slot activated when a file is clicked in the treeview -void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item) +void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadDir) { QFuture future; QFileDialog dialog; @@ -450,7 +453,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item) path = itemR->text(0).toStdString() + "/" + path; }; - if (item->text(1) == tr("File")) + if (item->text(1) == tr("File") or downloadDir == true) { // Item is a file this->downloading.path = path; @@ -761,3 +764,11 @@ void Downloading::clear() this->savePath.clear(); this->service.clear(); } + +void MainWindow::on_actionDownload_triggered() +{ + // action made in qt-designer and added in init function. + QTreeWidgetItem *item; + item = ui->treeWidget->currentItem(); + on_treeWidget_itemClicked(item, true); +} diff --git a/mainwindow.h b/mainwindow.h index 645e912..b046cc2 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -121,7 +121,7 @@ class MainWindow : public QMainWindow void on_listWidget_clicked(); - void on_treeWidget_itemClicked(QTreeWidgetItem *item); + void on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadDir = false); void downloadFinished(); @@ -141,6 +141,8 @@ class MainWindow : public QMainWindow void on_action_Settings_triggered(); + void on_actionDownload_triggered(); + public slots: void on_buttonBox_accepted(); diff --git a/mainwindow.ui b/mainwindow.ui index c3b4e16..c97aa3f 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -250,7 +250,7 @@ Qt::WheelFocus - Qt::NoContextMenu + Qt::ActionsContextMenu Click to add to download queue @@ -396,14 +396,10 @@ - - - Menu - - - + + .. Change save folder @@ -414,7 +410,8 @@ - + + .. About @@ -422,7 +419,8 @@ - + + .. About Qt @@ -430,12 +428,21 @@ - + + .. Settings + + + Download + + + Click on menu button to download the entire folder + +