diff --git a/plugins/libimhex/include/hex/api/event.hpp b/plugins/libimhex/include/hex/api/event.hpp index d1a0ad190..85d8b5d7a 100644 --- a/plugins/libimhex/include/hex/api/event.hpp +++ b/plugins/libimhex/include/hex/api/event.hpp @@ -110,6 +110,7 @@ namespace hex { EVENT_DEF(RequestSelectionChange, Region); EVENT_DEF(RequestAddBookmark, ImHexApi::Bookmarks::Entry); EVENT_DEF(RequestAppendPatternLanguageCode, std::string); + EVENT_DEF(RequestChangeWindowTitle, std::string); EVENT_DEF(RequestCloseImHex); } \ No newline at end of file diff --git a/source/views/view_hexeditor.cpp b/source/views/view_hexeditor.cpp index 0351c0185..03a1be680 100644 --- a/source/views/view_hexeditor.cpp +++ b/source/views/view_hexeditor.cpp @@ -14,6 +14,8 @@ #undef __STRICT_ANSI__ #include +#include + namespace hex { ViewHexEditor::ViewHexEditor(std::vector &patternData) @@ -171,6 +173,10 @@ namespace hex { }); } }); + + EventManager::subscribe(this, [](std::string path) { + EventManager::post(std::filesystem::path(path).filename().string()); + }); } ViewHexEditor::~ViewHexEditor() { diff --git a/source/window.cpp b/source/window.cpp index 7ac485157..433c9342a 100644 --- a/source/window.cpp +++ b/source/window.cpp @@ -138,6 +138,13 @@ namespace hex { glfwSetWindowShouldClose(this->m_window, true); }); + EventManager::subscribe(this, [this](std::string windowTitle) { + if (windowTitle.empty()) + glfwSetWindowTitle(this->m_window, "ImHex"); + else + glfwSetWindowTitle(this->m_window, ("ImHex - " + windowTitle).c_str()); + }); + this->initPlugins(); ContentRegistry::Settings::load(); @@ -163,6 +170,7 @@ namespace hex { EventManager::unsubscribe(this); EventManager::unsubscribe(this); EventManager::unsubscribe(this); + EventManager::unsubscribe(this); } void Window::loop() {