Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
2ef80f31
Commit
2ef80f31
authored
Feb 28, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(src/components/notifier/Notifier): use custom signal to close notification
parent
353eac81
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
22 deletions
+16
-22
Notifier.cpp
linphone-desktop/src/components/notifier/Notifier.cpp
+9
-19
Notifier.hpp
linphone-desktop/src/components/notifier/Notifier.hpp
+3
-1
Notification.qml
...esktop/ui/modules/Linphone/Notifications/Notification.qml
+4
-2
No files found.
linphone-desktop/src/components/notifier/Notifier.cpp
View file @
2ef80f31
...
...
@@ -140,11 +140,7 @@ void Notifier::showNotification (QObject *notification, int timeout) {
// Display notification.
QMetaObject
::
invokeMethod
(
notification
,
NOTIFICATION_SHOW_METHOD_NAME
,
Qt
::
DirectConnection
);
QQuickWindow
*
window
=
notification
->
findChild
<
QQuickWindow
*>
();
if
(
!
window
)
qFatal
(
"Cannot found a `QQuickWindow` instance in `notification`."
);
QTimer
*
timer
=
new
QTimer
(
window
);
QTimer
*
timer
=
new
QTimer
(
notification
);
timer
->
setInterval
(
timeout
>
MAX_TIMEOUT
?
MAX_TIMEOUT
:
timeout
);
timer
->
setSingleShot
(
true
);
notification
->
setProperty
(
NOTIFICATION_PROPERTY_TIMER
,
QVariant
::
fromValue
(
timer
));
...
...
@@ -152,30 +148,24 @@ void Notifier::showNotification (QObject *notification, int timeout) {
// Destroy it after timeout.
QObject
::
connect
(
timer
,
&
QTimer
::
timeout
,
this
,
[
this
,
notification
]()
{
notification
->
property
(
NOTIFICATION_PROPERTY_TIMER
).
value
<
QTimer
*>
()
->
stop
();
deleteNotification
(
notification
);
deleteNotification
(
QVariant
::
fromValue
(
notification
));
}
);
// Called explicitly (by a click on notification for example)
// or when single shot happen and if notification is visible.
QObject
::
connect
(
window
,
&
QQuickWindow
::
visibilityChanged
,
[
this
,
notification
](
QWindow
::
Visibility
visibility
)
{
if
(
visibility
!=
QWindow
::
Visibility
::
Hidden
)
return
;
qInfo
()
<<
"Update notifications counter, hidden notification detected."
;
notification
->
property
(
NOTIFICATION_PROPERTY_TIMER
).
value
<
QTimer
*>
()
->
stop
();
deleteNotification
(
notification
);
}
);
QObject
::
connect
(
notification
,
SIGNAL
(
deleteNotification
(
QVariant
)),
this
,
SLOT
(
deleteNotification
(
QVariant
)));
timer
->
start
();
}
// -----------------------------------------------------------------------------
void
Notifier
::
deleteNotification
(
QObject
*
notification
)
{
void
Notifier
::
deleteNotification
(
QVariant
notification
)
{
QObject
*
instance
=
notification
.
value
<
QObject
*>
();
instance
->
property
(
NOTIFICATION_PROPERTY_TIMER
).
value
<
QTimer
*>
()
->
stop
();
m_mutex
.
lock
();
m_n_instances
--
;
...
...
@@ -185,7 +175,7 @@ void Notifier::deleteNotification (QObject *notification) {
m_mutex
.
unlock
();
notification
->
deleteLater
();
instance
->
deleteLater
();
}
// -----------------------------------------------------------------------------
...
...
linphone-desktop/src/components/notifier/Notifier.hpp
View file @
2ef80f31
...
...
@@ -50,10 +50,12 @@ public:
void
notifyReceivedFileMessage
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
void
notifyReceivedCall
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
call
);
public
slots
:
void
deleteNotification
(
QVariant
notification
);
private:
QObject
*
createNotification
(
NotificationType
type
);
void
showNotification
(
QObject
*
notification
,
int
timeout
);
void
deleteNotification
(
QObject
*
notification
);
QQmlComponent
*
m_components
[
MaxNbTypes
];
...
...
linphone-desktop/ui/modules/Linphone/Notifications/Notification.qml
View file @
2ef80f31
...
...
@@ -24,12 +24,14 @@ DesktopPopup {
// ---------------------------------------------------------------------------
function
_close
(
cb
)
{
window
.
visibility
=
Window
.
Hidden
signal
deleteNotification
(
var
notification
)
function
_close
(
cb
)
{
if
(
cb
)
{
cb
()
}
deleteNotification
(
notification
)
}
// ---------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment