KateModeManager::updateFileType(): validate modes and reload menu of the status bar
ClosedPublic

Authored by nibags on Nov 19 2019, 7:22 AM.

Details

Summary

KateModeManager::updateFileType():

  • Validate modes of katemoderc: In the same way as in D25389, the file katemoderc may contain invalid modes due to custom XML files that are deleted or renamed. Therefore, the existing modes are now verified and then the configuration of the katemoderc file is overwritten.
  • Prevent the Normal mode from being duplicated if the file katemoderc exists.
  • Modes with empty names are skipped. It's understood that the name of a mode shouldn't be empty, since it acts as a unique identifier.
  • Update the list of modes in the status bar menu (class KateModeMenuList) by calling updateFileType(). The menu uses the KateFileType objects to do a file extension search, so it's necessary. To do this, the KateModeMenuList::reloadAll() function is added, which updates the data model of the menu.

Diff Detail

Repository
R39 KTextEditor
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nibags created this revision.Nov 19 2019, 7:22 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptNov 19 2019, 7:22 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Nov 19 2019, 7:22 AM
nibags updated this revision to Diff 69971.Nov 19 2019, 7:25 AM
  • Fix format
nibags edited the summary of this revision. (Show Details)Nov 19 2019, 7:26 AM
nibags added reviewers: KTextEditor, cullmann, dhaumann.
cullmann requested changes to this revision.Nov 26 2019, 6:10 PM

I like the overall effect, but I don't like the new static registry.
We already have some registry in KateGlobal for all views, we would just need to allow to access the KateModeMenuList for the individual view then we can use that global list of views to touch all of them.
That would be preferable to have an other global hashing.

This revision now requires changes to proceed.Nov 26 2019, 6:10 PM
nibags updated this revision to Diff 70392.Nov 27 2019, 5:45 AM
  • Get the KateMenuList objects using KateGlobal

Now the object KateModeMenuList is obtained from the object KateStatusBar. I don't know if you prefer this way

cullmann accepted this revision.Nov 27 2019, 8:45 AM

I think that is nicer, not yet-an-other global hash ;=)

Thanks!

This revision is now accepted and ready to land.Nov 27 2019, 8:45 AM
This revision was automatically updated to reflect the committed changes.