rsyncui/mainwindow.h

144 lines
3.4 KiB
C
Raw Normal View History

2023-01-07 12:44:45 +01:00
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
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-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;
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;
int pid = 0;
};
class About
{
public:
QString title = "RsyncUI";
2023-01-26 12:04:08 +01:00
QString version = "1.6";
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;
void displayTree();
void populateTree(QTreeWidgetItem * parent);
2023-01-12 09:23:45 +01:00
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);
2023-01-12 09:23:45 +01:00
void scanDir(std::string server, int portN, QTreeWidgetItem *parent = NULL, std::string path = "" );
void startDownloading();
void loadSettings();
void saveSettings();
2023-01-22 14:33:23 +01:00
void closeEvent (QCloseEvent *event);
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
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-01-22 14:33:23 +01:00
void on_treeWidget_itemClicked(QTreeWidgetItem *item);
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-01-15 15:25:22 +01:00
void on_DefaultSaveFolder_triggered();
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-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);
// void accepted();
};
2023-01-12 09:23:45 +01:00
2023-01-07 12:44:45 +01:00
#endif // MAINWINDOW_H