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
41cab406
Commit
41cab406
authored
Nov 16, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(notifier): supports visible property changed to false
parent
fbfa00a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
23 deletions
+67
-23
Notifier.cpp
tests/src/components/notifier/Notifier.cpp
+56
-19
Notifier.hpp
tests/src/components/notifier/Notifier.hpp
+6
-3
Notification.spec.qml
...s/ui/modules/Linphone/Notifications/Notification.spec.qml
+5
-1
No files found.
tests/src/components/notifier/Notifier.cpp
View file @
41cab406
#include <QQuickWindow>
#include <QTimer>
#include <QtDebug>
...
...
@@ -13,6 +14,7 @@
// Arbitrary hardcoded values.
#define NOTIFICATION_SPACING 10
#define N_MAX_NOTIFICATIONS 15
#define MAX_TIMEOUT 60000
// ===================================================================
...
...
@@ -71,24 +73,18 @@ Notifier::~Notifier () {
// -------------------------------------------------------------------
void
Notifier
::
showCallMessage
(
int
timeout
,
const
QString
&
sip_address
)
{
qDebug
()
<<
"Show call notification message. (addr="
<<
sip_address
<<
")"
;
QObject
*
Notifier
::
createNotification
(
Notifier
::
NotificationType
type
)
{
m_mutex
.
lock
();
// Check existing instances.
if
(
m_n_instances
>=
N_MAX_NOTIFICATIONS
)
{
qWarning
()
<<
"Unable to create another notification"
;
m_mutex
.
unlock
();
return
;
return
nullptr
;
}
// Create instance and set attributes.
QObject
*
object
=
m_components
[
Notifier
::
Call
]
->
create
();
QObject
*
object
=
m_components
[
type
]
->
create
();
int
offset
=
getNotificationSize
(
*
object
,
NOTIFICATION_HEIGHT_PROPERTY
);
if
(
...
...
@@ -97,7 +93,7 @@ void Notifier::showCallMessage (
)
{
delete
object
;
m_mutex
.
unlock
();
return
;
return
nullptr
;
}
m_offset
=
(
offset
+
m_offset
)
+
NOTIFICATION_SPACING
;
...
...
@@ -105,22 +101,63 @@ void Notifier::showCallMessage (
m_mutex
.
unlock
();
return
object
;
}
void
Notifier
::
showNotification
(
QObject
*
notification
,
int
timeout
)
{
if
(
timeout
>
MAX_TIMEOUT
)
{
timeout
=
MAX_TIMEOUT
;
}
// Display notification.
QMetaObject
::
invokeMethod
(
object
,
NOTIFICATION_SHOW_METHOD_NAME
,
notification
,
NOTIFICATION_SHOW_METHOD_NAME
,
Qt
::
DirectConnection
);
// Destroy it after timeout.
QTimer
::
singleShot
(
timeout
,
this
,
[
object
,
this
]()
{
delete
object
;
// Called explicitly (by a click on notification for example)
// or when single shot happen and if notification is visible.
QObject
::
connect
(
notification
->
findChild
<
QQuickWindow
*>
(),
&
QQuickWindow
::
visibleChanged
,
[
this
](
const
bool
&
value
)
{
qDebug
()
<<
"Update notifications counter, hidden notification detected."
;
m_mutex
.
lock
();
m_n_instances
--
;
if
(
value
)
{
qFatal
(
"A notification cannot be visible twice!"
);
return
;
}
if
(
m_n_instances
==
0
)
m_offset
=
0
;
m_mutex
.
lock
();
m_mutex
.
unlock
();
m_n_instances
--
;
if
(
m_n_instances
==
0
)
m_offset
=
0
;
m_mutex
.
unlock
();
}
);
// Destroy it after timeout.
QTimer
::
singleShot
(
timeout
,
this
,
[
notification
]()
{
delete
notification
;
});
}
// -------------------------------------------------------------------
void
Notifier
::
showCallMessage
(
int
timeout
,
const
QString
&
sip_address
)
{
qDebug
()
<<
"Show call notification message. (addr="
<<
sip_address
<<
")"
;
QObject
*
object
=
createNotification
(
Notifier
::
Call
);
if
(
!
object
)
return
;
showNotification
(
object
,
timeout
);
}
tests/src/components/notifier/Notifier.hpp
View file @
41cab406
...
...
@@ -14,20 +14,23 @@ public:
Notifier
(
QObject
*
parent
=
Q_NULLPTR
);
virtual
~
Notifier
();
enum
Type
{
enum
Notification
Type
{
Call
,
MaxNbTypes
};
Q_ENUM
(
Type
);
public
slots
:
void
showCallMessage
(
int
timeout
,
const
QString
&
sip_address
);
private:
QObject
*
createNotification
(
NotificationType
type
);
void
handleNotificationHidden
();
void
showNotification
(
QObject
*
notification
,
int
timeout
);
QQmlComponent
*
m_components
[
MaxNbTypes
];
int
m_offset
=
0
;
int
m_n_instances
=
0
;
unsigned
int
m_n_instances
=
0
;
QMutex
m_mutex
;
};
...
...
tests/ui/modules/Linphone/Notifications/Notification.spec.qml
View file @
41cab406
...
...
@@ -13,7 +13,7 @@ TestCase {
function
test_notificationHeightProperty
()
{
compare
(
Utils
.
isInteger
(
notification
.
notificationHeight
),
true
)
}
}
function
test_notificationOffsetProperty
()
{
compare
(
Utils
.
isInteger
(
notification
.
notificationOffset
),
true
)
...
...
@@ -22,4 +22,8 @@ TestCase {
function
test_notificationShowMethod
()
{
compare
(
Utils
.
isFunction
(
notification
.
show
),
true
)
}
function
test_childWindow
()
{
compare
(
Utils
.
qmlTypeof
(
notification
.
data
[
0
],
'
QQuickWindowQmlImpl
'
),
true
)
}
}
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