gsplash
Loading...
Searching...
No Matches
GSplash Class Reference

Splash screen utility for GUI runs. More...

#include <gsplash.h>

Public Member Functions

void message (const std::string &msg)
 Displays a message on the splash screen immediately.
 
void messageAfter (int delay, const std::string &msg)
 Displays a message on the splash screen after a delay.
 
void finish (QWidget *callingWindow) const
 Finishes the splash screen and returns focus to the calling window.
 
- Public Member Functions inherited from GBase< GSplash >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
 
 GBase (const std::shared_ptr< GLogger > &logger)
 
 GBase (const GBase &)=default
 
 GBase (GBase &&) noexcept=default
 
virtual ~GBase ()
 
GBaseoperator= (const GBase &)=default
 
GBaseoperator= (GBase &&) noexcept=default
 

Static Public Member Functions

static std::unique_ptr< GSplashcreate (const std::shared_ptr< GOptions > &gopts, const std::string &imageName="gemcArchitecture")
 Factory method for creating a GSplash instance.
 

Additional Inherited Members

- Protected Attributes inherited from GBase< GSplash >
std::shared_ptr< GLoggerlog
 

Detailed Description

GSplash shows a splash image and supports overlaying messages on top of it. It is designed to be optional: when GUI mode is disabled, create() returns nullptr so callers can safely use it in both GUI and headless workflows.

Image selection rules:

  • If imageName is not NOSPLASHIMAGESELECTED, GSplash tries to load it first as a filesystem path, then as a Qt resource by prefixing ":/".
  • If imageName is NOSPLASHIMAGESELECTED, GSplash reads the image filename from the environment variable GSPLASH.

Message behavior:

  • message() sets the overlay text immediately.
  • messageAfter() schedules a message update after a delay using QTimer.
  • When no splash is active (e.g. image failed to load), message calls are no-ops.

Definition at line 65 of file gsplash.h.

Member Function Documentation

◆ create()

std::unique_ptr< GSplash > GSplash::create ( const std::shared_ptr< GOptions > & gopts,
const std::string & imageName = "gemcArchitecture" )
static

This method centralizes the “GUI enabled?” policy:

  • If gopts is null or the --gui switch is not enabled, it returns nullptr.
  • Otherwise it constructs GSplash and loads the selected image.

Ownership is returned as a std::unique_ptr to enforce a single owner and avoid ambiguous lifetime.

Parameters
goptsShared application options.
imageNameSplash image name or path. When set to NOSPLASHIMAGESELECTED, the image path is taken from the environment variable GSPLASH. Defaults to "gemcArchitecture".
Returns
A std::unique_ptr to GSplash when GUI is enabled, otherwise nullptr.

Definition at line 8 of file gsplash.cc.

◆ finish()

void GSplash::finish ( QWidget * callingWindow) const
inline

This is typically invoked by applications once initialization is complete and the main UI is ready. If the splash is inactive, this method does nothing.

Parameters
callingWindowThe window that should receive focus after closing the splash.

Definition at line 117 of file gsplash.h.

◆ message()

void GSplash::message ( const std::string & msg)

If the splash is inactive (no valid image was loaded or GUI is disabled), this method does nothing. Internally, the message is shown via QSplashScreen::showMessage and the event loop is processed briefly to keep the UI responsive during initialization.

Parameters
msgThe message to display.

Definition at line 67 of file gsplash.cc.

◆ messageAfter()

void GSplash::messageAfter ( int delay,
const std::string & msg )

This schedules an update via QTimer::singleShot. A guarded pointer is used so the callback is safe even if the splash widget is destroyed before the timer fires.

If the splash is inactive (no valid image was loaded or GUI is disabled), this method does nothing.

Parameters
delayDelay in milliseconds before displaying msg.
msgThe message to display.

Definition at line 54 of file gsplash.cc.


The documentation for this class was generated from the following files: