<commit_before>#include "contextpanewidget.h"
#include <coreplugin/icore.h>
#include <QFontComboBox>
#include <QComboBox>
#include <QSpinBox>
#include <QToolButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QMouseEvent>
#include <QGridLayout>
#include <QToolButton>
#include <QAction>
#include <qmldesignerplugin.h>
#include "colorwidget.h"
#include "contextpanetextwidget.h"


namespace QmlDesigner {

ContextPaneWidget::ContextPaneWidget(QWidget *parent) : QFrame(parent), m_currentWidget(0), m_xPos(-1)
{
    setFrameStyle(QFrame::NoFrame);
    setFrameShape(QFrame::StyledPanel);
    setFrameShadow(QFrame::Sunken);
    m_oldPos = QPoint(-1, -1);

    m_dropShadowEffect = new QGraphicsDropShadowEffect;
    m_dropShadowEffect->setBlurRadius(6);
    m_dropShadowEffect->setOffset(2, 2);
    setGraphicsEffect(m_dropShadowEffect);

    QGridLayout *layout = new QGridLayout(this);
    layout->setMargin(2);
    layout->setContentsMargins(2, 4, 2, 2);
    QToolButton *toolButton = new QToolButton(this);    
    QIcon icon(style()->standardIcon(QStyle::SP_DockWidgetCloseButton));
    toolButton->setIcon(icon);
    toolButton->setToolButtonStyle(Qt::ToolButtonIconOnly);    
    toolButton->setFixedSize(icon.availableSizes().first() + QSize(4, 4));
    connect(toolButton, SIGNAL(clicked()), this, SLOT(onTogglePane()));
    layout->addWidget(toolButton, 0, 0, 1, 1);
    colorDialog();

    QWidget *fontWidget = createFontWidget();
    m_currentWidget = fontWidget;
    layout->addWidget(fontWidget, 0, 1, 2, 1);
    setAutoFillBackground(true);
    setContextMenuPolicy(Qt::ActionsContextMenu);

    QAction *resetAction = new QAction(tr("Reset position"), this);
    addAction(resetAction);
    connect(resetAction, SIGNAL(triggered()), this, SLOT(onResetPosition()));

    QAction *disableAction = new QAction(tr("Disable permanently"), this);
    addAction(disableAction);
    connect(disableAction, SIGNAL(triggered()), this, SLOT(onDisable())); 
}

ContextPaneWidget::~ContextPaneWidget()
{
    //if the pane was never activated the widget is not in a widget tree
    if (!m_bauhausColorDialog.isNull())
        delete m_bauhausColorDialog.data();
        m_bauhausColorDialog.clear();
}

void ContextPaneWidget::activate(const QPoint &pos, const QPoint &alternative)
{
    //uncheck all color buttons
    foreach (ColorButton *colorButton, findChildren<ColorButton*>()) {
            colorButton->setChecked(false);
    }
    resize(sizeHint());
    show();
    rePosition(pos, alternative);
    raise();
}

void ContextPaneWidget::rePosition(const QPoint &position, const QPoint &alternative)
{
    if (position.y() > 0)
        move(position);
    else
        move(alternative);

    m_originalPos = pos();
    if (m_xPos > 0)
        move(m_xPos, pos().y());
}

void ContextPaneWidget::deactivate()
{
    hide();
    if (m_bauhausColorDialog)<commit_msg>QmlDesigner.contextPane: do not remeber position<commit_after>#include "contextpanewidget.h"
#include <coreplugin/icore.h>
#include <QFontComboBox>
#include <QComboBox>
#include <QSpinBox>
#include <QToolButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QMouseEvent>
#include <QGridLayout>
#include <QToolButton>
#include <QAction>
#include <qmldesignerplugin.h>
#include "colorwidget.h"
#include "contextpanetextwidget.h"


namespace QmlDesigner {

ContextPaneWidget::ContextPaneWidget(QWidget *parent) : QFrame(parent), m_currentWidget(0), m_xPos(-1)
{
    setFrameStyle(QFrame::NoFrame);
    setFrameShape(QFrame::StyledPanel);
    setFrameShadow(QFrame::Sunken);
    m_oldPos = QPoint(-1, -1);

    m_dropShadowEffect = new QGraphicsDropShadowEffect;
    m_dropShadowEffect->setBlurRadius(6);
    m_dropShadowEffect->setOffset(2, 2);
    setGraphicsEffect(m_dropShadowEffect);

    QGridLayout *layout = new QGridLayout(this);
    layout->setMargin(2);
    layout->setContentsMargins(2, 4, 2, 2);
    QToolButton *toolButton = new QToolButton(this);    
    QIcon icon(style()->standardIcon(QStyle::SP_DockWidgetCloseButton));
    toolButton->setIcon(icon);
    toolButton->setToolButtonStyle(Qt::ToolButtonIconOnly);    
    toolButton->setFixedSize(icon.availableSizes().first() + QSize(4, 4));
    connect(toolButton, SIGNAL(clicked()), this, SLOT(onTogglePane()));
    layout->addWidget(toolButton, 0, 0, 1, 1);
    colorDialog();

    QWidget *fontWidget = createFontWidget();
    m_currentWidget = fontWidget;
    layout->addWidget(fontWidget, 0, 1, 2, 1);
    setAutoFillBackground(true);
    setContextMenuPolicy(Qt::ActionsContextMenu);

    QAction *resetAction = new QAction(tr("Reset position"), this);
    addAction(resetAction);
    connect(resetAction, SIGNAL(triggered()), this, SLOT(onResetPosition()));

    QAction *disableAction = new QAction(tr("Disable permanently"), this);
    addAction(disableAction);
    connect(disableAction, SIGNAL(triggered()), this, SLOT(onDisable())); 
}

ContextPaneWidget::~ContextPaneWidget()
{
    //if the pane was never activated the widget is not in a widget tree
    if (!m_bauhausColorDialog.isNull())
        delete m_bauhausColorDialog.data();
        m_bauhausColorDialog.clear();
}

void ContextPaneWidget::activate(const QPoint &pos, const QPoint &alternative, const QPoint &alternative2)
{
    //uncheck all color buttons
    foreach (ColorButton *colorButton, findChildren<ColorButton*>()) {
            colorButton->setChecked(false);
    }
    resize(sizeHint());
    show();
    rePosition(pos, alternative, alternative2);
    raise();
}

void ContextPaneWidget::rePosition(const QPoint &position, const QPoint &alternative, const QPoint &alternative2)
{
    if ((position.x()  + width()) < parentWidget()->width())
        move(position);
    else
        move(alternative);

    if (pos().y() < 0)
        move(alternative2);
}

void ContextPaneWidget::deactivate()
{
    hide();
    if (m_bauhausColorDialog)
{'fraction_non_alphanumeric': 0.13397533367122824, 'fraction_numerical': 0.008616320324379118, 'mean_word_length': 4.973763874873865, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 56, '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': '2771050', 'n_tokens_mistral': 1923, 'n_tokens_neox': 1872, 'n_words': 372}