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
93c4aeea
Commit
93c4aeea
authored
Sep 19, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app): close main window reduce app in notifications area
parent
be082fa2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
21 deletions
+29
-21
linphone.pro
tests/linphone.pro
+1
-0
main.cpp
tests/src/main.cpp
+28
-21
No files found.
tests/linphone.pro
View file @
93c4aeea
...
@@ -2,6 +2,7 @@ QT = core gui quick widgets quickcontrols2
...
@@ -2,6 +2,7 @@ QT = core gui quick widgets quickcontrols2
TARGET
=
linphone
TARGET
=
linphone
TEMPLATE
=
app
TEMPLATE
=
app
CONFIG
+=
c
++
11
SOURCES
=
\
SOURCES
=
\
src
/
app
.
cpp
\
src
/
app
.
cpp
\
...
...
tests/src/main.cpp
View file @
93c4aeea
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include <QMenu>
#include <QMenu>
#include <QQmlApplicationEngine>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QSystemTrayIcon>
#include <QSystemTrayIcon>
#include <QtDebug>
#include <QtDebug>
...
@@ -9,26 +10,37 @@
...
@@ -9,26 +10,37 @@
// ===================================================================
// ===================================================================
void
createSystemTrayIcon
(
QQmlApplicationEngine
&
engine
)
{
int
exec
(
App
&
app
,
QQmlApplicationEngine
&
engine
)
{
QObject
*
root
=
engine
.
rootObjects
().
at
(
0
);
if
(
!
QSystemTrayIcon
::
isSystemTrayAvailable
())
QMenu
*
menu
=
new
QMenu
();
qWarning
()
<<
"System tray not found on this system."
;
QSystemTrayIcon
*
tray_icon
=
new
QSystemTrayIcon
(
root
);
else
{
QQuickWindow
*
root
=
qobject_cast
<
QQuickWindow
*>
(
engine
.
rootObjects
().
at
(
0
));
QMenu
*
menu
=
new
QMenu
();
QSystemTrayIcon
*
tray_icon
=
new
QSystemTrayIcon
(
root
);
QAction
*
quitAction
=
new
QAction
(
QObject
::
tr
(
"Quit"
),
root
);
// Right click actions.
root
->
connect
(
quitAction
,
&
QAction
::
triggered
,
qApp
,
&
QCoreApplication
::
quit
);
QAction
*
quitAction
=
new
QAction
(
QObject
::
tr
(
"Quit"
),
root
);
root
->
connect
(
quitAction
,
&
QAction
::
triggered
,
qApp
,
&
QCoreApplication
::
quit
);
QAction
*
restoreAction
=
new
QAction
(
QObject
::
tr
(
"Restore"
),
root
);
QAction
*
restoreAction
=
new
QAction
(
QObject
::
tr
(
"Restore"
),
root
);
root
->
connect
(
restoreAction
,
SIGNAL
(
triggered
()),
root
,
SLOT
(
showNormal
())
);
root
->
connect
(
restoreAction
,
&
QAction
::
triggered
,
root
,
&
QQuickWindow
::
showNormal
);
menu
->
addAction
(
restoreAction
);
// Left click action.
menu
->
addSeparator
();
root
->
connect
(
tray_icon
,
&
QSystemTrayIcon
::
activated
,
[
&
root
](
QSystemTrayIcon
::
ActivationReason
reason
)
{
menu
->
addAction
(
quitAction
);
if
(
reason
==
QSystemTrayIcon
::
DoubleClick
)
root
->
showNormal
();
});
tray_icon
->
setContextMenu
(
menu
);
menu
->
addAction
(
restoreAction
);
tray_icon
->
setIcon
(
QIcon
(
":/imgs/linphone.png"
)
);
menu
->
addSeparator
(
);
tray_icon
->
show
(
);
menu
->
addAction
(
quitAction
);
return
;
tray_icon
->
setContextMenu
(
menu
);
tray_icon
->
setIcon
(
QIcon
(
":/imgs/linphone.png"
));
tray_icon
->
show
();
}
return
app
.
exec
();
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
...
@@ -38,10 +50,5 @@ int main (int argc, char *argv[]) {
...
@@ -38,10 +50,5 @@ int main (int argc, char *argv[]) {
if
(
engine
.
rootObjects
().
isEmpty
())
if
(
engine
.
rootObjects
().
isEmpty
())
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
if
(
!
QSystemTrayIcon
::
isSystemTrayAvailable
())
return
exec
(
app
,
engine
);
qWarning
()
<<
"System tray not found on this system."
;
else
createSystemTrayIcon
(
engine
);
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