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
4d91eb4a
Commit
4d91eb4a
authored
Nov 16, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app): provide a custom notifier
parent
cf6eecbd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
53 deletions
+25
-53
CMakeLists.txt
tests/CMakeLists.txt
+2
-2
App.cpp
tests/src/app/App.cpp
+2
-25
App.hpp
tests/src/app/App.hpp
+2
-4
Notifier.cpp
tests/src/components/notifier/Notifier.cpp
+10
-10
Notifier.hpp
tests/src/components/notifier/Notifier.hpp
+8
-11
Contacts.qml
tests/ui/views/App/MainWindow/Contacts.qml
+1
-1
No files found.
tests/CMakeLists.txt
View file @
4d91eb4a
...
@@ -34,7 +34,7 @@ set(SOURCES
...
@@ -34,7 +34,7 @@ set(SOURCES
src/components/contacts/ContactsListModel.cpp
src/components/contacts/ContactsListModel.cpp
src/components/contacts/ContactsListProxyModel.cpp
src/components/contacts/ContactsListProxyModel.cpp
src/components/linphone/LinphoneCore.cpp
src/components/linphone/LinphoneCore.cpp
src/components/notifi
cation/Notification
.cpp
src/components/notifi
er/Notifier
.cpp
src/components/settings/AccountSettingsModel.cpp
src/components/settings/AccountSettingsModel.cpp
src/components/settings/SettingsModel.cpp
src/components/settings/SettingsModel.cpp
src/components/timeline/TimelineModel.cpp
src/components/timeline/TimelineModel.cpp
...
@@ -49,7 +49,7 @@ set(HEADERS
...
@@ -49,7 +49,7 @@ set(HEADERS
src/components/contacts/ContactsListModel.hpp
src/components/contacts/ContactsListModel.hpp
src/components/contacts/ContactsListProxyModel.hpp
src/components/contacts/ContactsListProxyModel.hpp
src/components/linphone/LinphoneCore.hpp
src/components/linphone/LinphoneCore.hpp
src/components/notifi
cation/Notification
.hpp
src/components/notifi
er/Notifier
.hpp
src/components/presence/Presence.hpp
src/components/presence/Presence.hpp
src/components/settings/AccountSettingsModel.hpp
src/components/settings/AccountSettingsModel.hpp
src/components/settings/SettingsModel.hpp
src/components/settings/SettingsModel.hpp
...
...
tests/src/app/App.cpp
View file @
4d91eb4a
#include <QDesktopWidget>
#include <QMenu>
#include <QMenu>
#include <QQmlComponent>
#include <QQmlComponent>
#include <QQmlContext>
#include <QQmlContext>
...
@@ -57,9 +56,6 @@ void App::initContentApp () {
...
@@ -57,9 +56,6 @@ void App::initContentApp () {
qWarning
(
"System tray not found on this system."
);
qWarning
(
"System tray not found on this system."
);
else
else
setTrayIcon
();
setTrayIcon
();
// Set notification attr.
setNotificationAttributes
();
}
}
void
App
::
registerTypes
()
{
void
App
::
registerTypes
()
{
...
@@ -100,8 +96,8 @@ void App::addContextProperties () {
...
@@ -100,8 +96,8 @@ void App::addContextProperties () {
// Other.
// Other.
context
->
setContextProperty
(
"LinphoneCore"
,
LinphoneCore
::
getInstance
());
context
->
setContextProperty
(
"LinphoneCore"
,
LinphoneCore
::
getInstance
());
m_notifi
cation
=
new
Notification
();
m_notifi
er
=
new
Notifier
();
context
->
setContextProperty
(
"Notifi
cation"
,
m_notification
);
context
->
setContextProperty
(
"Notifi
er"
,
m_notifier
);
}
}
void
App
::
setTrayIcon
()
{
void
App
::
setTrayIcon
()
{
...
@@ -137,22 +133,3 @@ void App::setTrayIcon () {
...
@@ -137,22 +133,3 @@ void App::setTrayIcon () {
m_system_tray_icon
->
setToolTip
(
"Linphone"
);
m_system_tray_icon
->
setToolTip
(
"Linphone"
);
m_system_tray_icon
->
show
();
m_system_tray_icon
->
show
();
}
}
void
App
::
setNotificationAttributes
()
{
if
(
!
m_system_tray_icon
)
{
return
;
}
QDesktopWidget
*
desktop
=
QApplication
::
desktop
();
QRect
icon_rect
=
m_system_tray_icon
->
geometry
();
QRect
screen_rect
=
desktop
->
screenGeometry
();
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
;
m_notification
->
setEdge
(
edge
);
}
tests/src/app/App.hpp
View file @
4d91eb4a
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include <QSystemTrayIcon>
#include <QSystemTrayIcon>
#include <QTranslator>
#include <QTranslator>
#include "../components/notifi
cation/Notification
.hpp"
#include "../components/notifi
er/Notifier
.hpp"
// ===================================================================
// ===================================================================
...
@@ -37,14 +37,12 @@ private:
...
@@ -37,14 +37,12 @@ private:
void
addContextProperties
();
void
addContextProperties
();
void
setTrayIcon
();
void
setTrayIcon
();
void
setNotificationAttributes
();
QQmlApplicationEngine
m_engine
;
QQmlApplicationEngine
m_engine
;
QQmlFileSelector
*
m_file_selector
=
nullptr
;
QQmlFileSelector
*
m_file_selector
=
nullptr
;
QSystemTrayIcon
*
m_system_tray_icon
=
nullptr
;
QSystemTrayIcon
*
m_system_tray_icon
=
nullptr
;
QTranslator
m_translator
;
QTranslator
m_translator
;
Notifi
cation
*
m_notification
=
nullptr
;
Notifi
er
*
m_notifier
=
nullptr
;
static
App
*
m_instance
;
static
App
*
m_instance
;
};
};
...
...
tests/src/components/notifi
cation/Notification
.cpp
→
tests/src/components/notifi
er/Notifier
.cpp
View file @
4d91eb4a
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#include <QtDebug>
#include <QtDebug>
#include "../../app/App.hpp"
#include "../../app/App.hpp"
#include "Notifi
cation
.hpp"
#include "Notifi
er
.hpp"
#define NOTIFICATION_SHOW_METHOD_NAME "show"
#define NOTIFICATION_SHOW_METHOD_NAME "show"
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
// Helpers.
// Helpers.
inline
int
getNotificationSize
(
const
QObject
&
object
,
const
char
*
property
)
{
inline
int
getNotificationSize
(
const
QObject
&
object
,
const
char
*
property
)
{
QVariant
variant
=
object
.
property
(
property
);
QVariant
variant
(
object
.
property
(
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
);
...
@@ -44,17 +44,17 @@ bool setProperty (QObject &object, const char *property, const T &value) {
...
@@ -44,17 +44,17 @@ bool setProperty (QObject &object, const char *property, const T &value) {
// -------------------------------------------------------------------
// -------------------------------------------------------------------
Notifi
cation
::
Notification
(
QObject
*
parent
)
:
Notifi
er
::
Notifier
(
QObject
*
parent
)
:
QObject
(
parent
)
{
QObject
(
parent
)
{
QQmlEngine
*
engine
=
App
::
getInstance
()
->
getEngine
();
QQmlEngine
*
engine
=
App
::
getInstance
()
->
getEngine
();
// Build components.
// Build components.
m_components
[
Notifi
cation
::
Call
]
=
new
QQmlComponent
(
m_components
[
Notifi
er
::
Call
]
=
new
QQmlComponent
(
engine
,
QUrl
(
"qrc:/ui/modules/Linphone/Notifications/CallNotification.qml"
)
engine
,
QUrl
(
"qrc:/ui/modules/Linphone/Notifications/CallNotification.qml"
)
);
);
// Check errors.
// Check errors.
for
(
int
i
=
0
;
i
<
Notifi
cation
::
MaxNbTypes
;
i
++
)
{
for
(
int
i
=
0
;
i
<
Notifi
er
::
MaxNbTypes
;
i
++
)
{
QQmlComponent
&
component
=
*
m_components
[
i
];
QQmlComponent
&
component
=
*
m_components
[
i
];
if
(
component
.
isError
())
{
if
(
component
.
isError
())
{
qWarning
()
<<
"Errors found in `Notification` component "
qWarning
()
<<
"Errors found in `Notification` component "
...
@@ -64,14 +64,14 @@ Notification::Notification (QObject *parent) :
...
@@ -64,14 +64,14 @@ Notification::Notification (QObject *parent) :
}
}
}
}
Notifi
cation
::~
Notification
()
{
Notifi
er
::~
Notifier
()
{
for
(
int
i
=
0
;
i
<
Notifi
cation
::
MaxNbTypes
;
i
++
)
for
(
int
i
=
0
;
i
<
Notifi
er
::
MaxNbTypes
;
i
++
)
delete
m_components
[
i
];
delete
m_components
[
i
];
}
}
// -------------------------------------------------------------------
// -------------------------------------------------------------------
void
Notifi
cation
::
showCallMessage
(
void
Notifi
er
::
showCallMessage
(
int
timeout
,
int
timeout
,
const
QString
&
sip_address
const
QString
&
sip_address
)
{
)
{
...
@@ -88,12 +88,12 @@ void Notification::showCallMessage (
...
@@ -88,12 +88,12 @@ void Notification::showCallMessage (
}
}
// Create instance and set attributes.
// Create instance and set attributes.
QObject
*
object
=
m_components
[
Notifi
cation
::
Call
]
->
create
();
QObject
*
object
=
m_components
[
Notifi
er
::
Call
]
->
create
();
int
offset
=
getNotificationSize
(
*
object
,
NOTIFICATION_HEIGHT_PROPERTY
);
int
offset
=
getNotificationSize
(
*
object
,
NOTIFICATION_HEIGHT_PROPERTY
);
if
(
if
(
offset
==
-
1
||
offset
==
-
1
||
!::
setProperty
(
*
object
,
NOTIFICATION_EDGE_PROPERTY_NAME
,
m_e
dge
)
||
!::
setProperty
(
*
object
,
NOTIFICATION_EDGE_PROPERTY_NAME
,
Qt
::
TopEdge
|
Qt
::
RightE
dge
)
||
!::
setProperty
(
*
object
,
NOTIFICATION_OFFSET_PROPERTY_NAME
,
m_offset
)
!::
setProperty
(
*
object
,
NOTIFICATION_OFFSET_PROPERTY_NAME
,
m_offset
)
)
{
)
{
delete
object
;
delete
object
;
...
...
tests/src/components/notifi
cation/Notification
.hpp
→
tests/src/components/notifi
er/Notifier
.hpp
View file @
4d91eb4a
#ifndef NOTIFI
CATION
_H_
#ifndef NOTIFI
ER
_H_
#define NOTIFI
CATION
_H_
#define NOTIFI
ER
_H_
#include <QMutex>
#include <QMutex>
#include <QObject>
#include <QObject>
...
@@ -7,12 +7,12 @@
...
@@ -7,12 +7,12 @@
// ===================================================================
// ===================================================================
class
Notifi
cation
:
public
QObject
{
class
Notifi
er
:
public
QObject
{
Q_OBJECT
;
Q_OBJECT
;
public:
public:
Notifi
cation
(
QObject
*
parent
=
Q_NULLPTR
);
Notifi
er
(
QObject
*
parent
=
Q_NULLPTR
);
virtual
~
Notifi
cation
();
virtual
~
Notifi
er
();
enum
Type
{
enum
Type
{
Call
,
Call
,
...
@@ -20,15 +20,12 @@ public:
...
@@ -20,15 +20,12 @@ public:
};
};
Q_ENUM
(
Type
);
Q_ENUM
(
Type
);
void
setEdge
(
Qt
::
Edges
edge
)
{
m_edge
=
edge
;
}
public
slots
:
public
slots
:
void
showCallMessage
(
int
timeout
,
const
QString
&
sip_address
);
void
showCallMessage
(
int
timeout
,
const
QString
&
sip_address
);
private:
private:
Qt
::
Edges
m_edge
=
Qt
::
RightEdge
|
Qt
::
TopEdge
;
void
computePositions
();
QQmlComponent
*
m_components
[
MaxNbTypes
];
QQmlComponent
*
m_components
[
MaxNbTypes
];
int
m_offset
=
0
;
int
m_offset
=
0
;
...
@@ -36,4 +33,4 @@ private:
...
@@ -36,4 +33,4 @@ private:
QMutex
m_mutex
;
QMutex
m_mutex
;
};
};
#endif // NOTIFI
CATION
_H_
#endif // NOTIFI
ER
_H_
tests/ui/views/App/MainWindow/Contacts.qml
View file @
4d91eb4a
...
@@ -36,7 +36,7 @@ ColumnLayout {
...
@@ -36,7 +36,7 @@ ColumnLayout {
})
})
}
}
spacing
:
Notifi
cation
.
showCallMessage
(
5000
,
"
toto@toto.com
"
)
||
0
spacing
:
Notifi
er
.
showCallMessage
(
5000
,
"
toto@toto.com
"
)
||
0
// -----------------------------------------------------------------
// -----------------------------------------------------------------
// Search Bar & actions.
// 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