forked from qt-creator/qt-creator
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user