Removed legacy QtUi/ClickableLabel and re-worked about dialog to use QLabel for terms of use label
Signed-off-by: Chris Galvan <chgalvan@amazon.com>
This commit is contained in:
@@ -30,8 +30,6 @@ CAboutDialog::CAboutDialog(QString versionText, QString richTextCopyrightNotice,
|
||||
m_ui->setupUi(this);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
connect(m_ui->m_transparentAgreement, &QLabel::linkActivated, this, &CAboutDialog::OnCustomerAgreement);
|
||||
|
||||
m_ui->m_transparentTrademarks->setText(versionText);
|
||||
|
||||
m_ui->m_transparentAllRightReserved->setObjectName("copyrightNotice");
|
||||
@@ -84,9 +82,4 @@ void CAboutDialog::mouseReleaseEvent(QMouseEvent* event)
|
||||
QDialog::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void CAboutDialog::OnCustomerAgreement()
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(QStringLiteral("https://www.o3debinaries.org/license")));
|
||||
}
|
||||
|
||||
#include <moc_AboutDialog.cpp>
|
||||
|
||||
@@ -30,8 +30,6 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void OnCustomerAgreement();
|
||||
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
|
||||
@@ -181,14 +181,17 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ClickableLabel" name="m_transparentAgreement">
|
||||
<widget class="QLabel" name="m_transparentAgreement">
|
||||
<property name="text">
|
||||
<string>Terms of Use</string>
|
||||
<string><a href="https://www.o3debinaries.org/license">Terms of Use</a></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="showDecoration" stdset="0">
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -274,11 +277,6 @@
|
||||
<extends>QWidget</extends>
|
||||
<header>qsvgwidget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ClickableLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>QtUI/ClickableLabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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 "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <QtUI/ClickableLabel.h>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
using namespace AZ;
|
||||
using namespace ::testing;
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class TestingClickableLabel
|
||||
: public ScopedAllocatorSetupFixture
|
||||
{
|
||||
public:
|
||||
ClickableLabel m_clickableLabel;
|
||||
};
|
||||
|
||||
TEST_F(TestingClickableLabel, CursorDoesNotUpdateWhileDisabled)
|
||||
{
|
||||
m_clickableLabel.setEnabled(false);
|
||||
|
||||
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
|
||||
QEnterEvent enterEvent{ QPointF(), QPointF(), QPointF() };
|
||||
QApplication::sendEvent(&m_clickableLabel, &enterEvent);
|
||||
|
||||
const Qt::CursorShape cursorShape = QApplication::overrideCursor()->shape();
|
||||
EXPECT_THAT(cursorShape, Ne(Qt::PointingHandCursor));
|
||||
EXPECT_THAT(cursorShape, Eq(Qt::BlankCursor));
|
||||
}
|
||||
|
||||
TEST_F(TestingClickableLabel, DoesNotRespondToDblClickWhileDisabled)
|
||||
{
|
||||
m_clickableLabel.setEnabled(false);
|
||||
|
||||
bool linkActivated = false;
|
||||
QObject::connect(&m_clickableLabel, &QLabel::linkActivated, [&linkActivated]()
|
||||
{
|
||||
linkActivated = true;
|
||||
});
|
||||
|
||||
QMouseEvent mouseEvent {
|
||||
QEvent::MouseButtonDblClick, QPointF(),
|
||||
Qt::LeftButton, Qt::LeftButton, Qt::NoModifier };
|
||||
QApplication::sendEvent(&m_clickableLabel, &mouseEvent);
|
||||
|
||||
EXPECT_THAT(linkActivated, Eq(false));
|
||||
}
|
||||
} // namespace UnitTest
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* 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 "EditorDefs.h"
|
||||
|
||||
#include "ClickableLabel.h"
|
||||
|
||||
|
||||
ClickableLabel::ClickableLabel(const QString& text, QWidget* parent)
|
||||
: QLabel(parent)
|
||||
, m_text(text)
|
||||
, m_showDecoration(false)
|
||||
{
|
||||
setTextFormat(Qt::RichText);
|
||||
setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
}
|
||||
|
||||
ClickableLabel::ClickableLabel(QWidget* parent)
|
||||
: QLabel(parent)
|
||||
, m_showDecoration(false)
|
||||
{
|
||||
setTextFormat(Qt::RichText);
|
||||
setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
}
|
||||
|
||||
void ClickableLabel::showEvent([[maybe_unused]] QShowEvent* event)
|
||||
{
|
||||
updateFormatting(false);
|
||||
}
|
||||
|
||||
void ClickableLabel::enterEvent(QEvent* ev)
|
||||
{
|
||||
if (!isEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
updateFormatting(true);
|
||||
QApplication::setOverrideCursor(QCursor(Qt::PointingHandCursor));
|
||||
QLabel::enterEvent(ev);
|
||||
}
|
||||
|
||||
void ClickableLabel::leaveEvent(QEvent* ev)
|
||||
{
|
||||
if (!isEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
updateFormatting(false);
|
||||
QApplication::restoreOverrideCursor();
|
||||
QLabel::leaveEvent(ev);
|
||||
}
|
||||
|
||||
void ClickableLabel::setText(const QString& text)
|
||||
{
|
||||
m_text = text;
|
||||
QLabel::setText(text);
|
||||
updateFormatting(false);
|
||||
}
|
||||
|
||||
void ClickableLabel::setShowDecoration(bool b)
|
||||
{
|
||||
m_showDecoration = b;
|
||||
updateFormatting(false);
|
||||
}
|
||||
|
||||
void ClickableLabel::updateFormatting(bool mouseOver)
|
||||
{
|
||||
//FIXME: this should be done differently. Using a style sheet would be easiest.
|
||||
|
||||
QColor c = palette().color(QPalette::WindowText);
|
||||
if (mouseOver || m_showDecoration)
|
||||
{
|
||||
QLabel::setText(QString(R"(<a href="dummy" style="color: %1";>%2</a>)").arg(c.name(), m_text));
|
||||
}
|
||||
else
|
||||
{
|
||||
QLabel::setText(m_text);
|
||||
}
|
||||
}
|
||||
|
||||
bool ClickableLabel::event(QEvent* e)
|
||||
{
|
||||
if (isEnabled())
|
||||
{
|
||||
if (e->type() == QEvent::MouseButtonDblClick)
|
||||
{
|
||||
emit linkActivated(QString());
|
||||
return true; //ignore
|
||||
}
|
||||
}
|
||||
|
||||
return QLabel::event(e);
|
||||
}
|
||||
|
||||
#include <QtUI/moc_ClickableLabel.cpp>
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
#ifndef CRYINCLUDE_EDITORCOMMON_CLICKABLELABEL_H
|
||||
#define CRYINCLUDE_EDITORCOMMON_CLICKABLELABEL_H
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QLabel>
|
||||
#endif
|
||||
|
||||
class SANDBOX_API ClickableLabel
|
||||
: public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ClickableLabel(const QString& text, QWidget* parent = nullptr);
|
||||
explicit ClickableLabel(QWidget* parent = nullptr);
|
||||
bool event(QEvent* e) override;
|
||||
|
||||
void setText(const QString& text);
|
||||
void setShowDecoration(bool b);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
void enterEvent(QEvent* ev) override;
|
||||
void leaveEvent(QEvent* ev) override;
|
||||
|
||||
private:
|
||||
void updateFormatting(bool mouseOver);
|
||||
QString m_text;
|
||||
bool m_showDecoration;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -526,8 +526,6 @@ set(FILES
|
||||
PythonEditorFuncs.h
|
||||
QtUI/QCollapsibleGroupBox.h
|
||||
QtUI/QCollapsibleGroupBox.cpp
|
||||
QtUI/ClickableLabel.h
|
||||
QtUI/ClickableLabel.cpp
|
||||
QtUI/PixmapLabelPreview.h
|
||||
QtUI/PixmapLabelPreview.cpp
|
||||
QtUI/WaitCursor.h
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
set(FILES
|
||||
Lib/Tests/IEditorMock.h
|
||||
Lib/Tests/test_ClickableLabel.cpp
|
||||
Lib/Tests/test_CryEditPythonBindings.cpp
|
||||
Lib/Tests/test_CryEditDocPythonBindings.cpp
|
||||
Lib/Tests/test_EditorPythonBindings.cpp
|
||||
|
||||
Reference in New Issue
Block a user