/*
 * Copyright (C) 2023, KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
#ifndef MENUMODULE_H
#define MENUMODULE_H

#include <QObject>
#include <QtWidgets>
#include <QMenu>
#include <QPushButton>
#include <QToolButton>
#include <QDebug>
#include <QString>
#include <QLabel>
#include <QVBoxLayout>
#include <QUrl>
#include <QHBoxLayout>
#include <QDesktopServices>
#include <QRect>
#include <QScreen>
#include <QGSettings>
#include <QMetaEnum>
#include <QApplication>
#include <QFont>
#include "daemondbus.h"
#include "controller/Interaction.h"
#include "global/viewvar.h"
#include <user_manual.hpp>
// 主题sdk关于
#include "kaboutdialog.h"
class menuModule : public QWidget
{
    Q_OBJECT
public:
    explicit menuModule(QWidget *parent = nullptr);

private:
    QString m_appShowingName = "tianqi";
    QString m_appVersion = "3.1.1";
    QString m_appName = "tianqi";
    QString m_appDesc = "appDesc字段未填充!";
    QString m_iconPath;
    QString m_confPath = "org.china-weather-data.settings";
    QMenu *m_themeMenu = nullptr;
    enum typeThemeStatus { themeAuto = 0, themeBlackOnly = 1, themeLightOnly = 2 } themeStatus;
    QFont m_ft; //固定字号
    QAction *m_locationYes = nullptr;
    QAction *m_locationNo = nullptr;

public:
    QToolButton *menuButton = nullptr;
    //    QPushButton *menuButton = nullptr;
    QMenu *m_menu = nullptr;
    QDialog *m_aboutWindow = nullptr;

private:
    void init();
    QHBoxLayout *initTitleBar(); //关于窗口标题栏初始化
    QVBoxLayout *initBody();     // 关于窗口body初始化
                                 ////    void initGsetting();
    void initAction();
    void triggerMenu(QAction *act); //主菜单动作4
                                    ////    void triggerThemeMenu(QAction* act); //主题动作
    void aboutAction();
    void initAbout(); //关于窗口初始化
    void helpAction();
    //    void setThemeFromLocalThemeSetting(QList<QAction* >); //获取本地主题配置
    //    void setStyleByThemeGsetting(); //通过外部主题配置设置主题

    //    void refreshThemeBySystemConf();    //通过系统配置更改主题

    QLabel *m_titleText = nullptr;
    QLabel *m_bodyAppVersion = nullptr;
    QLabel *m_bodySupport = nullptr;
    QLabel *m_bodyDescription = nullptr;
    QLabel *m_bodyAppName = nullptr;
    void initConnect();

public slots:
    void monitorThemeChanged(QString themeChange);
    void setMenuModuleAllowLocationYes();

signals:
    void menuModuleClose(); //从标题栏点击退出的信号
    void allowLocationYes();
    void allowLocationNo();
};

#endif // MENUMODULE_H
