rsyncui/mainwindow.h
2023-02-03 15:59:53 +01:00

154 lines
3.7 KiB
C++

#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"
#include "tools.h"
#include <QMainWindow>
#include <string>
#include <QTreeWidgetItem>
#include <QListWidgetItem>
#include <QProgressDialog>
#include <QSettings>
#include <vector>
#include <iostream>
#include <KTreeWidgetSearchLineWidget>
#include <pstreams/pstream.h>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <cstdio>
#include <QMessageBox>
#include <boost/algorithm/string/replace.hpp>
#include <QFuture>
#include <qtconcurrentrun.h>
#include <QFileDialog>
#include <QThread>
#include <QProgressDialog>
#include <sys/wait.h>
#include <QGuiApplication>
#include <QShortcut>
#include <QCloseEvent>
#include <unistd.h>
#include <magic.h>
#include <QComboBox>
#include <QStringBuilder>
#include <pwd.h>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class Connexion
{
public:
int bandwidthLimit = 0;
std::string bandwidthLimitUnit = "";
std::string server;
std::string service;
int port = 873;
};
class Downloading
{
public:
std::string server;
std::string service;
std::string path;
std::string savePath;
void clear();
};
class About
{
public:
QString title = "RsyncUI";
QString version = "1.8.17";
QString author = "Daniel TARTAVEL-JEANNOT";
QString licence = "GPL_V3";
QString description;
QString email = "dtux@free.fr";
QString git = "https://git.labolyon.fr/dtux/RsyncUI/issues";
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
Ui::MainWindow *ui;
MainWindow(QWidget *parent = nullptr);
~MainWindow();
QProgressDialog *progress;
int pid = 0;
Connexion connexion;
Downloading downloading;
downloadFile downloadO;
QSettings settings;
About about;
QDialog Configuration;
Ui::Configuration config;
std::vector <QString> serversList;
map<char, int> bwUnixIndex {
{'B', 0},
{'K', 1},
{'M', 2},
{'G', 3},
{'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, bool downloadDir = false);
void downloadFinished();
void stoppingDownload();
void on_listDownload_itemClicked(QListWidgetItem *item);
void on_actionAbout_triggered();
void on_actionAbout_Qt_triggered();
void on_khistorycombobox_currentIndexChanged(int);
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);
};
#endif // MAINWINDOW_H