<commit_before>#include <QPaintEvent>
#include <QPainter>
#include "QBouton.h"



QBouton::QBouton(QVariant id, bool resizeInsteadOfCropping, int border, QColor color, QWidget *parent)
	: QPushButton(parent), _id(id), _resizeInsteadOfCropping(resizeInsteadOfCropping), _np(false), _originalSize(QSize(-1,-1)), _penColor(color), _border(border)
{ }

QBouton::~QBouton()
{ }

void QBouton::scale(QPixmap image, float scale)
{
	if (scale > 1.00001f)
	{
		QSize size = image.size() * scale;
		setIcon(image.scaled(size));
		setIconSize(size);
	}
	else
	{
		setIcon(image);
		setIconSize(image.size());
	}
}

QVariant QBouton::id()
{ return _id; }
void QBouton::setId(QVariant id)
{ _id = id; }

void QBouton::paintEvent(QPaintEvent *event)
{
	QRect region = event->rect();
	int p = _border, x = region.x(), y = region.y(), w = iconSize().width(), h = iconSize().height();

	// Ignore invalid images
	if (w == 0 || h == 0)
		return;

	QPainter painter(this);

	// Calculate ratio to resize by keeping proportions
	if (_resizeInsteadOfCropping)
	{
		float coef = qMin(1.0f, qMin(float(region.width()) / float(w), float(region.height()) / float(h)));
		w *= coef;
		h *= coef;
	}
	// Center the image
	x += (region.width() - w) / 2;
	y += (region.height() - h) / 2;<commit_msg>Fix buttons in source window<commit_after>#include <QPaintEvent>
#include <QPainter>
#include "QBouton.h"



QBouton::QBouton(QVariant id, bool resizeInsteadOfCropping, int border, QColor color, QWidget *parent)
	: QPushButton(parent), _id(id), _resizeInsteadOfCropping(resizeInsteadOfCropping), _np(false), _originalSize(QSize(-1,-1)), _penColor(color), _border(border)
{ }

QBouton::~QBouton()
{ }

void QBouton::scale(QPixmap image, float scale)
{
	if (scale > 1.00001f)
	{
		QSize size = image.size() * scale;
		setIcon(image.scaled(size));
		setIconSize(size);
	}
	else
	{
		setIcon(image);
		setIconSize(image.size());
	}
}

QVariant QBouton::id()
{ return _id; }
void QBouton::setId(QVariant id)
{ _id = id; }

void QBouton::paintEvent(QPaintEvent *event)
{
	// Used for normal buttons
	if (!_resizeInsteadOfCropping && _border == 0)
	{
		QPushButton::paintEvent(event);
		return;
	}

	QRect region = event->rect();
	int p = _border, x = region.x(), y = region.y(), w = iconSize().width(), h = iconSize().height();

	// Ignore invalid images
	if (w == 0 || h == 0)
		return;

	QPainter painter(this);

	// Calculate ratio to resize by keeping proportions
	if (_resizeInsteadOfCropping)
	{
		float coef = qMin(1.0f, qMin(float(region.width()) / float(w), float(region.height()) / float(h)));
		w *= coef;
		h *= coef;
	}
	// Center the image
	x += (region.width() - w) / 2;
	y += (region.height() - h) / 2;
{'fraction_non_alphanumeric': 0.17188665175242357, 'fraction_numerical': 0.01081282624906786, 'mean_word_length': 4.486707566462168, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '2440609', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1022, 'n_words': 231}