/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #include #include #include #include #include #include #include #include #include #include #include using namespace AZStd; // The URL embedded here isn't expected to be used. See ActiveDeployment::OnSetupDeploymentClicked. static const char* NO_DEPLOYMENTS_LABEL_TEXT = "There aren't any deployments associated with this Lumberyard project. AWS account admins can add new deployments using the Resource Manager." " Learn how to create a deployment. "; static const char* HAS_DEPLOYMENTS_LABEL_TEXT = "AWS account admins can add new deployments using the Resource Manager. Otherwise, authorized users can switch the active deployment here."; static const char* SELECT_DEPLOYMENT_LABEL = "Select deployment"; static const char* PROTECTED_LABEL = " (protected)"; ActiveDeployment::ActiveDeployment(QWidget* parent) : ScrollSelectionDialog(parent) , m_model(GetIEditor()->GetAWSResourceManager()->GetDeploymentModel()) { AzQtComponents::StyleManager::setStyleSheet(this, "style:CloudCanvas.qss"); InitializeWindow(); } void ActiveDeployment::SetupConnections() { connect(&*m_model, &IAWSDeploymentModel::modelReset, this, &ActiveDeployment::OnModelReset); if (GetNoDataLabel()) { connect(GetNoDataLabel(), &QLabel::linkActivated, this, &ActiveDeployment::OnSetupDeploymentClicked); } } void ActiveDeployment::SetupNoDataConnection() { if (GetNoDataLabel()) { connect(GetNoDataLabel(), &QLabel::linkActivated, this, &ActiveDeployment::OnSetupDeploymentClicked); } } void ActiveDeployment::AddScrollHeadings(QVBoxLayout* boxLayout) { QLabel* selectLabel = new QLabel(SELECT_DEPLOYMENT_LABEL); boxLayout->addWidget(selectLabel); } void ActiveDeployment::SetCurrentSelection(QString& selectedText) const { if (selectedText.endsWith(PROTECTED_LABEL)) { int snipIndex = selectedText.lastIndexOf(PROTECTED_LABEL); selectedText = selectedText.left(snipIndex); } m_model->SetUserDefaultDeployment(selectedText); } bool ActiveDeployment::IsSelected(int rowNum) const { return m_model->data(rowNum, AWSDeploymentColumn::Default).value(); } QString ActiveDeployment::GetDataForRow(int rowNum) const { QString returnString; if (rowNum < GetRowCount()) { returnString = m_model->data(rowNum, AWSDeploymentColumn::Name).value(); if (m_model->data(rowNum, AWSDeploymentColumn::Protected).value()) { returnString += PROTECTED_LABEL; } } return returnString; } int ActiveDeployment::GetRowCount() const { return m_model->rowCount(); } const char* ActiveDeployment::GetNoDataText() const { return NO_DEPLOYMENTS_LABEL_TEXT; } const char* ActiveDeployment::GetHasDataText() const { return HAS_DEPLOYMENTS_LABEL_TEXT; } void ActiveDeployment::OnSetupDeploymentClicked() { QDesktopServices::openUrl(QUrl(QString(MaglevControlPanelPlugin::GetDeploymentHelpLink()))); }