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:
@@ -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
|
||||
Reference in New Issue
Block a user