RibbonPopup and RibbonWindow: Use a new method to use custom Component.
This commit is contained in:
parent
79a17c3fb1
commit
7e48832312
|
@ -7,18 +7,6 @@ Item {
|
||||||
id: root
|
id: root
|
||||||
implicitHeight: layout.height + layout.anchors.margins * 2
|
implicitHeight: layout.height + layout.anchors.margins * 2
|
||||||
implicitWidth: 500
|
implicitWidth: 500
|
||||||
RibbonButton{
|
|
||||||
anchors{
|
|
||||||
top:parent.top
|
|
||||||
topMargin: 8
|
|
||||||
right: parent.right
|
|
||||||
rightMargin: anchors.topMargin
|
|
||||||
}
|
|
||||||
show_bg: false
|
|
||||||
show_hovered_bg: false
|
|
||||||
icon_source: RibbonIcons.Dismiss
|
|
||||||
onClicked: close_popup()
|
|
||||||
}
|
|
||||||
ColumnLayout{
|
ColumnLayout{
|
||||||
id: layout
|
id: layout
|
||||||
width: parent.width - anchors.margins * 2
|
width: parent.width - anchors.margins * 2
|
||||||
|
|
|
@ -432,7 +432,9 @@ RibbonWindow {
|
||||||
RibbonButton{
|
RibbonButton{
|
||||||
text: qsTr('Open Message List View')
|
text: qsTr('Open Message List View')
|
||||||
icon_source: RibbonIcons.Open
|
icon_source: RibbonIcons.Open
|
||||||
onClicked: root.show_popup("qrc:/qt/qml/RibbonUIAPP/components/RibbonMessageListViewExample.qml")
|
onClicked: {
|
||||||
|
Window.window.popup.show_content("qrc:/qt/qml/RibbonUIAPP/components/RibbonMessageListViewExample.qml")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,10 @@ Popup {
|
||||||
property alias target: blur.target
|
property alias target: blur.target
|
||||||
property alias target_rect: blur.target_rect
|
property alias target_rect: blur.target_rect
|
||||||
property alias radius: blur.radius
|
property alias radius: blur.radius
|
||||||
|
property string content_source: ""
|
||||||
|
property var content_items: undefined
|
||||||
|
property bool destroy_after_close: true
|
||||||
|
|
||||||
enter: Transition {
|
enter: Transition {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
properties: "scale"
|
properties: "scale"
|
||||||
|
@ -71,19 +75,43 @@ Popup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentItem: Item{
|
contentItem: Item{
|
||||||
|
id: control
|
||||||
|
implicitHeight: container.height
|
||||||
|
implicitWidth: container.width
|
||||||
|
property var args
|
||||||
RibbonButton{
|
RibbonButton{
|
||||||
anchors{
|
anchors{
|
||||||
top:parent.top
|
top:parent.top
|
||||||
topMargin: 8
|
topMargin: 8
|
||||||
right:parent.right
|
right:parent.right
|
||||||
rightMargin: topMargin
|
rightMargin: anchors.topMargin
|
||||||
}
|
}
|
||||||
show_bg: false
|
show_bg: false
|
||||||
show_hovered_bg: false
|
show_hovered_bg: false
|
||||||
icon_source: RibbonIcons.Dismiss
|
icon_source: RibbonIcons.Dismiss
|
||||||
onClicked: close()
|
onClicked: popup.close_content()
|
||||||
visible: show_close_btn
|
visible: show_close_btn
|
||||||
}
|
}
|
||||||
|
Loader{
|
||||||
|
id: container
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: item ? item.implicitWidth : 0
|
||||||
|
height: item ? item.implicitHeight : 0
|
||||||
|
sourceComponent: content_source ? undefined : content_items
|
||||||
|
source: content_source
|
||||||
|
onLoaded: {
|
||||||
|
if (!control.args)
|
||||||
|
return
|
||||||
|
else if(Object.keys(control.args).length){
|
||||||
|
for (let arg in control.args){
|
||||||
|
item[arg] = control.args[arg]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.error("RibbonPopup: Arguments error, please check.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Overlay.modal:Rectangle{
|
Overlay.modal:Rectangle{
|
||||||
color:"transparent"
|
color:"transparent"
|
||||||
|
@ -91,4 +119,29 @@ Popup {
|
||||||
Overlay.modeless:Rectangle{
|
Overlay.modeless:Rectangle{
|
||||||
color:"transparent"
|
color:"transparent"
|
||||||
}
|
}
|
||||||
|
onClosed: free_content()
|
||||||
|
function show_content(content, args){
|
||||||
|
popup.contentItem.args = args
|
||||||
|
if (content instanceof Component)
|
||||||
|
{
|
||||||
|
content_items = content
|
||||||
|
content.parent = popup
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
content_source = content
|
||||||
|
}
|
||||||
|
open()
|
||||||
|
}
|
||||||
|
function close_content(){
|
||||||
|
free_content()
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
function free_content(){
|
||||||
|
if (destroy_after_close)
|
||||||
|
{
|
||||||
|
content_source = ""
|
||||||
|
content_items = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,6 @@ Window {
|
||||||
target: window_items
|
target: window_items
|
||||||
target_rect: Qt.rect(window_items.x + x, window_items.y + y, width, height)
|
target_rect: Qt.rect(window_items.x + x, window_items.y + y, width, height)
|
||||||
blur_enabled: true
|
blur_enabled: true
|
||||||
onClosed: contentItem.destroy()
|
|
||||||
}
|
}
|
||||||
RibbonPopupDialog{
|
RibbonPopupDialog{
|
||||||
id: dialog
|
id: dialog
|
||||||
|
@ -110,26 +109,15 @@ Window {
|
||||||
dialog.open()
|
dialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_popup(content_url, argument)
|
function show_popup(content_url, arguments)
|
||||||
{
|
{
|
||||||
let component = Qt.createComponent(content_url,pop)
|
console.warn("RibbonWindow: This \"show_popup()\" function deprecated, please use RibbonPopup.open_content()")
|
||||||
|
popup.show_content(content_url, arguments)
|
||||||
if (component.status === Component.Error) {
|
|
||||||
console.log(qsTr("Error loading component:"), component.errorString());
|
|
||||||
return
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (typeof(argument)!='undefined')
|
|
||||||
pop.contentItem = component.createObject(pop,argument)
|
|
||||||
else
|
|
||||||
pop.contentItem = component.createObject(pop)
|
|
||||||
}
|
|
||||||
pop.open()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function close_popup()
|
function close_popup()
|
||||||
{
|
{
|
||||||
pop.close()
|
console.warn("RibbonWindow: This \"close_popup()\" function deprecated, please use RibbonPopup.close_content()")
|
||||||
|
pop.close_content()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue