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
cf6eecbd
Commit
cf6eecbd
authored
Nov 15, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unstable
parent
363d03e6
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
37 deletions
+63
-37
App.cpp
tests/src/app/App.cpp
+2
-2
Notification.cpp
tests/src/components/notification/Notification.cpp
+43
-27
Notification.hpp
tests/src/components/notification/Notification.hpp
+1
-0
DesktopPopup.qml
tests/ui/modules/Common/Popup/DesktopPopup.qml
+10
-7
SearchBox.qml
tests/ui/modules/Common/SearchBox.qml
+1
-0
PopupStyle.qml
tests/ui/modules/Common/Styles/PopupStyle.qml
+4
-0
CallNotification.qml
tests/ui/modules/Linphone/Notifications/CallNotification.qml
+1
-0
Contacts.qml
tests/ui/views/App/MainWindow/Contacts.qml
+1
-1
No files found.
tests/src/app/App.cpp
View file @
cf6eecbd
...
...
@@ -148,8 +148,8 @@ void App::setNotificationAttributes () {
QRect
icon_rect
=
m_system_tray_icon
->
geometry
();
QRect
screen_rect
=
desktop
->
screenGeometry
();
int
x
=
icon_rect
.
x
()
+
icon_rect
.
width
()
/
2
;
int
y
=
icon_rect
.
y
()
+
icon_rect
.
height
()
/
2
;
int
x
=
icon_rect
.
x
()
/
2
+
icon_rect
.
width
()
/
2
;
int
y
=
icon_rect
.
y
()
/
2
+
icon_rect
.
height
()
/
2
;
Qt
::
Edges
edge
=
(
x
<
screen_rect
.
width
()
/
2
)
?
Qt
::
LeftEdge
:
Qt
::
RightEdge
;
edge
|=
(
y
<
screen_rect
.
height
()
/
2
)
?
Qt
::
TopEdge
:
Qt
::
BottomEdge
;
...
...
tests/src/components/notification/Notification.cpp
View file @
cf6eecbd
...
...
@@ -8,12 +8,42 @@
#define NOTIFICATION_EDGE_PROPERTY_NAME "edge"
#define NOTIFICATION_HEIGHT_PROPERTY "popupHeight"
#define NOTIFICATION_WIDTH_PROPERTY "popupWidth"
#define NOTIFICATION_OFFSET_PROPERTY_NAME "edgeOffset"
#define NOTIFICATION_SPACING 10
#define N_MAX_NOTIFICATIONS 3
// ===================================================================
// Helpers.
inline
int
getNotificationSize
(
const
QObject
&
object
,
const
char
*
property
)
{
QVariant
variant
=
object
.
property
(
property
);
bool
so_far_so_good
;
int
size
=
variant
.
toInt
(
&
so_far_so_good
);
if
(
!
so_far_so_good
||
size
<
0
)
{
qWarning
()
<<
"Unable to get notification size."
;
return
-
1
;
}
return
size
;
}
template
<
class
T
>
bool
setProperty
(
QObject
&
object
,
const
char
*
property
,
const
T
&
value
)
{
QVariant
qvariant
(
value
);
if
(
!
object
.
setProperty
(
property
,
qvariant
))
{
qWarning
()
<<
"Unable to set property `"
<<
property
<<
"`."
;
return
false
;
}
return
true
;
}
// -------------------------------------------------------------------
Notification
::
Notification
(
QObject
*
parent
)
:
QObject
(
parent
)
{
QQmlEngine
*
engine
=
App
::
getInstance
()
->
getEngine
();
...
...
@@ -41,30 +71,6 @@ Notification::~Notification () {
// -------------------------------------------------------------------
inline
int
getNotificationSize
(
const
QObject
&
object
,
const
char
*
size_property
)
{
QVariant
variant
=
object
.
property
(
size_property
);
bool
so_far_so_good
;
int
size
=
variant
.
toInt
(
&
so_far_so_good
);
if
(
!
so_far_so_good
||
size
<
0
)
{
qWarning
()
<<
"Unable to get notification size."
;
return
-
1
;
}
return
size
;
}
inline
bool
setNotificationEdge
(
QObject
&
object
,
int
value
)
{
QVariant
edge
(
value
);
if
(
!
object
.
setProperty
(
"edge"
,
edge
))
{
qWarning
()
<<
"Unable to set notification edge."
;
return
false
;
}
return
true
;
}
void
Notification
::
showCallMessage
(
int
timeout
,
const
QString
&
sip_address
...
...
@@ -75,7 +81,7 @@ void Notification::showCallMessage (
m_mutex
.
lock
();
// Check existing instances.
if
(
m_n_instances
+
1
>=
N_MAX_NOTIFICATIONS
)
{
if
(
m_n_instances
>=
N_MAX_NOTIFICATIONS
)
{
qWarning
()
<<
"Unable to create another notification"
;
m_mutex
.
unlock
();
return
;
...
...
@@ -83,13 +89,19 @@ void Notification::showCallMessage (
// Create instance and set attributes.
QObject
*
object
=
m_components
[
Notification
::
Call
]
->
create
();
int
offset
=
getNotificationSize
(
*
object
,
NOTIFICATION_HEIGHT_PROPERTY
);
if
(
!
setNotificationEdge
(
*
object
,
m_edge
))
{
if
(
offset
==
-
1
||
!::
setProperty
(
*
object
,
NOTIFICATION_EDGE_PROPERTY_NAME
,
m_edge
)
||
!::
setProperty
(
*
object
,
NOTIFICATION_OFFSET_PROPERTY_NAME
,
m_offset
)
)
{
delete
object
;
m_mutex
.
unlock
();
return
;
}
m_offset
=
(
m_n_instances
==
0
?
offset
:
offset
+
m_offset
)
+
NOTIFICATION_SPACING
;
m_n_instances
++
;
m_mutex
.
unlock
();
...
...
@@ -103,6 +115,10 @@ void Notification::showCallMessage (
m_mutex
.
lock
();
m_n_instances
--
;
if
(
m_n_instances
==
0
)
m_offset
=
0
;
m_mutex
.
unlock
();
});
}
tests/src/components/notification/Notification.hpp
View file @
cf6eecbd
...
...
@@ -31,6 +31,7 @@ private:
Qt
::
Edges
m_edge
=
Qt
::
RightEdge
|
Qt
::
TopEdge
;
QQmlComponent
*
m_components
[
MaxNbTypes
];
int
m_offset
=
0
;
int
m_n_instances
=
0
;
QMutex
m_mutex
;
};
...
...
tests/ui/modules/Common/Popup/DesktopPopup.qml
View file @
cf6eecbd
...
...
@@ -12,6 +12,9 @@ Item {
property
int
popupY
:
0
property
int
edge
:
0
property
int
edgeOffset
:
0
property
int
flags
:
Qt
.
Popup
readonly
property
alias
popupWidth
:
popup
.
width
readonly
property
alias
popupHeight
:
popup
.
height
...
...
@@ -27,7 +30,7 @@ Item {
_isOpen
=
false
}
function
_applyXEdge
(
edge
)
{
function
_applyXEdge
()
{
var
screen
=
popup
.
Screen
if
(
screen
==
null
)
{
...
...
@@ -35,13 +38,13 @@ Item {
}
if
(
edge
&
Qt
.
LeftEdge
)
{
return
0
return
PopupStyle
.
desktop
.
edgeMargin
}
return
screen
.
width
-
popup
.
width
return
screen
.
width
-
popup
.
width
-
PopupStyle
.
desktop
.
edgeMargin
}
function
_applyYEdge
(
edge
)
{
function
_applyYEdge
()
{
var
screen
=
popup
.
Screen
if
(
screen
==
null
)
{
...
...
@@ -49,10 +52,10 @@ Item {
}
if
(
edge
&
Qt
.
TopEdge
)
{
return
0
return
edgeOffset
+
PopupStyle
.
desktop
.
edgeMargin
}
return
screen
.
height
-
popup
.
height
return
screen
.
height
-
popup
.
height
-
edgeOffset
-
PopupStyle
.
desktop
.
edgeMargin
}
// -----------------------------------------------------------------
...
...
@@ -71,7 +74,7 @@ Item {
Window
{
id
:
popup
flags
:
Qt
.
SplashScreen
flags
:
wrapper
.
flags
opacity
:
0
height
:
_content
[
0
]
!=
null
?
_content
[
0
].
height
:
0
width
:
_content
[
0
]
!=
null
?
_content
[
0
].
width
:
0
...
...
tests/ui/modules/Common/SearchBox.qml
View file @
cf6eecbd
...
...
@@ -90,6 +90,7 @@ Item {
return
point
}
flags
:
Qt
.
SplashScreen
popupX
:
coords
.
x
popupY
:
coords
.
y
...
...
tests/ui/modules/Common/Styles/PopupStyle.qml
View file @
cf6eecbd
...
...
@@ -13,6 +13,10 @@ QtObject {
property
int
closingDuration
:
250
}
property
QtObject
desktop
:
QtObject
{
property
int
edgeMargin
:
10
}
property
QtObject
shadow
:
QtObject
{
property
color
color
:
Colors
.
l
property
int
horizontalOffset
:
4
...
...
tests/ui/modules/Linphone/Notifications/CallNotification.qml
View file @
cf6eecbd
...
...
@@ -5,6 +5,7 @@ import Common 1.0
DesktopPopup
{
Rectangle
{
color
:
'
red
'
width
:
200
height
:
100
}
...
...
tests/ui/views/App/MainWindow/Contacts.qml
View file @
cf6eecbd
...
...
@@ -36,7 +36,7 @@ ColumnLayout {
})
}
spacing
:
Notification
.
showCallMessage
(
10
000
,
"
toto@toto.com
"
)
||
0
spacing
:
Notification
.
showCallMessage
(
5
000
,
"
toto@toto.com
"
)
||
0
// -----------------------------------------------------------------
// Search Bar & actions.
...
...
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