katedocument: Use first line of text as document title

A document typically starts with a headline which can be used as default document title. It will also be prefilled into the save dialog.

Handling of "Untitled" and the suffix is done ad-hoc in documentName now so that m_docName only includes the actual name, either deduced from first line or text, or from filename, so that the deduplication handling can work with this.

Comes with a unit test.

katedocument: Add relevant MIME types to Save dialog

This uses a proper QFileDialog instance for more control. Rather than only offer "All files", this adds relevant file types to the dialog:

  • The current file type, if available
  • File types supported by the mode (highlighter). If you e.g. chose Markdown highlighter, chances are you want to save the file as Markdown, too
  • Plain text as fallback option

When saving an existing document, this also reduces the chance of accidentally changing the file type. Since Kate has always defaulted to "All files", the default is kept when saving a new file, so all files are shown in the file browser.


Created a new file, typed someting:

Bildschirmfoto_20260210_164333

Bildschirmfoto_20260210_165310

Opened an existing CPP file, Save As:

Bildschirmfoto_20260210_164438

Tested both with Plasma and portal dialog. Needs testing under Windows and others.

Edited by Kai Uwe Broulik

Merge request reports

Loading