mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-29 00:10:02 -05:00
sys: Clear project context when closing all providers, Display project name in window title (#860)
* clear project context when closing all providers * Show project name on window title * refactor RequestChangeWindowTitle to RequestUpdateWindowTitle * add spaces
This commit is contained in:
@@ -115,13 +115,19 @@ namespace hex {
|
||||
EventManager::post<EventWindowClosing>(this->m_window);
|
||||
});
|
||||
|
||||
EventManager::subscribe<RequestChangeWindowTitle>(this, [this](const std::string &windowTitle) {
|
||||
EventManager::subscribe<RequestUpdateWindowTitle>(this, [this]() {
|
||||
std::string title = "ImHex";
|
||||
|
||||
if (ImHexApi::Provider::isValid()) {
|
||||
if (ProjectFile::hasPath()) {
|
||||
title += " - Project " + hex::limitStringLength(ProjectFile::getPath().stem().string(), 32);
|
||||
|
||||
if (ImHexApi::Provider::isDirty())
|
||||
title += " (*)";
|
||||
|
||||
} else if (ImHexApi::Provider::isValid()) {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
if (!windowTitle.empty() && provider != nullptr) {
|
||||
title += " - " + hex::limitStringLength(windowTitle, 32);
|
||||
if (provider != nullptr) {
|
||||
title += " - " + hex::limitStringLength(provider->getName(), 32);
|
||||
|
||||
if (provider->isDirty())
|
||||
title += " (*)";
|
||||
@@ -177,7 +183,7 @@ namespace hex {
|
||||
Window::~Window() {
|
||||
EventManager::unsubscribe<EventProviderDeleted>(this);
|
||||
EventManager::unsubscribe<RequestCloseImHex>(this);
|
||||
EventManager::unsubscribe<RequestChangeWindowTitle>(this);
|
||||
EventManager::unsubscribe<RequestUpdateWindowTitle>(this);
|
||||
EventManager::unsubscribe<EventAbnormalTermination>(this);
|
||||
EventManager::unsubscribe<RequestOpenPopup>(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user