You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
4.1 KiB
C++
140 lines
4.1 KiB
C++
/*
|
|
* 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.
|
|
*
|
|
*/
|
|
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
|
|
|
#include "EditorDefs.h"
|
|
|
|
#include "CheckOutDialog.h"
|
|
|
|
// Qt
|
|
#include <QStyle>
|
|
|
|
// AzToolsFramework
|
|
#include <AzToolsFramework/SourceControl/SourceControlAPI.h> // for AzToolsFramework::SourceControlConnectionRequestBus
|
|
|
|
|
|
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
|
#include "ui_CheckOutDialog.h"
|
|
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
|
|
|
|
|
|
|
// CCheckOutDialog dialog
|
|
int CCheckOutDialog::m_lastResult = CCheckOutDialog::CANCEL;
|
|
|
|
CCheckOutDialog::CCheckOutDialog(const QString& file, QWidget* pParent)
|
|
: QDialog(pParent)
|
|
, m_ui(new Ui::CheckOutDialog)
|
|
{
|
|
m_ui->setupUi(this);
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
m_file = file;
|
|
|
|
m_ui->icon->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(m_ui->icon->width()));
|
|
|
|
OnInitDialog();
|
|
|
|
connect(m_ui->buttonCancel, &QPushButton::clicked, this, &CCheckOutDialog::OnBnClickedCancel);
|
|
connect(m_ui->buttonCheckout, &QPushButton::clicked, this, &CCheckOutDialog::OnBnClickedCheckout);
|
|
connect(m_ui->buttonOverwrite, &QPushButton::clicked, this, &CCheckOutDialog::OnBnClickedOverwrite);
|
|
}
|
|
|
|
CCheckOutDialog::~CCheckOutDialog()
|
|
{
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
void CCheckOutDialog::OnBnClickedCancel()
|
|
{
|
|
// Cancel operation
|
|
HandleResult(CANCEL);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// CCheckOutDialog message handlers
|
|
void CCheckOutDialog::OnBnClickedCheckout()
|
|
{
|
|
// Check out this file.
|
|
HandleResult(CHECKOUT);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
void CCheckOutDialog::OnBnClickedOverwrite()
|
|
{
|
|
// Overwrite this file.
|
|
HandleResult(OVERWRITE);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
void CCheckOutDialog::HandleResult(int result)
|
|
{
|
|
m_lastResult = result;
|
|
InstanceIsForAll() = m_ui->chkForAll->isChecked();
|
|
done(result);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
void CCheckOutDialog::OnInitDialog()
|
|
{
|
|
setWindowTitle(tr("Source Control"));
|
|
|
|
using namespace AzToolsFramework;
|
|
SourceControlState state = SourceControlState::Disabled;
|
|
SourceControlConnectionRequestBus::BroadcastResult(state, &SourceControlConnectionRequestBus::Events::GetSourceControlState);
|
|
bool sccAvailable = state == SourceControlState::Active ? true : false;
|
|
|
|
QString text(tr("%1\n\nis read-only, and needs to be writable to continue.").arg(m_file));
|
|
|
|
if (!sccAvailable)
|
|
{
|
|
text.append("\nEnable and connect to source control for more options.");
|
|
}
|
|
|
|
m_ui->m_text->setText(text);
|
|
|
|
m_ui->chkForAll->setEnabled(InstanceEnableForAll());
|
|
m_ui->chkForAll->setChecked(InstanceIsForAll());
|
|
m_ui->buttonCheckout->setEnabled(sccAvailable);
|
|
|
|
adjustSize();
|
|
}
|
|
|
|
//static ////////////////////////////////////////////////////////////////
|
|
bool& CCheckOutDialog::InstanceEnableForAll()
|
|
{
|
|
static bool isEnableForAll = false;
|
|
return isEnableForAll;
|
|
}
|
|
|
|
//static ////////////////////////////////////////////////////////////////
|
|
bool& CCheckOutDialog::InstanceIsForAll()
|
|
{
|
|
static bool isForAll = false;
|
|
return isForAll;
|
|
}
|
|
|
|
//static ////////////////////////////////////////////////////////////////
|
|
bool CCheckOutDialog::EnableForAll(bool isEnable)
|
|
{
|
|
bool bPrevEnable = InstanceEnableForAll();
|
|
InstanceEnableForAll() = isEnable;
|
|
if (!bPrevEnable || !isEnable)
|
|
{
|
|
InstanceIsForAll() = false;
|
|
m_lastResult = CANCEL;
|
|
}
|
|
return bPrevEnable;
|
|
}
|
|
|
|
#include <moc_CheckOutDialog.cpp>
|