Files
o3de/Code/Tools/ProjectManager/Source/TemplateButtonWidget.cpp
T
Alex Peterson 2a3c2b67cc Prism/fix create project bugs (#7539)
* Don't show ${Name} gems and fix template names

Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>

* Fix overlay size so it doesn't overlap parent border

Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>

* Hide warning when building

Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>

* Fix gem download fail due to param type change

Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>

* Restore missing functionionality for gem repos

Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>

* Use the parent's width for the gem inspector

Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>

* Restore regressed code for gem repos and folders

Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>

* Revert home folder override

Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>
2022-02-11 12:23:10 -08:00

63 lines
1.8 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <TemplateButtonWidget.h>
#include <ProjectManagerDefs.h>
#include <QVBoxLayout>
#include <QLabel>
#include <QPixmap>
#include <QAbstractButton>
#include <QStyle>
#include <QVariant>
namespace O3DE::ProjectManager
{
TemplateButton::TemplateButton(const QString& imagePath, const QString& labelText, QWidget* parent)
: QPushButton(parent)
{
setAutoExclusive(true);
setObjectName("templateButton");
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->setSpacing(0);
vLayout->setContentsMargins(0, 0, 0, 0);
setLayout(vLayout);
QLabel* image = new QLabel(this);
image->setObjectName("templateImage");
image->setPixmap(QPixmap(imagePath).scaled(
QSize(ProjectTemplateImageWidth, ProjectTemplateImageWidth), Qt::KeepAspectRatio, Qt::SmoothTransformation));
vLayout->addWidget(image);
QLabel* label = new QLabel(labelText, this);
label->setObjectName("templateLabel");
label->setWordWrap(true);
vLayout->addWidget(label);
connect(this, &QAbstractButton::toggled, this, &TemplateButton::onToggled);
}
void TemplateButton::onToggled()
{
setProperty("Checked", isChecked());
// we must unpolish/polish every child after changing a property
// or else they won't use the correct stylesheet selector
for (auto child : findChildren<QWidget*>())
{
child->style()->unpolish(child);
child->style()->polish(child);
}
style()->unpolish(this);
style()->polish(this);
}
} // namespace O3DE::ProjectManager