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
64e3c942
Commit
64e3c942
authored
Sep 20, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(main): better code
parent
92c948a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
16 deletions
+15
-16
app.cpp
tests/src/app.cpp
+1
-0
app.hpp
tests/src/app.hpp
+0
-3
main.cpp
tests/src/main.cpp
+14
-13
No files found.
tests/src/app.cpp
View file @
64e3c942
...
...
@@ -2,6 +2,7 @@
#include <QIcon>
#include <QtDebug>
#include "app.hpp"
#define LANGUAGES_PATH ":/languages/"
...
...
tests/src/app.hpp
View file @
64e3c942
...
...
@@ -4,14 +4,11 @@
#include <QApplication>
#include <QTranslator>
// TODO: Make it Singleton.
class
App
:
public
QApplication
{
public:
App
(
int
&
argc
,
char
**
argv
);
virtual
~
App
()
{}
private
slots
:
private:
QTranslator
m_translator
;
};
...
...
tests/src/main.cpp
View file @
64e3c942
...
...
@@ -12,10 +12,7 @@
// ===================================================================
int
exec
(
App
&
app
,
QQmlApplicationEngine
&
engine
)
{
if
(
!
QSystemTrayIcon
::
isSystemTrayAvailable
())
qWarning
()
<<
"System tray not found on this system."
;
void
setTrayIcon
(
QQmlApplicationEngine
&
engine
)
{
QQuickWindow
*
root
=
qobject_cast
<
QQuickWindow
*>
(
engine
.
rootObjects
().
at
(
0
));
QMenu
*
menu
=
new
QMenu
();
QSystemTrayIcon
*
tray_icon
=
new
QSystemTrayIcon
(
root
);
...
...
@@ -28,7 +25,7 @@ int exec (App &app, QQmlApplicationEngine &engine) {
root
->
connect
(
restore_action
,
&
QAction
::
triggered
,
root
,
&
QQuickWindow
::
showNormal
);
// trayIcon: Left click actions.
root
->
connect
(
tray_icon
,
&
QSystemTrayIcon
::
activated
,
[
&
root
](
QSystemTrayIcon
::
ActivationReason
reason
)
{
root
->
connect
(
tray_icon
,
&
QSystemTrayIcon
::
activated
,
[
root
](
QSystemTrayIcon
::
ActivationReason
reason
)
{
if
(
reason
==
QSystemTrayIcon
::
Trigger
)
{
if
(
root
->
visibility
()
==
QWindow
::
Hidden
)
root
->
showNormal
();
...
...
@@ -46,13 +43,6 @@ int exec (App &app, QQmlApplicationEngine &engine) {
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
();
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -62,5 +52,16 @@ int main (int argc, char *argv[]) {
if
(
engine
.
rootObjects
().
isEmpty
())
return
EXIT_FAILURE
;
return
exec
(
app
,
engine
);
// Enable TrayIconSystem.
if
(
!
QSystemTrayIcon
::
isSystemTrayAvailable
())
qWarning
()
<<
"System tray not found on this system."
;
else
setTrayIcon
(
engine
);
// Warning: Add global context Notification for all views!
NotificationModel
notification
;
engine
.
rootContext
()
->
setContextProperty
(
"Notification"
,
&
notification
);
// Run!
return
app
.
exec
();
}
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