diff --git a/src/VivyApplication.cc b/src/VivyApplication.cc index f4bf46f0aed2598552e5615cb45186fddcaf2d7f..0cce1bc793cd402765dce585d75a10a679008afa 100644 --- a/src/VivyApplication.cc +++ b/src/VivyApplication.cc @@ -91,3 +91,14 @@ VivyApplication::getMainWindow() const throw std::logic_error("No main window in the graphic VivyApplication"); return mainWindowPtr.get(); } + +/* + * @return the current VivyDocument, or null if there isn't one or if the current document is not a VivyDocument + */ +VivyDocument * +VivyApplication::getCurrentVivyDocument() const +{ + if (!mainWindowPtr) + throw std::logic_error("No main window in the graphic VivyApplication"); + return dynamic_cast<VivyDocument*>(mainWindowPtr.get()->getCurrentDocument()); +} diff --git a/src/VivyApplication.hh b/src/VivyApplication.hh index 06e04780be68fcb541ba5dc6d3c0af559806d9fa..d992f5e16fb576a9387c625c8b1f5533e6bf637f 100644 --- a/src/VivyApplication.hh +++ b/src/VivyApplication.hh @@ -71,6 +71,7 @@ public: QFont getApplicationFont(Font) const noexcept; [[nodiscard("handle-it")]] MainWindow *getMainWindow() const; + [[nodiscard("handle-it")]] VivyDocument *getCurrentVivyDocument() const; void setTheme(Theme) noexcept; };