RibbonWindow: Use an unified set to store sub windows pointers.
This commit is contained in:
parent
87c11a384a
commit
6419045f0e
|
@ -10,7 +10,6 @@ Window {
|
||||||
property alias title_bar: titleBar
|
property alias title_bar: titleBar
|
||||||
property alias popup: pop
|
property alias popup: pop
|
||||||
property bool comfirmed_quit: false
|
property bool comfirmed_quit: false
|
||||||
property var sub_windows: ({})
|
|
||||||
visible: false
|
visible: false
|
||||||
color: {
|
color: {
|
||||||
if (FramelessHelper.blurBehindWindowEnabled) {
|
if (FramelessHelper.blurBehindWindowEnabled) {
|
||||||
|
@ -114,6 +113,7 @@ Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_window(window_url, args){
|
function show_window(window_url, args){
|
||||||
|
let sub_windows = RibbonUI.windowsSet
|
||||||
if (sub_windows.hasOwnProperty(window_url))
|
if (sub_windows.hasOwnProperty(window_url))
|
||||||
{
|
{
|
||||||
if (args && Object.keys(args).length)
|
if (args && Object.keys(args).length)
|
||||||
|
@ -128,15 +128,24 @@ Window {
|
||||||
}
|
}
|
||||||
sub_windows[window_url].raise()
|
sub_windows[window_url].raise()
|
||||||
sub_windows[window_url].requestActivate()
|
sub_windows[window_url].requestActivate()
|
||||||
|
RibbonUI.windowsSet = sub_windows
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var component = Qt.createComponent(window_url, Component.PreferSynchronous, undefined);
|
var component = Qt.createComponent(window_url, Component.PreferSynchronous, undefined);
|
||||||
if (component.status === Component.Ready) {
|
if (component.status === Component.Ready) {
|
||||||
var window = component.createObject(undefined, args);
|
var window = component.createObject(undefined, args)
|
||||||
|
if (!(window instanceof Window))
|
||||||
|
{
|
||||||
|
console.error("RibbonWindow: Error loading Window: Instance is not Window.")
|
||||||
|
return
|
||||||
|
}
|
||||||
sub_windows[window_url] = window
|
sub_windows[window_url] = window
|
||||||
|
RibbonUI.windowsSet = sub_windows
|
||||||
window.onClosing.connect(function() {
|
window.onClosing.connect(function() {
|
||||||
window.destroy()
|
window.destroy()
|
||||||
|
let sub_windows = RibbonUI.windowsSet
|
||||||
delete sub_windows[window_url]
|
delete sub_windows[window_url]
|
||||||
|
RibbonUI.windowsSet = sub_windows
|
||||||
});
|
});
|
||||||
window.raise()
|
window.raise()
|
||||||
window.requestActivate()
|
window.requestActivate()
|
||||||
|
|
|
@ -16,6 +16,7 @@ class RibbonUI : public QQuickItem
|
||||||
Q_PROPERTY_R(QString, version)
|
Q_PROPERTY_R(QString, version)
|
||||||
Q_PROPERTY_R(int, qt_version)
|
Q_PROPERTY_R(int, qt_version)
|
||||||
Q_PROPERTY_R(int, is_win11)
|
Q_PROPERTY_R(int, is_win11)
|
||||||
|
Q_PROPERTY_RW(QVariantMap, windowsSet)
|
||||||
public:
|
public:
|
||||||
static RibbonUI* instance();
|
static RibbonUI* instance();
|
||||||
static RibbonUI* create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return instance();}
|
static RibbonUI* create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return instance();}
|
||||||
|
|
Loading…
Reference in New Issue