/*
 * Copyright (C) 2020, 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 INTRODUCTIONVIEW_H
#define INTRODUCTIONVIEW_H

#include <QObject>
#include <QDialog>
#include <QPushButton>
#include <QLayout>
#include <QLabel>
#include <QWidget>
#include <QPainter>
#include <QLinearGradient>
#include <QLineEdit>
#include <QTextEdit>
#include <QPalette>
#include <QDebug>
#include <QScrollArea>
#include <QScrollBar>
#include <QTextBrowser>
#include <QCoreApplication>
#include <QTimer>
#include <QApplication>
#include <QPainterPath>

#include <ukuistylehelper/ukuistylehelper.h>
#include "global/kaglobal.h"
#include <windowmanager/windowmanager.h>


class InnerWidget : public QWidget{
    Q_OBJECT

public:
    InnerWidget(QWidget * parent = nullptr);

protected:
    void paintEvent(QPaintEvent *event) override;
    void resizeEvent(QResizeEvent *event) override;

};

class IntroductionContent : public QWidget{
    Q_OBJECT

public:
    IntroductionContent(QWidget * parent);
    void initChild();
    void initLayout();
    void initConnection();    
    bool hasLocalModel();

public slots:
    void showFirst();
    void showSecond();
    void showAgreement();  // 新增：显示用户协议页面

private slots:
    void onAgreeClicked();    // 新增：处理“同意并继续”点击事件
    void onDisagreeClicked(); // 新增：处理“不同意”点击事件

protected:
    void paintEvent(QPaintEvent *event) override;

private:
    // 原有成员
    QLabel * m_icon = nullptr;
    QLabel * m_shortcut = nullptr;
    QLabel * m_addModel = nullptr;
    InnerWidget * m_winCWid = nullptr;
    InnerWidget * m_winAltCWid = nullptr;
    InnerWidget * setPageWid = nullptr;
    QPushButton *m_nextBtn = nullptr;
    QPushButton *m_previousBtn = nullptr;
    QPushButton *m_acceptBtn = nullptr;
    QPushButton *m_closeBtn = nullptr;
    QWidget *contentWid = nullptr;

    // 新增：用户协议页面相关成员
    QWidget     *m_agreementPageWid   = nullptr; // 整个用户协议页容器
    QLabel      *m_agreementTitle   = nullptr;  // 用户协议标题
    QTextBrowser *m_agreementContent = nullptr;  // 用户协议正文内容
    QPushButton *m_agreeBtn         = nullptr;  // “同意并继续”按钮
    QPushButton *m_disagreeBtn      = nullptr;  // “不同意”按钮

    InnerWidget * m_agreementInnerWid = nullptr; // 用户协议正文白色圆角框
    QScrollArea *m_agreementScroll =nullptr;

};

class IntroductionView : public QDialog
{
    Q_OBJECT

public:
    IntroductionView(QWidget * parent = nullptr);
    void showView();
    void hideView();
    void closeView();
    bool isClosed() const;

public:
    bool m_isClosed;

signals:
    void showSettingPage();
    void openUKUIControlCenterView();

private:
    IntroductionContent * m_content = nullptr;
};

#endif // INTRODUCTIONVIEW_H
