#ifndef STARTUPTOOL_H
#define STARTUPTOOL_H

#include <QObject>
#include <QString>
#include <QMap>
#include <QSet>
#include <QSettings>
//#include "publicattributes.hpp"
#include "ctrl.h"
#include <glib.h>

enum opType{
    CLOSE = 0,
    OPEN,
    ORTHER
};

class StartUpTools : public QObject
{
    Q_OBJECT
public:
    static StartUpTools *getInstance();

//    void setModel(PublicAttributes::Model model);
    bool inspectCtrl(const QString &key);
    QString findNmKey(const QString &key);
    opType isExit(const QString &key);
    QString findKey(const QString &key, opType type);
    void startUp(const QString &path);
    void killProcess(const QString key);
    static QSet<QString> initConfigBrightnessUpSet();
    static QSet<QString> initConfigBrightnessDownSet();
    static QMap<QString, QString> initConfigNmMap();
    static QMap<QString, QString> initConfigPlayMap();
    static QMap<QString, QString> initConfigNomalMap();
//    static QMap<QString, QString> initConfigTabletMap();
    static QMap<QString, QString> initConfigExitMap();
    void initConfig();
    void getAndroidApp();//获取安卓应用
    QStringList getDesktopFilePath();//获取系统desktop文件路径
    QStringList getFullDesktopFileList();
    bool addToSchedule(QString summary, QString msg);
    bool addToDoList(QString summary);
    int getScheduleYear();
    int getScheduleDay();
    int getScheduleMonth();
    int getTodoListDay();
    int getTodoListMonth();
    int getTodoListYear();
    bool openSchedule(int year, int month, int day);

protected:
     void recursiveSearchFile(const QString &_filePath);//遍历/usr/share/applications/文件夹

private:
    StartUpTools(QObject *parent = nullptr)
    {
        m_ctrl = new ctrl;
    };

    ~StartUpTools()
    {
        if (m_ctrl != nullptr) {
            delete m_ctrl;
        }
    }

    ctrl *m_ctrl = nullptr;
//    PublicAttributes::Model m_model = PublicAttributes::Model::PcModel;

    static QSet<QString> s_brightnessUpSet;
    static QSet<QString> s_brightnessDownSet;
    static QMap<QString, QString> s_playMap;
    static QMap<QString, QString> s_nmMap;
    static QMap<QString, QString> s_nomalMap;
//    static QMap<QString, QString> s_tabletMap;
    static QMap<QString, QString> s_exitMap;
    QSettings *m_settingsIni;
    static QStringList m_androidDesktopfnList;
    static QStringList m_fullFillPathList;
    GError **m_error = nullptr;
    GKeyFileFlags m_flags = G_KEY_FILE_NONE;
    GKeyFile *m_keyfile = nullptr;

};

#endif  // STARTUPTOOL_H
