File > New: Bring existing dialog to foreground

Task-number: QTCREATORBUG-16932
Change-Id: I1a90ab01825b5cd2f439395cbdf4400075943dc4
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Eike Ziller
2016-09-26 16:39:49 +02:00
parent 79be19a8a0
commit 94a58b4653
10 changed files with 66 additions and 50 deletions

View File

@@ -307,7 +307,14 @@ ICore *ICore::instance()
bool ICore::isNewItemDialogRunning()
{
return NewDialog::isRunning() || IWizardFactory::isWizardRunning();
return NewDialog::currentDialog() || IWizardFactory::isWizardRunning();
}
QWidget *ICore::newItemDialog()
{
if (NewDialog::currentDialog())
return NewDialog::currentDialog();
return IWizardFactory::currentWizard();
}
ICore::ICore(MainWindow *mainwindow)
@@ -336,12 +343,12 @@ void ICore::showNewItemDialog(const QString &title,
{
QTC_ASSERT(!isNewItemDialogRunning(), return);
auto newDialog = new NewDialog(dialogParent());
connect(newDialog, &QObject::destroyed, m_instance, &ICore::validateNewItemDialogIsRunning);
connect(newDialog, &QObject::destroyed, m_instance, &ICore::updateNewItemDialogState);
newDialog->setWizardFactories(factories, defaultLocation, extraVariables);
newDialog->setWindowTitle(title);
newDialog->showDialog();
validateNewItemDialogIsRunning();
updateNewItemDialogState();
}
bool ICore::showOptionsDialog(const Id page, QWidget *parent)
@@ -610,13 +617,15 @@ void ICore::appendAboutInformation(const QString &line)
m_mainwindow->appendAboutInformation(line);
}
void ICore::validateNewItemDialogIsRunning()
void ICore::updateNewItemDialogState()
{
static bool wasRunning = false;
if (wasRunning == isNewItemDialogRunning())
static QWidget *previousDialog = nullptr;
if (wasRunning == isNewItemDialogRunning() && previousDialog == newItemDialog())
return;
wasRunning = isNewItemDialogRunning();
emit instance()->newItemDialogRunningChanged();
previousDialog = newItemDialog();
emit instance()->newItemDialogStateChanged();
}
} // namespace Core