Wizards: Fix custom wizards (fix up delayed creation).

Fixes e5f60a956f
This commit is contained in:
Friedemann Kleint
2010-08-31 14:34:09 +02:00
parent 7607f2ffbe
commit 1d45330153
5 changed files with 25 additions and 3 deletions

View File

@@ -233,3 +233,7 @@ void CoreImpl::openFiles(const QStringList &arguments)
m_mainwindow->openFiles(arguments); m_mainwindow->openFiles(arguments);
} }
void CoreImpl::emitNewItemsDialogRequested()
{
emit newItemsDialogRequested();
}

View File

@@ -90,6 +90,8 @@ public:
void openFiles(const QStringList &fileNames); void openFiles(const QStringList &fileNames);
void emitNewItemsDialogRequested();
private: private:
MainWindow *m_mainwindow; MainWindow *m_mainwindow;
friend class MainWindow; friend class MainWindow;

View File

@@ -28,6 +28,7 @@
**************************************************************************/ **************************************************************************/
#include "iwizard.h" #include "iwizard.h"
#include "coreimpl.h"
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
@@ -139,6 +140,9 @@ using namespace Core;
template <class Predicate> template <class Predicate>
QList<IWizard*> findWizards(Predicate predicate) QList<IWizard*> findWizards(Predicate predicate)
{ {
// Hack: Trigger delayed creation of wizards
if (Core::Internal::CoreImpl *ci = qobject_cast<Core::Internal::CoreImpl*>(ICore::instance()))
ci->emitNewItemsDialogRequested();
// Filter all wizards // Filter all wizards
const QList<IWizard*> allWizards = IWizard::allWizards(); const QList<IWizard*> allWizards = IWizard::allWizards();
QList<IWizard*> rc; QList<IWizard*> rc;
@@ -151,6 +155,9 @@ template <class Predicate>
QList<IWizard*> IWizard::allWizards() QList<IWizard*> IWizard::allWizards()
{ {
// Hack: Trigger delayed creation of wizards
if (Core::Internal::CoreImpl *ci = qobject_cast<Core::Internal::CoreImpl*>(ICore::instance()))
ci->emitNewItemsDialogRequested();
return ExtensionSystem::PluginManager::instance()->getObjects<IWizard>(); return ExtensionSystem::PluginManager::instance()->getObjects<IWizard>();
} }

View File

@@ -885,7 +885,6 @@ QStringList MainWindow::showNewItemDialog(const QString &title,
const QList<IWizard *> &wizards, const QList<IWizard *> &wizards,
const QString &defaultLocation) const QString &defaultLocation)
{ {
emit m_coreImpl->newItemsDialogRequested();
// Scan for wizards matching the filter and pick one. Don't show // Scan for wizards matching the filter and pick one. Don't show
// dialog if there is only one. // dialog if there is only one.
IWizard *wizard = 0; IWizard *wizard = 0;

View File

@@ -42,6 +42,7 @@
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QTextStream>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
@@ -350,9 +351,17 @@ QList<CustomWizard*> CustomWizard::createWizards()
case Internal::CustomWizardParameters::ParseOk: case Internal::CustomWizardParameters::ParseOk:
parameters->directory = dir.absolutePath(); parameters->directory = dir.absolutePath();
if (CustomWizardPrivate::verbose) if (CustomWizardPrivate::verbose)
verboseLog += parameters->toString(); QTextStream(&verboseLog)
if (CustomWizard *w = createWizard(parameters, baseFileParameters)) << "\n### Adding: " << baseFileParameters.id() << " / " << baseFileParameters.displayName() << '\n'
<< baseFileParameters.category() << " / " <<baseFileParameters.displayCategory() << '\n'
<< " (" << baseFileParameters.description() << ")\n"
<< parameters->toString();
if (CustomWizard *w = createWizard(parameters, baseFileParameters)) {
rc.push_back(w); rc.push_back(w);
} else {
qWarning("Custom wizard factory function failed for %s", qPrintable(baseFileParameters.id()));
}
break;
case Internal::CustomWizardParameters::ParseDisabled: case Internal::CustomWizardParameters::ParseDisabled:
if (CustomWizardPrivate::verbose) if (CustomWizardPrivate::verbose)
qWarning("Ignoring disabled wizard %s...", qPrintable(dir.absolutePath())); qWarning("Ignoring disabled wizard %s...", qPrintable(dir.absolutePath()));
@@ -360,6 +369,7 @@ QList<CustomWizard*> CustomWizard::createWizards()
case Internal::CustomWizardParameters::ParseFailed: case Internal::CustomWizardParameters::ParseFailed:
qWarning("Failed to initialize custom project wizard in %s: %s", qWarning("Failed to initialize custom project wizard in %s: %s",
qPrintable(dir.absolutePath()), qPrintable(errorMessage)); qPrintable(dir.absolutePath()), qPrintable(errorMessage));
break;
} }
} else { } else {
if (CustomWizardPrivate::verbose) if (CustomWizardPrivate::verbose)