#ifndef FILERECEIVINGPOPUPWIDGET_H
#define FILERECEIVINGPOPUPWIDGET_H
extern "C" {
#include <gio/gio.h>
#include <gio/gfile.h>
#include <gio/gioerror.h>
#include <sys/stat.h>
#include <sys/types.h>
}
#include <string>

#include <QApplication>
#include <QDesktopWidget>
#include <QWidget>
#include <QDialog>
#include <QIcon>
#include <QLabel>
#include <QPushButton>
#include <QProgressBar>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QPalette>
#include <QString>
#include <QRect>
#include <QPoint>
#include <QDebug>
#include <QDir>
#include <QTimer>
#include <QFile>
#include <QProcess>
#include <QGSettings>
#include <QHBoxLayout>
#include <QPainter>
#include <QKeyEvent>
#define TRANSPARENCY_SETTINGS       "org.ukui.control-center.personalise"
#define TRANSPARENCY_KEY            "transparency"


class FileReceivingPopupWidget : public QWidget
{
    Q_OBJECT
public:
    explicit FileReceivingPopupWidget(QString address, QString devname = "", QString filename = "", QString type = "", QString root = "", quint64 size = 0);
    ~FileReceivingPopupWidget();
    void configuration_transfer_progress_bar(quint64);
    void window_pop_up_animation();
    bool move_file();
public slots:
    void updateUI(QString name, quint64 size, QString type);
    void OnClickedAcceptBtn();
    void update_transfer_progress_bar(quint64, QString path);
    void file_transfer_completed(QString status, QString dev, QString path);
    void cancelReceivingFiles();
    void GSettings_value_chanage(const QString &key);
    void GSettingsChanges(const QString &key);
    void transferCompelete();
    void initTransferPath(QString path, bool isSend);
signals:
    void cancel();
    void rejected();
    void accepted();
    void clearOldSession();
    void continueRecieveFilesRequest();
private:
    bool isCanceled = false;
    bool isIntel = false;
    bool isError = false;
    QGSettings   *StyleSettings = nullptr;
    QGSettings   *settings      = nullptr;
    QGSettings *transparency_gsettings = nullptr;

    QPushButton  *close_btn     = nullptr;
    QPushButton  *cancel_btn    = nullptr;
    QPushButton  *accept_btn    = nullptr;
    QPushButton  *view_btn      = nullptr;

    QLabel       *icon_label    = nullptr;
    QLabel       *file_source   = nullptr;
    QLabel       *window_Title  = nullptr;
    QLabel       *file_name     = nullptr;
    QLabel       *file_size     = nullptr;
    QLabel       *file_icon     = nullptr;
    QLabel       *warn_icon     = nullptr;
    QProgressBar *transfer_progress = nullptr;

    QRect   desktop;
    QString unitString[5] = {"Bytes", "KB", "MB", "GB", "TB"};
    QString target_address;
    QString target_name;
    QString target_source;
    QString target_type;
    QString root_address;
    QString file_path;
    quint64 target_size;
    QString _objectPath;
    QTimer *receiveTimer;
    int fileNums = 0;
    QList<QString> receivedFiles;
    int pressCnt = 0;

    QPushButton *getButton();
    void initLayout();
    void initIntelLayout();
    QIcon getFileIconFromType(QString type);

protected:
    void paintEvent(QPaintEvent *event);
    void keyPressEvent(QKeyEvent *event);
};

#endif // FILERECEIVINGPOPUPWIDGET_H
