rsyncui/mainwindow.h

154 lines
3.7 KiB
C
Raw Permalink Normal View History

2023-01-07 12:44:45 +01:00
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
2023-02-02 16:10:51 +01:00
#define QT_USE_FAST_CONCATENATION
#define QT_USE_FAST_OPERATOR_PLUS
2023-01-22 14:33:23 +01:00
#include "ui_mainwindow.h"
#include "ui_configuration.h"
#include "downloadfile.h"
2023-01-18 23:12:21 +01:00
#include "tools.h"
2023-01-07 12:44:45 +01:00
#include <QMainWindow>
#include <string>
#include <QTreeWidgetItem>
#include <QListWidgetItem>
#include <QProgressDialog>
2023-01-12 09:23:45 +01:00
#include <QSettings>
#include <vector>
2023-01-22 14:33:23 +01:00
#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>
2023-01-27 18:14:50 +01:00
#include <QComboBox>
2023-02-02 16:10:51 +01:00
#include <QStringBuilder>
#include <pwd.h>
2023-01-07 12:44:45 +01:00
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
2023-01-12 09:23:45 +01:00
class Connexion
{
public:
2023-01-22 14:33:23 +01:00
int bandwidthLimit = 0;
std::string bandwidthLimitUnit = "";
2023-01-12 09:23:45 +01:00
std::string server;
2023-02-02 16:10:51 +01:00
std::string service;
2023-01-12 09:23:45 +01:00
int port = 873;
};
class Downloading
{
public:
std::string server;
2023-01-12 09:23:45 +01:00
std::string service;
std::string path;
std::string savePath;
2023-02-02 16:10:51 +01:00
void clear();
2023-01-12 09:23:45 +01:00
};
class About
{
public:
QString title = "RsyncUI";
2023-02-03 16:02:01 +01:00
QString version = "1.8.18";
QString author = "Daniel TARTAVEL-JEANNOT";
QString licence = "GPL_V3";
2023-01-26 12:02:12 +01:00
QString description;
QString email = "dtux@free.fr";
QString git = "https://git.labolyon.fr/dtux/RsyncUI/issues";
};
2023-01-07 12:44:45 +01:00
class MainWindow : public QMainWindow
{
Q_OBJECT
2023-01-12 09:23:45 +01:00
public:
Ui::MainWindow *ui;
MainWindow(QWidget *parent = nullptr);
~MainWindow();
QProgressDialog *progress;
2023-02-02 16:10:51 +01:00
int pid = 0;
2023-01-12 09:23:45 +01:00
Connexion connexion;
Downloading downloading;
downloadFile downloadO;
QSettings settings;
About about;
2023-01-22 14:33:23 +01:00
QDialog Configuration;
Ui::Configuration config;
std::vector <QString> serversList;
map<char, int> bwUnixIndex {
{'B', 0},
{'K', 1},
{'M', 2},
{'G', 3},
{'P', 4}
};
2023-01-12 09:23:45 +01:00
2023-02-02 16:10:51 +01:00
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();
2023-01-12 09:23:45 +01:00
private slots:
2023-01-07 12:44:45 +01:00
2023-01-18 23:12:21 +01:00
void on_listWidget_clicked();
2023-01-07 12:44:45 +01:00
2023-02-02 17:14:04 +01:00
void on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadDir = false);
2023-01-07 12:44:45 +01:00
2023-01-12 09:23:45 +01:00
void downloadFinished();
2023-01-07 12:44:45 +01:00
2023-01-12 09:23:45 +01:00
void stoppingDownload();
2023-01-07 12:44:45 +01:00
2023-01-12 09:23:45 +01:00
void on_listDownload_itemClicked(QListWidgetItem *item);
2023-01-07 12:44:45 +01:00
void on_actionAbout_triggered();
void on_actionAbout_Qt_triggered();
2023-01-18 23:12:21 +01:00
void on_khistorycombobox_currentIndexChanged(int);
2023-02-02 16:10:51 +01:00
bool on_DefaultSaveFolder_triggered();
2023-01-15 15:25:22 +01:00
2023-01-18 23:12:21 +01:00
void on_connectButton_clicked();
2023-01-22 14:33:23 +01:00
void on_action_Settings_triggered();
2023-01-07 12:44:45 +01:00
2023-02-02 17:14:04 +01:00
void on_actionDownload_triggered();
2023-01-27 18:14:50 +01:00
public slots:
2023-01-22 14:33:23 +01:00
void on_buttonBox_accepted();
2023-01-12 09:23:45 +01:00
2023-01-22 14:33:23 +01:00
signals:
void stopDownloading(int);
};
2023-01-12 09:23:45 +01:00
2023-01-07 12:44:45 +01:00
#endif // MAINWINDOW_H