Dialogs: detect and handle dynamic creation with Window parent

When instantiating via Qt.createQmlObject('Dialog { }', window, "path")
the dialog's parent will be the Window.  That was an unanticipated use
case, but also a simpler one: if the platform does not support multiple
windows, then we only need to construct the dialog and its decoration
on top of that window's contentItem.  Or if there is to be a separate
dialog window, then it should be transient for the main window.

Also rearranged the parenting strategy around the fact that the
application is always within a QQuickWindow: parentWindow() is
responsible for finding it, and it's not necessary to recursively go
up the Item hierarchy to find the root item if we are sure that
there is a window, because the root item is that window's contentItem.

Task-number: QTBUG-38578
Change-Id: I79e0cf44f789701f5d40e5e9d0449a55947be907
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>