#ifndef CONTROLLERWINDOW_H
#define CONTROLLERWINDOW_H

#include "fancontroller.h"
#include <QMainWindow>
#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <qpushbutton.h>
#include <QComboBox>
#include <curveeditor.h>

/**
 * @brief 控制窗口
 */
class ControllerWindow : public QMainWindow
{
    Q_OBJECT

public:
    ControllerWindow(const bool isRunAsRoot, QWidget *parent = nullptr);
    ~ControllerWindow();

private slots:

    /**
     * @brief 切换 CPU 超线程状态
     */
    void toggleCpuSMT();

    /**
     * @brief 切换 CPU 睿频状态
     */
    void toggleCpuBoost();

    /**
     * @brief 设置 CPU 最高频率
     */
    void setCpuMaxFreq(int index);

    /**
     * @brief 设置 CPU 最低频率
     */
    void setCpuMinFreq(int index);

private:    
    /**
     * @brief 更新 UI
     */
    void updateUI();

    /**
     * @brief 检查是否为 root 用户
     */
    bool checkIsRoot();
    

    QLabel *cpuModelLabel;
    QLabel *cpuSmtStatusLabel;
    QLabel *coreOnlineCountLabel;
    QPushButton *cpuSmtToggleButton;
    QLabel *cpuBoostStatusLabel;
    QPushButton *cpuBoostToggleButton;

    QComboBox *cpuMaxFreqComboBox;
    // 临时记录回退
    int cpuMaxFreqTmpIndex;
    QComboBox *cpuMinFreqComboBox;
    int cpuMinFreqTmpIndex;


    FanController *fanController;

    QComboBox *fanComboBox;

    /**
     * @brief 风扇曲线编辑器
     */
    CurveEditor *fanCurveEditor;

    /**
     * @brief 风扇曲线
     */
    std::vector<QVector<CurvePoint>> fanCurves;
};

#endif // CONTROLLERWINDOW_H
