<commit_before>#include "extlineedit.h"
#include <QPushButton>
#include <QIcon>
#include <QPropertyAnimation>
#include <QSignalTransition>


CExtLineEdit::CExtLineEdit(QWidget* parent)
    : QLineEdit(parent)
    , m_animated(true)
    , m_animationDurationMS(500)
    , m_clearButton(new QPushButton(this))
    , m_textStateMachine(new QStateMachine(this))
    , m_textNotEmptyState(new QState(m_textStateMachine))
    , m_textEmptyState(new QState(m_textStateMachine))
    , m_animHideClearButton(new QPropertyAnimation(m_clearButton, "pos"))
    , m_animShowClearButton(new QPropertyAnimation(m_clearButton, "pos"))
{
    QPixmap buttonImage(":/Icon/remove_16.png");
    QIcon icon;
    icon.addPixmap(buttonImage, QIcon::Normal, QIcon::Off);

    m_clearButton->setFlat(true);
    m_clearButton->setIcon(icon);
    m_clearButton->setFocusPolicy(Qt::NoFocus);    
    m_clearButton->setCursor(Qt::ArrowCursor);

    m_animHideClearButton->setDuration(m_animationDurationMS);
    m_animHideClearButton->setEasingCurve(QEasingCurve::OutExpo);
    m_animShowClearButton->setDuration(m_animationDurationMS);
    m_animShowClearButton->setEasingCurve(QEasingCurve::OutBounce);

    // Note on the StateMachine:
    // Propertyassignment is added in CExtLineEdit::layoutClearButton()
    // because we don't no the size of the button here.
    // Starting of the the StateMachine is also done in CExtLineEdit::layoutClearButton().
    QSignalTransition *transition;
    transition = m_textNotEmptyState->addTransition(this, SIGNAL(textEmptyToggled()), m_textEmptyState);
    transition->addAnimation(m_animHideClearButton);

    transition = m_textEmptyState->addTransition(this, SIGNAL(textEmptyToggled()), m_textNotEmptyState);
    transition->addAnimation(m_animShowClearButton);

    connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clear()));
    connect(this, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged(QString)));
}


bool CExtLineEdit::isAnimated()
{
    return m_animated;
}

void CExtLineEdit::setAnimated(bool animate)
{
    m_animated = animate;
    if ( m_animated ) {
        m_animHideClearButton->setDuration(m_animationDurationMS);
        m_animShowClearButton->setDuration(m_animationDurationMS);
    } else {<commit_msg>Fixed typo<commit_after>#include "extlineedit.h"
#include <QPushButton>
#include <QIcon>
#include <QPropertyAnimation>
#include <QSignalTransition>


CExtLineEdit::CExtLineEdit(QWidget* parent)
    : QLineEdit(parent)
    , m_animated(true)
    , m_animationDurationMS(500)
    , m_clearButton(new QPushButton(this))
    , m_textStateMachine(new QStateMachine(this))
    , m_textNotEmptyState(new QState(m_textStateMachine))
    , m_textEmptyState(new QState(m_textStateMachine))
    , m_animHideClearButton(new QPropertyAnimation(m_clearButton, "pos"))
    , m_animShowClearButton(new QPropertyAnimation(m_clearButton, "pos"))
{
    QPixmap buttonImage(":/Icon/remove_16.png");
    QIcon icon;
    icon.addPixmap(buttonImage, QIcon::Normal, QIcon::Off);

    m_clearButton->setFlat(true);
    m_clearButton->setIcon(icon);
    m_clearButton->setFocusPolicy(Qt::NoFocus);    
    m_clearButton->setCursor(Qt::ArrowCursor);

    m_animHideClearButton->setDuration(m_animationDurationMS);
    m_animHideClearButton->setEasingCurve(QEasingCurve::OutExpo);
    m_animShowClearButton->setDuration(m_animationDurationMS);
    m_animShowClearButton->setEasingCurve(QEasingCurve::OutBounce);

    // Note on the StateMachine:
    // Propertyassignment is added in CExtLineEdit::layoutClearButton()
    // because we don't know the size of the button here.
    // Starting of the the StateMachine is also done in CExtLineEdit::layoutClearButton().
    QSignalTransition *transition;
    transition = m_textNotEmptyState->addTransition(this, SIGNAL(textEmptyToggled()), m_textEmptyState);
    transition->addAnimation(m_animHideClearButton);

    transition = m_textEmptyState->addTransition(this, SIGNAL(textEmptyToggled()), m_textNotEmptyState);
    transition->addAnimation(m_animShowClearButton);

    connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clear()));
    connect(this, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged(QString)));
}


bool CExtLineEdit::isAnimated()
{
    return m_animated;
}

void CExtLineEdit::setAnimated(bool animate)
{
    m_animated = animate;
    if ( m_animated ) {
        m_animHideClearButton->setDuration(m_animationDurationMS);
        m_animShowClearButton->setDuration(m_animationDurationMS);
    } else {
{'fraction_non_alphanumeric': 0.11187569367369589, 'fraction_numerical': 0.0022197558268590455, 'mean_word_length': 5.786144578313253, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6562719', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1434, 'n_words': 215}