forked from qt-creator/qt-creator
Fix: Recents don't show up for Custom presets
In the New Project dialog for QDS, if the user had created a project from a User-defined (i.e. Custom) preset, this preset did not appear under the Recents tab. Task-number: QDS-4989 Change-Id: Ib1f5e772fc9a45ad727627152f292f6e1178ee8c Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -39,6 +39,12 @@ static const QString CustomTabName = QObject::tr("Custom");
|
||||
|
||||
/****************** PresetData ******************/
|
||||
|
||||
|
||||
QString PresetData::recentsTabName()
|
||||
{
|
||||
return RecentsTabName;
|
||||
}
|
||||
|
||||
void PresetData::setData(const PresetsByCategory &presetsByCategory,
|
||||
const std::vector<UserPresetData> &userPresetsData,
|
||||
const std::vector<RecentPresetData> &loadedRecentsData)
|
||||
@@ -47,11 +53,6 @@ void PresetData::setData(const PresetsByCategory &presetsByCategory,
|
||||
m_recents = loadedRecentsData;
|
||||
m_userPresets = userPresetsData;
|
||||
|
||||
if (!m_recents.empty()) {
|
||||
m_categories.push_back(RecentsTabName);
|
||||
m_presets.push_back({});
|
||||
}
|
||||
|
||||
for (auto &[id, category] : presetsByCategory) {
|
||||
m_categories.push_back(category.name);
|
||||
m_presets.push_back(category.items);
|
||||
@@ -59,17 +60,21 @@ void PresetData::setData(const PresetsByCategory &presetsByCategory,
|
||||
|
||||
PresetItems wizardPresets = Utils::flatten(m_presets);
|
||||
|
||||
PresetItems recentPresets = makeRecentPresets(wizardPresets);
|
||||
if (!m_recents.empty()) {
|
||||
m_presets[0] = recentPresets;
|
||||
}
|
||||
|
||||
PresetItems userPresetItems = makeUserPresets(wizardPresets);
|
||||
if (!userPresetItems.empty()) {
|
||||
m_categories.push_back(CustomTabName);
|
||||
m_presets.push_back(userPresetItems);
|
||||
}
|
||||
|
||||
PresetItems allWizardPresets = std::move(wizardPresets);
|
||||
Utils::concat(allWizardPresets, userPresetItems);
|
||||
|
||||
PresetItems recentPresets = makeRecentPresets(allWizardPresets);
|
||||
if (!recentPresets.empty()) {
|
||||
Utils::prepend(m_categories, RecentsTabName);
|
||||
Utils::prepend(m_presets, recentPresets);
|
||||
}
|
||||
|
||||
m_presetsByCategory = presetsByCategory;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ inline QDebug &operator<<(QDebug &d, const PresetItem &item)
|
||||
d << "; size = " << item.screenSizeName;
|
||||
|
||||
if (item.isUserPreset())
|
||||
d << (UserPresetItem &) item;
|
||||
d << "; " << (UserPresetItem &) item;
|
||||
|
||||
return d;
|
||||
}
|
||||
@@ -177,6 +177,8 @@ public:
|
||||
const std::vector<PresetItems> &presets() const { return m_presets; }
|
||||
const Categories &categories() const { return m_categories; }
|
||||
|
||||
static QString recentsTabName();
|
||||
|
||||
private:
|
||||
PresetItems makeRecentPresets(const PresetItems &wizardPresets);
|
||||
PresetItems makeUserPresets(const PresetItems &wizardPresets);
|
||||
|
||||
@@ -376,6 +376,11 @@ void QdsNewDialog::setWizardFactories(QList<Core::IWizardFactory *> factories_,
|
||||
}
|
||||
}
|
||||
|
||||
QString QdsNewDialog::recentsTabName() const
|
||||
{
|
||||
return PresetData::recentsTabName();
|
||||
}
|
||||
|
||||
QString QdsNewDialog::qmlPath() const
|
||||
{
|
||||
return Core::ICore::resourcePath("qmldesigner/newprojectdialog/NewProjectDialog.qml").toString();
|
||||
|
||||
@@ -74,6 +74,7 @@ public:
|
||||
Q_INVOKABLE int screenSizeIndex() const;
|
||||
|
||||
Q_INVOKABLE QString chooseProjectLocation();
|
||||
Q_INVOKABLE QString recentsTabName() const;
|
||||
|
||||
Q_PROPERTY(QAbstractListModel *categoryModel MEMBER m_categoryModel CONSTANT);
|
||||
Q_PROPERTY(QAbstractListModel *presetModel MEMBER m_presetModel CONSTANT);
|
||||
|
||||
Reference in New Issue
Block a user