Bug 503042

Summary: Editor toolview state should not be saved per file
Product: [Applications] lokalize Reporter: Kisaragi Hiu <mail>
Component: editorAssignee: Simon Depiets <sdepiets>
Status: RESOLVED FIXED    
Severity: normal CC: aacid, fin-w, karl, kishore96, shafff
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Kisaragi Hiu 2025-04-20 06:01:52 UTC
SUMMARY
Editor toolview state being per-file makes configuring the UI in the editor next to useless, as it doesn't get applied to the next file and every change would have to manually be mirrored to other files.

In precisely zero case would one want a different window layout for every file. EditorState should be global; open tabs not seeing the change until they are reopened is better than the status quo.

https://invent.kde.org/sdk/lokalize/-/merge_requests/212 made the state save/restore reliable but this issue remains.

STEPS TO REPRODUCE
1. Open a PO file
2. Customize the UI for one's needs: enabling primary/secondary sync, moving unit metadata to a different place to maximize item list etc.
3. Open another file

OBSERVED RESULT
Observe none of the customizations carried over even though none of the customization is specific to one file.

This may be intentional, but either way it makes UI customizations utterly useless even if restore works fine now.

EXPECTED RESULT
I can customize the UI once and have it not care about which file I'm editing. Saving state from the last tab opened is fine.

SOFTWARE/OS VERSIONS
Operating System: KDE neon Unstable Edition
KDE Plasma Version: 6.3.80
KDE Frameworks Version: 6.14.0
Qt Version: 6.8.3
Kernel Version: 6.11.0-24-generic (64-bit)
Graphics Platform: X11

ADDITIONAL INFORMATION
Lokalize is actually the Neon Unstable build on 20250417.1956, probably commit 6bb09931e5506f1e06cd4ecc086d30740bb591da.
The Neon package version is 4:25.04.0+p24.04+vunstable+git20250417.1956-0.
Comment 1 Finley Watson 2025-04-20 09:19:29 UTC
Thanks for reporting. There are two things at play here: state saving per editor / file, and a default state used when there is no data saved for the editor state, which should correspond to the state of the last used editor. The second aspect is broken.
Comment 2 Finley Watson 2025-04-20 09:33:04 UTC
But you're saying you think there should be only one layout state that all editor tabs follow? Meaning all open tabs use the same layout, tabs when reopened use the same layout...?
Comment 3 Kishore Gopalakrishnan 2025-04-27 06:56:22 UTC
I concur with the original reporter that as a translator, I expect the editor state (shown toolviews and panel sizes) to be saved globally, and not per file. The per-file saving was so unexpected that I initially assumed the state was not being saved at all.

(In reply to fin-w from comment #1)
> Thanks for reporting. There are two things at play here: state saving per
> editor / file, and a default state used when there is no data saved for the
> editor state, which should correspond to the state of the last used editor.
> The second aspect is broken.

I don't understand this. Where can I configure the default state? All changes I make through 'Settings > Toolviews' or by dragging the panes seem to be saved per file, while the 'default state' appears to be whatever I configured prior to upgrading to 25.04.0.
Comment 4 Kishore Gopalakrishnan 2025-04-27 07:01:02 UTC
(In reply to Kishore Gopalakrishnan from comment #3)
> I concur with the original reporter that as a translator, I expect the
> editor state (shown toolviews and panel sizes) to be saved globally, and not
> per file. The per-file saving was so unexpected that I initially assumed the
> state was not being saved at all.

To elaborate on this, I can see some people wanting to save the configuration per project, but per file seems like something no one would want. My recommendation would be to make the configuration apply either per project or globally.
Comment 5 Finley Watson 2025-04-27 09:04:26 UTC
Thanks for the feedback, this is useful. The default state is internal to the code, and is a fallback state when an editor-specific state can't be found. It can't be manually set as far as I know, it should just work, but I think it's broken (again).

The original behaviour was something like: save file states, and save default state to whatever state the last used editor was in. File states are only saved for open files, and are project-specific. Closing a project / closing Lokalize will lose the states of unopen editors (at the project level) that were previously saved and associated with the project. It was a bit buggy and because it lost user config, I've tried to make editor state saving exist independently of projects.

Since two people have mentioned this now, I can make it a priority to fix ready for 25.04.1. Sorry for upsetting your workflow. Does a single editor state, that all editor tabs use, sound better? Configure once, open a new editor / new project / close and reopen Lokalize and the editor layout is always the same? The only time editor tabs would look different is if two are open and you make changes to one of them. OR, I can force all to follow any changes made, so even open tabs will stay looking the same. This then locks the translator into one layout for all editor tabs: if that's wanted, then it's simple to implement.

If either of you are available for testing / feedback, I'll open an empty merge request now that you can tag yourselves in if you want to help test and give feedback.
Comment 6 Bug Janitor Service 2025-04-27 09:36:53 UTC
A possibly relevant merge request was started @ https://invent.kde.org/sdk/lokalize/-/merge_requests/233
Comment 7 Kishore Gopalakrishnan 2025-04-27 10:34:45 UTC
(In reply to fin-w from comment #5)
> Does a single editor
> state, that all editor tabs use, sound better? Configure once, open a new
> editor / new project / close and reopen Lokalize and the editor layout is
> always the same? The only time editor tabs would look different is if two
> are open and you make changes to one of them. OR, I can force all to follow
> any changes made, so even open tabs will stay looking the same. This then
> locks the translator into one layout for all editor tabs: if that's wanted,
> then it's simple to implement.

This sounds good to me (including the forced synchronization of all open tabs).

> I've tried to make editor state saving exist independently of projects.

While is this fine for me personally (because I only have a single project),
I am not sure if everyone would feel that way. But I suppose this is a good
opportunity to find out if people still want project-specific view configuration.
Comment 8 Karl Ove Hufthammer 2025-04-27 11:17:05 UTC
I very much agree that per-file settings are useless. The current/old behaviour has always been annoying. I guess a per-project setting could be useful for *some* people (e.g., use a glossary file pane only for a specific project), but I don’t think it’s very important.

I would greatly prefer a ‘lock into one layout for all editor tabs’ behaviour. This is my typical workflow:

I open a bunch of PO files (e.g., 10) at once. Then figure out that Lokalize has *again* changed the layout from my preferred setting. I rearrange it to my preference and finish editing the first file. Then I close it and is annoyed that the layout for the *second* file is the ‘old’ layout. Only after finishing all the files and opening new ones are my preferred layout used (until Lokalize decided to ignore it).

So having a global layout that is applied to all files and automatically saved would be a great improvement. Any per-project support can always come later (if needed).
Comment 9 Kisaragi Hiu 2025-04-27 23:54:11 UTC
I share Karl's experience.

Open tabs also sharing state would probably be an improvement.
Comment 10 Finley Watson 2025-04-29 02:59:26 UTC
Please test this merge request if you are able. If not, tell me what you think, based on the description of behaviour in the merge request. It should be in 25.04.1 so you should see the fix fairly soon. https://invent.kde.org/sdk/lokalize/-/merge_requests/233
Comment 11 Finley Watson 2025-05-01 08:45:12 UTC
Git commit 081c153263e8ad7684208fead066ba586f2a8101 by Finley Watson.
Committed on 01/05/2025 at 08:45.
Pushed by finw into branch 'master'.

Use one global synchronised editor layout across all projects and all editors

Completely change the behaviour of the editor tab state management.
Editor tabs have widgets associated with them (dock widgets) which
can be resized (the editor tab's state). Here the resizing is watched
for changes, changes are "debounced" so every pixel change doesn't
write to disk, then after 0.5s without resizing occurring, the state
is saved to disk meaning reopening Lokalize opens editors with the
same layout. The state is also applied to all open editor tabs,
meaning they all share the same layout at all times.

The glossary widget is moved to `m_glossaryView` in line with the
other widgets belonging to the editor tab.
Related: bug 503329

M  +2    -0    src/CMakeLists.txt
M  +16   -7    src/editortab.cpp
M  +5    -0    src/editortab.h
M  +46   -21   src/lokalizemainwindow.cpp
M  +3    -1    src/lokalizemainwindow.h
A  +62   -0    src/resizewatcher.cpp  *
A  +33   -0    src/resizewatcher.h  *

The files marked with a * at the end have a non valid license. Please read: https://community.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.


https://invent.kde.org/sdk/lokalize/-/commit/081c153263e8ad7684208fead066ba586f2a8101
Comment 12 Finley Watson 2025-05-01 09:02:19 UTC
Git commit cf7492fa762dcabbe97423195282f74a06e3e621 by Finley Watson.
Committed on 01/05/2025 at 09:00.
Pushed by finw into branch 'release/25.04'.

Use one global synchronised editor layout across all projects and all editors

Completely change the behaviour of the editor tab state management.
Editor tabs have widgets associated with them (dock widgets) which
can be resized (the editor tab's state). Here the resizing is watched
for changes, changes are "debounced" so every pixel change doesn't
write to disk, then after 0.5s without resizing occurring, the state
is saved to disk meaning reopening Lokalize opens editors with the
same layout. The state is also applied to all open editor tabs,
meaning they all share the same layout at all times.

The glossary widget is moved to `m_glossaryView` in line with the
other widgets belonging to the editor tab.
Related: bug 503329
(cherry picked from commit 081c153263e8ad7684208fead066ba586f2a8101)

M  +2    -0    src/CMakeLists.txt
M  +16   -7    src/editortab.cpp
M  +5    -0    src/editortab.h
M  +46   -21   src/lokalizemainwindow.cpp
M  +3    -1    src/lokalizemainwindow.h
A  +62   -0    src/resizewatcher.cpp  *
A  +33   -0    src/resizewatcher.h  *

The files marked with a * at the end have a non valid license. Please read: https://community.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.


https://invent.kde.org/sdk/lokalize/-/commit/cf7492fa762dcabbe97423195282f74a06e3e621