#ifndef FILECONFIGDECODE_H
#define FILECONFIGDECODE_H

#include <QObject>
#include <QStandardPaths>
#include <QFile>
#include <QSettings>
#include <QFileInfo>
#include <QDebug>
#if (QT_VERSION <= QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif

typedef enum {
    RENAME_TYPE_NONE = 0,
    RENAME_TYPE_NORMAL,
    RENAME_TYPE_TIME
} RenameType;

class FileConfigDecode
{
public:
    static FileConfigDecode* getInstance();
    ~FileConfigDecode();

    QString getAddress();
    quint16 getPort();
    bool getAutoSetup();
    bool getRename();
    bool getTimeRename();
    bool getAutoCopy();
    QString getUserName();
    QString getPassword();
    RenameType getRenameType();

    void setAddress(QString value);
    void setPort(quint16 value);
    void setAutoSetup(bool value);
    void setRename(bool value);
    void setTimeRename(bool value, int flag);
    void setAutoCopy(bool value);
    void setUserName(QString username);
    void setPassword(QString password);

    void initFile();
    void updateFile();

private:
    QString address;
    quint16 port;
    bool autoSetup;
    bool rename;
    bool timeRename;
    bool autoCopy;
    QString userName;
    QString password;

    bool firstCreate;

    RenameType  renameType = RENAME_TYPE_NONE;

    void fileWrite(QString path, QString address, bool autosetup, bool rename, bool timerename, bool autocopy, QString username, QString password);

    static QScopedPointer<FileConfigDecode> m_instance;

private:
    FileConfigDecode();

    void checkConfig();

//    void initForm();

};

#endif // FILECONFIGDECODE_H
