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
c1e6d7d2
Commit
c1e6d7d2
authored
Nov 15, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unstable
parent
6a6d3752
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
57 deletions
+56
-57
App.cpp
tests/src/app/App.cpp
+11
-16
Notification.cpp
tests/src/components/notification/Notification.cpp
+8
-33
Notification.hpp
tests/src/components/notification/Notification.hpp
+0
-6
DesktopPopup.qml
tests/ui/modules/Common/Popup/DesktopPopup.qml
+37
-2
No files found.
tests/src/app/App.cpp
View file @
c1e6d7d2
...
@@ -139,25 +139,20 @@ void App::setTrayIcon () {
...
@@ -139,25 +139,20 @@ void App::setTrayIcon () {
}
}
void
App
::
setNotificationAttributes
()
{
void
App
::
setNotificationAttributes
()
{
QDesktopWidget
*
desktop
=
QApplication
::
desktop
();
if
(
!
m_system_tray_icon
)
{
return
;
// The primary screen is the default given by Qt or the screen of
}
// system tray icon.
int
primary_screen
=
desktop
->
primaryScreen
();
if
(
m_system_tray_icon
)
{
// primary_screen = QDesktopWidget::screenNumber(m_system_tray_icon);
QRect
icon_rect
=
m_system_tray_icon
->
geometry
();
QDesktopWidget
*
desktop
=
QApplication
::
desktop
();
QRect
screen_rect
=
desktop
->
screenGeometry
(
primary_screen
);
int
x
=
icon_rect
.
x
()
+
icon_rect
.
width
()
/
2
;
QRect
icon_rect
=
m_system_tray_icon
->
geometry
()
;
int
y
=
icon_rect
.
y
()
+
icon_rect
.
height
()
/
2
;
QRect
screen_rect
=
desktop
->
screenGeometry
()
;
Qt
::
Edges
edge
=
(
x
<
screen_rect
.
width
()
/
2
)
?
Qt
::
LeftEdge
:
Qt
::
RightEdge
;
int
x
=
icon_rect
.
x
()
+
icon_rect
.
width
()
/
2
;
edge
|=
(
y
<
screen_rect
.
height
()
/
2
)
?
Qt
::
TopEdge
:
Qt
::
BottomEdge
;
int
y
=
icon_rect
.
y
()
+
icon_rect
.
height
()
/
2
;
m_notification
->
setEdge
(
edge
)
;
Qt
::
Edges
edge
=
(
x
<
screen_rect
.
width
()
/
2
)
?
Qt
::
LeftEdge
:
Qt
::
RightEdge
;
}
edge
|=
(
y
<
screen_rect
.
height
()
/
2
)
?
Qt
::
TopEdge
:
Qt
::
BottomEdge
;
m_notification
->
set
ScreenNumber
(
primary_screen
);
m_notification
->
set
Edge
(
edge
);
}
}
tests/src/components/notification/Notification.cpp
View file @
c1e6d7d2
#include <QDesktopWidget>
#include <QTimer>
#include <QTimer>
#include <QtDebug>
#include <QtDebug>
#include "../../app/App.hpp"
#include "../../app/App.hpp"
#include "Notification.hpp"
#include "Notification.hpp"
#define NOTIFICATION_
X_PROPERTY "popupX
"
#define NOTIFICATION_
SHOW_METHOD_NAME "show
"
#define NOTIFICATION_
Y_PROPERTY "popupY
"
#define NOTIFICATION_
EDGE_PROPERTY_NAME "edge
"
#define NOTIFICATION_HEIGHT_PROPERTY "popupHeight"
#define NOTIFICATION_HEIGHT_PROPERTY "popupHeight"
#define NOTIFICATION_WIDTH_PROPERTY "popupWidth"
#define NOTIFICATION_WIDTH_PROPERTY "popupWidth"
#define NOTIFICATION_SHOW_METHOD_NAME "show"
#define N_MAX_NOTIFICATIONS 3
#define N_MAX_NOTIFICATIONS 3
// ===================================================================
// ===================================================================
...
@@ -47,8 +44,8 @@ Notification::~Notification () {
...
@@ -47,8 +44,8 @@ Notification::~Notification () {
inline
int
getNotificationSize
(
const
QObject
&
object
,
const
char
*
size_property
)
{
inline
int
getNotificationSize
(
const
QObject
&
object
,
const
char
*
size_property
)
{
QVariant
variant
=
object
.
property
(
size_property
);
QVariant
variant
=
object
.
property
(
size_property
);
bool
so_far_so_good
;
bool
so_far_so_good
;
int
size
=
variant
.
toInt
(
&
so_far_so_good
);
int
size
=
variant
.
toInt
(
&
so_far_so_good
);
if
(
!
so_far_so_good
||
size
<
0
)
{
if
(
!
so_far_so_good
||
size
<
0
)
{
qWarning
()
<<
"Unable to get notification size."
;
qWarning
()
<<
"Unable to get notification size."
;
return
-
1
;
return
-
1
;
...
@@ -57,13 +54,11 @@ inline int getNotificationSize (const QObject &object, const char *size_property
...
@@ -57,13 +54,11 @@ inline int getNotificationSize (const QObject &object, const char *size_property
return
size
;
return
size
;
}
}
inline
bool
setNotificationPosition
(
inline
bool
setNotificationEdge
(
QObject
&
object
,
int
value
)
{
QObject
&
object
,
const
char
*
position_property
,
int
value
QVariant
edge
(
value
);
)
{
QVariant
position
(
value
);
if
(
!
object
.
setProperty
(
position_property
,
position
))
{
if
(
!
object
.
setProperty
(
"edge"
,
edge
))
{
qWarning
()
<<
"Unable to set notification
position
."
;
qWarning
()
<<
"Unable to set notification
edge
."
;
return
false
;
return
false
;
}
}
...
@@ -78,32 +73,12 @@ void Notification::showCallMessage (
...
@@ -78,32 +73,12 @@ void Notification::showCallMessage (
sip_address
<<
")"
;
sip_address
<<
")"
;
QObject
*
object
=
m_components
[
Notification
::
Call
]
->
create
();
QObject
*
object
=
m_components
[
Notification
::
Call
]
->
create
();
int
width
,
height
;
if
(
if
(
!
setNotificationEdge
(
*
object
,
m_edge
))
{
(
width
=
getNotificationSize
(
*
object
,
NOTIFICATION_WIDTH_PROPERTY
))
==
-
1
||
(
height
=
getNotificationSize
(
*
object
,
NOTIFICATION_HEIGHT_PROPERTY
))
==
-
1
)
{
delete
object
;
delete
object
;
return
;
return
;
}
}
QRect
screen_rect
=
QApplication
::
desktop
()
->
screenGeometry
(
m_screen_number
);
int
x
=
(
m_edge
&
Qt
::
LeftEdge
)
?
5
:
screen_rect
.
width
()
-
5
-
width
;
int
y
=
(
m_edge
&
Qt
::
TopEdge
)
?
5
:
screen_rect
.
height
()
-
5
-
height
;
if
(
!
setNotificationPosition
(
*
object
,
NOTIFICATION_X_PROPERTY
,
x
)
||
!
setNotificationPosition
(
*
object
,
NOTIFICATION_Y_PROPERTY
,
y
)
)
{
delete
object
;
return
;
}
QMetaObject
::
invokeMethod
(
object
,
"show"
,
Qt
::
DirectConnection
);
QMetaObject
::
invokeMethod
(
object
,
"show"
,
Qt
::
DirectConnection
);
QTimer
::
singleShot
(
timeout
,
object
,
[
object
]()
{
QTimer
::
singleShot
(
timeout
,
object
,
[
object
]()
{
delete
object
;
delete
object
;
...
...
tests/src/components/notification/Notification.hpp
View file @
c1e6d7d2
...
@@ -24,10 +24,6 @@ public:
...
@@ -24,10 +24,6 @@ public:
m_edge
=
edge
;
m_edge
=
edge
;
}
}
void
setScreenNumber
(
int
screen_number
)
{
m_screen_number
=
screen_number
;
}
public
slots
:
public
slots
:
void
showCallMessage
(
int
timeout
,
const
QString
&
sip_address
);
void
showCallMessage
(
int
timeout
,
const
QString
&
sip_address
);
...
@@ -35,8 +31,6 @@ private:
...
@@ -35,8 +31,6 @@ private:
Qt
::
Edges
m_edge
=
Qt
::
RightEdge
|
Qt
::
TopEdge
;
Qt
::
Edges
m_edge
=
Qt
::
RightEdge
|
Qt
::
TopEdge
;
QQmlComponent
*
m_components
[
MaxNbTypes
];
QQmlComponent
*
m_components
[
MaxNbTypes
];
int
m_screen_number
=
0
;
int
m_n_instances
=
0
;
int
m_n_instances
=
0
;
QMutex
m_mutex
;
QMutex
m_mutex
;
};
};
...
...
tests/ui/modules/Common/Popup/DesktopPopup.qml
View file @
c1e6d7d2
...
@@ -8,8 +8,10 @@ import Common.Styles 1.0
...
@@ -8,8 +8,10 @@ import Common.Styles 1.0
Item
{
Item
{
id
:
wrapper
id
:
wrapper
property
alias
popupX
:
popup
.
x
property
int
popupX
:
0
property
alias
popupY
:
popup
.
y
property
int
popupY
:
0
property
int
edge
:
0
readonly
property
alias
popupWidth
:
popup
.
width
readonly
property
alias
popupWidth
:
popup
.
width
readonly
property
alias
popupHeight
:
popup
.
height
readonly
property
alias
popupHeight
:
popup
.
height
...
@@ -25,6 +27,36 @@ Item {
...
@@ -25,6 +27,36 @@ Item {
_isOpen
=
false
_isOpen
=
false
}
}
function
_applyXEdge
(
edge
)
{
var
screen
=
popup
.
Screen
if
(
screen
==
null
)
{
return
popupX
}
if
(
edge
&
Qt
.
LeftEdge
)
{
return
0
}
return
screen
.
width
-
popup
.
width
}
function
_applyYEdge
(
edge
)
{
var
screen
=
popup
.
Screen
if
(
screen
==
null
)
{
return
popupY
}
if
(
edge
&
Qt
.
TopEdge
)
{
return
0
}
return
screen
.
height
-
popup
.
height
}
// -----------------------------------------------------------------
// DO NOT TOUCH THIS PROPERTIES.
// DO NOT TOUCH THIS PROPERTIES.
// No visible.
// No visible.
...
@@ -44,6 +76,9 @@ Item {
...
@@ -44,6 +76,9 @@ Item {
height
:
_content
[
0
]
!=
null
?
_content
[
0
].
height
:
0
height
:
_content
[
0
]
!=
null
?
_content
[
0
].
height
:
0
width
:
_content
[
0
]
!=
null
?
_content
[
0
].
width
:
0
width
:
_content
[
0
]
!=
null
?
_content
[
0
].
width
:
0
x
:
edge
?
_applyXEdge
()
:
popupX
y
:
edge
?
_applyYEdge
()
:
popupY
Item
{
Item
{
id
:
content
id
:
content
...
...
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