Allow the NewDialog to be overridden by other plugins

So that Qt Design Studio can set its own implementation for the New
Project dialog box.

Task-number: QDS-4490
Change-Id: Ie04b041a5b6e25b38416f53b0ee4943839c2f64f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Samuel Ghinet
2021-08-26 20:02:55 +03:00
parent d739ba8a7d
commit 4e7ee4687b
10 changed files with 653 additions and 542 deletions

View File

@@ -141,6 +141,7 @@
from the focus object as well as the additional context.
*/
#include "dialogs/newdialogwidget.h"
#include "dialogs/newdialog.h"
#include "iwizardfactory.h"
#include "mainwindow.h"
@@ -164,6 +165,9 @@ namespace Core {
// The Core Singleton
static ICore *m_instance = nullptr;
static MainWindow *m_mainwindow = nullptr;
std::function<NewDialog *(QWidget *)> ICore::m_newDialogFactory = [](QWidget *parent) {
return new NewDialogWidget(parent);
};
/*!
Returns the pointer to the instance. Only use for connecting to signals.
@@ -249,8 +253,8 @@ void ICore::showNewItemDialog(const QString &title,
const QVariantMap &extraVariables)
{
QTC_ASSERT(!isNewItemDialogRunning(), return);
auto newDialog = new NewDialog(dialogParent());
connect(newDialog, &QObject::destroyed, m_instance, &ICore::updateNewItemDialogState);
NewDialog *newDialog = ICore::m_newDialogFactory(dialogParent());
connect(newDialog->widget(), &QObject::destroyed, m_instance, &ICore::updateNewItemDialogState);
newDialog->setWizardFactories(factories, defaultLocation, extraVariables);
newDialog->setWindowTitle(title);
newDialog->showDialog();
@@ -944,4 +948,12 @@ void ICore::updateNewItemDialogState()
emit instance()->newItemDialogStateChanged();
}
/*!
\internal
*/
void ICore::setNewDialogFactory(const std::function<NewDialog *(QWidget *)> &newFactory)
{
m_newDialogFactory = newFactory;
}
} // namespace Core