I'm currently working on the implementation of the documentation links. It is possible using the whatsThis or modal dialog, but I think the programming and documenting workflow could be improved much.
Rather than having to enable context help and write the text for every UI element that is added, context help should be available by default.
Developers tend to forget to add context help support and it can only be added by modifying the code. It would be better to have the context text and links externalized (I have read into localization, but there a first text is always required, from which is then translated).
Our old implementation was:
@
class SomeUIElement {
Q_OBJECT
// context help action is added in constructor
SomeUIElement() {
QString vHelpText = ...;
QAction* vContextHelpAction = new QAction(QIcon(""), tr(vHelpText), this);
connect(vContextHelpAction, SIGNAL(triggered()), this, SLOT(OnContextHelp()));
addAction(vContextHelpAction);
setContextMenuPolicy(Qt::ActionsContextMenu);
}
void OnContextHelp() {
QString vLink = GetContextLinkFor("myClassIdentifier");
OpenHtmlFile(vLink);
}
}
@
A first improvement is that I could replace "myClassIdentifier" by QString vClassName = metaObject()→className(); and use this as the identifier. Like that, the OnContextHelp method is the same for every class.
In a second step, I thought I could create my own version of QWidget
@
class MyContextHelpEnabledWidget
{
void OnContextHelp() {
...
}
}
@
and make all my user interface elements inherit from MyContextHelpEnabledWidget instead of QWidget. But this works only for the dialogs I create. I would prefer to have this on a "core UI element" level, i.e. for every button, dropdown, table, etc. but then I do not know how I could have QButton inherit from MyContextHelpEnabledWidget instead of QWidget. (I guess this is too much hacking anyway).
In short again, how can I implement a default context help for every button in my application?