forked from qt-creator/qt-creator
Make changes in the QtCreator side required for QDS new project dialog
* We need the showing of the Wizard dialog to be optional * Each wizard has a "detailsPage.qml" file that stores wizard-specific UI configuration. We need a way to access that path (QUrl) from QDS. * ComboboxField is used directly by QDS, and the field object is fetched by a call to JsonFieldPage::jsonField() - hence, the ComboboxField needs to be dllexported. We need to access fields directly from QDS because the QML controls use those fields as backend. * From QDS we need to select / activate in a combobox field, and to see which item is current (activated). We also need to make use of the model that the ComboBoxField uses in order to show those same items in the qml controls of QDS. * From QDS we need to set the text in a LineEditField Task-number: QDS-4490 Change-Id: Ia42d539a5bcbf3dff4593fb027ac18c52da4d046 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -71,8 +71,10 @@ static int indexOfFile(const GeneratedFiles &f, const QString &path)
|
|||||||
|
|
||||||
Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const QString &path, QWidget *parent,
|
Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const QString &path, QWidget *parent,
|
||||||
Id platform,
|
Id platform,
|
||||||
const QVariantMap &extraValues)
|
const QVariantMap &extraValues,
|
||||||
|
bool showWizard)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(showWizard);
|
||||||
QTC_ASSERT(!path.isEmpty(), return nullptr);
|
QTC_ASSERT(!path.isEmpty(), return nullptr);
|
||||||
|
|
||||||
// Create dialog and run it. Ensure that the dialog is deleted when
|
// Create dialog and run it. Ensure that the dialog is deleted when
|
||||||
|
@@ -116,7 +116,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
// IWizard
|
// IWizard
|
||||||
Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, Utils::Id platform,
|
Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, Utils::Id platform,
|
||||||
const QVariantMap &extraValues) override;
|
const QVariantMap &extraValues, bool showWizard = true) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -257,14 +257,17 @@ QString IWizardFactory::runPath(const QString &defaultPath) const
|
|||||||
created. The wizard should fill this in its path selection elements as a
|
created. The wizard should fill this in its path selection elements as a
|
||||||
default path.
|
default path.
|
||||||
*/
|
*/
|
||||||
Utils::Wizard *IWizardFactory::runWizard(const QString &path, QWidget *parent, Id platform, const QVariantMap &variables)
|
Utils::Wizard *IWizardFactory::runWizard(const QString &path, QWidget *parent, Id platform,
|
||||||
|
const QVariantMap &variables,
|
||||||
|
bool showWizard)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!s_isWizardRunning, return nullptr);
|
QTC_ASSERT(!s_isWizardRunning, return nullptr);
|
||||||
|
|
||||||
s_isWizardRunning = true;
|
s_isWizardRunning = true;
|
||||||
ICore::updateNewItemDialogState();
|
ICore::updateNewItemDialogState();
|
||||||
|
|
||||||
Utils::Wizard *wizard = runWizardImpl(path, parent, platform, variables);
|
Utils::Wizard *wizard = runWizardImpl(path, parent, platform, variables, showWizard);
|
||||||
|
|
||||||
|
|
||||||
if (wizard) {
|
if (wizard) {
|
||||||
s_currentWizard = wizard;
|
s_currentWizard = wizard;
|
||||||
@@ -286,7 +289,8 @@ Utils::Wizard *IWizardFactory::runWizard(const QString &path, QWidget *parent, I
|
|||||||
s_reopenData.reopen();
|
s_reopenData.reopen();
|
||||||
});
|
});
|
||||||
s_inspectWizardAction->setEnabled(true);
|
s_inspectWizardAction->setEnabled(true);
|
||||||
wizard->show();
|
if (showWizard)
|
||||||
|
wizard->show();
|
||||||
Core::ICore::registerWindow(wizard, Core::Context("Core.NewWizard"));
|
Core::ICore::registerWindow(wizard, Core::Context("Core.NewWizard"));
|
||||||
} else {
|
} else {
|
||||||
s_isWizardRunning = false;
|
s_isWizardRunning = false;
|
||||||
@@ -418,3 +422,18 @@ void IWizardFactory::initialize()
|
|||||||
s_inspectWizardAction = new QAction(tr("Inspect Wizard State"), ActionManager::instance());
|
s_inspectWizardAction = new QAction(tr("Inspect Wizard State"), ActionManager::instance());
|
||||||
ActionManager::registerAction(s_inspectWizardAction, "Wizard.Inspect");
|
ActionManager::registerAction(s_inspectWizardAction, "Wizard.Inspect");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IWizardFactory::setDetailsPageQmlPath(const QString &filePath)
|
||||||
|
{
|
||||||
|
if (filePath.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (filePath.startsWith(':')) {
|
||||||
|
m_detailsPageQmlPath.setScheme(QLatin1String("qrc"));
|
||||||
|
QString path = filePath;
|
||||||
|
path.remove(0, 1);
|
||||||
|
m_detailsPageQmlPath.setPath(path);
|
||||||
|
} else {
|
||||||
|
m_detailsPageQmlPath = QUrl::fromLocalFile(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
@@ -71,6 +72,8 @@ public:
|
|||||||
QString descriptionImage() const { return m_descriptionImage; }
|
QString descriptionImage() const { return m_descriptionImage; }
|
||||||
QSet<Utils::Id> requiredFeatures() const { return m_requiredFeatures; }
|
QSet<Utils::Id> requiredFeatures() const { return m_requiredFeatures; }
|
||||||
WizardFlags flags() const { return m_flags; }
|
WizardFlags flags() const { return m_flags; }
|
||||||
|
QUrl detailsPageQmlPath() const { return m_detailsPageQmlPath; }
|
||||||
|
|
||||||
QSet<Utils::Id> supportedProjectTypes() const { return m_supportedProjectTypes; }
|
QSet<Utils::Id> supportedProjectTypes() const { return m_supportedProjectTypes; }
|
||||||
|
|
||||||
void setId(const Utils::Id id) { m_id = id; }
|
void setId(const Utils::Id id) { m_id = id; }
|
||||||
@@ -85,12 +88,13 @@ public:
|
|||||||
void setRequiredFeatures(const QSet<Utils::Id> &featureSet) { m_requiredFeatures = featureSet; }
|
void setRequiredFeatures(const QSet<Utils::Id> &featureSet) { m_requiredFeatures = featureSet; }
|
||||||
void addRequiredFeature(const Utils::Id &feature) { m_requiredFeatures |= feature; }
|
void addRequiredFeature(const Utils::Id &feature) { m_requiredFeatures |= feature; }
|
||||||
void setFlags(WizardFlags flags) { m_flags = flags; }
|
void setFlags(WizardFlags flags) { m_flags = flags; }
|
||||||
|
void setDetailsPageQmlPath(const QString &filePath);
|
||||||
|
|
||||||
QString runPath(const QString &defaultPath) const;
|
QString runPath(const QString &defaultPath) const;
|
||||||
|
|
||||||
// Does bookkeeping and the calls runWizardImpl. Please implement that.
|
// Does bookkeeping and the calls runWizardImpl. Please implement that.
|
||||||
Utils::Wizard *runWizard(const QString &path, QWidget *parent, Utils::Id platform,
|
Utils::Wizard *runWizard(const QString &path, QWidget *parent, Utils::Id platform,
|
||||||
const QVariantMap &variables);
|
const QVariantMap &variables, bool showWizard = true);
|
||||||
|
|
||||||
virtual bool isAvailable(Utils::Id platformId) const;
|
virtual bool isAvailable(Utils::Id platformId) const;
|
||||||
QSet<Utils::Id> supportedPlatforms() const;
|
QSet<Utils::Id> supportedPlatforms() const;
|
||||||
@@ -118,7 +122,7 @@ protected:
|
|||||||
static QSet<Utils::Id> availableFeatures(Utils::Id platformId);
|
static QSet<Utils::Id> availableFeatures(Utils::Id platformId);
|
||||||
|
|
||||||
virtual Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, Utils::Id platform,
|
virtual Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, Utils::Id platform,
|
||||||
const QVariantMap &variables) = 0;
|
const QVariantMap &variables, bool showWizard = true) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void initialize();
|
static void initialize();
|
||||||
@@ -134,6 +138,7 @@ private:
|
|||||||
QString m_category;
|
QString m_category;
|
||||||
QString m_displayCategory;
|
QString m_displayCategory;
|
||||||
QString m_descriptionImage;
|
QString m_descriptionImage;
|
||||||
|
QUrl m_detailsPageQmlPath;
|
||||||
QSet<Utils::Id> m_requiredFeatures;
|
QSet<Utils::Id> m_requiredFeatures;
|
||||||
QSet<Utils::Id> m_supportedProjectTypes;
|
QSet<Utils::Id> m_supportedProjectTypes;
|
||||||
WizardFlags m_flags;
|
WizardFlags m_flags;
|
||||||
|
@@ -701,6 +701,14 @@ void LineEditField::setupCompletion(FancyLineEdit *lineEdit)
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LineEditField::setText(const QString &text)
|
||||||
|
{
|
||||||
|
m_currentText = text;
|
||||||
|
|
||||||
|
auto w = qobject_cast<FancyLineEdit *>(widget());
|
||||||
|
w->setText(m_currentText);
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// TextEditFieldData:
|
// TextEditFieldData:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -1145,6 +1153,14 @@ QStandardItemModel *ListField::itemModel()
|
|||||||
return m_itemModel;
|
return m_itemModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListField::selectRow(int row)
|
||||||
|
{
|
||||||
|
auto index = itemModel()->index(row, 0);
|
||||||
|
selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect);
|
||||||
|
|
||||||
|
this->updateIndex();
|
||||||
|
}
|
||||||
|
|
||||||
QItemSelectionModel *ListField::selectionModel() const
|
QItemSelectionModel *ListField::selectionModel() const
|
||||||
{
|
{
|
||||||
return m_selectionModel;
|
return m_selectionModel;
|
||||||
@@ -1251,6 +1267,20 @@ QVariant ComboBoxField::toSettings() const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComboBoxField::selectRow(int row)
|
||||||
|
{
|
||||||
|
ListField::selectRow(row);
|
||||||
|
|
||||||
|
auto w = qobject_cast<QComboBox *>(widget());
|
||||||
|
w->setCurrentIndex(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ComboBoxField::selectedRow() const
|
||||||
|
{
|
||||||
|
auto w = qobject_cast<QComboBox *>(widget());
|
||||||
|
return w->currentIndex();
|
||||||
|
}
|
||||||
|
|
||||||
void IconListField::setup(JsonFieldPage *page, const QString &name)
|
void IconListField::setup(JsonFieldPage *page, const QString &name)
|
||||||
{
|
{
|
||||||
auto w = qobject_cast<QListView*>(widget());
|
auto w = qobject_cast<QListView*>(widget());
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/wizardpage.h>
|
#include <utils/wizardpage.h>
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@@ -141,6 +142,13 @@ public:
|
|||||||
|
|
||||||
QVariant value(const QString &key);
|
QVariant value(const QString &key);
|
||||||
|
|
||||||
|
public:
|
||||||
|
Field *jsonField(const QString &name) {
|
||||||
|
return Utils::findOr(m_fields, nullptr, [&name](Field *f) {
|
||||||
|
return f->name() == name;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QHash<QString, FieldFactory> m_factories;
|
static QHash<QString, FieldFactory> m_factories;
|
||||||
|
|
||||||
|
@@ -113,7 +113,7 @@ private:
|
|||||||
int m_factor = 1;
|
int m_factor = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LineEditField : public JsonFieldPage::Field
|
class PROJECTEXPLORER_EXPORT LineEditField : public JsonFieldPage::Field
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool parseData(const QVariant &data, QString *errorMessage) override;
|
bool parseData(const QVariant &data, QString *errorMessage) override;
|
||||||
@@ -159,6 +159,9 @@ private:
|
|||||||
|
|
||||||
enum class Completion { Classes, Namespaces, None };
|
enum class Completion { Classes, Namespaces, None };
|
||||||
Completion m_completion = Completion::None;
|
Completion m_completion = Completion::None;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setText(const QString &text);
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextEditField : public JsonFieldPage::Field
|
class TextEditField : public JsonFieldPage::Field
|
||||||
@@ -279,7 +282,10 @@ public:
|
|||||||
ListField();
|
ListField();
|
||||||
~ListField() override;
|
~ListField() override;
|
||||||
|
|
||||||
protected:
|
QStandardItemModel *model() { return m_itemModel; }
|
||||||
|
virtual void selectRow(int row);
|
||||||
|
|
||||||
|
protected:
|
||||||
bool parseData(const QVariant &data, QString *errorMessage) override;
|
bool parseData(const QVariant &data, QString *errorMessage) override;
|
||||||
|
|
||||||
QWidget *createWidget(const QString &displayName, JsonFieldPage *page) override = 0;
|
QWidget *createWidget(const QString &displayName, JsonFieldPage *page) override = 0;
|
||||||
@@ -329,7 +335,7 @@ private:
|
|||||||
mutable int m_savedIndex = -1;
|
mutable int m_savedIndex = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ComboBoxField : public ListField
|
class PROJECTEXPLORER_EXPORT ComboBoxField : public ListField
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
void setup(JsonFieldPage *page, const QString &name) override;
|
void setup(JsonFieldPage *page, const QString &name) override;
|
||||||
@@ -344,6 +350,10 @@ private:
|
|||||||
out << "ComboBox{" << ListField::toString() << "}";
|
out << "ComboBox{" << ListField::toString() << "}";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
void selectRow(int row) override;
|
||||||
|
int selectedRow() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IconListField : public ListField
|
class IconListField : public ListField
|
||||||
|
@@ -373,7 +373,7 @@ void JsonWizardFactory::registerGeneratorFactory(JsonWizardGeneratorFactory *fac
|
|||||||
|
|
||||||
Utils::Wizard *JsonWizardFactory::runWizardImpl(const QString &path, QWidget *parent,
|
Utils::Wizard *JsonWizardFactory::runWizardImpl(const QString &path, QWidget *parent,
|
||||||
Utils::Id platform,
|
Utils::Id platform,
|
||||||
const QVariantMap &variables)
|
const QVariantMap &variables, bool showWizard)
|
||||||
{
|
{
|
||||||
auto wizard = new JsonWizard(parent);
|
auto wizard = new JsonWizard(parent);
|
||||||
wizard->setWindowIcon(icon());
|
wizard->setWindowIcon(icon());
|
||||||
@@ -464,7 +464,8 @@ Utils::Wizard *JsonWizardFactory::runWizardImpl(const QString &path, QWidget *pa
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
wizard->show();
|
if (showWizard)
|
||||||
|
wizard->show();
|
||||||
return wizard;
|
return wizard;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,6 +603,10 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir,
|
|||||||
setDescriptionImage(strVal);
|
setDescriptionImage(strVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strVal = baseDir.absoluteFilePath("detailsPage.qml");
|
||||||
|
if (QFileInfo::exists(strVal))
|
||||||
|
setDetailsPageQmlPath(strVal);
|
||||||
|
|
||||||
setRequiredFeatures(Utils::Id::fromStringList(data.value(QLatin1String(REQUIRED_FEATURES_KEY)).toStringList()));
|
setRequiredFeatures(Utils::Id::fromStringList(data.value(QLatin1String(REQUIRED_FEATURES_KEY)).toStringList()));
|
||||||
m_preferredFeatures = Utils::Id::fromStringList(data.value(QLatin1String(SUGGESTED_FEATURES_KEY)).toStringList());
|
m_preferredFeatures = Utils::Id::fromStringList(data.value(QLatin1String(SUGGESTED_FEATURES_KEY)).toStringList());
|
||||||
m_preferredFeatures.unite(requiredFeatures());
|
m_preferredFeatures.unite(requiredFeatures());
|
||||||
|
@@ -89,7 +89,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, Utils::Id platform,
|
Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, Utils::Id platform,
|
||||||
const QVariantMap &variables) override;
|
const QVariantMap &variables, bool showWizard = true) override;
|
||||||
|
|
||||||
// Create all wizards. As other plugins might register factories for derived
|
// Create all wizards. As other plugins might register factories for derived
|
||||||
// classes. Called when the new file dialog is shown for the first time.
|
// classes. Called when the new file dialog is shown for the first time.
|
||||||
|
Reference in New Issue
Block a user