#ifndef KAGLOBAL_H
#define KAGLOBAL_H

#include <QGSettings>
#include <QUrl>

#include <aiconfig/modelconfig.h>
#include <kylin-ai/private/osassistant/osassistant.h>
#include <kylin-ai/coreai/speech/error.h>
#include <kysdk/kysdk-system/libkysysinfo.h>
#include <QProcess>
#include <math.h>
#include <ukui-log4qt.h>
#include "configmanager.h"
#include <QDir>


using namespace kyai::assistant;
using namespace kyai::config::model;

// 文件类型
enum FileType
{
    ERROR = 0,
    IMAGE,
    DOCUMENT,
    SOURCE,
    SCHEDULE
};
// 消息去向
enum TartgetType
{
    RECVMSG = 0,
    SUMMARY,
    CALENDAR,
    TODOLIST
};
// 页面状态
enum PageType {
    MAIN_PAGE_SIDEBAR_MODE = 0,       // 侧边栏模式下主页面
    SHOW_SIDEBAR,                     // 显示侧边栏
    MAIN_PAGE_WINDOW_MODE,            // 窗口模式下显示主界面
};

extern bool isChatInitCompleted;
extern bool isSettingOpen;
extern bool isTextAreaFocus;
extern bool isSpeechSynthesizing;
extern bool isWayland;
extern bool isMinimizeClicked;
extern bool isSupportWindowMode;
extern PageType g_currentPage;

//static QGSettings *g_gsettings = new QGSettings("org.kylin.aiassistant.settings");
static QGSettings *g_panelGettings = new QGSettings("org.ukui.panel.settings");
static QGSettings *g_ukuiGettings = new QGSettings("org.ukui.style");
static ConfigManager * g_configManager = new ConfigManager(QDir::homePath().append("/.config/kylin-aiassistant/settings.ini"));


class Globals : public QObject
{
    Q_OBJECT
    Q_PROPERTY(float fontsize READ fontsize NOTIFY fontsizeChanged FINAL)

public:
    float fontsize() const {return Globals::fontSize;};
    static Globals * getinstance();

signals:
    void fontsizeChanged(float size);


public:
    static int themeColor;      // 主題顏色
    static float fontSize;        // 字体大小
    static QUrl openLink;       // 帮助文档链接
    static double scaleFactor;  // 屏幕缩放比
    static QString defaultPath; // 助手文件存储路径
    static QString sysMajorVersion; // 系统主版本
    static void borderColor(QWidget *widget,int xradius,int yradius, QColor borderColor);
    static void borderRound(QWidget *widget,int xradius,int yradius);
    static QString getErrorMsg(int errorCode);  //根据文本对话错误码，返回错误信息
    static QString getErrorMsg(SpeechErrorCode errorCode);//根据语音对话错误码，返回错误信息
    static bool getIsSupportWindowMode(); //根据主题版本号判断，是否开启大窗口模式、独占模式
    static QString getCurrentSysVersion(); //获取当前操作系统版本信息


private:
    explicit Globals(QObject *parent = nullptr);
    static Globals *m_global;

};

#endif // KAGLOBAL_H
