#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QObject>
#include <QScopedPointer>
#include <QString>
#include <QEvent>
#include <QWheelEvent>
extern int a;
class MainWindow : public QObject
{
    Q_OBJECT
        Q_PROPERTY(QString currentPage READ currentPage NOTIFY currentPageChanged)
        Q_PROPERTY(int suofang READ suofang NOTIFY suofangChanged)
        Q_PROPERTY(int exit READ exit NOTIFY exitChanged)
        Q_PROPERTY(int next READ next NOTIFY nextChanged)
        Q_PROPERTY(int Auto READ Auto NOTIFY AutoChanged)
        Q_PROPERTY(int skip READ skip NOTIFY skipChanged)
        Q_PROPERTY(int save READ save NOTIFY saveChanged)
        Q_PROPERTY(float vzi READ vzi NOTIFY vziChanged)
        Q_PROPERTY(float vhang READ vhang NOTIFY vhangChanged)
        Q_PROPERTY(float inliang READ inliang NOTIFY inliangChanged)
        Q_PROPERTY(int saveCount READ saveCount NOTIFY saveCountChanged)
        Q_PROPERTY(int drop READ drop NOTIFY Drop)
        Q_PROPERTY(int wheelDelta READ wheelDelta NOTIFY wheelChanged)
        Q_PROPERTY(int da READ da NOTIFY daChanged)
        Q_PROPERTY(QString shuru READ shuru NOTIFY shuruChanged)
        Q_PROPERTY(float weizhix READ weizhiy NOTIFY weizhiChanged)
        Q_PROPERTY(float weizhix READ weizhiy NOTIFY weizhiChanged)
        Q_PROPERTY(int ws READ ws NOTIFY wsChanged)
        Q_PROPERTY(int ad READ ad NOTIFY adChanged)
        Q_PROPERTY(QVariantList elementArray READ elementArray NOTIFY elementArrayChanged)
        Q_PROPERTY(int fs READ fs NOTIFY fsChanged)
        Q_PROPERTY(int inextra READ inextra NOTIFY inextraChanged)
        Q_PROPERTY(int inbextra READ inbextra NOTIFY inbextraChanged)
public:
    explicit MainWindow(QObject* parent = nullptr);

    QString currentPage() const;
    int suofang() const;
    int exit() const;
    int next() const;
    int Auto() const;
    int skip() const;
    int save() const;
    float vzi() const;
    float vhang() const;
    float inliang() const;
    int saveCount() const;
    int drop() const;
    int wheelDelta() const;
    int da() const;
    QString shuru() const;
    float weizhix() const;
    float weizhiy() const;
    int ws() const;
    int ad() const;
    QVariantList elementArray() const;
    int fs() const;
    int inextra() const;
    int inbextra()const;

    Q_INVOKABLE void navigateindex();
    Q_INVOKABLE void navigatesetting(const QString& source);
    Q_INVOKABLE void navigategame(const QString& source);
    Q_INVOKABLE void navigateload(const QString& source);
    Q_INVOKABLE void navigateextra();
    Q_INVOKABLE void setLastSource(const QString& source);
    Q_INVOKABLE QString getLastSource();

    Q_INVOKABLE void exit1();

    Q_INVOKABLE void quanping();
    Q_INVOKABLE void xiaochuang();
    Q_INVOKABLE void fangda();

    Q_INVOKABLE void next1();
    Q_INVOKABLE void Auto1();
    Q_INVOKABLE void skip1();
    Q_INVOKABLE void save1();

    Q_INVOKABLE void vzi1(float value);
    Q_INVOKABLE void vhang1(float value);
    Q_INVOKABLE void inliang1(float value);

    Q_INVOKABLE void requestSaveCount();
    Q_INVOKABLE void loadSave(int position);
    Q_INVOKABLE bool fileExists(const QString& filePath) const;
    Q_INVOKABLE void dropsaves(int dropn);

    Q_INVOKABLE void da1(int da);
    Q_INVOKABLE void shuru1(QString shuru);

    Q_INVOKABLE void weizhi1(float sx,float sy);
    Q_INVOKABLE void ws1(int ws);
    Q_INVOKABLE void ad1(int ad);
    Q_INVOKABLE void updateElementArray(const QVariantList& newArray);
    Q_INVOKABLE void fs1();

    Q_INVOKABLE void inextra1(int inextra1);
    Q_INVOKABLE void inbextra1(int inbextra1);

    bool eventFilter(QObject* obj, QEvent* event) override;
signals:
    void currentPageChanged();
    void suofangChanged(int suofang);
    void exitChanged(int exit);
    void nextChanged(int next);
    void AutoChanged(int Auto);
    void skipChanged(int skip);
    void saveChanged(int save);
    void vziChanged(float vzi);
    void vhangChanged(float vhang);
    void inliangChanged(float inliang);
    void saveCountChanged(int count);
    void Load(int loadn);
    void Drop(int dropn);
    void refreshImagesRequested();
    void wheelChanged(int udwheel);
    void daChanged(int da);
    void shuruChanged(QString shuru);
    void Start(int start);
    void Extra(int extrac);
    void toindex(int toindexc);
    void weizhiChanged(float sx, float sy);
    void wsChanged(int ws);
    void adChanged(int ad);
    void elementArrayChanged(QString newArray);
    void fsChanged(int fs);
    void inextraChanged(int inextra1);
    void inbextraChanged(int inbextra1);
private:
    // 使用智能指针单独管理状态变量
    QScopedPointer<QString> m_currentPage;
    QString m_lastSource;
    QScopedPointer<int> m_suofang;
    QScopedPointer<int> m_exit;
    int m_next;
    int m_Auto;
    int m_skip;
    int m_save;
    QScopedPointer<float> m_vzi;
    QScopedPointer<float> m_vhang;
    QScopedPointer<float> m_inliang;
    int m_saveCount;
    int m_drop;
    int m_wheelDelta;
    int m_da;
    QString m_shuru;
    float m_weizhix;
    float m_weizhiy;
    int m_ws;
    int m_ad;
    QVariantList m_elementArray;
    int m_fs;
    int m_inextra;
    int m_inbextra;
};

#endif // MAINWINDOW_H