Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
cbb09fe258 | |||
fa7f3a1ca8 | |||
c9f85354a6 | |||
ab91309abd | |||
7f767b0576 | |||
9229d3523e | |||
7770813647 | |||
4b434fc393 | |||
5804e43d1f | |||
d70d081139 |
5
README_FR.md
Normal file
5
README_FR.md
Normal file
@ -0,0 +1,5 @@
|
||||
# RsyncUI
|
||||
|
||||
client Rsync - QT5 - KDE
|
||||
|
||||
#Compilation:
|
@ -4,12 +4,12 @@ Name=RsyncUI
|
||||
GenericName=rsync client
|
||||
Comment=Client for rsync servers
|
||||
Comment[fr]=Client pour serveur rsync
|
||||
Version=1.8.2
|
||||
Version=1.0
|
||||
Exec=RsyncUI
|
||||
Icon=
|
||||
Type=Application
|
||||
Terminal=false
|
||||
StartupNotify=true
|
||||
Categories=Networking;
|
||||
Keywords=internet;
|
||||
Categories=Network
|
||||
Keywords=internet,rsync
|
||||
|
||||
|
10
RsyncUI.pro
10
RsyncUI.pro
@ -44,8 +44,18 @@ else: unix:!android: target.path = /usr/bin/
|
||||
lang.path = /languages/fr_FR/
|
||||
lang.files = languages/fr_FR/*
|
||||
INSTALLS += lang
|
||||
INSTALLS += documentation
|
||||
INSTALLS += desktopfile
|
||||
INSTALLS += icon
|
||||
|
||||
RESOURCES +=
|
||||
|
||||
DISTFILES += \
|
||||
RsyncUI.desktop
|
||||
|
||||
documentation.path = /usr/share/doc/RsyncUI
|
||||
documentation.files = README*
|
||||
desktopfile.path = /usr/share/applications
|
||||
desktopfile.files = RsyncUI.desktop
|
||||
icon.path = /usr/share/icons/
|
||||
icon.files = RsyncUI.png
|
||||
|
@ -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>
|
||||
|
72
RsyncUI.spec
Normal file
72
RsyncUI.spec
Normal file
@ -0,0 +1,72 @@
|
||||
%define oname RsyncUI
|
||||
|
||||
Name: rsyncui
|
||||
Summary: Client for rsync server
|
||||
Version: 1.8.5
|
||||
Release: %mkrel 1
|
||||
License: GPLv3
|
||||
Group: Networking/Remote access
|
||||
Source0: %{oname}-%{version}.tar.gz
|
||||
Packager: dtux@free.fr
|
||||
Distribution: Mageia
|
||||
Url: https://www.librepc.fr
|
||||
Vendor: DTux
|
||||
BuildRequires: qmake
|
||||
BuildRequires: make
|
||||
BuildRequires: pkgconfig(Qt5Core)
|
||||
BuildRequires: pkgconfig(Qt5Gui)
|
||||
BuildRequires: pkgconfig(Qt5Concurrent)
|
||||
BuildRequires: pkgconfig(Qt5Widgets)
|
||||
BuildRequires: pkgconfig(Qt5Xml)
|
||||
BuildRequires: pkgconfig(libmagic)
|
||||
BuildRequires: cmake(KF5Completion)
|
||||
BuildRequires: cmake(KF5CoreAddons)
|
||||
BuildRequires: cmake(KF5I18n)
|
||||
BuildRequires: cmake(KF5DBusAddons)
|
||||
BuildRequires: cmake(KF5Config)
|
||||
BuildRequires: cmake(KF5ItemViews)
|
||||
BuildRequires: pstreams-devel
|
||||
BuildRequires: boost-devel
|
||||
|
||||
#Requires: kitemviews
|
||||
#Requires: kcompletion
|
||||
#Requires: kcoreaddons
|
||||
#Requires: kdbusaddons
|
||||
Requires: rsync
|
||||
Requires: bind-utils
|
||||
|
||||
%global debug_package %{nil}
|
||||
|
||||
%description
|
||||
RsyncUI can connect to an rsync server, get the list of services,
|
||||
and download files.
|
||||
|
||||
%prep
|
||||
%setup -q -n %{oname}
|
||||
|
||||
%build
|
||||
%make_build
|
||||
|
||||
%install
|
||||
#INSTALL_ROOT=%{BUILDROOT} make install
|
||||
|
||||
mkdir -p %{buildroot}%{_bindir}
|
||||
mkdir -p %{buildroot}%{_datadir}/applications/
|
||||
mkdir -p %{buildroot}%{_datadir}/icons/
|
||||
install -p -m 755 %{oname} %{buildroot}%{_bindir}/%{oname}
|
||||
install -p -m 644 %{oname}.desktop %{buildroot}%{_datadir}/applications/
|
||||
install -p -m 644 %{oname}.png %{buildroot}%{_datadir}/icons/
|
||||
|
||||
pushd languages
|
||||
for locale in *;
|
||||
do
|
||||
mkdir -p %{buildroot}%{_datadir}/locale/$locale/LC_MESSAGES
|
||||
install -m 644 $locale/*.qm "%{buildroot}%{_datadir}/locale/$locale/LC_MESSAGES/"
|
||||
done
|
||||
popd
|
||||
%find_lang %{oname} --with-qt
|
||||
|
||||
%files -f %{oname}.lang
|
||||
%{_bindir}/%{oname}
|
||||
%{_datadir}/applications/%{oname}.desktop
|
||||
%{_datadir}/icons/%{oname}.png
|
@ -47,6 +47,9 @@ void downloadFile::download(MainWindow *mw)
|
||||
vector<string> v;
|
||||
int value;
|
||||
char buffer[4096];
|
||||
Downloading d;
|
||||
|
||||
d = mw->downloading;
|
||||
|
||||
// Populating array with command and parameters for popen2
|
||||
argv[0] = "/usr/bin/rsync";
|
||||
@ -58,13 +61,13 @@ 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[4] = mw->downloading.server + "::" + mw->downloading.service + "/" + mw->downloading.path;
|
||||
argv[5] = mw->downloading.savePath + "/";
|
||||
argv[3] = "-aP";
|
||||
argv[4] = d.server + "::" + d.service + "/" + d.path;
|
||||
argv[5] = d.savePath + "/";
|
||||
argv[6].clear();
|
||||
|
||||
//launching downloading thread
|
||||
FILE * fp = popen2(argv, "r", mw->downloading.pid);
|
||||
FILE * fp = popen2(argv, "r", mw->pid);
|
||||
if (fp <= (FILE *) 0)
|
||||
{
|
||||
sprintf(buffer, "popen2() failed!: returning code:%d", fileno(fp));
|
||||
@ -98,7 +101,7 @@ void downloadFile::download(MainWindow *mw)
|
||||
}
|
||||
// download ended
|
||||
}
|
||||
pclose2(fp, mw->downloading.pid);
|
||||
pclose2(fp, mw->pid);
|
||||
|
||||
// ProgressBar to 100% and emit signal finished to main application
|
||||
emit progressSignal(100);
|
||||
|
Binary file not shown.
@ -127,64 +127,69 @@
|
||||
<translation>Barre d'outils</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.ui" line="401"/>
|
||||
<source>Menu</source>
|
||||
<translation>Menu</translation>
|
||||
<location filename="../../mainwindow.ui" line="440"/>
|
||||
<source>Download</source>
|
||||
<translation>Télécharger</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.ui" line="409"/>
|
||||
<location filename="../../mainwindow.ui" line="412"/>
|
||||
<location filename="../../mainwindow.ui" line="443"/>
|
||||
<source>Click on menu button to download the entire folder</source>
|
||||
<translation>Cliquer sur le bouton droit de la souris pour télécharger le dossier entier</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.ui" line="405"/>
|
||||
<location filename="../../mainwindow.ui" line="408"/>
|
||||
<source>Change save folder</source>
|
||||
<translation>Changer le dossier de destination</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.ui" line="420"/>
|
||||
<location filename="../../mainwindow.ui" line="417"/>
|
||||
<source>About</source>
|
||||
<translation>À propos</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.ui" line="428"/>
|
||||
<location filename="../../mainwindow.ui" line="426"/>
|
||||
<source>About Qt</source>
|
||||
<translation>À propos de Qt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.ui" line="436"/>
|
||||
<location filename="../../mainwindow.ui" line="435"/>
|
||||
<source>Settings</source>
|
||||
<translation>Paramètres</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="23"/>
|
||||
<location filename="../../mainwindow.cpp" line="28"/>
|
||||
<source>Byte</source>
|
||||
<translation>Octet</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="23"/>
|
||||
<location filename="../../mainwindow.cpp" line="28"/>
|
||||
<source>KB</source>
|
||||
<translation>Ko</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="23"/>
|
||||
<location filename="../../mainwindow.cpp" line="28"/>
|
||||
<source>MB</source>
|
||||
<translation>Mo</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="23"/>
|
||||
<location filename="../../mainwindow.cpp" line="28"/>
|
||||
<source>GB</source>
|
||||
<translation>Go</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="23"/>
|
||||
<location filename="../../mainwindow.cpp" line="28"/>
|
||||
<source>TB</source>
|
||||
<translation>To</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="23"/>
|
||||
<location filename="../../mainwindow.cpp" line="634"/>
|
||||
<location filename="../../mainwindow.cpp" line="28"/>
|
||||
<location filename="../../mainwindow.cpp" line="698"/>
|
||||
<source>PB</source>
|
||||
<translation>Po</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="26"/>
|
||||
<location filename="../../mainwindow.cpp" line="31"/>
|
||||
<source>Client for rsync server
|
||||
|
||||
You click on file to enqueue it, and RyncUI Download one file a time</source>
|
||||
@ -193,81 +198,91 @@ You click on file to enqueue it, and RyncUI Download one file a time</source>
|
||||
Cliquez sur un fichier pour l'ajouter dans la file de téléchargement</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="37"/>
|
||||
<location filename="../../mainwindow.cpp" line="42"/>
|
||||
<source>Path</source>
|
||||
<translation>Chemin</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="37"/>
|
||||
<location filename="../../mainwindow.cpp" line="42"/>
|
||||
<source>Size</source>
|
||||
<translation>Taille</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="37"/>
|
||||
<location filename="../../mainwindow.cpp" line="42"/>
|
||||
<source>Type</source>
|
||||
<translation>Type</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="79"/>
|
||||
<source>Exiting will stop downloading, and will clear the download queue.
|
||||
Do you want to exit ?</source>
|
||||
<translation>Cela stoppera le téléchargement et effacera la file des téléchargements.
|
||||
Voulez-vous vraiment arrêter le programme ?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="329"/>
|
||||
<location filename="../../mainwindow.cpp" line="361"/>
|
||||
<source>server does not exists</source>
|
||||
<translation>Le serveur n'existe pas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="356"/>
|
||||
<location filename="../../mainwindow.cpp" line="376"/>
|
||||
<location filename="../../mainwindow.cpp" line="388"/>
|
||||
<location filename="../../mainwindow.cpp" line="408"/>
|
||||
<source>Dir</source>
|
||||
<translation>Dir</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="359"/>
|
||||
<location filename="../../mainwindow.cpp" line="424"/>
|
||||
<location filename="../../mainwindow.cpp" line="391"/>
|
||||
<location filename="../../mainwindow.cpp" line="456"/>
|
||||
<source>File</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="582"/>
|
||||
<location filename="../../mainwindow.cpp" line="634"/>
|
||||
<source>Version</source>
|
||||
<translation>Version</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="583"/>
|
||||
<location filename="../../mainwindow.cpp" line="635"/>
|
||||
<source>Licence</source>
|
||||
<translation>License</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="584"/>
|
||||
<location filename="../../mainwindow.cpp" line="636"/>
|
||||
<source>Author</source>
|
||||
<translation>Auteur</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="585"/>
|
||||
<location filename="../../mainwindow.cpp" line="637"/>
|
||||
<source>EMail</source>
|
||||
<translation>Courriel</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="586"/>
|
||||
<location filename="../../mainwindow.cpp" line="638"/>
|
||||
<source>Source code</source>
|
||||
<translation>Code source</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="603"/>
|
||||
<location filename="../../mainwindow.cpp" line="663"/>
|
||||
<source>Choose directory to save file</source>
|
||||
<translation>Choisissez le dossier où enregistrer</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="512"/>
|
||||
<location filename="../../mainwindow.cpp" line="563"/>
|
||||
<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="524"/>
|
||||
<location filename="../../mainwindow.cpp" line="66"/>
|
||||
<source>A list of interrupted downloads exists, do you want to continue downloading ? or you can delete the list</source>
|
||||
<translation>Voulez-vous reprendre les téléchargements interrompus la fois précédente? ou vous pouvez supprimer la liste</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="68"/>
|
||||
<source>Remove</source>
|
||||
<translation>Supprimer</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="107"/>
|
||||
<source>Exiting will stop downloading, and will clear the download queue.
|
||||
You can save the list of downloads
|
||||
Do you want to exit ?</source>
|
||||
<translation>Si vous sortez, les téléchargements seront arrêter, mais vous pouvez enregistrer la liste pour la prochaine fois</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../mainwindow.cpp" line="575"/>
|
||||
<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>
|
||||
|
222
mainwindow.cpp
222
mainwindow.cpp
@ -12,11 +12,16 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
QAbstractButton * reply;
|
||||
QMessageBox msgBox;
|
||||
ui->setupUi(this);
|
||||
|
||||
QCoreApplication::setOrganizationName("RsyncUI");
|
||||
QCoreApplication::setApplicationName("RsyncUI");
|
||||
|
||||
// context menu for treewidget
|
||||
ui->treeWidget->addAction(ui->actionDownload);
|
||||
|
||||
// init shortcut
|
||||
loadSettings();
|
||||
config.setupUi(&Configuration);
|
||||
@ -54,6 +59,29 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
// Hiding progress bar
|
||||
ui->progressBar->hide();
|
||||
|
||||
if (this->settings.value("Downloads/rows").toInt() != 0)
|
||||
{
|
||||
this->settings.endArray();
|
||||
msgBox.setWindowTitle("RsyncUI");
|
||||
msgBox.setInformativeText(tr("A list of interrupted downloads exists, do you want to continue downloading ? or you can delete the list" ));
|
||||
|
||||
QPushButton *remove = msgBox.addButton(tr("Remove"), QMessageBox::ActionRole);
|
||||
QPushButton *yes = msgBox.addButton(QMessageBox::Yes);
|
||||
|
||||
msgBox.addButton(QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
|
||||
msgBox.exec();
|
||||
reply = msgBox.clickedButton();
|
||||
if(reply == yes)
|
||||
{
|
||||
loadDownloadList();
|
||||
}else if (reply == remove)
|
||||
{
|
||||
this->settings.remove("Downloads");
|
||||
}
|
||||
}
|
||||
|
||||
populateList();
|
||||
}
|
||||
|
||||
@ -76,19 +104,22 @@ void MainWindow::closeEvent (QCloseEvent *event)
|
||||
reply = QMessageBox::question(
|
||||
this,
|
||||
"RsyncUI",
|
||||
tr("Exiting will stop downloading, and will clear the download queue.\n Do you want to exit ?"),
|
||||
QMessageBox::Yes|QMessageBox::No,
|
||||
tr("Exiting will stop downloading, and will clear the download queue.\nYou can save the list of downloads\nDo you want to exit ?"),
|
||||
QMessageBox::Yes|QMessageBox::Save|QMessageBox::No,
|
||||
QMessageBox::No);
|
||||
if (reply == QMessageBox::No)
|
||||
{
|
||||
// continuing
|
||||
event->ignore();
|
||||
return;
|
||||
}else
|
||||
}else if(reply == QMessageBox::Yes)
|
||||
{
|
||||
// emission of signal to downloading thread and stopping
|
||||
emit (stopDownloading(this->downloading.pid));
|
||||
waitpid(this->downloading.pid, NULL, WUNTRACED);
|
||||
emit (stopDownloading(this->pid));
|
||||
waitpid(this->pid, NULL, WUNTRACED);
|
||||
}else
|
||||
{
|
||||
saveDownloadList();
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
@ -135,21 +166,22 @@ void MainWindow::populateList()
|
||||
this->connexion.server.assign(server.toStdString());
|
||||
this->connexion.port = port;
|
||||
|
||||
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
// verify if server is in history
|
||||
this->settings.beginGroup("connexion/server");
|
||||
if (this->settings.contains(server))
|
||||
{
|
||||
// server is in history and completing port value
|
||||
// server is in history => setting port value
|
||||
port = this->settings.value(server).toUInt();
|
||||
ui->portEdit->setText(QString::number(port));
|
||||
this->connexion.port = port;
|
||||
}
|
||||
|
||||
listServices();
|
||||
}else
|
||||
{
|
||||
if (!server.isEmpty() and (port > 0 and port < 65536))
|
||||
{
|
||||
if (validateServer(server.toStdString()))
|
||||
{
|
||||
if (!this->settings.contains(server))
|
||||
{
|
||||
cout << server.toStdString() << endl;
|
||||
// storing serverURL and port in settings
|
||||
@ -159,14 +191,14 @@ void MainWindow::populateList()
|
||||
|
||||
// storing in history of combobox
|
||||
ui->khistorycombobox->addToHistory(server);
|
||||
}
|
||||
|
||||
// "waiting" cursor
|
||||
// load and display rsync services of the rsync server
|
||||
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
listServices();
|
||||
QGuiApplication::restoreOverrideCursor(); //setOverrideCursor(Qt::ArrowCursor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
this->settings.endGroup();
|
||||
QGuiApplication::restoreOverrideCursor(); //setOverrideCursor(Qt::ArrowCursor);
|
||||
}
|
||||
@ -393,8 +425,8 @@ void MainWindow::on_listWidget_clicked()
|
||||
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);
|
||||
this->connexion.service = v[0];
|
||||
str = QString::fromStdString("Folder/" + this->connexion.server + "/" + this->connexion.service);
|
||||
if (this->settings.contains(str))
|
||||
{
|
||||
this->downloading.savePath = this->settings.value(str).toString().toStdString();
|
||||
@ -403,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;
|
||||
@ -421,32 +453,41 @@ 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;
|
||||
if (this->downloading.savePath.empty())
|
||||
{
|
||||
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);
|
||||
this->downloading.service = this->connexion.service;
|
||||
|
||||
// exists saving path in settings ?
|
||||
str = QString::fromStdString("Folder/" + this->connexion.server + "/" + this->downloading.service);
|
||||
if(!this->settings.contains(str))
|
||||
{
|
||||
// saving path do not exists, asking for it
|
||||
if(!on_DefaultSaveFolder_triggered())
|
||||
{
|
||||
cout << "no directory selectioned, ignoring download request";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// is there a downloading process ?
|
||||
if (this->pid == 0)
|
||||
{
|
||||
// no downloading process launching it
|
||||
startDownloading();
|
||||
// wit 1 second to process start
|
||||
//sleep(1);
|
||||
}
|
||||
|
||||
// Adding download in download list
|
||||
str = QString::fromStdString(this->downloading.path + " => " + this->connexion.server + "/" + this->downloading.service);
|
||||
ui->listDownload->addItem(str);
|
||||
}else
|
||||
{
|
||||
//Item is a Directory
|
||||
scanDir(this->connexion.server, this->connexion.port, item, this->downloading.service + "/" + path +"/");
|
||||
scanDir(this->connexion.server, this->connexion.port, item, this->connexion.service + "/" + path +"/");
|
||||
item->setExpanded(true);
|
||||
}
|
||||
|
||||
@ -465,7 +506,7 @@ void MainWindow::startDownloading()
|
||||
// Slot stopping download
|
||||
void MainWindow::stoppingDownload()
|
||||
{
|
||||
emit (stopDownloading(this->downloading.pid));
|
||||
emit (stopDownloading(this->pid));
|
||||
}
|
||||
|
||||
// when download is finished, launch download of next file in queue
|
||||
@ -475,9 +516,10 @@ void MainWindow::downloadFinished()
|
||||
int pos;
|
||||
string str;
|
||||
|
||||
this->pid = 0;
|
||||
ui->progressBar->hide();
|
||||
delete ui->listDownload->takeItem(0);
|
||||
this->downloading.pid = 0;
|
||||
this->downloading.clear();
|
||||
if (ui->listDownload->count() != 0)
|
||||
{
|
||||
path = ui->listDownload->item(0)->text().toStdString();
|
||||
@ -489,14 +531,23 @@ void MainWindow::downloadFinished()
|
||||
path.resize(pos);
|
||||
this->downloading.path = path;
|
||||
str = "Folder/" + this->downloading.server + "/" + this->downloading.service;
|
||||
if (this->settings.contains(str.c_str()))
|
||||
if (this->settings.contains(QString::fromStdString(str)))
|
||||
{
|
||||
this->downloading.savePath = this->settings.value(str.c_str()).toString().toStdString();
|
||||
this->downloading.savePath = this->settings.value(QString::fromStdString(str)).toString().toStdString();
|
||||
}else
|
||||
{
|
||||
if(!on_DefaultSaveFolder_triggered())
|
||||
{
|
||||
cout << "Error no save path so deleting download";
|
||||
downloadFinished();
|
||||
return;
|
||||
}
|
||||
}
|
||||
startDownloading();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Slot activated when a line is clicked in queue list
|
||||
void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item)
|
||||
{
|
||||
@ -514,7 +565,7 @@ void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item)
|
||||
QMessageBox::No);
|
||||
if (reply == QMessageBox::Yes)
|
||||
{
|
||||
emit (stopDownloading(this->downloading.pid));
|
||||
emit (stopDownloading(this->pid));
|
||||
}
|
||||
}else
|
||||
{
|
||||
@ -536,12 +587,12 @@ void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item)
|
||||
void MainWindow::loadSettings()
|
||||
{
|
||||
// restoring geometry and state of window and widgets
|
||||
this->restoreGeometry(settings.value("window/geometry").toByteArray());
|
||||
this->restoreState(settings.value("window/state").toByteArray());
|
||||
ui->treeWidget->header()->restoreState(settings.value("treeWidget/state").toByteArray());
|
||||
ui->splitter->restoreState(settings.value("splitter/state").toByteArray());
|
||||
ui->splitter_2->restoreState(settings.value("splitter2/state").toByteArray());
|
||||
ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)settings.value("toolbar/state").toInt());
|
||||
this->restoreGeometry(this->settings.value("window/geometry").toByteArray());
|
||||
this->restoreState(this->settings.value("window/state").toByteArray());
|
||||
ui->treeWidget->header()->restoreState(this->settings.value("treeWidget/state").toByteArray());
|
||||
ui->splitter->restoreState(this->settings.value("splitter/state").toByteArray());
|
||||
ui->splitter_2->restoreState(this->settings.value("splitter2/state").toByteArray());
|
||||
ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)this->settings.value("toolbar/state").toInt());
|
||||
|
||||
// loading connexion settings
|
||||
// loading servers history
|
||||
@ -578,6 +629,7 @@ void MainWindow::saveSettings()
|
||||
// About
|
||||
void MainWindow::on_actionAbout_triggered()
|
||||
{
|
||||
//TODO => initialisation
|
||||
QString text = this->about.description + "\n\n" +
|
||||
tr("Version") + ": " + this->about.version + "\n" +
|
||||
tr("Licence") + ": " + this->about.licence + "\n" +
|
||||
@ -594,23 +646,35 @@ void MainWindow::on_actionAbout_Qt_triggered()
|
||||
}
|
||||
|
||||
// Activated when menu "change folder" is clicked
|
||||
void MainWindow::on_DefaultSaveFolder_triggered()
|
||||
bool MainWindow::on_DefaultSaveFolder_triggered()
|
||||
{
|
||||
QFileDialog dialog;
|
||||
string folder;
|
||||
string path;
|
||||
|
||||
path = dialog.getExistingDirectory(this, tr("Choose directory to save file"), QString::fromStdString(this->downloading.savePath), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks).toStdString();
|
||||
if (this->connexion.service.empty())
|
||||
{
|
||||
QMessageBox::warning(
|
||||
NULL,
|
||||
"RsyncUI",
|
||||
"Since the save path is linked to service, you need to select a service before you can select a folder");
|
||||
return false;
|
||||
}
|
||||
path = dialog.getExistingDirectory(this, tr("Choose directory to save file"), QString::fromStdString(getpwuid(getuid())->pw_dir), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks).toStdString();
|
||||
if (!path.empty())
|
||||
{
|
||||
this->downloading.savePath = path;
|
||||
if (!this->downloading.service.empty() and !this->connexion.server.empty())
|
||||
if (!this->connexion.service.empty() and !this->connexion.server.empty())
|
||||
{
|
||||
folder = "Folder/" + this->connexion.server + "/" + this->downloading.service;
|
||||
folder = "Folder/" + this->connexion.server + "/" + this->connexion.service;
|
||||
this->settings.setValue(folder.c_str(), this->downloading.savePath.c_str());
|
||||
this->settings.sync();
|
||||
}
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Activated when menu "settings" is clicked
|
||||
@ -642,3 +706,69 @@ void MainWindow::on_buttonBox_accepted()
|
||||
this->settings.sync();
|
||||
Configuration.hide();
|
||||
}
|
||||
|
||||
// Saving download list
|
||||
void MainWindow::saveDownloadList()
|
||||
{
|
||||
int nRows;
|
||||
|
||||
nRows = ui->listDownload->count();
|
||||
//this->settings.beginWriteArray("Downloads/");
|
||||
this->settings.beginGroup("Downloads");
|
||||
this->settings.setValue("rows", nRows);
|
||||
for (int i = 0; i < nRows; i++)
|
||||
{
|
||||
this->settings.setValue(QString::number(i), ui->listDownload->item(i)->text());
|
||||
}
|
||||
this->settings.endGroup();
|
||||
this->settings.sync();
|
||||
}
|
||||
|
||||
void MainWindow::loadDownloadList()
|
||||
{
|
||||
string path;
|
||||
string str;
|
||||
int pos;
|
||||
|
||||
this->settings.beginGroup("Downloads");
|
||||
int size = this->settings.value("rows").toInt();
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
ui->listDownload->addItem(this->settings.value(QString::number(i)).toString());
|
||||
}
|
||||
this->settings.endGroup();
|
||||
|
||||
this->settings.remove("Downloads");
|
||||
this->settings.sync();
|
||||
|
||||
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(QString::fromStdString(str)))
|
||||
{
|
||||
this->downloading.savePath = this->settings.value(QString::fromStdString(str)).toString().toStdString();
|
||||
}
|
||||
startDownloading();
|
||||
}
|
||||
|
||||
void Downloading::clear()
|
||||
{
|
||||
this->path.clear();
|
||||
this->server.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);
|
||||
}
|
||||
|
50
mainwindow.h
50
mainwindow.h
@ -1,6 +1,7 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#define QT_USE_FAST_CONCATENATION
|
||||
#define QT_USE_FAST_OPERATOR_PLUS
|
||||
#include "ui_mainwindow.h"
|
||||
#include "ui_configuration.h"
|
||||
#include "downloadfile.h"
|
||||
@ -33,6 +34,8 @@
|
||||
#include <unistd.h>
|
||||
#include <magic.h>
|
||||
#include <QComboBox>
|
||||
#include <QStringBuilder>
|
||||
#include <pwd.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
@ -44,6 +47,8 @@ class Connexion
|
||||
int bandwidthLimit = 0;
|
||||
std::string bandwidthLimitUnit = "";
|
||||
std::string server;
|
||||
std::string service;
|
||||
|
||||
int port = 873;
|
||||
};
|
||||
|
||||
@ -54,14 +59,15 @@ class Downloading
|
||||
std::string service;
|
||||
std::string path;
|
||||
std::string savePath;
|
||||
int pid = 0;
|
||||
|
||||
void clear();
|
||||
};
|
||||
|
||||
class About
|
||||
{
|
||||
public:
|
||||
QString title = "RsyncUI";
|
||||
QString version = "1.6";
|
||||
QString version = "1.8.10";
|
||||
QString author = "Daniel TARTAVEL-JEANNOT";
|
||||
QString licence = "GPL_V3";
|
||||
QString description;
|
||||
@ -78,20 +84,7 @@ class MainWindow : public QMainWindow
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
QProgressDialog *progress;
|
||||
void displayTree();
|
||||
void populateTree(QTreeWidgetItem * parent);
|
||||
void populateList();
|
||||
void listServices();
|
||||
bool validateServer(std::string server);
|
||||
bool isIpAddress(std::string server);
|
||||
QTreeWidgetItem * addTreeRoot(QString name, QString description, bool isDir);
|
||||
QTreeWidgetItem * addTreeChild(QTreeWidgetItem *parent, QString name, QString size, bool isDir);
|
||||
void scanDir(std::string server, int portN, QTreeWidgetItem *parent = NULL, std::string path = "" );
|
||||
void startDownloading();
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
void closeEvent (QCloseEvent *event);
|
||||
|
||||
int pid = 0;
|
||||
Connexion connexion;
|
||||
Downloading downloading;
|
||||
downloadFile downloadO;
|
||||
@ -108,11 +101,27 @@ class MainWindow : public QMainWindow
|
||||
{'P', 4}
|
||||
};
|
||||
|
||||
void displayTree();
|
||||
void populateTree(QTreeWidgetItem * parent);
|
||||
void populateList();
|
||||
void listServices();
|
||||
bool validateServer(std::string server);
|
||||
bool isIpAddress(std::string server);
|
||||
QTreeWidgetItem * addTreeRoot(QString name, QString description, bool isDir);
|
||||
QTreeWidgetItem * addTreeChild(QTreeWidgetItem *parent, QString name, QString size, bool isDir);
|
||||
void scanDir(std::string server, int portN, QTreeWidgetItem *parent = NULL, std::string path = "" );
|
||||
void startDownloading();
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
void closeEvent (QCloseEvent *event);
|
||||
void saveDownloadList();
|
||||
void loadDownloadList();
|
||||
|
||||
private slots:
|
||||
|
||||
void on_listWidget_clicked();
|
||||
|
||||
void on_treeWidget_itemClicked(QTreeWidgetItem *item);
|
||||
void on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadDir = false);
|
||||
|
||||
void downloadFinished();
|
||||
|
||||
@ -126,18 +135,19 @@ class MainWindow : public QMainWindow
|
||||
|
||||
void on_khistorycombobox_currentIndexChanged(int);
|
||||
|
||||
void on_DefaultSaveFolder_triggered();
|
||||
bool on_DefaultSaveFolder_triggered();
|
||||
|
||||
void on_connectButton_clicked();
|
||||
|
||||
void on_action_Settings_triggered();
|
||||
|
||||
void on_actionDownload_triggered();
|
||||
|
||||
public slots:
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
signals:
|
||||
void stopDownloading(int);
|
||||
// void accepted();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user