nickbnf/glogg — pull request #30 by alexeicolin (2012-05-06 04:16:10+00:00)
Title: Encoding patch from Stanislav Sikora with encoding selector in view menu

The first patch (a slightly adjusted version of original patch from Stanislav Sikora) implements some support for different encodings. The second patch is an implementation of a encoding selector in the view menu with a few useful features.

I'm afraid that the first patch is not a complete solution to Issue 16 and Issue 25 because it converts at display time. I'm no expert, but I think the conversion needs to be done at time of reading the file in order to correctly split up the content into lines. Maybe using QTextStream::setCodec(). That said, the current scheme does work in many (most?) cases. One counter example is UTF16-LE (file created in gedit with either line endings): only first line is converted. Not sure what's the success rate, but if it's high enough, maybe we could release it as is.

The second patch with the EncodingSelector is UI for encoding selection (original patch had a control in the main view, but this stuff should be in View menu instead, which is also consistent with other apps). This patch should be usable regardless of what implementation of the actual encoding conversion we settle on. It's a simple menu which maintains the list of all encodings, common encodings, the default encoding (as defined by previous patch), and recently used encodings. In the future, we could make the list of 'pinned' encodings customizable like in many other apps (e.g. Firefox), but that's not crucial given the recently-used list.