diff --git a/RsyncUI.pro b/RsyncUI.pro
index 7d096b4..acc92a1 100644
--- a/RsyncUI.pro
+++ b/RsyncUI.pro
@@ -1,7 +1,10 @@
-QT += core gui concurrent
-QT += KItemViews
-QT += KCompletion
-QT += widgets
+QT += core gui concurrent
+QT += KItemViews
+QT += KCompletion
+QT += widgets
+QT += KConfigCore KConfigGui
+QT += KCoreAddons
+QT += KDBusAddons
#LIBS += -lKF5WindowSystem
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
diff --git a/RsyncUI_fr_FR.ts b/RsyncUI_fr_FR.ts
index 531267a..5fa9855 100644
--- a/RsyncUI_fr_FR.ts
+++ b/RsyncUI_fr_FR.ts
@@ -1,19 +1,6 @@
-
- Dialog
-
-
-
-
-
-
-
-
-
-
-
MainWindow
@@ -40,28 +27,75 @@
-
- debug
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ debug
+
+
+
Chemin
-
+
Taille
-
+
+
+
+
+
+
Le serveur n'existe pas
-
+
Choisissez le dossier où enregistrer
+
+
+
+
+
+
+
+
+
+
diff --git a/downloadfile.cpp b/downloadfile.cpp
index 8e6234e..785453b 100644
--- a/downloadfile.cpp
+++ b/downloadfile.cpp
@@ -1,6 +1,6 @@
-#include "downloadfile.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
+#include "downloadfile.h"
#include "tools.h"
#include
#include
@@ -74,7 +74,7 @@ void downloadFile::download(MainWindow *mw)
{
line.erase(0, pos);
value = stoi(line);
- cout << value << endl;
+ //cout << value << endl;
emit progressSignal(value);
}
}
diff --git a/main.cpp b/main.cpp
index 21122c2..01e0f28 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,6 +1,10 @@
#include "mainwindow.h"
#include
#include
+#include
+#include
+#include
+#include
int main(int argc, char *argv[])
{
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 3237198..c16e1f8 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -41,6 +41,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->ktreewidgetsearchline->setCaseSensitivity(Qt::CaseInsensitive);
ui->treeWidget->setHeaderLabels({tr("Path"), tr("Size")} );
ui->progressBar->hide();
+
loadSettings();
populateList();
@@ -51,7 +52,6 @@ MainWindow::~MainWindow()
{
QMessageBox::StandardButton reply;
-
if (ui->listDownload->count() != 0)
{
reply = QMessageBox::question(
@@ -64,7 +64,8 @@ MainWindow::~MainWindow()
{
emit (stopDownloading(this->downloading.pid));
}
- }
+ }
+ saveSettings();
if (this->downloading.pid != 0)
{
waitpid(this->downloading.pid, NULL, WUNTRACED);
@@ -79,36 +80,59 @@ void MainWindow::populateTree()
if (!this->connexion.server.empty() and this->connexion.port > 0 and this->connexion.port < 65536)
{
+ QGuiApplication::setOverrideCursor(Qt::WaitCursor);
if (validateServer(this->connexion.server))
{
- QGuiApplication::setOverrideCursor(Qt::WaitCursor);
path = explode(ui->listWidget->currentItem()->text().toStdString(), '\n', 2);
scanDir(this->connexion.server, this->connexion.port, NULL, path[0].append("/") );
- this->unsetCursor();
- QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
}
+ QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
}
}
void MainWindow::populateList()
{
stringstream ss;
+ QString str;
+ QString server;
+ QString port;
- this->connexion.server.assign(ui->khistorycombobox->currentText().toStdString());
+ server = ui->khistorycombobox->currentText();
+ this->connexion.server.assign(server.toStdString());
ss << ui->portEdit->text().toStdString();
ss >> this->connexion.port;
- if (!this->connexion.server.empty() and this->connexion.port > 0 and this->connexion.port < 65536)
+ QGuiApplication::setOverrideCursor(Qt::WaitCursor);
+
+ this->settings.beginGroup("connexion/server");
+ if (this->settings.contains(server))
{
- if (validateServer(this->connexion.server))
+ port = this->settings.value(server).toString();
+ ui->portEdit->setText(port);
+ this->connexion.port = this->settings.value(server).toInt();
+ }
+
+ if (!server.isEmpty() and this->connexion.port > 0 and this->connexion.port < 65536)
+ {
+ if (validateServer(server.toStdString()))
{
- ui->khistorycombobox->addItem(this->connexion.server.c_str());
- ui->centralwidget->cursor().setShape(Qt::WaitCursor);
+ //this->settings.beginGroup("connexion/server");
+ if (!this->settings.contains(server))
+ {
+ cout << server.toStdString() << endl;
+ // storing serverURL and port in settings
+ this->settings.setValue(server, this->connexion.port);
+ this->settings.sync();
+
+ // storing in history of combobox
+ ui->khistorycombobox->addToHistory(server);
+ }
+ // "waiting" cursor
+ // load and display rsync services of the rsync server
listServices();
- ui->centralwidget->cursor().setShape(Qt::ArrowCursor);
- QStringList test = ui->khistorycombobox->historyItems();
- sleep(1);
}
}
+ this->settings.endGroup();
+ QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
}
void MainWindow::listServices()
@@ -119,11 +143,12 @@ void MainWindow::listServices()
vector v;
char service[4096];
+ ui->listWidget->clear();
sprintf(cmd, "rsync --contimeout=10 -P \"%s::\" --port %d ", this->connexion.server.c_str(), this->connexion.port );
redi::ipstream in(cmd, redi::pstreams::pstdout | redi::pstreams::pstderr);
while (getline(in.out(), line))
{
- cout << "stdout: " << line << endl;
+ //cout << "stdout: " << line << endl;
boost::replace_all(line," ","");
boost::replace_all(line, "\t", " - ");
v = explode(line, ' ', 3 );
@@ -221,7 +246,7 @@ bool MainWindow::validateServer(string server)
while (getline(in.out(), line))
{
- cout << "stdout: " << line << '\n';
+ //cout << "stdout: " << line << '\n';
if (line.find(";; ANSWER SECTION:") != string::npos)
{
flag = true;
@@ -268,7 +293,16 @@ void MainWindow::displayTree()
void MainWindow::on_khistorycombobox_returnPressed()
{
- populateList();
+ //populateList();
+}
+
+void MainWindow::on_khistorycombobox_currentIndexChanged(int i)
+{
+ /*QString server = ui->khistorycombobox->currentText();
+ this->settings.beginGroup("connexion/server");
+ ui->portEdit->setText(this->settings.value(server).toString());
+ this->settings.endGroup();*/
+ this->populateList();
}
void MainWindow::on_portEdit_returnPressed()
@@ -276,16 +310,6 @@ void MainWindow::on_portEdit_returnPressed()
populateList();
}
-void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
-{
-
-}
-
-void MainWindow::on_treeWidget_customContextMenuRequested()
-{
-
-}
-
void MainWindow::on_actionDownload_triggered()
{
@@ -387,7 +411,7 @@ void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item)
QFileDialog dialog;
QMessageBox::StandardButton reply;
- cout << item->text().toStdString() << endl;
+ //cout << item->text().toStdString() << endl;
if (item->listWidget()->row(item) == 0)
{
reply = QMessageBox::question(
@@ -418,10 +442,36 @@ void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item)
void MainWindow::loadSettings()
{
- this->settings.value("serverlist");
+ this->restoreGeometry(settings.value("window/geometry").toByteArray());
+ this->settings.beginGroup("connexion/server");
+
+ QStringList servers = this->settings.allKeys();
+ this->settings.endGroup();
+
+ for( const QString &server : servers )
+ {
+ ui->khistorycombobox->addToHistory(server);
+ }
}
+
void MainWindow::saveSettings()
{
- //ui->khistorycombobox->
+ this->settings.setValue("window/geometry", saveGeometry());
+ this->settings.sync();
+}
+
+void MainWindow::on_actionAbout_triggered()
+{
+ QString text = this->about.description + "\n\n" +
+ "Licence: " + this->about.licence + "\n" +
+ "Author: " + this->about.author + "\n" +
+ "EMail : " + this->about.email + "\n" +
+ "Source code: " + this->about.git;
+ QMessageBox::about(this, this->about.title, text);
+}
+
+void MainWindow::on_actionAbout_Qt_triggered()
+{
+ QMessageBox::aboutQt(this);
}
diff --git a/mainwindow.h b/mainwindow.h
index 438e49f..e710537 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -8,6 +8,7 @@
#include "downloadfile.h"
#include
#include
+#include
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
@@ -32,6 +33,17 @@ class Downloading
int pid = 0;
};
+class About
+{
+ public:
+ QString title = "RsyncUI";
+ QString author = "Daniel TARTAVEL-JEANNOT";
+ QString licence = "GPL_V3";
+ QString description = "Client for rsync server";
+ QString email = "dtux@free.fr";
+ QString git = "https://git.labolyon.fr/dtux/RsyncUI/issues";
+};
+
class MainWindow : public QMainWindow
{
Q_OBJECT
@@ -58,6 +70,9 @@ class MainWindow : public QMainWindow
Downloading downloading;
downloadFile downloadO;
QSettings settings;
+ About about;
+
+ std::vector serversList;
private slots:
void on_khistorycombobox_returnPressed();
@@ -66,10 +81,6 @@ class MainWindow : public QMainWindow
void on_portEdit_returnPressed();
- void on_treeWidget_itemClicked(QTreeWidgetItem *item, int column);
-
- void on_treeWidget_customContextMenuRequested();
-
void on_actionDownload_triggered();
void on_listWidget_clicked(const QModelIndex &index);
@@ -82,6 +93,12 @@ class MainWindow : public QMainWindow
void on_listDownload_itemClicked(QListWidgetItem *item);
+ void on_actionAbout_triggered();
+
+ void on_actionAbout_Qt_triggered();
+
+ void on_khistorycombobox_currentIndexChanged(int i);
+
signals:
void stopDownloading(int);
diff --git a/mainwindow.ui b/mainwindow.ui
index 4a8795c..8bfaf92 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -296,7 +296,15 @@
+
+
@@ -317,6 +325,16 @@
Bandwidth limit
+
+
+ About
+
+
+
+
+ About Qt
+
+
diff --git a/tools.cpp b/tools.cpp
index 3bbef34..2002a9f 100644
--- a/tools.cpp
+++ b/tools.cpp
@@ -1,3 +1,4 @@
+#include "mainwindow.h"
#include
#include
#include