Re: File dialog filters
On Tue, Feb 16, 2016 at 6:27 PM, Christian Dávid wrote: > Hi, > > I noticed that in KMyMoney the filter strings for file dialogs are created "by > hand", e.g. i18n("C++ sources (*.cpp *.cxx *.c++);;All files (*)"). So each of > them must be translated. Alternatively something like > > QMimeDatabase db; > db.mimeTypeForName("text/x-c++src").filterString() > > could be used to create these string lowering the burden on the translators > and resulting in consistent translations for all mimetypes. > > Do we have a policy regarding this? Are there any drawbacks? Can it happen > that the mimetype database does not include all files on some systems? > > I know there is QFileDialog::setMimeTypeFilters() where the mimetype can be > set directly, but this does not work with the static functions. That's exactly what ends up happening when you call your QFileDialog with setMimeTypeFilters, the filters will be constructed out of QMimeType. Aleix
Re: File dialog filters
Am Dienstag, 16. Februar 2016, 18:27:23 schrieb Christian Dávid: Hi, > I noticed that in KMyMoney the filter strings for file dialogs are > created "by hand", e.g. i18n("C++ sources (*.cpp *.cxx *.c++);;All > files (*)"). So each of them must be translated. Alternatively > something like > > QMimeDatabase db; > db.mimeTypeForName("text/x-c++src").filterString() Just a guess but many application might not succeed in finding their MIME type in the db. They could provide an XML file for that, but this is quite a hassle compared to just writing a few characters. Also how can several mime types be represented? Like your example "C++ sources;;Allfiles". >From the docs: "If the MIME type database cannot be found on the system, as is the case on most Windows, OS X, and iOS systems, Qt will use its own copy of it." While this does not sound too bad, it at least gives the impression of a not too well working process. > could be used to create these string lowering the burden on the > translators and resulting in consistent translations for all > mimetypes. Thank you for thinking about the translators. :) I did not know about QMimeDatabase until now. On my system I have 930 MIME types in the db. Just for you to compare with yours. To me this looks like a nice way to have unified strings for file types and I would also like to know if there are things speaking against using it. Regards, Frederik
File dialog filters
Hi, I noticed that in KMyMoney the filter strings for file dialogs are created "by hand", e.g. i18n("C++ sources (*.cpp *.cxx *.c++);;All files (*)"). So each of them must be translated. Alternatively something like QMimeDatabase db; db.mimeTypeForName("text/x-c++src").filterString() could be used to create these string lowering the burden on the translators and resulting in consistent translations for all mimetypes. Do we have a policy regarding this? Are there any drawbacks? Can it happen that the mimetype database does not include all files on some systems? I know there is QFileDialog::setMimeTypeFilters() where the mimetype can be set directly, but this does not work with the static functions. Greetings Christian