Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification Area - Non-Intrusive notifications #8120

Closed
wants to merge 13 commits into from
Closed

Notification Area - Non-Intrusive notifications #8120

wants to merge 13 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 2, 2023

DRAFT PR! DO NOT MERGE! Not intended for code review!

The intention of this PR is to be a kind of proof of concept and provide a basis for discussion of whether we need something like this or not.

Problems:

  1. Users have complained in the past that they are not notified of issues that may impact the ability to open with an older version of FreeCAD a file saved with a newer version of FreeCAD (Forward compability issues).
  2. While running FreeCAD, many users prefer not to have the report window open (as it takes quite some space), but then they may miss notifications about errors and warnings that may be useful.
  3. While running FreeCAD, many notifications of errors where the user can do nothing, but press ok, are modal (blocking) and interrupt the workflow.
  4. In many errors/warnings it is not clear where the error originates. This is specially problematic when opening a file.

Solution:
(a) FreeCAD has a error/warning/message mechanism in place (Console based).
(b) FreeCAD has a user Message signaling mechanism which can be used to require confirmation from a user for (1).

The solution here seeks to implement a Notification Area in the statusbar at Application level, so that it can gather notifications from different documents [to solve (4)]. It extends (a) and (b), so that both can provide a "notifier" field. This notifier field can be the fullname of a Document or DocumentObject, or any string usable for identifying the notifier within the Application [to solve (4)]. Both (a) and (b) feed the Notification Area. The notification Area is a single button in the tool bar which makes accessible all notifications upon clicking on it [in order to address the space issue in (2)]. New notifications (error/warning/messages) are briefly shown, in a look similar to a tooltip, via a non-intrusive non-modal auto-closing widget over the Notification Area [addressing (2) and (3)]. The idea is to also integrate user messages into this system and do away with blocking modal dialogs (the Sketcher is full of them) [addressing (3)]. Well, "do away" may mean "provide the user with a preference to choose between non-intrusive non-blocking and intrusive blocking".

The solution described is an early basic implementation for discussion.

NotificationArea.webm

Tooltip alike non-intrusive auto-closing notification:
image

Notifications widget:
image

===================================================

Extend Console and Ilogger interface to include a string to identify the notifier, which may be the fullname Document#DocumentObject when available.
======================

New NotificationArea class to show non-intrusive notifications.
=======================================================

The former system of autoclosing messageboxes is removed in favour of notification via the Notification Area.
====================================================

A new widget heavily based on QToolTip, to have a similar look and feel
and interface, while avoiding early closing on user action.

QToolTip is not intended for notifications, but to provide contextual help.
However, QToolTip is an example of non-modal non-intrusive contextual information
widget. It cannot reasonably be used for notification, as there is no control by
the user code about the several Events that cause it to close early (which are
appropriate for contextual help, but not make it unsuitable for notification).

QToolTip implementation is internally based on an implementation only class QTipLabel,
deriving from QLabel, which uses an event filter to react to several events to early
hide the label ("early" meaning: before enough time has lapsed for the user to read it,
sometimes insufficient even to notice it). This makes the unsuitable behaviour difficult
or even impossible to override (e.g. by inheritance).

Gui::NotificationBox is a reimplementation intended to provide user notifications. It
relies on the proven code of QToolTip for the wanted behaviour, but the notification box
can only be hidden earlier than the provided time (or the time calculated internally if none
is provided), if the left mouse button is clicked.

In short, a "tooltip" alike notification appears. The user can continue working without having
to interact with the notification. If the user is interested in the notification, he or she can
stop to read it. If not interested, the user can ignore it and continue working. The notification
will automatically disappear when the timer lapses or when the user clicks the LMB (showing no
interest in the message or actively deciding to do away with it), whatever happens first.
@github-actions github-actions bot added Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD WB Sketcher Related to the Sketcher Workbench WB Test Related to the Test Workbench labels Jan 2, 2023
@freecadci
Copy link

pipeline status for feature branch PR_8120. Pipeline 735848086 was triggered at 3ef4c71. All CI branches and pipelines.

@luzpaz
Copy link
Contributor

luzpaz commented Jan 2, 2023

This is amazing work! Auto-closing/dissolving messages are what I've been waiting for a long time!

@chennes
Copy link
Member

chennes commented Jan 2, 2023

This looks excellent. +1 from me for sure.

@@ -489,7 +489,7 @@ class BaseExport ILogger

/** Used to send a Log message at the given level.
*/
virtual void SendLog(const std::string& msg, LogStyle level) = 0;
virtual void SendLog(const std::string& notifiername, const std::string& msg, LogStyle level) = 0;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes:
ILogger interface is extended to include a new string "notifiername". This would ultimately enable Console messaging to offer notifier identification, which is specially useful to discern between Documents and Document Objects where an notification may originate, while still allowing other, client defined, identification where the object is neither a Document or a DocumentObject (such as sketch.cpp). In part, this is done to separate the actual error messages and notifier (which could be treated differently by different observers, and may lead to reusing the same message for different observers despite how the handle notifier information) and, in part, to support multi-document projects.

This implies a change in the API. The majority of the rest of the changes in this commit are to deal with this change of API. If there is client code that links against FreeCAD and uses this interface, that client code would need to be adapted too. In those changes, I have not made a decision yet on how to best convey the notifier information.

public:
static const unsigned int BufferSize = 4024;
// exported functions goes here +++++++++++++++++++++++++++++++++++++++
/// Prints a Message
virtual void Message ( const char * pMsg, ... );
void Message ( const char * pMsg, ... );
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

Legacy Message/Warning/Error/Log functions stop being virtual. New MessageS/WarningS/ErrorS/LogS counterparts are created, which take an additional notifier parameter (also non-virtual). Both this are then handled via a virtual private interface (NVI pattern) for extension (see MessageV/WarningV/ErrorV/LogV).

The Console client user has then the option to emit regular legacy message (not identifying the notifier), or use the new versions identifying the notifier.

@ghost
Copy link
Author

ghost commented Jan 2, 2023

Thanks.

It would be great if somebody could check how it runs on Windows, as the auto-closing notification has some windows specific code, and I have no Windows.

This file will trigger parabola migration, and partially redundant constraint warnings:
test2.FCStd.zip

@ghost ghost closed this by deleting the head repository Jan 9, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD WB Sketcher Related to the Sketcher Workbench WB Test Related to the Test Workbench
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants