2016-08-30 06:47:02 +00:00
|
|
|
#ifndef IEDITOR
|
|
|
|
#define IEDITOR
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
2018-12-27 06:59:59 +00:00
|
|
|
#include <QAction>
|
|
|
|
#include <QList>
|
|
|
|
#include <QUndoStack>
|
|
|
|
|
2016-08-30 06:47:02 +00:00
|
|
|
#include "CEditorApplication.h"
|
|
|
|
|
2018-12-27 06:59:59 +00:00
|
|
|
/** Base class of all editor windows */
|
2016-08-30 06:47:02 +00:00
|
|
|
class IEditor : public QMainWindow
|
|
|
|
{
|
2016-08-31 08:09:13 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2018-12-27 06:59:59 +00:00
|
|
|
protected:
|
|
|
|
// Undo stack
|
|
|
|
QUndoStack mUndoStack;
|
|
|
|
QList<QAction*> mUndoActions;
|
|
|
|
|
2016-08-30 06:47:02 +00:00
|
|
|
public:
|
2018-12-27 06:59:59 +00:00
|
|
|
IEditor(QWidget* pParent);
|
|
|
|
QUndoStack& UndoStack();
|
2018-12-30 10:55:50 +00:00
|
|
|
void AddUndoActions(QToolBar* pToolBar, QAction* pBefore = 0);
|
|
|
|
void AddUndoActions(QMenu* pMenu, QAction* pBefore = 0);
|
2018-12-27 06:59:59 +00:00
|
|
|
bool CheckUnsavedChanges();
|
|
|
|
|
|
|
|
/** QMainWindow overrides */
|
|
|
|
virtual void closeEvent(QCloseEvent*);
|
2016-08-30 06:47:02 +00:00
|
|
|
|
2018-12-27 06:59:59 +00:00
|
|
|
/** Interface */
|
2016-08-30 06:47:02 +00:00
|
|
|
virtual void EditorTick(float /*DeltaTime*/) { }
|
2016-08-31 08:09:13 +00:00
|
|
|
virtual CBasicViewport* Viewport() const { return nullptr; }
|
|
|
|
|
2018-12-27 06:59:59 +00:00
|
|
|
public slots:
|
|
|
|
/** Virtual slots */
|
|
|
|
virtual bool Save()
|
|
|
|
{
|
|
|
|
// Default implementation for editor windows that do not support resaving assets.
|
|
|
|
// This should not be called.
|
2018-12-30 23:41:43 +00:00
|
|
|
errorf("Base IEditor::Save() implementation called. Changes will not be saved.");
|
2018-12-27 06:59:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Non-virtual slots */
|
|
|
|
bool SaveAndRepack();
|
2018-12-30 10:55:50 +00:00
|
|
|
void OnUndoStackIndexChanged();
|
2018-12-27 06:59:59 +00:00
|
|
|
|
2016-08-31 08:09:13 +00:00
|
|
|
signals:
|
|
|
|
void Closed();
|
2016-08-30 06:47:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // IEDITOR
|
|
|
|
|