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
eda5ee59
Commit
eda5ee59
authored
Feb 27, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(src/components/notifier/Notifier): better handlers & supports correctly mac os
parent
214809ec
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
40 deletions
+49
-40
Notifier.cpp
linphone-desktop/src/components/notifier/Notifier.cpp
+34
-26
Notifier.hpp
linphone-desktop/src/components/notifier/Notifier.hpp
+1
-1
Notification.qml
...esktop/ui/modules/Linphone/Notifications/Notification.qml
+10
-0
NotificationReceivedCall.qml
...dules/Linphone/Notifications/NotificationReceivedCall.qml
+0
-7
NotificationReceivedFileMessage.qml
...inphone/Notifications/NotificationReceivedFileMessage.qml
+2
-3
NotificationReceivedMessage.qml
...es/Linphone/Notifications/NotificationReceivedMessage.qml
+2
-3
No files found.
linphone-desktop/src/components/notifier/Notifier.cpp
View file @
eda5ee59
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
#define NOTIFICATION_TIMEOUT_RECEIVED_MESSAGE 10000
#define NOTIFICATION_TIMEOUT_RECEIVED_MESSAGE 10000
#define NOTIFICATION_TIMEOUT_RECEIVED_FILE_MESSAGE 10000
#define NOTIFICATION_TIMEOUT_RECEIVED_FILE_MESSAGE 10000
#define NOTIFICATION_TIMEOUT_RECEIVED_CALL
1
0000
#define NOTIFICATION_TIMEOUT_RECEIVED_CALL
3
0000
// Arbitrary hardcoded values.
// Arbitrary hardcoded values.
#define NOTIFICATION_SPACING 10
#define NOTIFICATION_SPACING 10
...
@@ -135,30 +135,45 @@ QObject *Notifier::createNotification (Notifier::NotificationType type) {
...
@@ -135,30 +135,45 @@ QObject *Notifier::createNotification (Notifier::NotificationType type) {
}
}
void
Notifier
::
showNotification
(
QObject
*
notification
,
int
timeout
)
{
void
Notifier
::
showNotification
(
QObject
*
notification
,
int
timeout
)
{
if
(
timeout
>
MAX_TIMEOUT
)
{
timeout
=
MAX_TIMEOUT
;
}
// Display notification.
// Display notification.
QMetaObject
::
invokeMethod
(
QMetaObject
::
invokeMethod
(
notification
,
NOTIFICATION_SHOW_METHOD_NAME
,
Qt
::
DirectConnection
);
notification
,
NOTIFICATION_SHOW_METHOD_NAME
,
Qt
::
DirectConnection
);
QQuickWindow
*
window
=
notification
->
findChild
<
QQuickWindow
*>
();
QQuickWindow
*
window
=
notification
->
findChild
<
QQuickWindow
*>
();
if
(
!
window
)
if
(
!
window
)
qFatal
(
"Cannot found a `QQuickWindow` instance in `notification`."
);
qFatal
(
"Cannot found a `QQuickWindow` instance in `notification`."
);
QTimer
*
timer
=
new
QTimer
(
window
);
timer
->
setInterval
(
timeout
>
MAX_TIMEOUT
?
MAX_TIMEOUT
:
timeout
);
timer
->
setSingleShot
(
true
);
notification
->
setProperty
(
"__timer"
,
QVariant
::
fromValue
(
timer
));
// Destroy it after timeout.
QObject
::
connect
(
timer
,
&
QTimer
::
timeout
,
this
,
[
this
,
notification
]()
{
notification
->
property
(
"__timer"
).
value
<
QTimer
*>
()
->
stop
();
deleteNotification
(
notification
);
}
);
// Called explicitly (by a click on notification for example)
// Called explicitly (by a click on notification for example)
// or when single shot happen and if notification is visible.
// or when single shot happen and if notification is visible.
QObject
::
connect
(
QObject
::
connect
(
window
,
&
QQuickWindow
::
visibleChanged
,
[
this
](
const
bool
&
visible
)
{
window
,
&
QQuickWindow
::
visibilityChanged
,
[
this
,
notification
](
QWindow
::
Visibility
visibility
)
{
if
(
visibility
!=
QWindow
::
Visibility
::
Hidden
)
return
;
qInfo
()
<<
"Update notifications counter, hidden notification detected."
;
qInfo
()
<<
"Update notifications counter, hidden notification detected."
;
notification
->
property
(
"__timer"
).
value
<
QTimer
*>
()
->
stop
();
deleteNotification
(
notification
);
}
);
if
(
visible
)
timer
->
start
();
qWarning
(
"A notification cannot be visible twice!"
);
}
// -----------------------------------------------------------------------------
void
Notifier
::
deleteNotification
(
QObject
*
notification
)
{
m_mutex
.
lock
();
m_mutex
.
lock
();
m_n_instances
--
;
m_n_instances
--
;
...
@@ -167,15 +182,8 @@ void Notifier::showNotification (QObject *notification, int timeout) {
...
@@ -167,15 +182,8 @@ void Notifier::showNotification (QObject *notification, int timeout) {
m_offset
=
0
;
m_offset
=
0
;
m_mutex
.
unlock
();
m_mutex
.
unlock
();
}
);
// Destroy it after timeout.
notification
->
deleteLater
();
QTimer
::
singleShot
(
timeout
,
this
,
[
notification
]()
{
delete
notification
;
}
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
...
linphone-desktop/src/components/notifier/Notifier.hpp
View file @
eda5ee59
...
@@ -52,8 +52,8 @@ public:
...
@@ -52,8 +52,8 @@ public:
private:
private:
QObject
*
createNotification
(
NotificationType
type
);
QObject
*
createNotification
(
NotificationType
type
);
void
handleNotificationHidden
();
void
showNotification
(
QObject
*
notification
,
int
timeout
);
void
showNotification
(
QObject
*
notification
,
int
timeout
);
void
deleteNotification
(
QObject
*
notification
);
QQmlComponent
*
m_components
[
MaxNbTypes
];
QQmlComponent
*
m_components
[
MaxNbTypes
];
...
...
linphone-desktop/ui/modules/Linphone/Notifications/Notification.qml
View file @
eda5ee59
...
@@ -24,6 +24,16 @@ DesktopPopup {
...
@@ -24,6 +24,16 @@ DesktopPopup {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function
_close
(
cb
)
{
window
.
visibility
=
Window
.
Hidden
if
(
cb
)
{
cb
()
}
}
// ---------------------------------------------------------------------------
flags
:
Qt
.
Popup
flags
:
Qt
.
Popup
Component.onCompleted
:
{
Component.onCompleted
:
{
...
...
linphone-desktop/ui/modules/Linphone/Notifications/NotificationReceivedCall.qml
View file @
eda5ee59
...
@@ -18,13 +18,6 @@ Notification {
...
@@ -18,13 +18,6 @@ Notification {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function
_close
(
cb
)
{
notification
.
window
.
setVisible
(
false
)
cb
()
}
// ---------------------------------------------------------------------------
Rectangle
{
Rectangle
{
color
:
NotificationReceivedCallStyle
.
color
color
:
NotificationReceivedCallStyle
.
color
height
:
NotificationReceivedCallStyle
.
height
height
:
NotificationReceivedCallStyle
.
height
...
...
linphone-desktop/ui/modules/Linphone/Notifications/NotificationReceivedFileMessage.qml
View file @
eda5ee59
...
@@ -70,10 +70,9 @@ Notification {
...
@@ -70,10 +70,9 @@ Notification {
cursorShape
:
containsMouse
?
Qt
.
PointingHandCursor
:
Qt
.
ArrowCursor
cursorShape
:
containsMouse
?
Qt
.
PointingHandCursor
:
Qt
.
ArrowCursor
hoverEnabled
:
true
hoverEnabled
:
true
onClicked
:
{
onClicked
:
notification
.
_close
(
function
()
{
notification
.
window
.
setVisible
(
false
)
Qt
.
openUrlExternally
(
'
file://
'
+
Utils
.
dirname
(
notification
.
_fileUri
))
Qt
.
openUrlExternally
(
'
file://
'
+
Utils
.
dirname
(
notification
.
_fileUri
))
}
}
)
}
}
}
}
}
}
...
...
linphone-desktop/ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml
View file @
eda5ee59
...
@@ -89,12 +89,11 @@ Notification {
...
@@ -89,12 +89,11 @@ Notification {
cursorShape
:
containsMouse
?
Qt
.
PointingHandCursor
:
Qt
.
ArrowCursor
cursorShape
:
containsMouse
?
Qt
.
PointingHandCursor
:
Qt
.
ArrowCursor
hoverEnabled
:
true
hoverEnabled
:
true
onClicked
:
{
onClicked
:
notification
.
_close
(
function
()
{
notification
.
window
.
setVisible
(
false
)
notification
.
notificationData
.
window
.
setView
(
'
Conversation
'
,
{
notification
.
notificationData
.
window
.
setView
(
'
Conversation
'
,
{
sipAddress
:
notification
.
_sipAddress
sipAddress
:
notification
.
_sipAddress
})
})
}
}
)
}
}
}
}
}
}
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