/*
 * 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 SETTINGDIALOG_H
#define SETTINGDIALOG_H

#include <QDialog>
#include <QLabel>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <memory>
#include <kwidget.h>
#include <aiconfig/modelconfig.h>
#include <ukuistylehelper/ukuistylehelper.h>

#include "commandpage.h"
#include "scribewordpage.h"
#include "systemchat.h"
#include "global/kaglobal.h"

using namespace kdk;
using namespace std;
using namespace kyai::config::model;

class ConfirmSaveDialog : public QDialog
{
    Q_OBJECT
public:
    explicit ConfirmSaveDialog(QWidget *parent = nullptr);
    ~ConfirmSaveDialog();

signals:
    void sigSaveBtnClicked();
    void sigCancelBtnClicked();
    void sigCloseBtnClicked();

public slots:
    void onSaveBtnClicked();
    void onCancelBtnClicked();
    void onCloseBtnClicked();

private:
    void initLayout();
    void initConnect();

    QLabel *m_textLabel;
    QLabel *m_iconLabel;
    QPushButton *m_saveButton;
    QPushButton *m_cancelButton;
    QPushButton *m_closeButton;

    QWidget *m_titleWidget;
    QWidget *m_contentWidget;
    QWidget *m_buttonWidget;
};

class SettingDialog : public KWidget
{
    Q_OBJECT
    friend class ConfirmSaveDialog;
public:
    SettingDialog(QWidget *parent = nullptr);
    static SettingDialog *sharedInstance;
    ~SettingDialog();
    void scribeWordsDisabled();
    void resetIndex();

signals:
    void sigEnableScribeWords();
    void sigDisableScribeWords();
    void sigChangeTheme();
    void sigSetCloudModel(AiCapability capability, QString modelName);

public slots:
    void onThemeChanged();
    void onSetSelectCloudModel(AiCapability capability, QString modelName);

private:
    void initLayout();
    void initConnect();
    void initSideBar();
    void initBaseBar();

private slots:
    void onCancelOperation();
    void showSaveMsgBox();
    void slotNaviClicked(const QModelIndex &index);

protected:
    void closeEvent(QCloseEvent *event) override;

private:
    class Private;
    shared_ptr<Private> d_ptr;
};

#endif // SETTINGDIALOG_H
