OpenMS
Loading...
Searching...
No Matches
InteractiveSplashScreen Class Reference

A QSplashScreen which stays responsive and can be dismissed early by the user. More...

#include <OpenMS/VISUAL/MISC/InteractiveSplashScreen.h>

Inheritance diagram for InteractiveSplashScreen:
[legend]
Collaboration diagram for InteractiveSplashScreen:
[legend]

Public Member Functions

 InteractiveSplashScreen (const QPixmap &pixmap)
 C'tor from a pixmap (as for QSplashScreen). Starts an internal timer used by showFor().
 
 ~InteractiveSplashScreen () override
 D'tor.
 
void showFor (double max_seconds)
 Keep the splash visible and responsive for at most max_seconds, then close it.
 

Protected Member Functions

void mousePressEvent (QMouseEvent *e) override
 
void keyPressEvent (QKeyEvent *e) override
 

Private Attributes

std::unique_ptr< Impl > impl_
 

Detailed Description

A QSplashScreen which stays responsive and can be dismissed early by the user.

Applications typically want to show a splash screen for a minimum duration (so users can actually read it).

This class instead offers showFor(), which runs a nested, interruptible event loop. The splash stays responsive for at most the requested time and closes immediately once the user clicks it or presses a key.

Usage:

InteractiveSplashScreen splash(pixmap);
splash.show();
// load data, optionally calling splash.showMessage(...)
// ...
splash.showFor(3.0); // keep it up for <= 3s since construction, but let the user dismiss it early
A QSplashScreen which stays responsive and can be dismissed early by the user.
Definition InteractiveSplashScreen.h:44

Constructor & Destructor Documentation

◆ InteractiveSplashScreen()

InteractiveSplashScreen ( const QPixmap &  pixmap)
explicit

C'tor from a pixmap (as for QSplashScreen). Starts an internal timer used by showFor().

◆ ~InteractiveSplashScreen()

~InteractiveSplashScreen ( )
override

D'tor.

Member Function Documentation

◆ keyPressEvent()

void keyPressEvent ( QKeyEvent *  e)
overrideprotected

◆ mousePressEvent()

void mousePressEvent ( QMouseEvent *  e)
overrideprotected

◆ showFor()

void showFor ( double  max_seconds)

Keep the splash visible and responsive for at most max_seconds, then close it.

Returns early (closing the splash) as soon as the user clicks the splash or presses a key. The elapsed time is counted from construction, so any work done between constructing the splash and calling this method counts towards max_seconds.

Referenced by main().

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> impl_
private