~aleteoryx/muditaos

5bff92e2b5fe92e7f6023193a43d1d9378dcda22 — Mateusz Piesta 4 years ago 3a244f2
[EGD-7052] Generate unique window name

Added virtual method to Window class in order to be able
to prepend specific application name to the window name. 
It wasn't possible to use existing getName method as it is 
used throughout the codebase for switching windows
M module-apps/apps-common/windows/AppWindow.cpp => module-apps/apps-common/windows/AppWindow.cpp +6 -0
@@ 275,4 275,10 @@ namespace gui
        visitor.visit(*this);
    }

    std::string AppWindow::getUniqueName()
    {
        constexpr auto separator = "/";
        return application->GetName() + separator + getName();
    }

} /* namespace gui */

M module-apps/apps-common/windows/AppWindow.hpp => module-apps/apps-common/windows/AppWindow.hpp +2 -0
@@ 69,6 69,8 @@ namespace gui
            return application;
        };

        std::string getUniqueName() override;

        virtual bool onDatabaseMessage(sys::Message *msg);

        bool updateSim();

M module-gui/gui/dom/Item2JsonSerializingVisitor.cpp => module-gui/gui/dom/Item2JsonSerializingVisitor.cpp +1 -1
@@ 74,7 74,7 @@ void Item2JsonSerializingVisitor::visit(gui::Window &item)
    if (itemName.empty()) {
        itemName = magic_enum::enum_name(visitor::Names::Window);
    }
    sink.emplace(magic_enum::enum_name(visitor::Window::WindowName), std::string{item.getName()});
    sink.emplace(magic_enum::enum_name(visitor::Window::WindowName), std::string{item.getUniqueName()});
    visit(static_cast<gui::Item &>(item));
}


M module-gui/gui/widgets/Window.hpp => module-gui/gui/widgets/Window.hpp +7 -0
@@ 67,10 67,17 @@ namespace gui

        void buildDrawListImplementation(std::list<Command> &commands) override;

        /// used for window switching purposes
        std::string getName()
        {
            return name;
        };

        /// used for fetching unique name of window
        virtual std::string getUniqueName()
        {
            return name;
        }
    };

} /* namespace gui */