Workspace 6.21.5
Static Public Member Functions | List of all members
GlobalNotifications Class Reference

Singleton on which application-wide notifications can be observed. More...

#include <Workspace/Application/globalnotifications.h>

Inheritance diagram for GlobalNotifications:
[legend]

Static Public Member Functions

static GlobalNotificationsgetInstance ()
 

Additional Inherited Members

- Public Member Functions inherited from Observable
virtual ~Observable ()
 
void attachObserver (Observer &observer)
 
void destroy ()
 
void detachObserver (Observer &observer)
 
void notifyEvent (const ObservableEvent &event)
 
- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Detailed Description

Some event notifications don't really belong to any particular object. Rather, they are notifications that are effectively global to the whole application. For these events, GlobalNotifications provides a singleton object on which client code can create observers. Observers can be created at any time after the main QCoreApplication or QApplication object has been created, even before the main event loop has started.

It is the responsibility of the client code to ensure that the events they wish to observe will indeed be raised on the GlobalNotifications singleton. Client code is also free to raise any sort of event on the GlobalNotifications singleton for its own purposes, but it is also then responsible for ensuring that these events are not going to interfere with other client code which might also happen to be observing events of the same type.

Two event types have a special association with the GlobalNotifications class. A ShutdownEvent notification is raised on the GlobalNotifications singleton if the aboutToQuit() signal is emitted from the main QCoreApplication object. This allows non-Qt classes to still be notified when the application's main event loop is stopping. Client code may also raise ForcedShutdownEvent notifications on the GlobalNotifications singleton to indicate that they want to force the application to shutdown, but to do so cleanly. This gives other code a chance to do final processing, such as saving a project file or cleanly releasing system resources before the application ends.

Member Function Documentation

◆ getInstance()

GlobalNotifications & getInstance ( )
static
Returns
The GlobalNotifications singleton.