Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
fe74ab906f | |||
295c914b12 | |||
434b430869 | |||
0648a06dbc | |||
ff7a75e168 | |||
149eb24590 | |||
012573f89d | |||
eb7795c791 | |||
d1e45b8ba8 |
@ -31,7 +31,7 @@ FORMS += \
|
|||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
|
|
||||||
TRANSLATIONS += \
|
TRANSLATIONS += \
|
||||||
languages/fr/RsyncUI_fr_FR.ts
|
languages/fr_FR/RsyncUI_fr_FR.ts
|
||||||
|
|
||||||
INCLUDEPATH += \
|
INCLUDEPATH += \
|
||||||
/usr/include/KF5
|
/usr/include/KF5
|
||||||
@ -41,6 +41,8 @@ qnx: target.path = /tmp/$${TARGET}/bin
|
|||||||
else: unix:!android: target.path = /usr/bin/
|
else: unix:!android: target.path = /usr/bin/
|
||||||
!isEmpty(target.path): INSTALLS += target
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
lang.path = /languages
|
lang.path = /languages/fr_FR/
|
||||||
lang.files = languages/*
|
lang.files = languages/fr_FR/*
|
||||||
INSTALLS += lang
|
INSTALLS += lang
|
||||||
|
|
||||||
|
RESOURCES +=
|
||||||
|
@ -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-11T01:16:59. -->
|
<!-- Written by QtCreator 4.14.2, 2023-01-28T00:30:34. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
BIN
RsyncUI_fr_FR.qm
BIN
RsyncUI_fr_FR.qm
Binary file not shown.
110
configuration.ui
110
configuration.ui
@ -10,9 +10,12 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>300</height>
|
<height>163</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::DefaultContextMenu</enum>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Configuration</string>
|
<string>Configuration</string>
|
||||||
</property>
|
</property>
|
||||||
@ -22,17 +25,17 @@
|
|||||||
<x>9</x>
|
<x>9</x>
|
||||||
<y>9</y>
|
<y>9</y>
|
||||||
<width>381</width>
|
<width>381</width>
|
||||||
<height>251</height>
|
<height>101</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="1">
|
<property name="sizeConstraint">
|
||||||
<widget class="QSpinBox" name="spinBox">
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
<property name="alignment">
|
</property>
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<item row="1" column="0">
|
||||||
</property>
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="maximum">
|
<property name="text">
|
||||||
<number>1024</number>
|
<string>Toolbar view</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -43,6 +46,22 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="spinBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Enter the bandwidth limit (0 to 1024)</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTipDuration">
|
||||||
|
<number>5000</number>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>1024</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QComboBox" name="UnitCombobox">
|
<widget class="QComboBox" name="UnitCombobox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -52,7 +71,10 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string extracomment="Unit of bandwidth"/>
|
<string extracomment="Unit of bandwidth">Select th unit of bandwidth limit in Bytes, KiloBytes, MegaBytes, GigaBytes or PetaBytes</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTipDuration">
|
||||||
|
<number>5000</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>-1</number>
|
<number>-1</number>
|
||||||
@ -65,17 +87,55 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBox">
|
||||||
|
<property name="maxVisibleItems">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="maxCount">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Icon only</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Text only</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Text beside icon</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Text under icon</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Text follow icon</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>70</x>
|
<x>60</x>
|
||||||
<y>260</y>
|
<y>110</y>
|
||||||
<width>321</width>
|
<width>321</width>
|
||||||
<height>34</height>
|
<height>34</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::NoContextMenu</enum>
|
||||||
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -86,35 +146,19 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Configuration</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>Configuration</receiver>
|
<receiver>Configuration</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>hide()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>316</x>
|
<x>220</x>
|
||||||
<y>260</y>
|
<y>126</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>286</x>
|
<x>199</x>
|
||||||
<y>274</y>
|
<y>81</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -19,59 +19,70 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
// Initialization de la class
|
||||||
downloadFile::downloadFile()
|
downloadFile::downloadFile()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Slot activated when download is cancelled
|
||||||
void downloadFile::cancelled(int pid)
|
void downloadFile::cancelled(int pid)
|
||||||
{
|
{
|
||||||
if (kill(pid, SIGTERM) == -1)
|
if (pid == 0)
|
||||||
{
|
{
|
||||||
//TODO gestion erreur kill
|
perror("Pid = 0 : I do not kill"); // Error rsync process not launched so it can't be killed
|
||||||
|
}else if (kill(pid, SIGTERM) == -1)
|
||||||
|
{
|
||||||
|
//TODO managing error of kill
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// launch a rsync processus downloading a file
|
||||||
void downloadFile::download(MainWindow *mw)
|
void downloadFile::download(MainWindow *mw)
|
||||||
{
|
{
|
||||||
string line;
|
string line;
|
||||||
string errorRsync;
|
string errorRsync;
|
||||||
int pos;
|
int pos;
|
||||||
array<string, 7> argv;
|
array<string,8> argv;
|
||||||
stringstream output;
|
stringstream output;
|
||||||
vector<string> v;
|
vector<string> v;
|
||||||
int value;
|
int value;
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
|
|
||||||
|
// Populating array with command and parameters for popen2
|
||||||
argv[0] = "/usr/bin/rsync";
|
argv[0] = "/usr/bin/rsync";
|
||||||
if (mw->connexion.bandwidthLimit == 0)
|
if (mw->connexion.bandwidthLimit == 0)
|
||||||
{
|
{
|
||||||
argv[1] = "--bwlimit=1000P";
|
argv[1] = "--bwlimit=1000P";
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
output << mw->connexion.bandwidthLimit;
|
argv[1] = "--bwlimit=" + to_string(mw->connexion.bandwidthLimit) + mw->connexion.bandwidthLimitUnit;
|
||||||
argv[1] = "--bwlimit=" + output.str() + mw->connexion.bandwidthLimitUnit;
|
|
||||||
}
|
}
|
||||||
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->connexion.server + "::" + mw->downloading.service + "/" + mw->downloading.path;
|
||||||
argv[5] = mw->downloading.savePath + "/";
|
argv[5] = mw->downloading.savePath + "/";
|
||||||
argv[6] = "";
|
argv[6].clear();
|
||||||
|
|
||||||
//launching downloading thread
|
//launching downloading thread
|
||||||
FILE * fp = popen2(argv, "r", mw->downloading.pid);
|
FILE * fp = popen2(argv, "r", mw->downloading.pid);
|
||||||
if (!fp)
|
if (fp <= (FILE *) 0)
|
||||||
{
|
{
|
||||||
throw runtime_error("popen2() failed!");
|
sprintf(buffer, "popen2() failed!: returning code:%d", fileno(fp));
|
||||||
|
throw runtime_error(buffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// waiting rsync output
|
||||||
while (fgets(buffer, 4096, fp) != nullptr)
|
while (fgets(buffer, 4096, fp) != nullptr)
|
||||||
{
|
{
|
||||||
|
// Downloading is cancelled, we return
|
||||||
if (this->canceled == true)
|
if (this->canceled == true)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
line = buffer;
|
line = buffer;
|
||||||
|
|
||||||
|
// extracting percentage of completion
|
||||||
pos = line.find('%');
|
pos = line.find('%');
|
||||||
if (pos != -1)
|
if (pos != -1)
|
||||||
{
|
{
|
||||||
@ -81,9 +92,11 @@ void downloadFile::download(MainWindow *mw)
|
|||||||
{
|
{
|
||||||
line.erase(0, pos);
|
line.erase(0, pos);
|
||||||
value = stoi(line);
|
value = stoi(line);
|
||||||
|
// sending progress to Main window
|
||||||
emit progressSignal(value);
|
emit progressSignal(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// download ended
|
||||||
}
|
}
|
||||||
pclose2(fp, mw->downloading.pid);
|
pclose2(fp, mw->downloading.pid);
|
||||||
|
|
||||||
@ -91,4 +104,3 @@ void downloadFile::download(MainWindow *mw)
|
|||||||
emit progressSignal(100);
|
emit progressSignal(100);
|
||||||
emit finishedSignal(true);
|
emit finishedSignal(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1,190 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!DOCTYPE TS>
|
|
||||||
<TS version="2.1" language="fr_FR">
|
|
||||||
<context>
|
|
||||||
<name>Configuration</name>
|
|
||||||
<message>
|
|
||||||
<location filename="../../configuration.ui" line="17"/>
|
|
||||||
<source>Configuration</source>
|
|
||||||
<translation>Configuration</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../configuration.ui" line="42"/>
|
|
||||||
<source>Bandwidth limit</source>
|
|
||||||
<extracomment>Bandwidth limit</extracomment>
|
|
||||||
<translation>Limite de bande passante</translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
|
||||||
<context>
|
|
||||||
<name>MainWindow</name>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="21"/>
|
|
||||||
<source>MainWindow</source>
|
|
||||||
<translation>Fenêtre principale</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="80"/>
|
|
||||||
<source>Server</source>
|
|
||||||
<oldsource>Serveur</oldsource>
|
|
||||||
<translation>Serveur</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="112"/>
|
|
||||||
<source>Port</source>
|
|
||||||
<translation>Port</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="168"/>
|
|
||||||
<source>Connection</source>
|
|
||||||
<translation>Connexion</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="171"/>
|
|
||||||
<source>Return</source>
|
|
||||||
<translation>Retour</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="294"/>
|
|
||||||
<source>%p%</source>
|
|
||||||
<extracomment>Downloading</extracomment>
|
|
||||||
<translation>Téléchargement</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="311"/>
|
|
||||||
<location filename="../../mainwindow.ui" line="329"/>
|
|
||||||
<source>Menu</source>
|
|
||||||
<translation>Menu</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="318"/>
|
|
||||||
<source>help</source>
|
|
||||||
<translation>Aide</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="334"/>
|
|
||||||
<location filename="../../mainwindow.ui" line="337"/>
|
|
||||||
<source>Change save folder</source>
|
|
||||||
<translation>Changer le dossier de destination</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Default save folder</source>
|
|
||||||
<translation type="vanished">Dossier d'enregistrement</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="342"/>
|
|
||||||
<source>Bandwidth limit</source>
|
|
||||||
<translation>Limite de bande passante</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="347"/>
|
|
||||||
<source>About</source>
|
|
||||||
<translation>À propos</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="352"/>
|
|
||||||
<source>About Qt</source>
|
|
||||||
<translation>À propos de Qt</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.ui" line="357"/>
|
|
||||||
<source>Settings</source>
|
|
||||||
<translation>Paramètres</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>debug</source>
|
|
||||||
<translation type="vanished">debug</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="21"/>
|
|
||||||
<source>Byte</source>
|
|
||||||
<translation>Octet</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="21"/>
|
|
||||||
<source>KB</source>
|
|
||||||
<translation>Ko</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="21"/>
|
|
||||||
<source>MB</source>
|
|
||||||
<translation>Mo</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="21"/>
|
|
||||||
<source>GB</source>
|
|
||||||
<translation>Go</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="21"/>
|
|
||||||
<source>TB</source>
|
|
||||||
<translation>To</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="21"/>
|
|
||||||
<location filename="../../mainwindow.cpp" line="517"/>
|
|
||||||
<source>PB</source>
|
|
||||||
<translation>Po</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="35"/>
|
|
||||||
<source>Path</source>
|
|
||||||
<translation>Chemin</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="35"/>
|
|
||||||
<source>Size</source>
|
|
||||||
<translation>Taille</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="68"/>
|
|
||||||
<source>Exiting will stop downloading, and will clear the download queue.
|
|
||||||
Do you want to exit ?</source>
|
|
||||||
<translation>Soritr stoppera le téléchargement et effacera la file des téléchargements.
|
|
||||||
Voulez-vous vraiment sortir du programme ?</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="297"/>
|
|
||||||
<source>server does not exists</source>
|
|
||||||
<translation>Le serveur n'existe pas</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="479"/>
|
|
||||||
<source>Licence</source>
|
|
||||||
<translation>License</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="480"/>
|
|
||||||
<source>Author</source>
|
|
||||||
<translation>Auteur</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="481"/>
|
|
||||||
<source>EMail</source>
|
|
||||||
<translation>Courriel</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="482"/>
|
|
||||||
<source>Source code</source>
|
|
||||||
<translation>Code source</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="495"/>
|
|
||||||
<source>Choose directory to save file</source>
|
|
||||||
<translation>Choisissez le dossier où enregistrer</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="413"/>
|
|
||||||
<source>Do you want to stop downloading and delete this file from download queue ?</source>
|
|
||||||
<translation>Vouslez-vous arrêter le téléchargement et enlever ce fichier de la file de téléchargement ?</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Client for rsync server</source>
|
|
||||||
<translation type="vanished">Client pour serveur rsync</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../../mainwindow.cpp" line="425"/>
|
|
||||||
<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>
|
|
||||||
</context>
|
|
||||||
</TS>
|
|
BIN
languages/fr_FR/RsyncUI_fr_FR.qm
Normal file
BIN
languages/fr_FR/RsyncUI_fr_FR.qm
Normal file
Binary file not shown.
296
languages/fr_FR/RsyncUI_fr_FR.ts
Normal file
296
languages/fr_FR/RsyncUI_fr_FR.ts
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="fr_FR">
|
||||||
|
<context>
|
||||||
|
<name>Configuration</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../../configuration.ui" line="20"/>
|
||||||
|
<source>Configuration</source>
|
||||||
|
<translation>Configuration</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../configuration.ui" line="38"/>
|
||||||
|
<source>Toolbar view</source>
|
||||||
|
<translation>Toolbar</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../configuration.ui" line="45"/>
|
||||||
|
<source>Bandwidth limit</source>
|
||||||
|
<extracomment>Bandwidth limit</extracomment>
|
||||||
|
<translation>Limite de bande passante</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../configuration.ui" line="52"/>
|
||||||
|
<source>Enter the bandwidth limit (0 to 1024)</source>
|
||||||
|
<translation>Entrez la limite de bande passante (0 à 1024)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../configuration.ui" line="74"/>
|
||||||
|
<source>Select th unit of bandwidth limit in Bytes, KiloBytes, MegaBytes, GigaBytes or PetaBytes</source>
|
||||||
|
<extracomment>Unit of bandwidth</extracomment>
|
||||||
|
<translation>Sélectionnez l'unité de limite de bande passante en otctets, Ko, Mo, Go, Po</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../configuration.ui" line="100"/>
|
||||||
|
<source>Icon only</source>
|
||||||
|
<translation>Icône seule</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../configuration.ui" line="105"/>
|
||||||
|
<source>Text only</source>
|
||||||
|
<translation>Texte seul</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../configuration.ui" line="110"/>
|
||||||
|
<source>Text beside icon</source>
|
||||||
|
<translation>Text à côté de l'icône</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../configuration.ui" line="115"/>
|
||||||
|
<source>Text under icon</source>
|
||||||
|
<translation>Texte sous l'icöne</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../configuration.ui" line="120"/>
|
||||||
|
<source>Text follow icon</source>
|
||||||
|
<translation>Texte suit l'icône</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>MainWindow</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="21"/>
|
||||||
|
<source>MainWindow</source>
|
||||||
|
<translation>Fenêtre principale</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="83"/>
|
||||||
|
<source>Server</source>
|
||||||
|
<oldsource>Serveur</oldsource>
|
||||||
|
<translation>Serveur</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="105"/>
|
||||||
|
<source>Enter server's URL</source>
|
||||||
|
<translation>Entrez l'adresse du serveur</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="121"/>
|
||||||
|
<source>Port</source>
|
||||||
|
<translation>Port</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="149"/>
|
||||||
|
<source>Enter rsync port on server</source>
|
||||||
|
<translation>Entrez le port du serveur rsync</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="186"/>
|
||||||
|
<source>Press button to connect to rsync server</source>
|
||||||
|
<extracomment>Connect to server</extracomment>
|
||||||
|
<translation>Cliquez pour se connecter au serveur rsync</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="192"/>
|
||||||
|
<source>Connection</source>
|
||||||
|
<translation>Connexion</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="195"/>
|
||||||
|
<source>Return</source>
|
||||||
|
<translation>Retour</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="221"/>
|
||||||
|
<source>Click to view the list of files of this folder</source>
|
||||||
|
<translation>Cliquez pour afficher la liste des documents</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="256"/>
|
||||||
|
<source>Click to add to download queue</source>
|
||||||
|
<translation>Cliquez pour ajouter à la file de téléchargement</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="334"/>
|
||||||
|
<source>Click on file to stop downloading</source>
|
||||||
|
<translation>Cliquez sur le document pour arrêter le téléchargement et l'enlever de la file</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="357"/>
|
||||||
|
<source>%p%</source>
|
||||||
|
<extracomment>Downloading</extracomment>
|
||||||
|
<translation>Téléchargement</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="368"/>
|
||||||
|
<source>toolBar</source>
|
||||||
|
<translation>Barre d'outils</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="401"/>
|
||||||
|
<source>Menu</source>
|
||||||
|
<translation>Menu</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>help</source>
|
||||||
|
<translation type="vanished">Aide</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="409"/>
|
||||||
|
<location filename="../../mainwindow.ui" line="412"/>
|
||||||
|
<source>Change save folder</source>
|
||||||
|
<translation>Changer le dossier de destination</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Default save folder</source>
|
||||||
|
<translation type="vanished">Dossier d'enregistrement</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Bandwidth limit</source>
|
||||||
|
<translation type="vanished">Limite de bande passante</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="420"/>
|
||||||
|
<source>About</source>
|
||||||
|
<translation>À propos</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="428"/>
|
||||||
|
<source>About Qt</source>
|
||||||
|
<translation>À propos de Qt</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.ui" line="436"/>
|
||||||
|
<source>Settings</source>
|
||||||
|
<translation>Paramètres</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>debug</source>
|
||||||
|
<translation type="vanished">debug</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="23"/>
|
||||||
|
<source>Byte</source>
|
||||||
|
<translation>Octet</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="23"/>
|
||||||
|
<source>KB</source>
|
||||||
|
<translation>Ko</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="23"/>
|
||||||
|
<source>MB</source>
|
||||||
|
<translation>Mo</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="23"/>
|
||||||
|
<source>GB</source>
|
||||||
|
<translation>Go</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="23"/>
|
||||||
|
<source>TB</source>
|
||||||
|
<translation>To</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="23"/>
|
||||||
|
<location filename="../../mainwindow.cpp" line="614"/>
|
||||||
|
<source>PB</source>
|
||||||
|
<translation>Po</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="26"/>
|
||||||
|
<source>Client for rsync server
|
||||||
|
|
||||||
|
You click on file to enqueue it, and RyncUI Download one file a time</source>
|
||||||
|
<translation>Client pour serveur rsync
|
||||||
|
|
||||||
|
Cliquez sur un fichier pour l'ajouter dans la file de téléchargement</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="38"/>
|
||||||
|
<source>Path</source>
|
||||||
|
<translation>Chemin</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="38"/>
|
||||||
|
<source>Size</source>
|
||||||
|
<translation>Taille</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="38"/>
|
||||||
|
<source>Type</source>
|
||||||
|
<translation>Type</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="80"/>
|
||||||
|
<source>Exiting will stop downloading, and will clear the download queue.
|
||||||
|
Do you want to exit ?</source>
|
||||||
|
<translation>Soritr stoppera le téléchargement et effacera la file des téléchargements.
|
||||||
|
Voulez-vous vraiment sortir du programme ?</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="328"/>
|
||||||
|
<source>server does not exists</source>
|
||||||
|
<translation>Le serveur n'existe pas</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="355"/>
|
||||||
|
<location filename="../../mainwindow.cpp" line="375"/>
|
||||||
|
<source>Dir</source>
|
||||||
|
<translation>Dossier</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="358"/>
|
||||||
|
<location filename="../../mainwindow.cpp" line="378"/>
|
||||||
|
<location filename="../../mainwindow.cpp" line="424"/>
|
||||||
|
<source>File</source>
|
||||||
|
<translation></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="564"/>
|
||||||
|
<source>Version</source>
|
||||||
|
<translation>Version</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="565"/>
|
||||||
|
<source>Licence</source>
|
||||||
|
<translation>License</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="566"/>
|
||||||
|
<source>Author</source>
|
||||||
|
<translation>Auteur</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="567"/>
|
||||||
|
<source>EMail</source>
|
||||||
|
<translation>Courriel</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="568"/>
|
||||||
|
<source>Source code</source>
|
||||||
|
<translation>Code source</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="590"/>
|
||||||
|
<source>Choose directory to save file</source>
|
||||||
|
<translation>Choisissez le dossier où enregistrer</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../../mainwindow.cpp" line="497"/>
|
||||||
|
<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>
|
||||||
|
<source>Client for rsync server</source>
|
||||||
|
<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>
|
||||||
|
<translation>Voulez-vous enlever ce fichier de la file de téléchargement ?</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
14
main.cpp
14
main.cpp
@ -1,27 +1,23 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QApplication>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <KAboutData>
|
|
||||||
#include <KDBusService>
|
|
||||||
#include <QCommandLineParser>
|
|
||||||
#include <QTranslator>
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
QTranslator myappTranslator;
|
QTranslator myappTranslator;
|
||||||
|
|
||||||
|
QCoreApplication::setOrganizationName("RsyncUI");
|
||||||
|
QCoreApplication::setApplicationName("RsyncUI");
|
||||||
|
// Initialization of localization
|
||||||
QLocale localeName = QLocale::system();
|
QLocale localeName = QLocale::system();
|
||||||
QString localeFile = "usr/share/locale/" + localeName.name() + "LC_MESSAGES/RsyncUI_" + localeName.name() + ".qm";
|
QString localeFile = "/usr/share/locale/" + localeName.name() + "/LC_MESSAGES/RsyncUI_" + localeName.name() + ".qm";
|
||||||
if (myappTranslator.load(localeFile))
|
if (myappTranslator.load(localeFile))
|
||||||
{
|
{
|
||||||
a.installTranslator(&myappTranslator);
|
a.installTranslator(&myappTranslator);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
188
mainwindow.cpp
188
mainwindow.cpp
@ -1,9 +1,11 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QToolBar>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
bool display = false;
|
bool display = false;
|
||||||
extern QDialog Configuration;
|
//extern QDialog Configuration;
|
||||||
extern Ui::Configuration config;
|
extern Ui::Configuration config;
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
@ -21,18 +23,20 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
config.UnitCombobox->addItems({tr("Byte"), tr("KB"), tr("MB"), tr("GB"), tr("TB"), tr("PB")});
|
config.UnitCombobox->addItems({tr("Byte"), tr("KB"), tr("MB"), tr("GB"), tr("TB"), tr("PB")});
|
||||||
|
|
||||||
// init of About
|
// init of About
|
||||||
this->about.description = tr(this->about.description.toStdString().c_str());
|
this->about.description = tr("Client for rsync server\n\nYou click on file to enqueue it, and RyncUI Download one file a time");
|
||||||
|
|
||||||
// connectors
|
// connectors
|
||||||
connect(&downloadO, &downloadFile::progressSignal, ui->progressBar, &QProgressBar::setValue);
|
connect(&downloadO, &downloadFile::progressSignal, ui->progressBar, &QProgressBar::setValue);
|
||||||
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("Path"), tr("Size")} );
|
ui->treeWidget->setHeaderLabels({tr("Type"), tr("Path"), tr("Size")} );
|
||||||
|
config.comboBox->setCurrentIndex(ui->toolBar->toolButtonStyle());
|
||||||
if (this->settings.contains("connexion/lastServer"))
|
if (this->settings.contains("connexion/lastServer"))
|
||||||
{
|
{
|
||||||
ui->portEdit->setText(this->settings.value("connexion/port").toString());
|
ui->portEdit->setText(this->settings.value("connexion/port").toString());
|
||||||
@ -43,7 +47,12 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
ui->khistorycombobox->clear();
|
ui->khistorycombobox->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setting arrowcursor for treeWidget, listWidget and listDownload
|
||||||
|
ui->treeWidget->setCursor(Qt::ArrowCursor);
|
||||||
|
ui->listWidget->setCursor(Qt::ArrowCursor);
|
||||||
|
ui->listDownload->setCursor(Qt::ArrowCursor);
|
||||||
|
|
||||||
|
// Hiding progress bar
|
||||||
ui->progressBar->hide();
|
ui->progressBar->hide();
|
||||||
|
|
||||||
populateList();
|
populateList();
|
||||||
@ -54,15 +63,18 @@ MainWindow::~MainWindow()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Closing window has been clicked
|
||||||
void MainWindow::closeEvent (QCloseEvent *event)
|
void MainWindow::closeEvent (QCloseEvent *event)
|
||||||
{
|
{
|
||||||
QMessageBox::StandardButton reply;
|
QMessageBox::StandardButton reply;
|
||||||
|
|
||||||
|
// saving settings
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
||||||
if (ui->listDownload->count() != 0)
|
if (ui->listDownload->count() != 0) // some downloads waiting
|
||||||
{
|
{
|
||||||
reply = QMessageBox::question(
|
// Asking for stopping or continuing
|
||||||
|
reply = QMessageBox::question(
|
||||||
this,
|
this,
|
||||||
"RsyncUI",
|
"RsyncUI",
|
||||||
tr("Exiting will stop downloading, and will clear the download queue.\n Do you want to exit ?"),
|
tr("Exiting will stop downloading, and will clear the download queue.\n Do you want to exit ?"),
|
||||||
@ -70,10 +82,12 @@ void MainWindow::closeEvent (QCloseEvent *event)
|
|||||||
QMessageBox::No);
|
QMessageBox::No);
|
||||||
if (reply == QMessageBox::No)
|
if (reply == QMessageBox::No)
|
||||||
{
|
{
|
||||||
|
// continuing
|
||||||
event->ignore();
|
event->ignore();
|
||||||
return;
|
return;
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
|
// emission of signal to downloading thread and stopping
|
||||||
emit (stopDownloading(this->downloading.pid));
|
emit (stopDownloading(this->downloading.pid));
|
||||||
waitpid(this->downloading.pid, NULL, WUNTRACED);
|
waitpid(this->downloading.pid, NULL, WUNTRACED);
|
||||||
}
|
}
|
||||||
@ -81,24 +95,31 @@ void MainWindow::closeEvent (QCloseEvent *event)
|
|||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::populateTree()
|
// Populate treeview with list of files
|
||||||
|
void MainWindow::populateTree(QTreeWidgetItem * parent)
|
||||||
{
|
{
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
vector<string> path;
|
vector<string> path;
|
||||||
|
|
||||||
|
// Clear treewidget
|
||||||
ui->treeWidget->clear();
|
ui->treeWidget->clear();
|
||||||
if (!this->connexion.server.empty() and this->connexion.port > 0 and this->connexion.port < 65536)
|
if (!this->connexion.server.empty() and this->connexion.port > 0 and this->connexion.port < 65536)
|
||||||
{
|
{
|
||||||
|
// setting cursor to "Wait"
|
||||||
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
|
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
if (validateServer(this->connexion.server))
|
if (validateServer(this->connexion.server))
|
||||||
{
|
{
|
||||||
|
// server is validated
|
||||||
path = explode(ui->listWidget->currentItem()->text().toStdString(), '\n', 2);
|
path = explode(ui->listWidget->currentItem()->text().toStdString(), '\n', 2);
|
||||||
scanDir(this->connexion.server, this->connexion.port, NULL, path[0].append("/") );
|
scanDir(this->connexion.server, this->connexion.port, parent, path[0].append("/") );
|
||||||
}
|
}
|
||||||
QGuiApplication::restoreOverrideCursor(); //setOverrideCursor(Qt::ArrowCursor);
|
// Restoring cursor
|
||||||
|
QGuiApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate Listview with list of services
|
||||||
void MainWindow::populateList()
|
void MainWindow::populateList()
|
||||||
{
|
{
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
@ -110,13 +131,16 @@ void MainWindow::populateList()
|
|||||||
port = ui->portEdit->text().toUInt();
|
port = ui->portEdit->text().toUInt();
|
||||||
if ((server.toStdString() != this->connexion.server) or (port != this->connexion.port))
|
if ((server.toStdString() != this->connexion.server) or (port != this->connexion.port))
|
||||||
{
|
{
|
||||||
|
// clearing listwidget
|
||||||
ui->listWidget->clear();
|
ui->listWidget->clear();
|
||||||
this->connexion.server.assign(server.toStdString());
|
this->connexion.server.assign(server.toStdString());
|
||||||
this->connexion.port = port;
|
this->connexion.port = port;
|
||||||
|
|
||||||
|
// verify if server is in history
|
||||||
this->settings.beginGroup("connexion/server");
|
this->settings.beginGroup("connexion/server");
|
||||||
if (this->settings.contains(server))
|
if (this->settings.contains(server))
|
||||||
{
|
{
|
||||||
|
// server is in history and completing port value
|
||||||
port = this->settings.value(server).toUInt();
|
port = this->settings.value(server).toUInt();
|
||||||
ui->portEdit->setText(QString::number(port));
|
ui->portEdit->setText(QString::number(port));
|
||||||
this->connexion.port = port;
|
this->connexion.port = port;
|
||||||
@ -126,7 +150,7 @@ void MainWindow::populateList()
|
|||||||
{
|
{
|
||||||
if (validateServer(server.toStdString()))
|
if (validateServer(server.toStdString()))
|
||||||
{
|
{
|
||||||
//this->settings.beginGroup("connexion/server");
|
|
||||||
if (!this->settings.contains(server))
|
if (!this->settings.contains(server))
|
||||||
{
|
{
|
||||||
cout << server.toStdString() << endl;
|
cout << server.toStdString() << endl;
|
||||||
@ -149,6 +173,7 @@ void MainWindow::populateList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//list services of the rsync server
|
||||||
void MainWindow::listServices()
|
void MainWindow::listServices()
|
||||||
{
|
{
|
||||||
char cmd[4096];
|
char cmd[4096];
|
||||||
@ -169,6 +194,7 @@ void MainWindow::listServices()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// connect to rsync server to get list of files
|
||||||
void MainWindow::scanDir(string server, int portN, QTreeWidgetItem *parent, string path)
|
void MainWindow::scanDir(string server, int portN, QTreeWidgetItem *parent, string path)
|
||||||
{
|
{
|
||||||
char cmd[4096];
|
char cmd[4096];
|
||||||
@ -176,37 +202,41 @@ void MainWindow::scanDir(string server, int portN, QTreeWidgetItem *parent, stri
|
|||||||
string errorRsync;
|
string errorRsync;
|
||||||
vector<string> v;
|
vector<string> v;
|
||||||
QTreeWidgetItem * item;
|
QTreeWidgetItem * item;
|
||||||
char npath[4096];
|
bool isDir = false;
|
||||||
|
|
||||||
sprintf(cmd, "rsync --contimeout=10 -P \"%s::%s\" --port %d ", server.c_str(), path.c_str(), portN );
|
sprintf(cmd, "rsync --contimeout=10 -P \"%s::%s\" --port %d ", server.c_str(), path.c_str(), portN );
|
||||||
redi::ipstream in(cmd, redi::pstreams::pstdout | redi::pstreams::pstderr);
|
redi::ipstream in(cmd, redi::pstreams::pstdout | redi::pstreams::pstderr);
|
||||||
|
|
||||||
while (getline(in.out(), line))
|
while (getline(in.out(), line))
|
||||||
{
|
{
|
||||||
|
|
||||||
v = explode(line, ' ', 5);
|
v = explode(line, ' ', 5);
|
||||||
if (v.size() == 5)
|
if (v.size() == 5)
|
||||||
{
|
{
|
||||||
if (v[4].at(0) != '.' and (v[0].at(0) == '-' or v[0].at(0) == 'd'))
|
if (v[4].at(0) != '.' and (v[0].at(0) == '-' or v[0].at(0) == 'd'))
|
||||||
{
|
{
|
||||||
if (parent != NULL)
|
|
||||||
{
|
|
||||||
item = addTreeChild(parent,QString::fromStdString(v[4]), QString::fromStdString(v[1]));
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
item = addTreeRoot(QString::fromStdString(v[4]), QString::fromStdString(v[1]));
|
|
||||||
}
|
|
||||||
if (v[0].at(0) == 'd')
|
if (v[0].at(0) == 'd')
|
||||||
{
|
{
|
||||||
sprintf(npath, "%s%s/", path.c_str(), v[4].c_str());
|
isDir = true;
|
||||||
scanDir(server, portN, item, npath);
|
}else
|
||||||
|
{
|
||||||
|
isDir = false;
|
||||||
}
|
}
|
||||||
|
if (parent != NULL)
|
||||||
|
{
|
||||||
|
item = addTreeChild(parent,QString::fromStdString(v[4]), QString::fromStdString(v[1]), isDir);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
item = addTreeRoot(QString::fromStdString(v[4]), QString::fromStdString(v[1]), isDir);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if reading stdout stopped at EOF then reset the state:
|
// if reading stdout stopped at EOF then reset the state:
|
||||||
if (in.eof() && in.fail())
|
if (in.eof() && in.fail())
|
||||||
in.clear();
|
in.clear();
|
||||||
|
|
||||||
// read child's stderr
|
// read child's stderr
|
||||||
while (getline(in.err(), line))
|
while (getline(in.err(), line))
|
||||||
{
|
{
|
||||||
@ -214,6 +244,7 @@ void MainWindow::scanDir(string server, int portN, QTreeWidgetItem *parent, stri
|
|||||||
errorRsync.append(line);
|
errorRsync.append(line);
|
||||||
errorRsync.append("\n");
|
errorRsync.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !errorRsync.empty())
|
if ( !errorRsync.empty())
|
||||||
{
|
{
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
@ -224,6 +255,7 @@ void MainWindow::scanDir(string server, int portN, QTreeWidgetItem *parent, stri
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify if server address is IP address
|
||||||
bool MainWindow::isIpAddress(string server)
|
bool MainWindow::isIpAddress(string server)
|
||||||
{
|
{
|
||||||
vector<string> r;
|
vector<string> r;
|
||||||
@ -249,6 +281,7 @@ bool MainWindow::isIpAddress(string server)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate address server
|
||||||
bool MainWindow::validateServer(string server)
|
bool MainWindow::validateServer(string server)
|
||||||
{
|
{
|
||||||
char cmd[512];
|
char cmd[512];
|
||||||
@ -300,79 +333,111 @@ bool MainWindow::validateServer(string server)
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::displayTree()
|
// slot activated when combobox is changed
|
||||||
{
|
|
||||||
populateTree();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_khistorycombobox_currentIndexChanged(int i)
|
void MainWindow::on_khistorycombobox_currentIndexChanged(int i)
|
||||||
{
|
{
|
||||||
on_connectButton_clicked();
|
on_connectButton_clicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// slot activated when button connection is clicked
|
||||||
void MainWindow::on_connectButton_clicked()
|
void MainWindow::on_connectButton_clicked()
|
||||||
{
|
{
|
||||||
populateList();
|
populateList();
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem * MainWindow::addTreeRoot(QString name, QString fileSize)
|
// add a dir in treeview
|
||||||
|
QTreeWidgetItem * MainWindow::addTreeRoot(QString name, QString fileSize, bool isDir)
|
||||||
{
|
{
|
||||||
// QTreeWidgetItem(QTreeWidget * parent, int type = Type)
|
// QTreeWidgetItem(QTreeWidget * parent, int type = Type)
|
||||||
QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui->treeWidget);
|
QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui->treeWidget);
|
||||||
|
|
||||||
// QTreeWidgetItem::setText(int column, const QString & text)
|
// QTreeWidgetItem::setText(int column, const QString & text)
|
||||||
treeItem->setText(0, name);
|
if (isDir == true)
|
||||||
treeItem->setText(1, fileSize);
|
{
|
||||||
|
treeItem->setText(0, "Dir");
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
treeItem->setText(0,"File");
|
||||||
|
}
|
||||||
|
treeItem->setText(1, name);
|
||||||
|
treeItem->setText(2, fileSize);
|
||||||
|
|
||||||
return treeItem;
|
return treeItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem * MainWindow::addTreeChild(QTreeWidgetItem *parent, QString name, QString fileSize)
|
// add a file in treeview
|
||||||
|
QTreeWidgetItem * MainWindow::addTreeChild(QTreeWidgetItem *parent, QString name, QString fileSize, bool isDir)
|
||||||
{
|
{
|
||||||
// QTreeWidgetItem(QTreeWidget * parent, int type = Type)
|
// QTreeWidgetItem(QTreeWidget * parent, int type = Type)
|
||||||
QTreeWidgetItem *treeItem = new QTreeWidgetItem();
|
QTreeWidgetItem *treeItem = new QTreeWidgetItem();
|
||||||
|
|
||||||
// QTreeWidgetItem::setText(int column, const QString & text)
|
// QTreeWidgetItem::setText(int column, const QString & text)
|
||||||
treeItem->setText(0, name);
|
if (isDir == true)
|
||||||
treeItem->setText(1, fileSize);
|
{
|
||||||
|
treeItem->setText(0, "Dir");
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
treeItem->setText(0,"File");
|
||||||
|
}
|
||||||
|
treeItem->setText(1, name);
|
||||||
|
treeItem->setText(2, fileSize);
|
||||||
|
|
||||||
// QTreeWidgetItem::addChild(QTreeWidgetItem * child)
|
// QTreeWidgetItem::addChild(QTreeWidgetItem * child)
|
||||||
parent->addChild(treeItem);
|
parent->addChild(treeItem);
|
||||||
return treeItem;
|
return treeItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Slot acivated when a service in the list is clicked
|
||||||
void MainWindow::on_listWidget_clicked()
|
void MainWindow::on_listWidget_clicked()
|
||||||
{
|
{
|
||||||
vector<string> v;
|
vector<string> v;
|
||||||
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];
|
||||||
populateTree();
|
populateTree(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Slot activated when a file is clicked in the treeview
|
||||||
void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item)
|
void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item)
|
||||||
{
|
{
|
||||||
QFuture<void> future;
|
QFuture<void> future;
|
||||||
QFileDialog dialog;
|
QFileDialog dialog;
|
||||||
|
QTreeWidgetItem * itemR;
|
||||||
|
string path;
|
||||||
|
|
||||||
item = ui->treeWidget->currentItem();
|
//item = ui->treeWidget->currentItem();
|
||||||
this->downloading.path = item->text(0).toStdString();
|
itemR = item;
|
||||||
while(item->parent() != NULL)
|
|
||||||
|
path = item->text(1).toStdString();
|
||||||
|
while(itemR->parent() != NULL)
|
||||||
{
|
{
|
||||||
item = item->parent();
|
itemR = itemR->parent();
|
||||||
this->downloading.path = item->text(0).toStdString() + "/" + this->downloading.path;
|
path = itemR->text(1).toStdString() + "/" + path;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this->downloading.savePath.empty())
|
if (item->text(0) == "File")
|
||||||
{
|
{
|
||||||
on_DefaultSaveFolder_triggered();
|
// Item is a file
|
||||||
}
|
this->downloading.path = path;
|
||||||
if (!this->downloading.savePath.empty() && this->downloading.pid == 0)
|
if (this->downloading.savePath.empty())
|
||||||
|
{
|
||||||
|
on_DefaultSaveFolder_triggered();
|
||||||
|
}else if (this->downloading.pid == 0)
|
||||||
|
{
|
||||||
|
startDownloading();
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
ui->listDownload->addItem(QString::fromStdString(this->downloading.path));
|
||||||
|
}else
|
||||||
{
|
{
|
||||||
startDownloading();
|
//Item is a Directory
|
||||||
|
scanDir(this->connexion.server, this->connexion.port, item, this->downloading.service + "/" + path +"/");
|
||||||
|
item->setExpanded(true);
|
||||||
}
|
}
|
||||||
ui->listDownload->addItem(QString::fromStdString(this->downloading.path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Launch the thread which download the file
|
||||||
void MainWindow::startDownloading()
|
void MainWindow::startDownloading()
|
||||||
{
|
{
|
||||||
ui->progressBar->setValue(0);
|
ui->progressBar->setValue(0);
|
||||||
@ -382,11 +447,13 @@ void MainWindow::startDownloading()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Slot stopping download
|
||||||
void MainWindow::stoppingDownload()
|
void MainWindow::stoppingDownload()
|
||||||
{
|
{
|
||||||
emit (stopDownloading(this->downloading.pid));
|
emit (stopDownloading(this->downloading.pid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// when download is finished, launch download of next file in queue
|
||||||
void MainWindow::downloadFinished()
|
void MainWindow::downloadFinished()
|
||||||
{
|
{
|
||||||
ui->progressBar->hide();
|
ui->progressBar->hide();
|
||||||
@ -399,6 +466,7 @@ void MainWindow::downloadFinished()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Slot activated when a line is clicked in queue list
|
||||||
void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item)
|
void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item)
|
||||||
{
|
{
|
||||||
QFileDialog dialog;
|
QFileDialog dialog;
|
||||||
@ -433,14 +501,16 @@ void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load settings
|
||||||
void MainWindow::loadSettings()
|
void MainWindow::loadSettings()
|
||||||
{
|
{
|
||||||
// restoring geometry and state of wondow and widgets
|
// restoring geometry and state of window and widgets
|
||||||
this->restoreGeometry(settings.value("window/geometry").toByteArray());
|
this->restoreGeometry(settings.value("window/geometry").toByteArray());
|
||||||
this->restoreState(settings.value("window/state").toByteArray());
|
this->restoreState(settings.value("window/state").toByteArray());
|
||||||
ui->treeWidget->header()->restoreState(settings.value("treeView/state").toByteArray());
|
ui->treeWidget->header()->restoreState(settings.value("treeWidget/state").toByteArray());
|
||||||
ui->splitter->restoreState(settings.value("splitter/state").toByteArray());
|
ui->splitter->restoreState(settings.value("splitter/state").toByteArray());
|
||||||
ui->splitter_2->restoreState(settings.value("splitter2/state").toByteArray());
|
ui->splitter_2->restoreState(settings.value("splitter2/state").toByteArray());
|
||||||
|
ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)settings.value("toolbar/state").toInt());
|
||||||
|
|
||||||
// loading connexion settings
|
// loading connexion settings
|
||||||
// loading servers history
|
// loading servers history
|
||||||
@ -460,51 +530,57 @@ void MainWindow::loadSettings()
|
|||||||
this->connexion.bandwidthLimitUnit = this->settings.value("bandwidthlimitunit").toString().toStdString();
|
this->connexion.bandwidthLimitUnit = this->settings.value("bandwidthlimitunit").toString().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// save settings
|
||||||
void MainWindow::saveSettings()
|
void MainWindow::saveSettings()
|
||||||
{
|
{
|
||||||
this->settings.setValue("window/geometry", saveGeometry());
|
this->settings.setValue("window/geometry", saveGeometry());
|
||||||
this->settings.setValue("window/state", saveState());
|
this->settings.setValue("window/state", saveState());
|
||||||
this->settings.setValue("treeView/state", ui->treeWidget->header()->saveState());
|
this->settings.setValue("treeWidget/state", ui->treeWidget->header()->saveState());
|
||||||
this->settings.setValue("splitter/state", ui->splitter->saveState());
|
this->settings.setValue("splitter/state", ui->splitter->saveState());
|
||||||
this->settings.setValue("splitter2/state", ui->splitter_2->saveState());
|
this->settings.setValue("splitter2/state", ui->splitter_2->saveState());
|
||||||
this->settings.setValue("connexion/lastServer", QString::fromStdString(this->connexion.server));
|
this->settings.setValue("connexion/lastServer", QString::fromStdString(this->connexion.server));
|
||||||
this->settings.setValue("connexion/lastPort", QString::number(this->connexion.port));
|
this->settings.setValue("connexion/lastPort", QString::number(this->connexion.port));
|
||||||
|
this->settings.setValue("toolbar/state", ui->toolBar->toolButtonStyle());
|
||||||
this->settings.sync();
|
this->settings.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// About
|
||||||
void MainWindow::on_actionAbout_triggered()
|
void MainWindow::on_actionAbout_triggered()
|
||||||
{
|
{
|
||||||
QString text = this->about.description + "\n\n" +
|
QString text = this->about.description + "\n\n" +
|
||||||
tr("Licence" ) + ": " + this->about.licence + "\n" +
|
tr("Version") + ": " + this->about.version + "\n" +
|
||||||
|
tr("Licence") + ": " + this->about.licence + "\n" +
|
||||||
tr("Author") + ": " + this->about.author + "\n" +
|
tr("Author") + ": " + this->about.author + "\n" +
|
||||||
tr("EMail") + ": " + this->about.email + "\n" +
|
tr("EMail") + ": " + this->about.email + "\n" +
|
||||||
tr("Source code") + ": " + this->about.git;
|
tr("Source code") + ": " + this->about.git;
|
||||||
QMessageBox::about(this, this->about.title, text);
|
QMessageBox::about(this, this->about.title, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// About QT
|
||||||
void MainWindow::on_actionAbout_Qt_triggered()
|
void MainWindow::on_actionAbout_Qt_triggered()
|
||||||
{
|
{
|
||||||
QMessageBox::aboutQt(this);
|
QMessageBox::aboutQt(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Activated when menu "change folder" is clicked
|
||||||
void MainWindow::on_DefaultSaveFolder_triggered()
|
void MainWindow::on_DefaultSaveFolder_triggered()
|
||||||
{
|
{
|
||||||
QFileDialog dialog;
|
QFileDialog dialog;
|
||||||
|
|
||||||
this->downloading.savePath = dialog.getExistingDirectory(this, tr("Choose directory to save file"), this->downloading.dirPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks).toStdString();
|
this->downloading.savePath = dialog.getExistingDirectory(this, tr("Choose directory to save file"), QString::fromStdString(this->downloading.savePath), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks).toStdString();
|
||||||
// this->downloading.dirPath = this->downloading.savePath.c_str();
|
|
||||||
this->settings.setValue("Folder/", this->downloading.savePath.c_str());
|
this->settings.setValue("Folder/", this->downloading.savePath.c_str());
|
||||||
this->settings.sync();
|
this->settings.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Activated when menu "settings" is clicked
|
||||||
void MainWindow::on_action_Settings_triggered()
|
void MainWindow::on_action_Settings_triggered()
|
||||||
{
|
{
|
||||||
config.UnitCombobox->setCurrentText(QString::fromStdString(this->connexion.bandwidthLimitUnit));
|
config.UnitCombobox->setCurrentIndex(bwUnixIndex[this->connexion.bandwidthLimitUnit[0]]);
|
||||||
config.spinBox->setValue(this->connexion.bandwidthLimit);
|
config.spinBox->setValue(this->connexion.bandwidthLimit);
|
||||||
Configuration.show();
|
Configuration.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Acivated when "Ok" is clicked in Configuration window
|
||||||
void MainWindow::on_buttonBox_accepted()
|
void MainWindow::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
QString unit;
|
QString unit;
|
||||||
@ -518,9 +594,15 @@ void MainWindow::on_buttonBox_accepted()
|
|||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
this->connexion.bandwidthLimit = config.spinBox->value();
|
this->connexion.bandwidthLimit = config.spinBox->value();
|
||||||
this->connexion.bandwidthLimitUnit = config.UnitCombobox->currentText().toStdString();
|
this->connexion.bandwidthLimitUnit = config.UnitCombobox->currentText().toStdString()[0];
|
||||||
}
|
}
|
||||||
this->settings.setValue("bandwidthlimit", this->connexion.bandwidthLimit);
|
this->settings.setValue("bandwidthlimit", this->connexion.bandwidthLimit);
|
||||||
this->settings.setValue("bandwidthlimitunit", this->connexion.bandwidthLimitUnit.c_str());
|
this->settings.setValue("bandwidthlimitunit", this->connexion.bandwidthLimitUnit.c_str());
|
||||||
this->settings.sync();
|
this->settings.sync();
|
||||||
|
Configuration.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_comboBox_currentIndexChanged(int index)
|
||||||
|
{
|
||||||
|
ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)index);
|
||||||
}
|
}
|
||||||
|
22
mainwindow.h
22
mainwindow.h
@ -31,6 +31,8 @@
|
|||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <magic.h>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
@ -52,7 +54,6 @@ class Downloading
|
|||||||
std::string path;
|
std::string path;
|
||||||
std::string defaultSavePath;
|
std::string defaultSavePath;
|
||||||
std::string savePath;
|
std::string savePath;
|
||||||
QString dirPath;
|
|
||||||
int pid = 0;
|
int pid = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,9 +61,10 @@ class About
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString title = "RsyncUI";
|
QString title = "RsyncUI";
|
||||||
|
QString version = "1.6";
|
||||||
QString author = "Daniel TARTAVEL-JEANNOT";
|
QString author = "Daniel TARTAVEL-JEANNOT";
|
||||||
QString licence = "GPL_V3";
|
QString licence = "GPL_V3";
|
||||||
QString description = "Client for rsync server";
|
QString description;
|
||||||
QString email = "dtux@free.fr";
|
QString email = "dtux@free.fr";
|
||||||
QString git = "https://git.labolyon.fr/dtux/RsyncUI/issues";
|
QString git = "https://git.labolyon.fr/dtux/RsyncUI/issues";
|
||||||
};
|
};
|
||||||
@ -77,13 +79,13 @@ class MainWindow : public QMainWindow
|
|||||||
~MainWindow();
|
~MainWindow();
|
||||||
QProgressDialog *progress;
|
QProgressDialog *progress;
|
||||||
void displayTree();
|
void displayTree();
|
||||||
void populateTree();
|
void populateTree(QTreeWidgetItem * parent);
|
||||||
void populateList();
|
void populateList();
|
||||||
void listServices();
|
void listServices();
|
||||||
bool validateServer(std::string server);
|
bool validateServer(std::string server);
|
||||||
bool isIpAddress(std::string server);
|
bool isIpAddress(std::string server);
|
||||||
QTreeWidgetItem * addTreeRoot(QString name, QString description);
|
QTreeWidgetItem * addTreeRoot(QString name, QString description, bool isDir);
|
||||||
QTreeWidgetItem * addTreeChild(QTreeWidgetItem *parent, QString name, QString size);
|
QTreeWidgetItem * addTreeChild(QTreeWidgetItem *parent, QString name, QString size, bool isDir);
|
||||||
void scanDir(std::string server, int portN, QTreeWidgetItem *parent = NULL, std::string path = "" );
|
void scanDir(std::string server, int portN, QTreeWidgetItem *parent = NULL, std::string path = "" );
|
||||||
void startDownloading();
|
void startDownloading();
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
@ -98,6 +100,13 @@ class MainWindow : public QMainWindow
|
|||||||
QDialog Configuration;
|
QDialog Configuration;
|
||||||
Ui::Configuration config;
|
Ui::Configuration config;
|
||||||
std::vector <QString> serversList;
|
std::vector <QString> serversList;
|
||||||
|
map<char, int> bwUnixIndex {
|
||||||
|
{'B', 0},
|
||||||
|
{'K', 1},
|
||||||
|
{'M', 2},
|
||||||
|
{'G', 3},
|
||||||
|
{'P', 4}
|
||||||
|
};
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
@ -123,8 +132,9 @@ 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();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
145
mainwindow.ui
145
mainwindow.ui
@ -20,6 +20,9 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||||
|
</property>
|
||||||
<property name="documentMode">
|
<property name="documentMode">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -57,7 +60,7 @@
|
|||||||
<cursorShape>IBeamCursor</cursorShape>
|
<cursorShape>IBeamCursor</cursorShape>
|
||||||
</property>
|
</property>
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::TabFocus</enum>
|
<enum>Qt::WheelFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="acceptDrops">
|
<property name="acceptDrops">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -98,6 +101,12 @@
|
|||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Enter server's URL</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTipDuration">
|
||||||
|
<number>5000</number>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -133,6 +142,15 @@
|
|||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::WheelFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Enter rsync port on server</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTipDuration">
|
||||||
|
<number>5000</number>
|
||||||
|
</property>
|
||||||
<property name="inputMethodHints">
|
<property name="inputMethodHints">
|
||||||
<set>Qt::ImhPreferNumbers</set>
|
<set>Qt::ImhPreferNumbers</set>
|
||||||
</property>
|
</property>
|
||||||
@ -161,8 +179,14 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="connectButton">
|
<widget class="QPushButton" name="connectButton">
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::WheelFocus</enum>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string extracomment="Connect to server"/>
|
<string extracomment="Connect to server">Press button to connect to rsync server</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTipDuration">
|
||||||
|
<number>5000</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Connection</string>
|
<string>Connection</string>
|
||||||
@ -190,9 +214,21 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::WheelFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Click to view the list of files of this folder</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTipDuration">
|
||||||
|
<number>5000</number>
|
||||||
|
</property>
|
||||||
<property name="editTriggers">
|
<property name="editTriggers">
|
||||||
<set>QAbstractItemView::SelectedClicked</set>
|
<set>QAbstractItemView::SelectedClicked</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="tabKeyNavigation">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="resizeMode">
|
<property name="resizeMode">
|
||||||
<enum>QListView::Adjust</enum>
|
<enum>QListView::Adjust</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -210,12 +246,27 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::WheelFocus</enum>
|
||||||
|
</property>
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
<enum>Qt::NoContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Click to add to download queue</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTipDuration">
|
||||||
|
<number>5000</number>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis">
|
||||||
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="editTriggers">
|
<property name="editTriggers">
|
||||||
<set>QAbstractItemView::NoEditTriggers</set>
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="tabKeyNavigation">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="showDropIndicator" stdset="0">
|
<property name="showDropIndicator" stdset="0">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -240,6 +291,9 @@
|
|||||||
<property name="sortingEnabled">
|
<property name="sortingEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="animated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="columnCount">
|
<property name="columnCount">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
@ -273,6 +327,15 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QListWidget" name="listDownload">
|
<widget class="QListWidget" name="listDownload">
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::WheelFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Click on file to stop downloading</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTipDuration">
|
||||||
|
<number>5000</number>
|
||||||
|
</property>
|
||||||
<property name="dragEnabled">
|
<property name="dragEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -297,39 +360,51 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QToolBar" name="toolBar">
|
||||||
<property name="geometry">
|
<property name="contextMenuPolicy">
|
||||||
<rect>
|
<enum>Qt::NoContextMenu</enum>
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>500</width>
|
|
||||||
<height>30</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menu">
|
<property name="windowTitle">
|
||||||
<property name="title">
|
<string>toolBar</string>
|
||||||
<string>Menu</string>
|
</property>
|
||||||
</property>
|
<property name="layoutDirection">
|
||||||
<addaction name="DefaultSaveFolder"/>
|
<enum>Qt::LeftToRight</enum>
|
||||||
<addaction name="action_Settings"/>
|
</property>
|
||||||
</widget>
|
<property name="autoFillBackground">
|
||||||
<widget class="QMenu" name="menuhelp">
|
<bool>true</bool>
|
||||||
<property name="title">
|
</property>
|
||||||
<string>help</string>
|
<property name="movable">
|
||||||
</property>
|
<bool>true</bool>
|
||||||
<addaction name="actionAbout"/>
|
</property>
|
||||||
<addaction name="actionAbout_Qt"/>
|
<property name="allowedAreas">
|
||||||
</widget>
|
<set>Qt::AllToolBarAreas</set>
|
||||||
<addaction name="menu"/>
|
</property>
|
||||||
<addaction name="menuhelp"/>
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||||
|
</property>
|
||||||
|
<property name="floatable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<addaction name="DefaultSaveFolder"/>
|
||||||
|
<addaction name="action_Settings"/>
|
||||||
|
<addaction name="actionAbout"/>
|
||||||
|
<addaction name="actionAbout_Qt"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
|
||||||
<action name="actionMenu">
|
<action name="actionMenu">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Menu</string>
|
<string>Menu</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="DefaultSaveFolder">
|
<action name="DefaultSaveFolder">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="system-file-manager"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Change save folder</string>
|
<string>Change save folder</string>
|
||||||
</property>
|
</property>
|
||||||
@ -337,22 +412,26 @@
|
|||||||
<string>Change save folder</string>
|
<string>Change save folder</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionBandwidth_limit">
|
|
||||||
<property name="text">
|
|
||||||
<string>Bandwidth limit</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionAbout">
|
<action name="actionAbout">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="help-about"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>About</string>
|
<string>About</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionAbout_Qt">
|
<action name="actionAbout_Qt">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="help-browser"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>About Qt</string>
|
<string>About Qt</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_Settings">
|
<action name="action_Settings">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="preferences-other"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Settings</string>
|
<string>Settings</string>
|
||||||
</property>
|
</property>
|
||||||
|
32
tools.cpp
32
tools.cpp
@ -1,17 +1,14 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <string>
|
|
||||||
#include <cstring>
|
|
||||||
#include <vector>
|
|
||||||
#include <iostream>
|
|
||||||
#include <pstreams/pstream.h>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define READ 0
|
#define READ 0
|
||||||
#define WRITE 1
|
#define WRITE 1
|
||||||
|
|
||||||
|
//Take a string and explode it in array
|
||||||
|
// s => string to explode
|
||||||
|
// c => character separator
|
||||||
|
// n => number of results in array, the last is the rest of string to end
|
||||||
const vector<string> explode(const string& s, const char& c, int n = 0)
|
const vector<string> explode(const string& s, const char& c, int n = 0)
|
||||||
{
|
{
|
||||||
string buff;
|
string buff;
|
||||||
@ -44,11 +41,14 @@ const vector<string> explode(const string& s, const char& c, int n = 0)
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE * popen2(array<string, 7> argv, string type, int & pid)
|
// open a pipe, fork and return pid of child
|
||||||
|
// argv => array of string with command in first and parameters following
|
||||||
|
FILE * popen2(array<string,8> argv, string type, int & pid)
|
||||||
{
|
{
|
||||||
pid_t child_pid;
|
pid_t child_pid;
|
||||||
int fd[2];
|
int fd[2];
|
||||||
QString message;
|
QString message;
|
||||||
|
string command;
|
||||||
|
|
||||||
if (pipe(fd) == -1)
|
if (pipe(fd) == -1)
|
||||||
{
|
{
|
||||||
@ -57,6 +57,7 @@ FILE * popen2(array<string, 7> argv, string type, int & pid)
|
|||||||
NULL,
|
NULL,
|
||||||
"RsyncUI",
|
"RsyncUI",
|
||||||
message);
|
message);
|
||||||
|
exit(-1);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
if((child_pid = fork()) == -1)
|
if((child_pid = fork()) == -1)
|
||||||
@ -80,10 +81,9 @@ FILE * popen2(array<string, 7> argv, string type, int & pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
setpgid(child_pid, child_pid); //Needed so negative PIDs can kill children of /bin/sh
|
setpgid(child_pid, child_pid); //Needed so negative PIDs can kill children of /bin/sh
|
||||||
if (execl(argv[0].c_str(), argv[0].c_str(), argv[1].c_str(), argv[2].c_str(), argv[3].c_str(), argv[4].c_str(), argv[5].c_str(), NULL ) == -1)
|
//TODO : change for execvp
|
||||||
{
|
|
||||||
perror("execl error => ");
|
if (execlp(argv[0].c_str(), argv[0].c_str(), argv[1].c_str(), argv[2].c_str(), argv[3].c_str(), argv[4].c_str(), argv[5].c_str(), NULL ) == -1)
|
||||||
}
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -98,19 +98,20 @@ FILE * popen2(array<string, 7> argv, string type, int & pid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pid = child_pid;
|
pid = child_pid;
|
||||||
|
|
||||||
if (type == "r")
|
if (type == "r")
|
||||||
{
|
{
|
||||||
return fdopen(fd[READ], "r");
|
return fdopen(fd[READ], "r");
|
||||||
}
|
}
|
||||||
|
|
||||||
return fdopen(fd[WRITE], "w");
|
return fdopen(fd[WRITE], "w");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// close pipe open by popen2 while pid is finished
|
||||||
|
// fp => file pointer
|
||||||
|
// pid => pid of the processus open bu popen2
|
||||||
|
|
||||||
int pclose2(FILE * fp, pid_t pid)
|
int pclose2(FILE * fp, pid_t pid)
|
||||||
{
|
{
|
||||||
int stat;
|
int stat;
|
||||||
@ -124,7 +125,6 @@ int pclose2(FILE * fp, pid_t pid)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
tools.h
2
tools.h
@ -9,7 +9,7 @@ using namespace std;
|
|||||||
|
|
||||||
const vector<string> explode(const string& s, const char& c, int n);
|
const vector<string> explode(const string& s, const char& c, int n);
|
||||||
|
|
||||||
FILE * popen2(array<string, 7> argv, string type, int & pid);
|
FILE * popen2(array<string,8> argv, string type, int & pid);
|
||||||
|
|
||||||
int pclose2(FILE * fp, pid_t pid);
|
int pclose2(FILE * fp, pid_t pid);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user