Fix Edit View 3D on top of Some widgets issue

setting the main window as the parent of a widget makes it open above
the Edit View 3D. Also other dialogs (open file dialog, options dialog,
etc) open above the 3D View now.

Task-number: QDS-1446
Change-Id: I6f6325d7b81eccb5aec3c07dfadc021a17dfd26b
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Mahmoud Badri
2020-01-14 16:06:45 +02:00
parent 07b04c2056
commit 1eb72aabef
2 changed files with 17 additions and 5 deletions

View File

@@ -197,15 +197,27 @@ MainWindow::MainWindow()
this, &MainWindow::openDroppedFiles);
}
// Edit View 3D needs to know when the main windows's state or activation change
// Edit View 3D needs to know when the main window's state or activation change
void MainWindow::changeEvent(QEvent *event)
{
if (event->type() == QEvent::WindowStateChange) {
emit m_coreImpl->windowStateChanged(m_previousWindowStates, windowState());
m_previousWindowStates = windowState();
} else if (event->type() == QEvent::ActivationChange) {
auto lastChild = qobject_cast<QWidget *>(children().last());
bool hasPopup = lastChild && lastChild->isActiveWindow();
// check the last 3 children for a possible active window
auto rIter = children().rbegin();
bool hasPopup = false;
for (int i = 0; i < 3; ++i) {
if (rIter < children().rend()) {
auto child = qobject_cast<QWidget *>(*(rIter++));
if (child && child->isActiveWindow()) {
hasPopup = true;
break;
}
} else {
break;
}
}
emit m_coreImpl->windowActivationChanged(isActiveWindow(), hasPopup);
}
}

View File

@@ -195,7 +195,7 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
&QmlDesignerPlugin::instance()->viewManager().designerActionManager();
auto handle3DModel = [](const QStringList &fileNames, const QString &defaultDir) -> bool {
auto importDlg = new ItemLibraryAssetImportDialog(fileNames, defaultDir);
auto importDlg = new ItemLibraryAssetImportDialog(fileNames, defaultDir, Core::ICore::mainWindow());
importDlg->show();
return true;
};
@@ -505,7 +505,7 @@ void ItemLibraryWidget::addResources()
static QString lastDir;
const QString currentDir = lastDir.isEmpty() ? document->fileName().parentDir().toString() : lastDir;
const auto fileNames = QFileDialog::getOpenFileNames(this,
const auto fileNames = QFileDialog::getOpenFileNames(Core::ICore::mainWindow(),
tr("Add Resources"),
currentDir,
filters.join(";;"));