#ifndef MULTITASKVIEWMANAGER_H
#define MULTITASKVIEWMANAGER_H

#include <memory>

#include <QQuickView>

#include <kwineffects.h>

#include "dbusservice.h"
#include "multitaskviewmodel.h"

namespace MultitaskView {

class MultitaskViewManager : public KWin::Effect
{
    Q_OBJECT

public:

    MultitaskViewManager();

    ~MultitaskViewManager() override;

    enum ProjectType {
        PC,
        TABLET,
    };

    void grabbedKeyboardEvent(QKeyEvent* e) override;

    Q_INVOKABLE void open();

    Q_INVOKABLE void close();
    Q_INVOKABLE void showDesktop(bool show);

    Q_INVOKABLE bool useOpenGL() { return useOpenGL_; }

private:

    void initModel();

    void setProjectType();

    void setQmlUrl();

    void registerQmlTypes();

    void registerShortcut();

    void initDBusService();

    void initView();

    void destroyView();

    void connectSignals();

    QString getProjectCodeName();

    QString getOSReleaseValue(const QString key);

    //!
    //! \brief getRotationModeStatus 获取当前旋转模式是否打开
    //!
    bool getRotationModeStatus();

    ///!
    //! \brief setRotationModeStatus
    //!
    void setRotationModeStatus(bool openRotationMode);

private:

    std::unique_ptr<MultitaskViewModel> model_ = nullptr;

    std::unique_ptr<QQuickView> view_ = nullptr;

    std::unique_ptr<DBusService> dbusService_ = nullptr;

    bool isOpen = false;

    bool useOpenGL_ = true;

    ProjectType projectType_ = MultitaskViewManager::PC;

    QUrl qmlUrl_ = QUrl("qrc:/qml/multitaskView.qml");

    //记录旋转模式是否打开
    bool isOpenRotationMode = false;
};

} // namespace MultitaskView

#endif // MULTITASKVIEWMANAGER_H
