#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QComboBox>
#include <QWidgetAction>
#include <QFileInfo>

#include "DockManager.h"
#include "DockAreaWidget.h"
#include "DockWidget.h"

#include "QDetailsView.h"
#include "graphicsItem/graphicsBaseItem.h"
#include "document.h"

QT_BEGIN_NAMESPACE
namespace Ui { class CMainWindow; }
QT_END_NAMESPACE

class QGraphicsItem;
class QUndoStack;
class DrawingPanel;
class GraphicElementsPanel;
class DesignerScene;

class CMainWindow : public QMainWindow
{
    Q_OBJECT

public:
    CMainWindow(QWidget *parent = nullptr);
    ~CMainWindow();

protected:
	virtual void closeEvent(QCloseEvent* event) override;
    virtual void changeEvent(QEvent* event) override;

private:
    void initializeDockUi();
    void initializeAction();
    void initializeDocument();

private slots:
    void onAction_zoomIn();
    void onAction_zoomOut();
    void onAction_zoomFit();
    void onAction_createGroup();
    void onAction_destroyGroup();
    void onSignal_addItem(GraphicsBaseItem*);
    void onSignal_deleteItem();
    void onSignal_selectionChanged();

private slots:
    // Document 文件操作
    void onAction_new();
    void onAction_open();
    void onAction_save();
    void onAction_saveAs();
    void onDocument_modifiedChanged(bool modified);
    void onDocument_filenameChanged(const QString& filename);
    void onDocument_saveStatusChanged(bool success, const QString& message);

    void updateWindowTitle();

private:
	QAction*       m_pSavePerspectiveAction = nullptr;
	QWidgetAction* m_pPerspectiveListAction = nullptr;
	QComboBox*     m_pPerspectiveComboBox = nullptr;

    QUndoStack*    m_pUndoStack;
    Document*      m_pDocument;  // 当前文档

    Ui::CMainWindow *ui;

    ads::CDockManager*     m_pDockManager;
    ads::CDockAreaWidget*  m_pStatusDockArea;
    ads::CDockWidget*      m_pTimelineDockWidget;

    DrawingPanel*          m_pDrawingPanel;
    GraphicElementsPanel*  m_pGraphicElementsPanel;
    QDetailsView*          m_pPropertiesEditorView;
};
#endif // MAINWINDOW_H
