Skip to content

Added font size feature

Vlad Rakhmanin requested to merge toadkarter/kontrast:font-size into master

What does this merge request add to the codebase?

This merge request adds a feature whereby a user can select a font size using a slider to check if it will work well with the currently displayed contrast value. There is a new line of text in the upper section of the screen which states whether or not the font size will perform poorly, well or perfectly given the contrast. This text is updated automatically when any relevant UI elements are tweaked.

How has this been implemented?

A new fontSize property has been added to the kontrast class, and works in a virtually identical way to the other properties of this class.

The only change that I made was to the way the text is displayed on the screen. Initially, I tried using tertiary operators to display the appropriate message, much in the same way that the "contrast" text currently works in the qml file. However, I quickly found that the logic grew quite complicated, as this involved checking how well the current contrast performs with different types of text, establish whether the current text is small, medium or large, and then check this font size against the current contrast. I thought that this was too complex to have in the qml file, and for this reason moved this logic to the Kontrast class. Hopefully this also helps with the "separation of concerns" idea - while I am still very much a beginner, from my rudimentary understanding of Qt, the qml file should just be responsible for the UI/view, so any logic more complex than a simple check should be located in the "QT_OBJECT".

Please let me know though if I have made this too complicated, and if so, I would be very happy to move this logic into the qml file instead!

Pipelines

For some reason that I can't quite figure out, the android and reuse pipelines are failing (all the other pipelines are working successfully). I have had a look through the error logs and can't pinpoint what specifically is going wrong or if it is related to my additions. The application seems to be building and running fine on my machine in any event - I will keep looking to see if I can figure out what is going wrong!

While my changes seem to be producing the expected results, please do let me know if there is anything here that you would like me to change, or if there is anything here that is not following best practices - as I mentioned I am quite new to C++/Qt and would love to improve, so I have no issues with making changes / rewriting any sections if needs be! Thanks for your time!

Merge request reports