/* * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once #include #include "undostack.hpp" #include "widget.hpp" #include "nostalgiastudio_export.h" namespace nostalgia::studio { class NOSTALGIASTUDIO_EXPORT Editor: public Widget { private: UndoStack m_cmdStack; bool m_unsavedChanges = false; bool m_exportable = false; bool m_cutEnabled = false; bool m_copyEnabled = false; bool m_pasteEnabled = false; public: ~Editor() override = default; /** * Returns the name of item being edited. */ [[nodiscard]] virtual ox::String itemName() const = 0; virtual ox::String itemDisplayName() const; virtual void cut(); virtual void copy(); virtual void paste(); virtual void exportFile(); void close(); /** * Save changes to item being edited. */ void save(); /** * Sets indication of item being edited has unsaved changes. Also emits * unsavedChangesChanged signal. */ void setUnsavedChanges(bool); [[nodiscard]] bool unsavedChanges() const noexcept; /** * Returns the undo stack holding changes to the item being edited. */ [[nodiscard]] UndoStack *undoStack(); void setExportable(bool); [[nodiscard]] bool exportable() const; void setCutEnabled(bool); [[nodiscard]] bool cutEnabled() const; void setCopyEnabled(bool); [[nodiscard]] bool copyEnabled() const; void setPasteEnabled(bool); [[nodiscard]] bool pasteEnabled() const; protected: /** * Save changes to item being edited. */ virtual void saveItem(); // signals public: ox::Signal unsavedChangesChanged; ox::Signal exportableChanged; ox::Signal cutEnabledChanged; ox::Signal copyEnabledChanged; ox::Signal pasteEnabledChanged; ox::Signal closed; }; }