RibbonWindow: Use asynchronous in RibbonWindow.showWindow() and fix a memery leak issue.
This commit is contained in:
parent
6af906333f
commit
6490a40faf
|
@ -60,9 +60,6 @@ Window {
|
||||||
windowAgent.setHitTestVisible(titleBar.leftContainer)
|
windowAgent.setHitTestVisible(titleBar.leftContainer)
|
||||||
windowAgent.setHitTestVisible(titleBar.rightContainer)
|
windowAgent.setHitTestVisible(titleBar.rightContainer)
|
||||||
windowAgent.setTitleBar(titleBar)
|
windowAgent.setTitleBar(titleBar)
|
||||||
window.visible = true
|
|
||||||
windowAgent.centralize()
|
|
||||||
raise()
|
|
||||||
windowAgent.setWindowAttribute("dark-mode", RibbonTheme.isDarkMode)
|
windowAgent.setWindowAttribute("dark-mode", RibbonTheme.isDarkMode)
|
||||||
blurBehindWindow = Qt.platform.os === 'windows' && !RibbonUI.isWin11 ? false : true
|
blurBehindWindow = Qt.platform.os === 'windows' && !RibbonUI.isWin11 ? false : true
|
||||||
if (Qt.platform.os === 'windows')
|
if (Qt.platform.os === 'windows')
|
||||||
|
@ -75,6 +72,11 @@ Window {
|
||||||
}
|
}
|
||||||
RibbonLocalization.bindEngine();
|
RibbonLocalization.bindEngine();
|
||||||
RibbonUI.setTranslator(RibbonLocalization)
|
RibbonUI.setTranslator(RibbonLocalization)
|
||||||
|
|
||||||
|
window.visible = true
|
||||||
|
windowAgent.centralize()
|
||||||
|
raise()
|
||||||
|
requestActivate()
|
||||||
}
|
}
|
||||||
Item{
|
Item{
|
||||||
id: windowItems
|
id: windowItems
|
||||||
|
@ -162,6 +164,44 @@ Window {
|
||||||
id: windowAgent
|
id: windowAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QtObject{
|
||||||
|
id: internal
|
||||||
|
function dealWithWindows(component, window, sub_windows, window_url){
|
||||||
|
if (!(window.object instanceof Window))
|
||||||
|
{
|
||||||
|
console.error("RibbonWindow: Error loading Window: Instance is not Window.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
window = window.object
|
||||||
|
sub_windows[window_url] = window
|
||||||
|
RibbonUI.windowsSet = sub_windows
|
||||||
|
window.onClosing.connect(function() {
|
||||||
|
component.destroy()
|
||||||
|
window.destroy()
|
||||||
|
let sub_windows = RibbonUI.windowsSet
|
||||||
|
delete sub_windows[window_url]
|
||||||
|
RibbonUI.windowsSet = sub_windows
|
||||||
|
});
|
||||||
|
window.raise()
|
||||||
|
window.requestActivate()
|
||||||
|
}
|
||||||
|
|
||||||
|
function configWindowAsynchronous(component, args, sub_windows, window_url){
|
||||||
|
let window = component.incubateObject(null, args)
|
||||||
|
if (window.status !== Component.Ready) {
|
||||||
|
window.onStatusChanged = function(status) {
|
||||||
|
if (status === Component.Ready) {
|
||||||
|
console.debug("Object", window.object, "is now ready.");
|
||||||
|
dealWithWindows(component, window, sub_windows, window_url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.debug("Object", window.object, "is ready immediately.");
|
||||||
|
dealWithWindows(component, window, sub_windows, window_url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onClosing:function(event){
|
onClosing:function(event){
|
||||||
window.raise()
|
window.raise()
|
||||||
event.accepted = !comfirmedQuit
|
event.accepted = !comfirmedQuit
|
||||||
|
@ -197,26 +237,22 @@ Window {
|
||||||
sub_windows[window_url].close()
|
sub_windows[window_url].close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var component = Qt.createComponent(window_url, Component.PreferSynchronous, null);
|
|
||||||
if (component.status === Component.Ready) {
|
const component = Qt.createComponent(window_url, Component.Asynchronous, null)
|
||||||
var window = component.createObject(null, args)
|
|
||||||
if (!(window instanceof Window))
|
if(component.status !== Component.Ready){
|
||||||
{
|
component.statusChanged.connect(function(){
|
||||||
console.error("RibbonWindow: Error loading Window: Instance is not Window.")
|
if (component.status === Component.Ready) {
|
||||||
return
|
console.debug("Component", component, "is now ready.");
|
||||||
}
|
internal.configWindowAsynchronous(component, args, sub_windows, window_url)
|
||||||
sub_windows[window_url] = window
|
} else if (component.status === Component.Error) {
|
||||||
RibbonUI.windowsSet = sub_windows
|
console.error("RibbonWindow: Error loading Window Component:", component.errorString())
|
||||||
window.onClosing.connect(function() {
|
}
|
||||||
window.destroy()
|
})
|
||||||
let sub_windows = RibbonUI.windowsSet
|
}
|
||||||
delete sub_windows[window_url]
|
else{
|
||||||
RibbonUI.windowsSet = sub_windows
|
console.debug("Component", component, "is ready immediately.");
|
||||||
});
|
internal.configWindowAsynchronous(component, args, sub_windows, window_url)
|
||||||
window.raise()
|
|
||||||
window.requestActivate()
|
|
||||||
} else if (component.status === Component.Error) {
|
|
||||||
console.error("RibbonWindow: Error loading Window:", component.errorString())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,6 @@ Window {
|
||||||
windowAgent.setHitTestVisible(titleBar.leftContainer)
|
windowAgent.setHitTestVisible(titleBar.leftContainer)
|
||||||
windowAgent.setHitTestVisible(titleBar.rightContainer)
|
windowAgent.setHitTestVisible(titleBar.rightContainer)
|
||||||
windowAgent.setTitleBar(titleBar)
|
windowAgent.setTitleBar(titleBar)
|
||||||
window.visible = true
|
|
||||||
windowAgent.centralize()
|
|
||||||
raise()
|
|
||||||
windowAgent.setWindowAttribute("dark-mode", RibbonTheme.isDarkMode)
|
windowAgent.setWindowAttribute("dark-mode", RibbonTheme.isDarkMode)
|
||||||
blurBehindWindow = Qt.platform.os === 'windows' && !RibbonUI.isWin11 ? false : true
|
blurBehindWindow = Qt.platform.os === 'windows' && !RibbonUI.isWin11 ? false : true
|
||||||
if (Qt.platform.os === 'windows')
|
if (Qt.platform.os === 'windows')
|
||||||
|
@ -75,6 +72,11 @@ Window {
|
||||||
}
|
}
|
||||||
RibbonLocalization.bindEngine();
|
RibbonLocalization.bindEngine();
|
||||||
RibbonUI.setTranslator(RibbonLocalization)
|
RibbonUI.setTranslator(RibbonLocalization)
|
||||||
|
|
||||||
|
window.visible = true
|
||||||
|
windowAgent.centralize()
|
||||||
|
raise()
|
||||||
|
requestActivate()
|
||||||
}
|
}
|
||||||
Item{
|
Item{
|
||||||
id: windowItems
|
id: windowItems
|
||||||
|
@ -162,6 +164,44 @@ Window {
|
||||||
id: windowAgent
|
id: windowAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QtObject{
|
||||||
|
id: internal
|
||||||
|
function dealWithWindows(component, window, sub_windows, window_url){
|
||||||
|
if (!(window.object instanceof Window))
|
||||||
|
{
|
||||||
|
console.error("RibbonWindow: Error loading Window: Instance is not Window.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
window = window.object
|
||||||
|
sub_windows[window_url] = window
|
||||||
|
RibbonUI.windowsSet = sub_windows
|
||||||
|
window.onClosing.connect(function() {
|
||||||
|
component.destroy()
|
||||||
|
window.destroy()
|
||||||
|
let sub_windows = RibbonUI.windowsSet
|
||||||
|
delete sub_windows[window_url]
|
||||||
|
RibbonUI.windowsSet = sub_windows
|
||||||
|
});
|
||||||
|
window.raise()
|
||||||
|
window.requestActivate()
|
||||||
|
}
|
||||||
|
|
||||||
|
function configWindowAsynchronous(component, args, sub_windows, window_url){
|
||||||
|
let window = component.incubateObject(null, args)
|
||||||
|
if (window.status !== Component.Ready) {
|
||||||
|
window.onStatusChanged = function(status) {
|
||||||
|
if (status === Component.Ready) {
|
||||||
|
console.debug("Object", window.object, "is now ready.");
|
||||||
|
dealWithWindows(component, window, sub_windows, window_url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.debug("Object", window.object, "is ready immediately.");
|
||||||
|
dealWithWindows(component, window, sub_windows, window_url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onClosing:function(event){
|
onClosing:function(event){
|
||||||
window.raise()
|
window.raise()
|
||||||
event.accepted = !comfirmedQuit
|
event.accepted = !comfirmedQuit
|
||||||
|
@ -197,26 +237,22 @@ Window {
|
||||||
sub_windows[window_url].close()
|
sub_windows[window_url].close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var component = Qt.createComponent(window_url, Component.PreferSynchronous, null);
|
|
||||||
if (component.status === Component.Ready) {
|
const component = Qt.createComponent(window_url, Component.Asynchronous, null)
|
||||||
var window = component.createObject(null, args)
|
|
||||||
if (!(window instanceof Window))
|
if(component.status !== Component.Ready){
|
||||||
{
|
component.statusChanged.connect(function(){
|
||||||
console.error("RibbonWindow: Error loading Window: Instance is not Window.")
|
if (component.status === Component.Ready) {
|
||||||
return
|
console.debug("Component", component, "is now ready.");
|
||||||
}
|
internal.configWindowAsynchronous(component, args, sub_windows, window_url)
|
||||||
sub_windows[window_url] = window
|
} else if (component.status === Component.Error) {
|
||||||
RibbonUI.windowsSet = sub_windows
|
console.error("RibbonWindow: Error loading Window Component:", component.errorString())
|
||||||
window.onClosing.connect(function() {
|
}
|
||||||
window.destroy()
|
})
|
||||||
let sub_windows = RibbonUI.windowsSet
|
}
|
||||||
delete sub_windows[window_url]
|
else{
|
||||||
RibbonUI.windowsSet = sub_windows
|
console.debug("Component", component, "is ready immediately.");
|
||||||
});
|
internal.configWindowAsynchronous(component, args, sub_windows, window_url)
|
||||||
window.raise()
|
|
||||||
window.requestActivate()
|
|
||||||
} else if (component.status === Component.Error) {
|
|
||||||
console.error("RibbonWindow: Error loading Window:", component.errorString())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue