PrimeWorldEditor/src/Editor/IEditor.h

55 lines
1.2 KiB
C
Raw Normal View History

#ifndef IEDITOR
#define IEDITOR
#include <QMainWindow>
2018-12-27 06:59:59 +00:00
#include <QAction>
#include <QList>
#include <QUndoStack>
#include "CEditorApplication.h"
2018-12-27 06:59:59 +00:00
/** Base class of all editor windows */
class IEditor : public QMainWindow
{
Q_OBJECT
2018-12-27 06:59:59 +00:00
protected:
// Undo stack
QUndoStack mUndoStack;
QList<QAction*> mUndoActions;
public:
2018-12-27 06:59:59 +00:00
IEditor(QWidget* pParent);
QUndoStack& UndoStack();
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*);
2018-12-27 06:59:59 +00:00
/** Interface */
virtual void EditorTick(float /*DeltaTime*/) { }
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();
void OnUndoStackIndexChanged();
2018-12-27 06:59:59 +00:00
signals:
void Closed();
};
#endif // IEDITOR