========================================================================================
Functions to transparently send errors, warnings, notifications and translatednotifications, either
as intrusive messages (modal pop-up QMessageBox style) or as non-intrusive messages (notificationarea),
depending on the preferences of the user.
It is intended to substitute calls to QMessageBox with these functions in WBs, including the Sketcher WB.
Example:
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Cannot add a constraint between two external geometries."));
Can be rewritten as:
Gui::TranslatedNotification(obj,
QObject::tr("Wrong selection"),
QObject::tr("Cannot add a constraint between two external geometries."));
or
Gui::TranslatedNotification("Sketcher",
QObject::tr("Wrong selection"),
QObject::tr("Cannot add a constraint between two external geometries."));
where the first parameter (obj or "Sketcher") is the notifier string. If obj is an App::DocumentObject
(or a derived class of it), internally the function transparently calls getFullLabel() to get the notifier
string.
===========================================================================
The former system of autoclosing messageboxes is removed in favour of the Notification Area.
========================================
Parameter "NotificationAreaEnabled" can be used to completely disable the Notification Area.
If disabled it won't appear on the UI at all and no non-intrusive notification will be generated.
======================
A notification area consisting of one area for non-intrusive notifications, and a widget showing previous
errors, warnings, critical messages and notifications.
Notifications being marked with QT_TRANSLATION_NOOP with context "Notifications" are translated.
Messages are shown during a minimum show time, unless pop up (clicked inside). Messages stay until
a maximum show time. Between the minimum and the maximum show times left mouse button events make
the non-intrusive notification disappear.
The widget stores a configurable amount of messages after which old messages are removed to make room for
new ones.
Unread messages are shown in bold.
======================
QToolTip removed the Windows specific behaviour of passing a screen widget as parent for QLabel
in 44fb925f50471ebc23dcccfaa4e9d9873b05d205. NotificationBox code is simplified not to use a
parent widget at all.
A inappropriate review fix actually causing a bug is fixed.
https://github.com/FreeCAD/FreeCAD/pull/8352#discussion_r1111342024
* removed header strings from ui file so that they can be dynamically set from cpp file
* use enum for column numbers
* only replace load button with loaded indicator (much faster and checkboxes no longer get unselected by loading a workbench)
* improved i18n (allows better positioning of argument for translators)
* improved column ordering (buttons and checkboxes much closer to icon and name)
* fixed variable camelCase (checkbox -> checkBox)
* exit for-loop if button was found
* added check for nullptr
=======================================
Refactor:
- Substitute the use of variadic templates with parameter packs.
- Use recently incorporated external library "fmt" to handle printf like formating.
- Extensive cleaning of pragmas and unnecessary forward declarations.
- Parameter packs and libfmt provide a much stronger type checking now, so
conversions that are by standard implicit as bool to int need an explicit static_cast
to avoid compilation warnings.
Extension:
- Include a notifier field, so that the originator of the message can be provided. E.g. Document#DocumentObject
- Include a new type of message called CriticalMessage, this message is intended to have
special behaviour in the future. Namely, it will be used to notify forward compatilibity issues.
It will be used to substitute the current signal/slot mechanism.
- Include two new types of messages for user notifications (Notification and TranslatedNotification). This messages
will be use to convey UI notifications intended for the user (such as non-intrusive message about the usage of a tool). There
are two versions to mark whether the string provided as a message is already translated or not. When using the console system for
notifications, these notifications may originate from the App or the Gui. In the former, it is generally the case that the strings
of messages are not (yet) translated (but they can be marked with QT_TRANSLATE_NOOP). In the latter, often the messages to be provided
are already translated.
Python support for CriticalMessage, Notification and TranslatedNofification, including shortcuts:
Crt = FreeCAD.Console.PrintCritical
Ntf = FreeCAD.Console.PrintNotification
Tnf = FreeCAD.Console.PrintTranslatedNotification
If the user e.g. activates the Clipboard toolbar then it should not be hidden any more if the user switches to another workbench.
The way it is now the user has to make this toolbar visible over and over again when changing the workbench. This also has the negative effect that
the workbench selector changes its position