Make dialog-in-separate-window kind of work

inlining is still broken, disabled right now. popupPosition has moved
into PlasmaCore.Dialog internally, so don't handle it in QML.
This commit is contained in:
Sebastian Kügler 2013-02-22 02:16:09 +01:00
parent e96671be05
commit 006eb99b55

View File

@ -128,20 +128,32 @@ Item {
*/ */
signal clickedOutside signal clickedOutside
function showObj(o) {
print("Showing object: " + o);
var e;
for (e in o) {
print(" e[" + e + "] = " + o[e]);
}
}
/** /**
* Shows the dialog to the user. * Shows the dialog to the user.
*/ */
function open() { function open() {
dialogLayout.parent = internalLoader.item.mainItem dialogLayout.parent = internalLoader.item.mainItem
print("opening.");
if (internalLoader.dialog) { if (internalLoader.dialog) {
var pos = internalLoader.dialog.popupPosition(root.visualParent, Qt.AlignCenter) print("Have dialog.");
internalLoader.dialog.x = pos.x // var pos = internalLoader.dialog.popupPosition(root.visualParent, Qt.AlignCenter)
internalLoader.dialog.y = pos.y // internalLoader.dialog.x = pos.x
// internalLoader.dialog.y = pos.y
internalLoader.dialog.visible = true internalLoader.dialog.visible = true
internalLoader.dialog.activateWindow() internalLoader.dialog.activateWindow()
} else { } else {
print("inlining.");
internalLoader.inlineDialog.open() internalLoader.inlineDialog.open()
} }
} }
@ -154,12 +166,12 @@ Item {
*/ */
function accept() { function accept() {
if (status == PlasmaComponents.DialogStatus.Open) { if (status == PlasmaComponents.DialogStatus.Open) {
coreDialog.visible = false; // coreDialog.visible = false;
// if (internalLoader.dialog) { if (internalLoader.dialog) {
// internalLoader.dialog.visible = false internalLoader.dialog.visible = false
// } else { } else {
// internalLoader.inlineDialog.close() internalLoader.inlineDialog.close()
// } }
accepted() accepted()
} }
} }
@ -172,12 +184,12 @@ Item {
*/ */
function reject() { function reject() {
if (status == PlasmaComponents.DialogStatus.Open) { if (status == PlasmaComponents.DialogStatus.Open) {
coreDialog.visible = false; // coreDialog.visible = false;
// if (internalLoader.dialog) { if (internalLoader.dialog) {
// internalLoader.dialog.visible = false internalLoader.dialog.visible = false
// } else { } else {
// internalLoader.inlineDialog.close() internalLoader.inlineDialog.close()
// } }
rejected() rejected()
} }
} }
@ -186,12 +198,13 @@ Item {
* Closes the dialog without any user interaction. * Closes the dialog without any user interaction.
*/ */
function close() { function close() {
internalLoader.sourceComponent.coreDialog.visible = false; //internalLoader.sourceComponent.
// if (internalLoader.dialog) { //coreDialog.visible = false;
// internalLoader.dialog.visible = false if (internalLoader.dialog) {
// } else { internalLoader.dialog.visible = false
// internalLoader.inlineDialog.close() } else {
// } internalLoader.inlineDialog.close()
}
} }
visible: false visible: false
@ -214,10 +227,14 @@ Item {
} }
sourceComponent: { sourceComponent: {
print(" XXX Loading Source component XXX");
print(" root: " + rootItem.width + "x" + rootItem.height + " dlg: " + dialogLayout.width + "x" + dialogLayout.height);
if (loadCompleted) { if (loadCompleted) {
if (rootItem == null || dialogLayout.width > rootItem.width || dialogLayout.height > rootItem.height) { if (true || rootItem == null || dialogLayout.width > rootItem.width || dialogLayout.height > rootItem.height) {
print(" in external window");
dialogComponent dialogComponent
} else { } else {
print(" inline window");
inlineDialogComponent inlineDialogComponent
} }
} }
@ -229,8 +246,8 @@ Item {
//property bool visible: coreDialog.visible //property bool visible: coreDialog.visible
PlasmaCore.Dialog { PlasmaCore.Dialog {
id: coreDialog id: coreDialog
windowFlags: Qt.Popup //windowFlags: Qt.Popup
visualParent: root.visualParent
// state: "Hidden" // state: "Hidden"
visible: false visible: false
onVisibleChanged: { onVisibleChanged: {