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
92c948a2
Commit
92c948a2
authored
Sep 20, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app): `Notification` component is exposed globally in qml
parent
bd7a4a2b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
10 deletions
+57
-10
linphone.pro
tests/linphone.pro
+3
-1
main.cpp
tests/src/main.cpp
+11
-9
NotificationModel.cpp
tests/src/models/notification/NotificationModel.cpp
+20
-0
NotificationModel.hpp
tests/src/models/notification/NotificationModel.hpp
+23
-0
No files found.
tests/linphone.pro
View file @
92c948a2
...
...
@@ -7,11 +7,13 @@ CONFIG += c++11
SOURCES
=
\
src
/
app
.
cpp
\
src
/
main
.
cpp
\
src
/
models
/
notification
/
NotificationModel
.
cpp
\
src
/
models
/
settings
/
AccountSettingsModel
.
cpp
\
src
/
models
/
settings
/
SettingsModel
.
cpp
HEADERS
=
\
src
/
app
.
hpp
\
src
/
app
.
hpp
\
src
/
models
/
notification
/
NotificationModel
.
hpp
\
src
/
models
/
settings
/
AccountSettingsModel
.
hpp
\
src
/
models
/
settings
/
SettingsModel
.
hpp
...
...
tests/src/main.cpp
View file @
92c948a2
...
...
@@ -8,6 +8,7 @@
#include <QtDebug>
#include "app.hpp"
#include "models/notification/NotificationModel.hpp"
// ===================================================================
...
...
@@ -19,15 +20,12 @@ int exec (App &app, QQmlApplicationEngine &engine) {
QMenu
*
menu
=
new
QMenu
();
QSystemTrayIcon
*
tray_icon
=
new
QSystemTrayIcon
(
root
);
// Warning: Add global context trayIcon for all views!
engine
.
rootContext
()
->
setContextProperty
(
"trayIcon"
,
tray_icon
);
// trayIcon: Right click actions.
QAction
*
quit
Action
=
new
QAction
(
QObject
::
tr
(
"Quit"
)
,
root
);
root
->
connect
(
quit
A
ction
,
&
QAction
::
triggered
,
qApp
,
&
QCoreApplication
::
quit
);
QAction
*
quit
_action
=
new
QAction
(
"Quit"
,
root
);
root
->
connect
(
quit
_a
ction
,
&
QAction
::
triggered
,
qApp
,
&
QCoreApplication
::
quit
);
QAction
*
restore
Action
=
new
QAction
(
QObject
::
tr
(
"Restore"
)
,
root
);
root
->
connect
(
restore
A
ction
,
&
QAction
::
triggered
,
root
,
&
QQuickWindow
::
showNormal
);
QAction
*
restore
_action
=
new
QAction
(
"Restore"
,
root
);
root
->
connect
(
restore
_a
ction
,
&
QAction
::
triggered
,
root
,
&
QQuickWindow
::
showNormal
);
// trayIcon: Left click actions.
root
->
connect
(
tray_icon
,
&
QSystemTrayIcon
::
activated
,
[
&
root
](
QSystemTrayIcon
::
ActivationReason
reason
)
{
...
...
@@ -40,15 +38,19 @@ int exec (App &app, QQmlApplicationEngine &engine) {
});
// Build trayIcon menu.
menu
->
addAction
(
restore
A
ction
);
menu
->
addAction
(
restore
_a
ction
);
menu
->
addSeparator
();
menu
->
addAction
(
quit
A
ction
);
menu
->
addAction
(
quit
_a
ction
);
tray_icon
->
setContextMenu
(
menu
);
tray_icon
->
setIcon
(
QIcon
(
":/imgs/linphone.png"
));
tray_icon
->
setToolTip
(
"Linphone"
);
tray_icon
->
show
();
// Warning: Add global context Notification for all views!
NotificationModel
notification
;
engine
.
rootContext
()
->
setContextProperty
(
"Notification"
,
&
notification
);
// Run.
return
app
.
exec
();
}
...
...
tests/src/models/notification/NotificationModel.cpp
0 → 100644
View file @
92c948a2
#include <QtDebug>
#include "NotificationModel.hpp"
// ===================================================================
NotificationModel
::
NotificationModel
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
void
NotificationModel
::
showMessage
(
const
QString
&
summary
,
const
QString
&
body
,
const
QString
&
icon
,
int
timeout
)
{
qDebug
()
<<
"Notification.showMessage("
<<
summary
<<
", "
<<
body
<<
", "
<<
icon
<<
", "
<<
timeout
<<
")"
;
}
tests/src/models/notification/NotificationModel.hpp
0 → 100644
View file @
92c948a2
#ifndef NOTIFICATION_MODEL_H_
#define NOTIFICATION_MODEL_H_
#include <QObject>
// ===================================================================
class
NotificationModel
:
public
QObject
{
Q_OBJECT
public:
NotificationModel
(
QObject
*
parent
=
Q_NULLPTR
);
public
slots
:
void
showMessage
(
const
QString
&
summary
,
const
QString
&
body
,
const
QString
&
icon
=
""
,
int
timeout
=
10000
);
};
#endif // NOTIFICATION_MODEL_H_
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