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
c8e57bc7
Commit
c8e57bc7
authored
Mar 22, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(src/app/App): create calls/settings windows only when it's requested
parent
3de09416
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
43 deletions
+39
-43
App.cpp
linphone-desktop/src/app/App.cpp
+37
-40
App.hpp
linphone-desktop/src/app/App.hpp
+2
-3
No files found.
linphone-desktop/src/app/App.cpp
View file @
c8e57bc7
...
@@ -156,9 +156,6 @@ void App::initContentApp () {
...
@@ -156,9 +156,6 @@ void App::initContentApp () {
core
->
setParent
(
this
);
core
->
setParent
(
this
);
}
}
// Create sub windows.
createSubWindows
();
// Load main view.
// Load main view.
qInfo
()
<<
"Loading main view..."
;
qInfo
()
<<
"Loading main view..."
;
m_engine
.
load
(
QUrl
(
QML_VIEW_MAIN_WINDOW
));
m_engine
.
load
(
QUrl
(
QML_VIEW_MAIN_WINDOW
));
...
@@ -216,7 +213,27 @@ void App::parseArgs () {
...
@@ -216,7 +213,27 @@ void App::parseArgs () {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
QQuickWindow
*
App
::
getCallsWindow
()
const
{
inline
QQuickWindow
*
createSubWindow
(
App
*
app
,
const
char
*
path
)
{
QQmlEngine
*
engine
=
app
->
getEngine
();
QQmlComponent
component
(
engine
,
QUrl
(
path
));
if
(
component
.
isError
())
{
qWarning
()
<<
component
.
errors
();
abort
();
}
QQuickWindow
*
window
=
qobject_cast
<
QQuickWindow
*>
(
component
.
create
());
QQmlEngine
::
setObjectOwnership
(
window
,
QQmlEngine
::
CppOwnership
);
return
window
;
}
// -----------------------------------------------------------------------------
QQuickWindow
*
App
::
getCallsWindow
()
{
if
(
!
m_calls_window
)
m_calls_window
=
createSubWindow
(
this
,
QML_VIEW_CALLS_WINDOW
);
return
m_calls_window
;
return
m_calls_window
;
}
}
...
@@ -225,14 +242,28 @@ QQuickWindow *App::getMainWindow () const {
...
@@ -225,14 +242,28 @@ QQuickWindow *App::getMainWindow () const {
return
qobject_cast
<
QQuickWindow
*>
(
engine
.
rootObjects
().
at
(
0
));
return
qobject_cast
<
QQuickWindow
*>
(
engine
.
rootObjects
().
at
(
0
));
}
}
QQuickWindow
*
App
::
getSettingsWindow
()
const
{
QQuickWindow
*
App
::
getSettingsWindow
()
{
if
(
!
m_settings_window
)
{
m_settings_window
=
createSubWindow
(
this
,
QML_VIEW_SETTINGS_WINDOW
);
QObject
::
connect
(
m_settings_window
,
&
QWindow
::
visibilityChanged
,
this
,
[](
QWindow
::
Visibility
visibility
)
{
if
(
visibility
==
QWindow
::
Hidden
)
{
qInfo
()
<<
"Update nat policy."
;
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
core
->
setNatPolicy
(
core
->
getNatPolicy
());
}
}
);
}
return
m_settings_window
;
return
m_settings_window
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
bool
App
::
hasFocus
()
const
{
bool
App
::
hasFocus
()
const
{
return
getMainWindow
()
->
isActive
()
||
m_calls_window
->
isActive
(
);
return
getMainWindow
()
->
isActive
()
||
(
m_calls_window
&&
m_calls_window
->
isActive
()
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -334,40 +365,6 @@ void App::registerTypes () {
...
@@ -334,40 +365,6 @@ void App::registerTypes () {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
inline
QQuickWindow
*
createSubWindow
(
App
*
app
,
const
char
*
path
)
{
QQmlEngine
*
engine
=
app
->
getEngine
();
QQmlComponent
component
(
engine
,
QUrl
(
path
));
if
(
component
.
isError
())
{
qWarning
()
<<
component
.
errors
();
abort
();
}
QQuickWindow
*
window
=
qobject_cast
<
QQuickWindow
*>
(
component
.
create
());
QQmlEngine
::
setObjectOwnership
(
window
,
QQmlEngine
::
CppOwnership
);
return
window
;
}
void
App
::
createSubWindows
()
{
qInfo
()
<<
"Create sub windows..."
;
m_calls_window
=
createSubWindow
(
this
,
QML_VIEW_CALLS_WINDOW
);
m_settings_window
=
createSubWindow
(
this
,
QML_VIEW_SETTINGS_WINDOW
);
QObject
::
connect
(
m_settings_window
,
&
QWindow
::
visibilityChanged
,
this
,
[](
QWindow
::
Visibility
visibility
)
{
if
(
visibility
==
QWindow
::
Hidden
)
{
qInfo
()
<<
"Update nat policy."
;
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
core
->
setNatPolicy
(
core
->
getNatPolicy
());
}
}
);
}
// -----------------------------------------------------------------------------
void
App
::
setTrayIcon
()
{
void
App
::
setTrayIcon
()
{
QQuickWindow
*
root
=
getMainWindow
();
QQuickWindow
*
root
=
getMainWindow
();
QMenu
*
menu
=
new
QMenu
();
QMenu
*
menu
=
new
QMenu
();
...
...
linphone-desktop/src/app/App.hpp
View file @
c8e57bc7
...
@@ -57,12 +57,12 @@ public:
...
@@ -57,12 +57,12 @@ public:
return
m_notifier
;
return
m_notifier
;
}
}
QQuickWindow
*
getCallsWindow
()
const
;
QQuickWindow
*
getCallsWindow
();
QQuickWindow
*
getMainWindow
()
const
;
QQuickWindow
*
getMainWindow
()
const
;
bool
hasFocus
()
const
;
bool
hasFocus
()
const
;
Q_INVOKABLE
QQuickWindow
*
getSettingsWindow
()
const
;
Q_INVOKABLE
QQuickWindow
*
getSettingsWindow
();
static
App
*
getInstance
()
{
static
App
*
getInstance
()
{
return
static_cast
<
App
*>
(
QApplication
::
instance
());
return
static_cast
<
App
*>
(
QApplication
::
instance
());
...
@@ -76,7 +76,6 @@ signals:
...
@@ -76,7 +76,6 @@ signals:
private:
private:
void
registerTypes
();
void
registerTypes
();
void
createSubWindows
();
void
setTrayIcon
();
void
setTrayIcon
();
QString
getConfigLocale
()
const
;
QString
getConfigLocale
()
const
;
...
...
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