Sunday, December 9, 2012

Qt Transition – Release

The Qt transition is now complete and the implementation of the GUI can begin.  But first this is a good point to make a development release.  Release 0.2.0 was made (branch0.2 was merged to the master branch and tagged v0.2.0).

There is one issue when running the program on Windows when starting the program from Explorer.  A console window is opened underneath the GUI (About box), which is closed upon exit.  This can be removed by adding the WIN32 option to the add_executable command in the CMake build file.  However, this causes the command line options to no longer work.  This issue will be resolved later.

Archive files containing the source files and binary files (with test files) have been uploaded to SourceForge.  For Windows, there is also the ibcp‑libs.zip file that contains all the dynamic linked libraries required to run the program if the MinGW and QtSDK packages have not been installed (extract in the ibcp directory).  Linux should already have the required libraries installed.

This concludes the 0.2 development series.  Implementation of the GUI elements will now begin with the 0.3 development series.

[commit 85d28cd9e5]

GUI Preparation – About Box

Qt contains a static library function for displaying an about box, QMessageBox::about().  All that is needed is the title for the dialog and a string with the contents for the dialog window.  This string supports a limited set of HTML tags for formatting the text.  There is an OK button to close the dialog.  The creation of the about string and call to the Qt about function was put into the about() function in the MainWindow class.

The about string contains the full name of the program using the HTML header tag for emphasis.  As done in the Tester run function, the lines of GPL statement are added next.  Instead of putting the program name as the first part of the copyright line, the version string will be used instead with the string "Version" in front of it.  For the about box, the tr() function is used to translate the strings.  Since this is a preliminary about box, a placeholder for the full GUI, an italicized message stating such is added next.  This is followed by the command line usage string (modified to show all the options are optional).  An image of the about box running on Windows 7 is shown below.

So that the new about function has access to the GPL statement, version string, copyright year and usage string, the CommandLine instance was made a member variable as a pointer to the MainWindow class instead of being temporary in the constructor.  The instance is created in the constructor and deleted in the destructor.

The show() function for the QMainWindow class was temporarily reimplemented in the MainWindow class to prevent the full GUI from appearing (which is currently empty).  The reimplemented function calls the about() function and then does a single shot timer connected to the application quit function to end the program once the event process loop is entered.  Finally, a check for no command line options was added towards the beginning of the constructor to exit the constructor (which will start the GUI in the main function).

[commit 6eab34398c]

GUI Preparation – Usage String

Since for now the GUI is only going to pop up the About box and then exit, it would be nice if it included some information about how to use the program from the command line, specifically displaying the usage string that was previously output when no arguments were given (which will start the GUI).  The CommandLine class was modified to generate the usage string at the beginning of the constructor and save it in a new member variable, with a new function to access it.

Previously, the test options were obtained from the Tester instance, but this isn't created until later in the constructor and won't be created if there are no command line options (the constructor will return).  The Tester options access function didn't actually use any instance variables, so this function was made a static member function so that now an instance isn't necessary to access the test options.

[commit 3b93360cff]

GUI Preparation – Version String

One of the items needed in the About box is the version string.  Two minor changes were made to the CommandLine class so that it can provide the version string.  The previous version() function was renamed to isVersionOption() to mirror the name of the isHelpOption() function.

A new version() function was added to access the version string.  The version string is accessed from the ibcp_RELEASE_STRING definition contained in the CMake generated ibcp_config.h header file (from ibcp_config.h.in).  CMake gets the release string from either git (if the repository is present) or from variables set in the CMakeLists.txt file.  The actual version string starts at the seventh character of release string, which skips over the "release" part of the string.

An include statement could be added to whichever source file needs the release string, but keeping the include in a single source file and providing access functions to its values allows this to be updated in the future without having to change a bunch of other source files.  This also applies to the copyright year value.  The CommandLine class also provides access to the program name.

[commit 5431b8f9b4]

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]