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
6a6d3752
Commit
6a6d3752
authored
Nov 15, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unstable
parent
69bb766e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
219 additions
and
31 deletions
+219
-31
resources.qrc
tests/resources.qrc
+1
-0
App.cpp
tests/src/app/App.cpp
+44
-10
App.hpp
tests/src/app/App.hpp
+28
-4
Notification.cpp
tests/src/components/notification/Notification.cpp
+99
-8
Notification.hpp
tests/src/components/notification/Notification.hpp
+27
-6
main.cpp
tests/src/main.cpp
+2
-2
DesktopPopup.qml
tests/ui/modules/Common/Popup/DesktopPopup.qml
+3
-0
CallNotification.qml
tests/ui/modules/Linphone/Notifications/CallNotification.qml
+11
-0
qmldir
tests/ui/modules/Linphone/qmldir
+3
-0
Contacts.qml
tests/ui/views/App/MainWindow/Contacts.qml
+1
-1
No files found.
tests/resources.qrc
View file @
6a6d3752
...
@@ -117,6 +117,7 @@
...
@@ -117,6 +117,7 @@
<file>
ui/modules/Linphone/Contact/Avatar.qml
</file>
<file>
ui/modules/Linphone/Contact/Avatar.qml
</file>
<file>
ui/modules/Linphone/Contact/ContactDescription.qml
</file>
<file>
ui/modules/Linphone/Contact/ContactDescription.qml
</file>
<file>
ui/modules/Linphone/Contact/Contact.qml
</file>
<file>
ui/modules/Linphone/Contact/Contact.qml
</file>
<file>
ui/modules/Linphone/Notifications/CallNotification.qml
</file>
<file>
ui/modules/Linphone/Presence/PresenceLevel.qml
</file>
<file>
ui/modules/Linphone/Presence/PresenceLevel.qml
</file>
<file>
ui/modules/Linphone/Presence/PresenceString.qml
</file>
<file>
ui/modules/Linphone/Presence/PresenceString.qml
</file>
<file>
ui/modules/Linphone/qmldir
</file>
<file>
ui/modules/Linphone/qmldir
</file>
...
...
tests/src/app/App.cpp
View file @
6a6d3752
#include <QDesktopWidget>
#include <QMenu>
#include <QMenu>
#include <QQmlComponent>
#include <QQmlComponent>
#include <QQmlContext>
#include <QQmlContext>
...
@@ -6,7 +7,6 @@
...
@@ -6,7 +7,6 @@
#include "../components/contacts/ContactsListProxyModel.hpp"
#include "../components/contacts/ContactsListProxyModel.hpp"
#include "../components/linphone/LinphoneCore.hpp"
#include "../components/linphone/LinphoneCore.hpp"
#include "../components/notification/Notification.hpp"
#include "../components/settings/AccountSettingsModel.hpp"
#include "../components/settings/AccountSettingsModel.hpp"
#include "../components/timeline/TimelineModel.hpp"
#include "../components/timeline/TimelineModel.hpp"
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
// ===================================================================
// ===================================================================
App
*
App
::
m_instance
=
nullptr
;
App
::
App
(
int
&
argc
,
char
**
argv
)
:
QApplication
(
argc
,
argv
)
{
App
::
App
(
int
&
argc
,
char
**
argv
)
:
QApplication
(
argc
,
argv
)
{
// Try to use default locale. Otherwise use english.
// Try to use default locale. Otherwise use english.
if
(
m_translator
.
load
(
QString
(
LANGUAGES_PATH
)
+
QLocale
::
system
().
name
())
||
if
(
m_translator
.
load
(
QString
(
LANGUAGES_PATH
)
+
QLocale
::
system
().
name
())
||
...
@@ -36,7 +38,11 @@ App::App (int &argc, char **argv) : QApplication(argc, argv) {
...
@@ -36,7 +38,11 @@ App::App (int &argc, char **argv) : QApplication(argc, argv) {
m_engine
.
addImportPath
(
":/ui/modules"
);
m_engine
.
addImportPath
(
":/ui/modules"
);
m_engine
.
addImportPath
(
":/ui/scripts"
);
m_engine
.
addImportPath
(
":/ui/scripts"
);
m_engine
.
addImportPath
(
":/ui/views"
);
m_engine
.
addImportPath
(
":/ui/views"
);
}
// -------------------------------------------------------------------
void
App
::
initContentApp
()
{
// Register types and load context properties.
// Register types and load context properties.
registerTypes
();
registerTypes
();
addContextProperties
();
addContextProperties
();
...
@@ -51,9 +57,10 @@ App::App (int &argc, char **argv) : QApplication(argc, argv) {
...
@@ -51,9 +57,10 @@ App::App (int &argc, char **argv) : QApplication(argc, argv) {
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
()
{
qmlRegisterUncreatableType
<
Presence
>
(
qmlRegisterUncreatableType
<
Presence
>
(
...
@@ -92,13 +99,16 @@ void App::addContextProperties () {
...
@@ -92,13 +99,16 @@ void App::addContextProperties () {
// Other.
// Other.
context
->
setContextProperty
(
"LinphoneCore"
,
LinphoneCore
::
getInstance
());
context
->
setContextProperty
(
"LinphoneCore"
,
LinphoneCore
::
getInstance
());
context
->
setContextProperty
(
"Notification"
,
new
Notification
());
m_notification
=
new
Notification
();
context
->
setContextProperty
(
"Notification"
,
m_notification
);
}
}
void
App
::
setTrayIcon
()
{
void
App
::
setTrayIcon
()
{
QQuickWindow
*
root
=
qobject_cast
<
QQuickWindow
*>
(
m_engine
.
rootObjects
().
at
(
0
));
QQuickWindow
*
root
=
qobject_cast
<
QQuickWindow
*>
(
m_engine
.
rootObjects
().
at
(
0
));
QMenu
*
menu
=
new
QMenu
();
QMenu
*
menu
=
new
QMenu
();
m_tray_icon
=
new
QSystemTrayIcon
(
root
);
m_system_tray_icon
=
new
QSystemTrayIcon
(
root
);
// trayIcon: Right click actions.
// trayIcon: Right click actions.
QAction
*
quit_action
=
new
QAction
(
"Quit"
,
root
);
QAction
*
quit_action
=
new
QAction
(
"Quit"
,
root
);
...
@@ -108,7 +118,7 @@ void App::setTrayIcon () {
...
@@ -108,7 +118,7 @@ void App::setTrayIcon () {
root
->
connect
(
restore_action
,
&
QAction
::
triggered
,
root
,
&
QQuickWindow
::
showNormal
);
root
->
connect
(
restore_action
,
&
QAction
::
triggered
,
root
,
&
QQuickWindow
::
showNormal
);
// trayIcon: Left click actions.
// trayIcon: Left click actions.
root
->
connect
(
m_tray_icon
,
&
QSystemTrayIcon
::
activated
,
[
root
](
QSystemTrayIcon
::
ActivationReason
reason
)
{
root
->
connect
(
m_
system_
tray_icon
,
&
QSystemTrayIcon
::
activated
,
[
root
](
QSystemTrayIcon
::
ActivationReason
reason
)
{
if
(
reason
==
QSystemTrayIcon
::
Trigger
)
{
if
(
reason
==
QSystemTrayIcon
::
Trigger
)
{
if
(
root
->
visibility
()
==
QWindow
::
Hidden
)
if
(
root
->
visibility
()
==
QWindow
::
Hidden
)
root
->
showNormal
();
root
->
showNormal
();
...
@@ -122,8 +132,32 @@ void App::setTrayIcon () {
...
@@ -122,8 +132,32 @@ void App::setTrayIcon () {
menu
->
addSeparator
();
menu
->
addSeparator
();
menu
->
addAction
(
quit_action
);
menu
->
addAction
(
quit_action
);
m_tray_icon
->
setContextMenu
(
menu
);
m_system_tray_icon
->
setContextMenu
(
menu
);
m_tray_icon
->
setIcon
(
QIcon
(
WINDOW_ICON_PATH
));
m_system_tray_icon
->
setIcon
(
QIcon
(
WINDOW_ICON_PATH
));
m_tray_icon
->
setToolTip
(
"Linphone"
);
m_system_tray_icon
->
setToolTip
(
"Linphone"
);
m_tray_icon
->
show
();
m_system_tray_icon
->
show
();
}
void
App
::
setNotificationAttributes
()
{
QDesktopWidget
*
desktop
=
QApplication
::
desktop
();
// 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
();
QRect
screen_rect
=
desktop
->
screenGeometry
(
primary_screen
);
int
x
=
icon_rect
.
x
()
+
icon_rect
.
width
()
/
2
;
int
y
=
icon_rect
.
y
()
+
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
);
}
m_notification
->
setScreenNumber
(
primary_screen
);
}
}
tests/src/app/App.hpp
View file @
6a6d3752
...
@@ -7,22 +7,46 @@
...
@@ -7,22 +7,46 @@
#include <QSystemTrayIcon>
#include <QSystemTrayIcon>
#include <QTranslator>
#include <QTranslator>
#include "../components/notification/Notification.hpp"
// ===================================================================
// ===================================================================
class
App
:
public
QApplication
{
class
App
:
public
QApplication
{
public:
public:
App
(
int
&
argc
,
char
**
argv
);
static
void
init
(
int
&
argc
,
char
**
argv
)
{
virtual
~
App
()
{}
if
(
!
m_instance
)
{
m_instance
=
new
App
(
argc
,
argv
);
m_instance
->
initContentApp
();
}
}
static
App
*
getInstance
()
{
return
m_instance
;
}
QQmlEngine
*
getEngine
()
{
return
&
m_engine
;
}
private:
private:
App
(
int
&
argc
,
char
**
argv
);
void
initContentApp
();
void
registerTypes
();
void
registerTypes
();
void
addContextProperties
();
void
addContextProperties
();
void
setTrayIcon
();
void
setTrayIcon
();
void
setNotificationAttributes
();
QQmlApplicationEngine
m_engine
;
QQmlApplicationEngine
m_engine
;
QQmlFileSelector
*
m_file_selector
;
QQmlFileSelector
*
m_file_selector
=
nullptr
;
QSystemTrayIcon
*
m_
tray_icon
;
QSystemTrayIcon
*
m_
system_tray_icon
=
nullptr
;
QTranslator
m_translator
;
QTranslator
m_translator
;
Notification
*
m_notification
=
nullptr
;
static
App
*
m_instance
;
};
};
#endif // APP_H_
#endif // APP_H_
tests/src/components/notification/Notification.cpp
View file @
6a6d3752
#include <QDesktopWidget>
#include <QTimer>
#include <QtDebug>
#include <QtDebug>
#include "../../app/App.hpp"
#include "Notification.hpp"
#include "Notification.hpp"
#define NOTIFICATION_X_PROPERTY "popupX"
#define NOTIFICATION_Y_PROPERTY "popupY"
#define NOTIFICATION_HEIGHT_PROPERTY "popupHeight"
#define NOTIFICATION_WIDTH_PROPERTY "popupWidth"
#define NOTIFICATION_SHOW_METHOD_NAME "show"
#define N_MAX_NOTIFICATIONS 3
// ===================================================================
// ===================================================================
Notification
::
Notification
(
QObject
*
parent
)
:
Notification
::
Notification
(
QObject
*
parent
)
:
QObject
(
parent
)
{
QObject
(
parent
)
{
QQmlEngine
*
engine
=
App
::
getInstance
()
->
getEngine
();
// Build components.
m_components
[
Notification
::
Call
]
=
new
QQmlComponent
(
engine
,
QUrl
(
"qrc:/ui/modules/Linphone/Notifications/CallNotification.qml"
)
);
// Check errors.
for
(
int
i
=
0
;
i
<
Notification
::
MaxNbTypes
;
i
++
)
{
QQmlComponent
&
component
=
*
m_components
[
i
];
if
(
component
.
isError
())
{
qWarning
()
<<
"Errors found in `Notification` component "
<<
i
<<
":"
<<
component
.
errors
();
abort
();
}
}
}
Notification
::~
Notification
()
{
for
(
int
i
=
0
;
i
<
Notification
::
MaxNbTypes
;
i
++
)
delete
m_components
[
i
];
}
}
void
Notification
::
showMessage
(
// -------------------------------------------------------------------
const
QString
&
summary
,
const
QString
&
body
,
inline
int
getNotificationSize
(
const
QObject
&
object
,
const
char
*
size_property
)
{
const
QString
&
icon
,
QVariant
variant
=
object
.
property
(
size_property
);
int
timeout
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
setNotificationPosition
(
QObject
&
object
,
const
char
*
position_property
,
int
value
)
{
)
{
qDebug
()
<<
QVariant
position
(
value
);
"Notification.showMessage("
<<
summary
<<
", "
<<
body
<<
", "
<<
icon
<<
", "
<<
timeout
<<
")"
;
if
(
!
object
.
setProperty
(
position_property
,
position
))
{
qWarning
()
<<
"Unable to set notification position."
;
return
false
;
}
return
true
;
}
void
Notification
::
showCallMessage
(
int
timeout
,
const
QString
&
sip_address
)
{
qDebug
()
<<
"Show call notification message. (addr="
<<
sip_address
<<
")"
;
QObject
*
object
=
m_components
[
Notification
::
Call
]
->
create
();
int
width
,
height
;
if
(
(
width
=
getNotificationSize
(
*
object
,
NOTIFICATION_WIDTH_PROPERTY
))
==
-
1
||
(
height
=
getNotificationSize
(
*
object
,
NOTIFICATION_HEIGHT_PROPERTY
))
==
-
1
)
{
delete
object
;
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
);
QTimer
::
singleShot
(
timeout
,
object
,
[
object
]()
{
delete
object
;
});
}
}
tests/src/components/notification/Notification.hpp
View file @
6a6d3752
#ifndef NOTIFICATION_H_
#ifndef NOTIFICATION_H_
#define NOTIFICATION_H_
#define NOTIFICATION_H_
#include <QMutex>
#include <QObject>
#include <QObject>
#include <QQmlComponent>
// ===================================================================
// ===================================================================
...
@@ -10,14 +12,33 @@ class Notification : public QObject {
...
@@ -10,14 +12,33 @@ class Notification : public QObject {
public:
public:
Notification
(
QObject
*
parent
=
Q_NULLPTR
);
Notification
(
QObject
*
parent
=
Q_NULLPTR
);
virtual
~
Notification
();
enum
Type
{
Call
,
MaxNbTypes
};
Q_ENUM
(
Type
);
void
setEdge
(
Qt
::
Edges
edge
)
{
m_edge
=
edge
;
}
void
setScreenNumber
(
int
screen_number
)
{
m_screen_number
=
screen_number
;
}
public
slots
:
public
slots
:
void
showMessage
(
void
showCallMessage
(
int
timeout
,
const
QString
&
sip_address
);
const
QString
&
summary
,
const
QString
&
body
,
private:
const
QString
&
icon
=
""
,
Qt
::
Edges
m_edge
=
Qt
::
RightEdge
|
Qt
::
TopEdge
;
int
timeout
=
10000
QQmlComponent
*
m_components
[
MaxNbTypes
];
);
int
m_screen_number
=
0
;
int
m_n_instances
=
0
;
QMutex
m_mutex
;
};
};
#endif // NOTIFICATION_H_
#endif // NOTIFICATION_H_
tests/src/main.cpp
View file @
6a6d3752
...
@@ -7,8 +7,8 @@ int main (int argc, char *argv[]) {
...
@@ -7,8 +7,8 @@ int main (int argc, char *argv[]) {
qInstallMessageHandler
(
qmlLogger
);
qInstallMessageHandler
(
qmlLogger
);
QGuiApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
);
QGuiApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
);
App
app
(
argc
,
argv
);
App
::
init
(
argc
,
argv
);
// Run!
// Run!
return
app
.
exec
();
return
App
::
getInstance
()
->
exec
();
}
}
tests/ui/modules/Common/Popup/DesktopPopup.qml
View file @
6a6d3752
...
@@ -11,6 +11,9 @@ Item {
...
@@ -11,6 +11,9 @@ Item {
property
alias
popupX
:
popup
.
x
property
alias
popupX
:
popup
.
x
property
alias
popupY
:
popup
.
y
property
alias
popupY
:
popup
.
y
readonly
property
alias
popupWidth
:
popup
.
width
readonly
property
alias
popupHeight
:
popup
.
height
default
property
alias
_content
:
content
.
data
default
property
alias
_content
:
content
.
data
property
bool
_isOpen
:
false
property
bool
_isOpen
:
false
...
...
tests/ui/modules/Linphone/Notifications/CallNotification.qml
0 → 100644
View file @
6a6d3752
import
QtQuick
2.7
import
Common
1.0
DesktopPopup
{
Rectangle
{
color
:
'
red
'
width
:
200
height
:
100
}
}
tests/ui/modules/Linphone/qmldir
View file @
6a6d3752
...
@@ -20,6 +20,9 @@ Avatar 1.0 Contact/Avatar.qml
...
@@ -20,6 +20,9 @@ Avatar 1.0 Contact/Avatar.qml
Contact 1.0 Contact/Contact.qml
Contact 1.0 Contact/Contact.qml
ContactDescription 1.0 Contact/ContactDescription.qml
ContactDescription 1.0 Contact/ContactDescription.qml
# Notifications
CallNotification 1.0 Notifications/CallNotification.qml
# Presence
# Presence
PresenceLevel 1.0 Presence/PresenceLevel.qml
PresenceLevel 1.0 Presence/PresenceLevel.qml
PresenceString 1.0 Presence/PresenceString.qml
PresenceString 1.0 Presence/PresenceString.qml
...
...
tests/ui/views/App/MainWindow/Contacts.qml
View file @
6a6d3752
...
@@ -36,7 +36,7 @@ ColumnLayout {
...
@@ -36,7 +36,7 @@ ColumnLayout {
})
})
}
}
spacing
:
0
spacing
:
Notification
.
showCallMessage
(
10000
,
"
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