added context menu to download folders

This commit is contained in:
Daniel Tartavel 2023-02-02 17:14:04 +01:00
parent d70d081139
commit 5804e43d1f
5 changed files with 35 additions and 15 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.14.2, 2023-01-31T13:04:06. -->
<!-- Written by QtCreator 4.14.2, 2023-02-02T16:28:47. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View File

@ -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();

View File

@ -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<void> 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);
}

View File

@ -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();

View File

@ -250,7 +250,7 @@
<enum>Qt::WheelFocus</enum>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="toolTip">
<string>Click to add to download queue</string>
@ -396,14 +396,10 @@
<addaction name="actionAbout"/>
<addaction name="actionAbout_Qt"/>
</widget>
<action name="actionMenu">
<property name="text">
<string>Menu</string>
</property>
</action>
<action name="DefaultSaveFolder">
<property name="icon">
<iconset theme="system-file-manager"/>
<iconset theme="system-file-manager">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>Change save folder</string>
@ -414,7 +410,8 @@
</action>
<action name="actionAbout">
<property name="icon">
<iconset theme="help-about"/>
<iconset theme="help-about">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>About</string>
@ -422,7 +419,8 @@
</action>
<action name="actionAbout_Qt">
<property name="icon">
<iconset theme="help-browser"/>
<iconset theme="help-browser">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>About Qt</string>
@ -430,12 +428,21 @@
</action>
<action name="action_Settings">
<property name="icon">
<iconset theme="preferences-other"/>
<iconset theme="preferences-other">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>Settings</string>
</property>
</action>
<action name="actionDownload">
<property name="text">
<string>Download</string>
</property>
<property name="toolTip">
<string>Click on menu button to download the entire folder</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>