Sunday, December 9, 2012

GUI Preparation – GPL Statement

The lines of the GPL statement was implemented as a QStringList in the CommandLine class.  The intention was to use this string untranslated for the test output (so the output matches the expected output files).  The QT_TR_NOOP() macro was used on the strings, so that the strings could be found by the Qt translation utilities.  The tr() function would be used later (by the GUI's About box), to translate strings (given the program was set up to do translations and the appropriate translation file was available).

However, this is not how the tr() function works.  The tr() function takes a constant char pointer and translates the string.  It does not accept a QString, so the scheme described above will not work.  Therefore, the GPL statement was changed from a QStringList to a const char * array, and also changed from a regular member to a static member.  The initialization of which was moved outside of the CommandLine constructor.  The variable was also appropriately prefixed with a 's_' to represent a static member.

The first line of the GPL statement requires special handling:
"%1  Copyright (c) 2010-%2  Thunder422"
Where the %1 and %2 are place holders for the program name and the current copyright year.  These were previously filled in by the CommandLine constructor when the QStringList was created.  This can only be done after the string is in a QString, in other words, after it has been translated (if it is going to be translated).

The Tester run function previously received the GPL statement (as a QStringList argument), which it simply output.  However, since the statement is now raw character strings, it will need to fill in the first line with the program name and copyright, neither of which it had access to.  These could have been added as additional arguments, but instead, the argument was changed to a CommandLine instance pointer, which has new access functions for these values.  After converting the GPL line to a QString, if at the first line, the program name and copyright year are filled in.

One other minor problem in the Tester run function was discovered and corrected with the interactive testing mode.  The "Testing Xxx..." string was being output before the GPL statement and it should have been after the statement and the "Table initialization successful" message.

[commit c25848a1829] [commit e27358a938]

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)