Make gem tags clickable and filter by their text in the Gem Catalog when clicked
Signed-off-by: nggieber <nggieber@amazon.com>
This commit is contained in:
@@ -439,4 +439,9 @@ namespace O3DE::ProjectManager
|
||||
{
|
||||
m_filterLineEdit->setText({});
|
||||
}
|
||||
|
||||
void GemCatalogHeaderWidget::SetSearchFilter(const QString& filter)
|
||||
{
|
||||
m_filterLineEdit->setText(filter);
|
||||
}
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
@@ -86,6 +86,9 @@ namespace O3DE::ProjectManager
|
||||
|
||||
void ReinitForProject();
|
||||
|
||||
public slots:
|
||||
void SetSearchFilter(const QString& filter);
|
||||
|
||||
signals:
|
||||
void AddGem();
|
||||
void OpenGemsRepo();
|
||||
|
||||
@@ -54,6 +54,8 @@ namespace O3DE::ProjectManager
|
||||
m_gemInspector = new GemInspector(m_gemModel, this);
|
||||
m_gemInspector->setFixedWidth(240);
|
||||
|
||||
connect(m_gemInspector, &GemInspector::TagClicked, m_headerWidget, &GemCatalogHeaderWidget::SetSearchFilter);
|
||||
|
||||
QWidget* filterWidget = new QWidget(this);
|
||||
filterWidget->setFixedWidth(240);
|
||||
m_filterWidgetLayout = new QVBoxLayout();
|
||||
|
||||
@@ -175,6 +175,7 @@ namespace O3DE::ProjectManager
|
||||
|
||||
// Depending gems
|
||||
m_dependingGems = new GemsSubWidget();
|
||||
connect(m_dependingGems, &GemsSubWidget::TagClicked, this, [=](const QString& tag){ emit TagClicked(tag); });
|
||||
m_mainLayout->addWidget(m_dependingGems);
|
||||
m_mainLayout->addSpacing(20);
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ namespace O3DE::ProjectManager
|
||||
inline constexpr static const char* s_headerColor = "#FFFFFF";
|
||||
inline constexpr static const char* s_textColor = "#DDDDDD";
|
||||
|
||||
signals:
|
||||
void TagClicked(const QString& tag);
|
||||
|
||||
private slots:
|
||||
void OnSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace O3DE::ProjectManager
|
||||
m_layout->addWidget(m_textLabel);
|
||||
|
||||
m_tagWidget = new TagContainerWidget();
|
||||
connect(m_tagWidget, &TagContainerWidget::TagClicked, this, [=](const QString& tag){ emit TagClicked(tag); });
|
||||
m_layout->addWidget(m_tagWidget);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,15 @@ namespace O3DE::ProjectManager
|
||||
class GemsSubWidget
|
||||
: public QWidget
|
||||
{
|
||||
Q_OBJECT // AUTOMOC
|
||||
|
||||
public:
|
||||
GemsSubWidget(QWidget* parent = nullptr);
|
||||
void Update(const QString& title, const QString& text, const QStringList& gemNames);
|
||||
|
||||
signals:
|
||||
void TagClicked(const QString& tag);
|
||||
|
||||
private:
|
||||
QLabel* m_titleLabel = nullptr;
|
||||
QLabel* m_textLabel = nullptr;
|
||||
|
||||
@@ -18,6 +18,11 @@ namespace O3DE::ProjectManager
|
||||
setObjectName("TagWidget");
|
||||
}
|
||||
|
||||
void TagWidget::mousePressEvent([[maybe_unused]] QMouseEvent* event)
|
||||
{
|
||||
emit(TagClicked(text()));
|
||||
}
|
||||
|
||||
TagContainerWidget::TagContainerWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
@@ -45,7 +50,9 @@ namespace O3DE::ProjectManager
|
||||
|
||||
foreach (const QString& tag, tags)
|
||||
{
|
||||
flowLayout->addWidget(new TagWidget(tag));
|
||||
TagWidget* tagWidget = new TagWidget(tag);
|
||||
connect(tagWidget, &TagWidget::TagClicked, this, [=](const QString& tag){ emit TagClicked(tag); });
|
||||
flowLayout->addWidget(tagWidget);
|
||||
}
|
||||
}
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
@@ -25,6 +25,12 @@ namespace O3DE::ProjectManager
|
||||
public:
|
||||
explicit TagWidget(const QString& text, QWidget* parent = nullptr);
|
||||
~TagWidget() = default;
|
||||
|
||||
signals:
|
||||
void TagClicked(const QString& tag);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
};
|
||||
|
||||
// Widget containing multiple tags, automatically wrapping based on the size
|
||||
@@ -38,5 +44,8 @@ namespace O3DE::ProjectManager
|
||||
~TagContainerWidget() = default;
|
||||
|
||||
void Update(const QStringList& tags);
|
||||
|
||||
signals:
|
||||
void TagClicked(const QString& tag);
|
||||
};
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
Reference in New Issue
Block a user