Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
51254335
Commit
51254335
authored
7 years ago
by
Konstantinos Sideris
Browse files
Options
Downloads
Patches
Plain Diff
Hide emoji panel if it's not under the mouse cursor
fixes #254 fixes #246
parent
8dc17cce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/emoji/Panel.h
+10
-2
10 additions, 2 deletions
include/emoji/Panel.h
include/emoji/PickButton.h
+3
-0
3 additions, 0 deletions
include/emoji/PickButton.h
src/emoji/Panel.cc
+1
-7
1 addition, 7 deletions
src/emoji/Panel.cc
src/emoji/PickButton.cc
+26
-2
26 additions, 2 deletions
src/emoji/PickButton.cc
with
40 additions
and
11 deletions
include/emoji/Panel.h
+
10
−
2
View file @
51254335
...
...
@@ -37,8 +37,16 @@ signals:
void
emojiSelected
(
const
QString
&
emoji
);
protected:
void
leaveEvent
(
QEvent
*
event
);
void
paintEvent
(
QPaintEvent
*
event
);
void
leaveEvent
(
QEvent
*
event
)
override
{
emit
leaving
();
QWidget
::
leaveEvent
(
event
);
}
void
paintEvent
(
QPaintEvent
*
event
)
override
;
signals
:
void
leaving
();
private
:
void
showCategory
(
const
Category
*
category
);
...
...
This diff is collapsed.
Click to expand it.
include/emoji/PickButton.h
+
3
−
0
View file @
51254335
...
...
@@ -18,6 +18,7 @@
#pragma once
#include
<QEvent>
#include
<QTimer>
#include
<QWidget>
#include
"FlatButton.h"
...
...
@@ -37,6 +38,7 @@ signals:
protected:
void
enterEvent
(
QEvent
*
e
)
override
;
void
leaveEvent
(
QEvent
*
e
)
override
;
private:
// Vertical distance from panel's bottom.
...
...
@@ -46,5 +48,6 @@ private:
int
horizontal_distance_
=
70
;
QSharedPointer
<
Panel
>
panel_
;
QTimer
hideTimer_
;
};
}
// namespace emoji
This diff is collapsed.
Click to expand it.
src/emoji/Panel.cc
+
1
−
7
View file @
51254335
...
...
@@ -39,7 +39,7 @@ Panel::Panel(QWidget *parent)
"QScrollBar::handle:vertical { min-height: 30px; }"
);
setAttribute
(
Qt
::
WA_ShowWithoutActivating
,
true
);
setWindowFlags
(
Qt
::
Popup
|
Qt
::
FramelessWindowHint
|
Qt
::
NoDropShadowWindowHint
);
setWindowFlags
(
Qt
::
Tool
|
Qt
::
FramelessWindowHint
|
Qt
::
NoDropShadowWindowHint
);
auto
mainWidget
=
new
QWidget
(
this
);
mainWidget
->
setMaximumSize
(
width_
,
height_
);
...
...
@@ -213,12 +213,6 @@ Panel::showCategory(const Category *category)
this
->
scrollArea_
->
ensureVisible
(
0
,
posToGo
,
0
,
0
);
}
void
Panel
::
leaveEvent
(
QEvent
*
)
{
hide
();
}
void
Panel
::
paintEvent
(
QPaintEvent
*
event
)
{
...
...
This diff is collapsed.
Click to expand it.
src/emoji/PickButton.cc
+
26
−
2
View file @
51254335
...
...
@@ -15,15 +15,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
"emoji/PickButton.h"
#include
<QDebug>
#include
"emoji/Panel.h"
#include
"emoji/PickButton.h"
using
namespace
emoji
;
// Number of milliseconds after which the panel will be hidden
// if the mouse cursor is not on top of the widget.
constexpr
int
TimeoutDuration
=
300
;
PickButton
::
PickButton
(
QWidget
*
parent
)
:
FlatButton
(
parent
)
,
panel_
{
nullptr
}
{}
{
connect
(
&
hideTimer_
,
&
QTimer
::
timeout
,
this
,
[
this
]()
{
if
(
panel_
&&
!
panel_
->
underMouse
())
{
hideTimer_
.
stop
();
panel_
->
hide
();
}
});
}
void
PickButton
::
enterEvent
(
QEvent
*
e
)
...
...
@@ -33,8 +46,12 @@ PickButton::enterEvent(QEvent *e)
if
(
panel_
.
isNull
())
{
panel_
=
QSharedPointer
<
Panel
>
(
new
Panel
(
this
));
connect
(
panel_
.
data
(),
&
Panel
::
emojiSelected
,
this
,
&
PickButton
::
emojiSelected
);
connect
(
panel_
.
data
(),
&
Panel
::
leaving
,
this
,
[
this
]()
{
panel_
->
hide
();
});
}
if
(
panel_
->
isVisible
())
return
;
QPoint
pos
(
rect
().
x
(),
rect
().
y
());
pos
=
this
->
mapToGlobal
(
pos
);
...
...
@@ -46,3 +63,10 @@ PickButton::enterEvent(QEvent *e)
panel_
->
move
(
x
,
y
);
panel_
->
show
();
}
void
PickButton
::
leaveEvent
(
QEvent
*
e
)
{
hideTimer_
.
start
(
TimeoutDuration
);
FlatButton
::
leaveEvent
(
e
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment