LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
LC::Util::UnhoverDeleteMixin Class Reference

Allows to hide a widget or popup after mouse leave. More...

#include "unhoverdeletemixin.h"

+ Inheritance diagram for LC::Util::UnhoverDeleteMixin:
+ Collaboration diagram for LC::Util::UnhoverDeleteMixin:

Public Member Functions

UTIL_GUI_API UnhoverDeleteMixin (QObject *parent, const char *slot=SLOT(deleteLater()))
 Creates the mixin for the given parent widget. More...
 
void UTIL_GUI_API Start (std::optional< int > timeout={})
 Manually starts the timer. More...
 
void UTIL_GUI_API Stop ()
 Stops the previously started timer. More...
 

Protected Member Functions

bool eventFilter (QObject *, QEvent *) override
 

Detailed Description

Allows to hide a widget or popup after mouse leave.

This class is used to automatically hide a top-level widget like a tooltip or popup after mouse has left the widget and some time has passed.

This class supports performing arbitrary operations in addition to destructing the widget, just pass the corresponding slot to call in the constructor. Despite this functionality, we will say "deletion" each time we speak of the operation without noticing that any other operation is possible on the widget.

It is also possible to directly start the destruction timer using the Start() function, and to stop is with its counterpart Stop().

The widget on which this mixin is constructed takes ownership of this class, so there is no need to keep it around or delete it explicitly.

Definition at line 42 of file unhoverdeletemixin.h.

Constructor & Destructor Documentation

◆ UnhoverDeleteMixin()

LC::Util::UnhoverDeleteMixin::UnhoverDeleteMixin ( QObject *  parent,
const char *  slot = SLOT (deleteLater ()) 
)
explicit

Creates the mixin for the given parent widget.

Parameters
[in]parentThe widget for which should be watched for mouse leave events.
[in]slotThe slot to call when enough time has passed since mouse leave. By default it is deleteLater().

Definition at line 25 of file unhoverdeletemixin.cpp.

Member Function Documentation

◆ eventFilter()

bool LC::Util::UnhoverDeleteMixin::eventFilter ( QObject *  ,
QEvent *  event 
)
overrideprotected

Definition at line 57 of file unhoverdeletemixin.cpp.

◆ Start()

void LC::Util::UnhoverDeleteMixin::Start ( std::optional< int >  timeout = {})

Manually starts the timer.

This function can be used to start the timer after a Stop().

If the widget currently contains the mouse, this function does nothing.

Parameters
[in]timeoutThe number of milliseconds to wait before the widget is deleted, or system-default timeout.
See also
Stop()

Definition at line 46 of file unhoverdeletemixin.cpp.

◆ Stop()

void LC::Util::UnhoverDeleteMixin::Stop ( )

Stops the previously started timer.

This function stops the started destruction timer, both if it is started as the result of mouse leave or due to Start().

After a Stop() the widget will never be deleted without mouse entering the widget and then leaving it again, or calling Start().

This function is useful if a user is currently interacting with a logical child of the watched widget, and though the watched widget doesn't contain mouse at the moment, it still makes sense to keep it around.

See also
Start()

Definition at line 52 of file unhoverdeletemixin.cpp.


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