LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
unhoverdeletemixin.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#include "
unhoverdeletemixin.h
"
10
#include <QWidget>
11
#include <QEvent>
12
#include <QTimer>
13
#include <QtDebug>
14
#include <QApplication>
15
#include <QStyle>
16
17
namespace
LC::Util
18
{
19
UnhoverDeleteMixin::UnhoverDeleteMixin
(QObject *watched,
const
char
*slot)
20
: QObject (watched)
21
, LeaveTimer_ (new QTimer (this))
22
{
23
watched->installEventFilter (
this
);
24
25
LeaveTimer_->setSingleShot (
true
);
26
connect (LeaveTimer_,
27
SIGNAL (timeout ()),
28
watched,
29
slot);
30
}
31
32
namespace
33
{
34
int
DefaultTimeout ()
35
{
36
return
QApplication::style ()->styleHint (QStyle::SH_ToolTip_WakeUpDelay) * 2;
37
}
38
}
39
40
void
UnhoverDeleteMixin::Start
(std::optional<int> timeout)
41
{
42
if
(!ContainsMouse_)
43
LeaveTimer_->start (timeout.value_or (DefaultTimeout ()));
44
}
45
46
void
UnhoverDeleteMixin::Stop
()
47
{
48
LeaveTimer_->stop ();
49
}
50
51
bool
UnhoverDeleteMixin::eventFilter
(QObject*, QEvent *event)
52
{
53
switch
(event->type ())
54
{
55
case
QEvent::Enter:
56
ContainsMouse_ =
true
;
57
LeaveTimer_->stop ();
58
break
;
59
case
QEvent::Leave:
60
ContainsMouse_ =
false
;
61
LeaveTimer_->start (DefaultTimeout ());
62
break
;
63
default
:
64
break
;
65
}
66
67
return
false
;
68
}
69
}
LC::Util::UnhoverDeleteMixin::Start
void UTIL_GUI_API Start(std::optional< int > timeout={})
Manually starts the timer.
Definition
unhoverdeletemixin.cpp:40
LC::Util::UnhoverDeleteMixin::Stop
void UTIL_GUI_API Stop()
Stops the previously started timer.
Definition
unhoverdeletemixin.cpp:46
LC::Util::UnhoverDeleteMixin::eventFilter
bool eventFilter(QObject *, QEvent *) override
Definition
unhoverdeletemixin.cpp:51
LC::Util::UnhoverDeleteMixin::UnhoverDeleteMixin
UTIL_GUI_API UnhoverDeleteMixin(QObject *parent, const char *slot=SLOT(deleteLater()))
Creates the mixin for the given parent widget.
Definition
unhoverdeletemixin.cpp:19
LC::Util
Definition
icoreproxy.h:34
unhoverdeletemixin.h
src
util
gui
unhoverdeletemixin.cpp
Generated by
1.17.0