Week 1: The Jumping Menubar Bug
If you use Lokalize, you’ve probably run into this bug: the menubar reshuffles every time you switch tabs. Go from the Editor to the Project Overview, and suddenly the Edit, Go, and Sync menus disappear or swap places. It totally breaks muscle memory. As part of my Season of KDE project, my task was to fix it.
To give you an idea of the chaos, here is how the menus were jumping around before the fix:





My initial thought was that this would be a five-minute fix-just tweak an XML file and move on. I was very wrong. My first instinct was to nuke the cache and blindly shuffle tags around in the .rc files, hoping the UI would magically fix itself. It didn't. After wasting a day treating symptoms and trying to brute-force a solution, I had to admit I was just guessing. I closed my IDE and decided to actually figure out how the UI was being generated.
After diving into the KXMLGUI documentation, I realized I wasn’t fighting a single XML file. I was fighting a dynamic merge of six different files happening in real-time. Whenever you switch tabs, KXMLGUI actively merges and removes XML definitions. The problem was that the main lokalizemainwindowui.rc file used generic tags. These acted like open doors with no assigned seating. Whichever tab loaded last got to decide where its menu items went. Implicit design was giving us random results.
At first, I thought about centralizing all the menu visibility in C++, but that would ruin KXMLGUI's distributed design and require a massive refactor. Instead, I decided to enforce a strict "Global Skeleton" in the main XML file. By hardcoding the menu structure using index="N" attributes, I could create a reservation system.
<MenuBar>
<Menu name="file" index="1"><text>&File</text>...
<Menu name="project" index="4"><text>&Project</text>...
<Menu name="tools" index="6">...
<Menu name="settings" index="7">...
<Menu name="edit" index="2"><text>&Edit</text><MergeLocal/></Menu>
<Menu name="go" index="3"><text>&Go</text><MergeLocal/></Menu>
<Menu name="merge" index="5"><text>S&ync</text><MergeLocal/></Menu>
</MenuBar>With the skeleton in place, I went through the child files (projectmanagerui.rc, translationmemoryrui.rc, filesearchtabui.rc) and updated them to respect these exact indices. The real trick here was giving tabs empty menus for sections they didn't even use.
<MenuBar>
<Menu name="tools" index="6">...
<Menu name="edit" index="2"><text>&Edit</text></Menu>
<Menu name="go" index="3"><text>&Go</text></Menu>
<Menu name="merge" index="5"><text>S&ync</text></Menu>
</MenuBar>By defining an empty menu with the correct index, KXMLGUI is forced to keep that menu on the menubar. Even if there are no actions inside it, the menu header holds its ground. This preserves the layout and stops the adjacent menus from sliding left and right when you switch contexts.
After updating the .rc files, adding one missing action (edit_approve_go_fuzzyUntr), and recompiling, the UI was rock solid. No more jumping menus, and all the keyboard shortcuts remained fully intact.





Lokalize Menubar Fix - Merge Request
