Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-qt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-qt
Commits
f808d426
Commit
f808d426
authored
2 years ago
by
Andreas Traczyk
Committed by
Sébastien Blin
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
misc: move viewmanager into a separate file
Change-Id: Id5659ede0fc870926b4b627a5bbe12c67d4f9224
parent
759e3ea3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/MainApplicationWindow.qml
+2
-0
2 additions, 0 deletions
src/app/MainApplicationWindow.qml
src/app/ViewCoordinator.qml
+2
-70
2 additions, 70 deletions
src/app/ViewCoordinator.qml
src/app/ViewManager.qml
+87
-0
87 additions, 0 deletions
src/app/ViewManager.qml
with
91 additions
and
70 deletions
src/app/MainApplicationWindow.qml
+
2
−
0
View file @
f808d426
...
...
@@ -51,6 +51,7 @@ ApplicationWindow {
property
LayoutManager
layoutManager
:
LayoutManager
{
appContainer
:
appContainer
}
property
ViewManager
viewManager
:
ViewManager
{}
property
ViewCoordinator
viewCoordinator
:
ViewCoordinator
{
resources
:
{
"
WelcomePage
"
:
"
mainview/components/WelcomePage.qml
"
,
...
...
@@ -60,6 +61,7 @@ ApplicationWindow {
"
WizardView
"
:
"
wizardview/WizardView.qml
"
,
"
SettingsView
"
:
"
settingsview/SettingsView.qml
"
,
}
viewManager
:
root
.
viewManager
}
property
bool
windowSettingsLoaded
:
false
...
...
This diff is collapsed.
Click to expand it.
src/app/ViewCoordinator.qml
+
2
−
70
View file @
f808d426
...
...
@@ -29,6 +29,8 @@ import net.jami.Models 1.1
QtObject
{
id
:
root
required
property
QtObject
viewManager
signal
requestAppWindowWizardView
// A map of view names to file paths for QML files that define each view.
...
...
@@ -139,76 +141,6 @@ QtObject {
return
viewManager
.
views
[
viewManager
.
viewPaths
[
viewName
]]
}
// A private object used to manage the lifecycle of views.
property
QtObject
viewManager
:
QtObject
{
id
:
viewManager
// A map of path strings to view objects.
property
variant
views
:
({})
// A map of view names to path strings.
property
variant
viewPaths
:
({})
// The number of views.
property
int
nViews
:
0
function
createView
(
path
,
parent
=
null
,
cb
=
null
,
props
=
{})
{
if
(
views
[
path
]
!==
undefined
)
{
// an instance of <path> already exists
return
views
[
path
]
}
const
component
=
Qt
.
createComponent
(
Qt
.
resolvedUrl
(
path
))
if
(
component
.
status
===
Component
.
Ready
)
{
const
obj
=
component
.
createObject
(
parent
,
props
)
if
(
obj
===
null
)
{
print
(
"
error creating object
"
)
return
null
}
views
[
path
]
=
obj
// Set the view name to the object name if it has one.
const
viewName
=
obj
.
objectName
.
toString
()
!==
''
?
obj
.
objectName
:
path
.
replace
(
/^.*
[\\\/]
/
,
''
).
replace
(
/
\.[^/
.
]
+$/
,
""
)
viewPaths
[
viewName
]
=
path
nViews
=
Object
.
keys
(
views
).
length
if
(
cb
!==
null
)
{
cb
(
obj
)
}
return
views
[
path
]
}
print
(
"
error creating component
"
,
path
)
console
.
error
(
component
.
errorString
())
Qt
.
exit
(
1
)
return
null
}
function
destroyView
(
path
)
{
if
(
views
[
path
]
===
undefined
)
{
print
(
path
,
"
instance does not exist
"
,
Object
.
keys
(
views
))
return
false
}
views
[
path
].
destroy
()
views
[
path
]
=
undefined
// QObject::destroy is queued, and we can't connect to its completion,
// so we queue the resulting mutation to our view storage.
Qt
.
callLater
(
function
()
{
delete
views
[
path
]
// Remove the view name from the viewPaths map.
for
(
var
viewName
in
viewPaths
)
{
if
(
viewPaths
[
viewName
]
===
path
)
{
delete
viewPaths
[
viewName
]
break
}
}
nViews
=
Object
.
keys
(
views
).
length
})
return
true
}
function
hasView
(
viewName
)
{
return
nViews
&&
viewPaths
[
viewName
]
!==
undefined
}
}
// Sets object references, onInitialized is a good time to present views.
function
setRootView
(
obj
)
{
rootView
=
obj
...
...
This diff is collapsed.
Click to expand it.
src/app/ViewManager.qml
0 → 100644
+
87
−
0
View file @
f808d426
/*
* Copyright (C) 2023 Savoir-faire Linux Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import
QtQuick
QtObject
{
id
:
viewManager
// A map of path strings to view objects.
property
variant
views
:
({})
// A map of view names to path strings.
property
variant
viewPaths
:
({})
// The number of views.
property
int
nViews
:
0
function
createView
(
path
,
parent
=
null
,
cb
=
null
,
props
=
{})
{
if
(
views
[
path
]
!==
undefined
)
{
// an instance of <path> already exists
return
views
[
path
]
}
const
component
=
Qt
.
createComponent
(
Qt
.
resolvedUrl
(
path
))
if
(
component
.
status
===
Component
.
Ready
)
{
const
obj
=
component
.
createObject
(
parent
,
props
)
if
(
obj
===
null
)
{
print
(
"
error creating object
"
)
return
null
}
views
[
path
]
=
obj
// Set the view name to the object name if it has one.
const
viewName
=
obj
.
objectName
.
toString
()
!==
''
?
obj
.
objectName
:
path
.
replace
(
/^.*
[\\\/]
/
,
''
).
replace
(
/
\.[^/
.
]
+$/
,
""
)
viewPaths
[
viewName
]
=
path
nViews
=
Object
.
keys
(
views
).
length
if
(
cb
!==
null
)
{
cb
(
obj
)
}
return
views
[
path
]
}
print
(
"
error creating component
"
,
path
)
console
.
error
(
component
.
errorString
())
Qt
.
exit
(
1
)
return
null
}
function
destroyView
(
path
)
{
if
(
views
[
path
]
===
undefined
)
{
print
(
path
,
"
instance does not exist
"
,
Object
.
keys
(
views
))
return
false
}
views
[
path
].
destroy
()
views
[
path
]
=
undefined
// QObject::destroy is queued, and we can't connect to its completion,
// so we queue the resulting mutation to our view storage.
Qt
.
callLater
(
function
()
{
delete
views
[
path
]
// Remove the view name from the viewPaths map.
for
(
var
viewName
in
viewPaths
)
{
if
(
viewPaths
[
viewName
]
===
path
)
{
delete
viewPaths
[
viewName
]
break
}
}
nViews
=
Object
.
keys
(
views
).
length
})
return
true
}
function
hasView
(
viewName
)
{
return
nViews
&&
viewPaths
[
viewName
]
!==
undefined
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment