LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
|
Allows to hide a widget or popup after mouse leave. More...
#include "unhoverdeletemixin.h"
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 |
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.
|
explicit |
Creates the mixin for the given parent widget.
[in] | parent | The widget for which should be watched for mouse leave events. |
[in] | slot | The slot to call when enough time has passed since mouse leave. By default it is deleteLater() . |
Definition at line 25 of file unhoverdeletemixin.cpp.
|
overrideprotected |
Definition at line 57 of file unhoverdeletemixin.cpp.
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.
[in] | timeout | The number of milliseconds to wait before the widget is deleted, or system-default timeout. |
Definition at line 46 of file unhoverdeletemixin.cpp.
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.
Definition at line 52 of file unhoverdeletemixin.cpp.