Add FileDialog to API and use it in plugins
4th commit:
Add FileDialog as a wrapper for KoFileDialog, so plugins can use it to respect Krita's 'Don't use native file dialogs' setting.
It's designed to be more similar to QFileDialog, so plugins can easily switch to it.
It allows setting filter strings instead of mimetypes for this reason as well as in the case of custom filters/mimetypes. For example, the Scripter expects .py
files only, but the mime database gives .pyx
and .wsgi
as suffixes for Python scripts.
Main difference is that KoFileDialog doesn't allow setting QFileDialog.options(), because it sets them itself based on the DialogType. For the most part this should be fine, but a minor example is the Photobash docker probably doesn't want ShowDirsOnly, so you can see the images in the folder you're selecting.
KoFileDialog also has the ability to set the DialogName used to remember what folder the dialog previously had open. I didn't add any usage of this, but it might be nice to do in the future.
Also fix some plugins to properly ignore cancelled file dialogs.
1st commit: Make Recorder docker respect the native file dialog setting by using KoFileDialog as well.
2nd commit:
Enable optional keyword arguments in PyKrita.
This allows using FileDialog more like QFileDialog, for instance
FileDialog.getOpenFileName(caption=i18n("Please select the JSON comic config file."), filter=str(i18n("JSON files") + "(*.json)"))
instead of needing to convert those to positional arguments.
3rd commit: PyQt6 fixes for the Comics Manager (shouldn't really be part of this MR).
Test Plan
4th/2nd commit: Everywhere a plugin uses FileDialog.
- Comics Manager docker:
-
- New Project
-
- Open Project
-
- Project Settings -> change folder
-
- Add Page from Template -> Import Template
-
- Add Existing Pages
- Export Layers: Initial directory
- Python Palette Docker:
-
- Export as .gpl
-
- Export as .svg
- Photobash Images docker: Change References Folder
- Import Python Plugin from File
- Scripter:
-
- Open
-
- Save
-
- Save as
- Ten scripts: Select script
- Workflow Buttons docker:
-
- Select icon
-
- Select script
1st commit: Recorder docker:
- Select recordings directory
- Select FFmpeg
- Timelapse export path
Formalities Checklist
-
I confirmed this builds. -
I confirmed Krita ran and the relevant functions work. -
I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!) -
I made sure my commits build individually and have good descriptions as per KDE guidelines. -
I made sure my code conforms to the standards set in the HACKING file. -
I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy. -
Does the patch add a user-visible feature? If yes, is there a documentation MR ready for it at Krita Documentation Repository?
Reminder: the reviewer is responsible for merging the patch, this is to ensure at the least two people can build the patch. In case a patch breaks the build, both the author and the reviewer should be contacted to fix the build. If this is not possible, the commits shall be reverted, and a notification with the reasoning and any relevant logs shall be sent to the mailing list, kimageshop@kde.org.