Add no repositories added screen

Signed-off-by: nggieber <nggieber@amazon.com>
monroegm-disable-blank-issue-2
nggieber 4 years ago
parent 04ee676e2f
commit e76ed67e95

@ -556,17 +556,20 @@ QProgressBar::chunk {
font-size: 12px;
}
#gemRepoNoReposLabel {
font-size: 16px;
}
#gemRepoHeaderRefreshButton {
background-color: transparent;
qproperty-flat: true;
qproperty-iconSize: 14px;
}
#gemRepoHeaderAddButton {
#gemRepoAddButton {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #888888, stop: 1.0 #555555);
qproperty-flat: true;
margin-right:30px;
min-width:120px;
max-width:120px;
min-height:24px;
@ -576,11 +579,11 @@ QProgressBar::chunk {
font-size:12px;
font-weight:600;
}
#gemRepoHeaderAddButton:hover {
#gemRepoAddButton:hover {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #999999, stop: 1.0 #666666);
}
#gemRepoHeaderAddButton:pressed {
#gemRepoAddButton:pressed {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #555555, stop: 1.0 #777777);
}

@ -0,0 +1,18 @@
/*
* 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 <GemRepo/GemRepoAddDialog.h>
namespace O3DE::ProjectManager
{
GemRepoAddDialog::GemRepoAddDialog(QWidget* parent)
: QDialog(parent)
{
}
} // namespace O3DE::ProjectManager

@ -0,0 +1,24 @@
/*
* 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
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <QDialog.h>
#endif
namespace O3DE::ProjectManager
{
class GemRepoAddDialog
: public QDialog
{
public:
explicit GemRepoAddDialog(QWidget* parent = nullptr);
~GemRepoAddDialog() = default;
};
} // namespace O3DE::ProjectManager

@ -20,6 +20,8 @@
#include <QLabel>
#include <QHeaderView>
#include <QTableWidget>
#include <QFrame>
#include <QStackedWidget>
namespace O3DE::ProjectManager
{
@ -33,11 +35,108 @@ namespace O3DE::ProjectManager
vLayout->setSpacing(0);
setLayout(vLayout);
m_contentStack = new QStackedWidget(this);
m_noRepoContent = CreateNoReposContent();
m_contentStack->addWidget(m_noRepoContent);
m_repoContent = CreateReposContent();
m_contentStack->addWidget(m_repoContent);
vLayout->addWidget(m_contentStack);
Reinit();
}
void GemRepoScreen::Reinit()
{
m_gemRepoModel->clear();
FillModel();
// If model contains any data show the repos
if (m_gemRepoModel->rowCount())
{
m_contentStack->setCurrentWidget(m_repoContent);
}
else
{
m_contentStack->setCurrentWidget(m_noRepoContent);
}
// Select the first entry after everything got correctly sized
QTimer::singleShot(200, [=]{
QModelIndex firstModelIndex = m_gemRepoListView->model()->index(0,0);
m_gemRepoListView->selectionModel()->select(firstModelIndex, QItemSelectionModel::ClearAndSelect);
});
}
void GemRepoScreen::FillModel()
{
AZ::Outcome<QVector<GemRepoInfo>, AZStd::string> allGemRepoInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoInfos();
if (allGemRepoInfosResult.IsSuccess())
{
// Add all available repos to the model
const QVector<GemRepoInfo> allGemRepoInfos = allGemRepoInfosResult.GetValue();
for (const GemRepoInfo& gemRepoInfo : allGemRepoInfos)
{
m_gemRepoModel->AddGemRepo(gemRepoInfo);
}
}
else
{
QMessageBox::critical(this, tr("Operation failed"), QString("Cannot retrieve gem repos for engine.\n\nError:\n%2").arg(allGemRepoInfosResult.GetError().c_str()));
}
}
QFrame* GemRepoScreen::CreateNoReposContent()
{
QFrame* contentFrame = new QFrame(this);
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->setAlignment(Qt::AlignHCenter);
vLayout->setMargin(0);
vLayout->setSpacing(0);
contentFrame->setLayout(vLayout);
vLayout->addStretch();
QLabel* noRepoLabel = new QLabel(tr("No repositories have been added yet."), this);
noRepoLabel->setObjectName("gemRepoNoReposLabel");
vLayout->addWidget(noRepoLabel);
vLayout->setAlignment(noRepoLabel, Qt::AlignHCenter);
vLayout->addSpacing(20);
// Size hint for button is wrong so horizontal layout with stretch is used to center it
QHBoxLayout* hLayout = new QHBoxLayout();
hLayout->setMargin(0);
hLayout->setSpacing(0);
hLayout->addStretch();
m_AddRepoButton = new QPushButton(tr("Add Repository"), this);
m_AddRepoButton->setObjectName("gemRepoAddButton");
m_AddRepoButton->setMinimumWidth(120);
hLayout->addWidget(m_AddRepoButton);
hLayout->addStretch();
vLayout->addLayout(hLayout);
vLayout->addStretch();
return contentFrame;
}
QFrame* GemRepoScreen::CreateReposContent()
{
QFrame* contentFrame = new QFrame(this);
QHBoxLayout* hLayout = new QHBoxLayout();
hLayout->setMargin(0);
hLayout->setSpacing(0);
contentFrame->setLayout(hLayout);
hLayout->addSpacing(60);
m_gemRepoInspector = new QFrame(this);
@ -67,9 +166,11 @@ namespace O3DE::ProjectManager
topMiddleHLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
m_AddRepoButton = new QPushButton(tr("Add Repository"), this);
m_AddRepoButton->setObjectName("gemRepoHeaderAddButton");
m_AddRepoButton->setObjectName("gemRepoAddButton");
topMiddleHLayout->addWidget(m_AddRepoButton);
topMiddleHLayout->addSpacing(30);
middleVLayout->addLayout(topMiddleHLayout);
middleVLayout->addSpacing(30);
@ -105,37 +206,7 @@ namespace O3DE::ProjectManager
hLayout->addLayout(middleVLayout);
hLayout->addWidget(m_gemRepoInspector);
Reinit();
}
void GemRepoScreen::Reinit()
{
m_gemRepoModel->clear();
FillModel();
// Select the first entry after everything got correctly sized
QTimer::singleShot(200, [=]{
QModelIndex firstModelIndex = m_gemRepoListView->model()->index(0,0);
m_gemRepoListView->selectionModel()->select(firstModelIndex, QItemSelectionModel::ClearAndSelect);
});
}
void GemRepoScreen::FillModel()
{
AZ::Outcome<QVector<GemRepoInfo>, AZStd::string> allGemRepoInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoInfos();
if (allGemRepoInfosResult.IsSuccess())
{
// Add all available repos to the model
const QVector<GemRepoInfo> allGemRepoInfos = allGemRepoInfosResult.GetValue();
for (const GemRepoInfo& gemRepoInfo : allGemRepoInfos)
{
m_gemRepoModel->AddGemRepo(gemRepoInfo);
}
}
else
{
QMessageBox::critical(this, tr("Operation failed"), QString("Cannot retrieve gem repos for engine.\n\nError:\n%2").arg(allGemRepoInfosResult.GetError().c_str()));
}
return contentFrame;
}
ProjectManagerScreen GemRepoScreen::GetScreenEnum()

@ -16,6 +16,8 @@ QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QPushButton)
QT_FORWARD_DECLARE_CLASS(QHeaderView)
QT_FORWARD_DECLARE_CLASS(QTableWidget)
QT_FORWARD_DECLARE_CLASS(QFrame)
QT_FORWARD_DECLARE_CLASS(QStackedWidget)
namespace O3DE::ProjectManager
{
@ -36,6 +38,12 @@ namespace O3DE::ProjectManager
private:
void FillModel();
QFrame* CreateNoReposContent();
QFrame* CreateReposContent();
QStackedWidget* m_contentStack = nullptr;
QFrame* m_noRepoContent;
QFrame* m_repoContent;
QTableWidget* m_gemRepoHeaderTable = nullptr;
QHeaderView* m_gemRepoListHeader = nullptr;

@ -102,6 +102,8 @@ set(FILES
Source/GemCatalog/GemSortFilterProxyModel.cpp
Source/GemRepo/GemRepoScreen.h
Source/GemRepo/GemRepoScreen.cpp
Source/GemRepo/GemRepoAddDialog.h
Source/GemRepo/GemRepoAddDialog.cpp
Source/GemRepo/GemRepoInfo.h
Source/GemRepo/GemRepoInfo.cpp
Source/GemRepo/GemRepoItemDelegate.h

Loading…
Cancel
Save