<commit_before>#include <ShaderNode/DataModels/ShaderNode.hpp>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QLabel>

ShaderNode::ShaderNode(ShaderGraph& graph) :
m_previewSize(64, 64),
m_pixmapLabel(nullptr),
m_graph(graph),
m_forceVariable(false),
m_isPreviewEnabled(false)
{
	m_pixmapLabel = new QLabel;
	m_pixmapLabel->setStyleSheet("background-color: rgba(0,0,0,0)");
}

void ShaderNode::BuildNodeEdition(QFormLayout* layout)
{
	QCheckBox* checkbox = new QCheckBox;
	checkbox->setCheckState((m_isPreviewEnabled) ? Qt::Checked : Qt::Unchecked);

	connect(checkbox, &QCheckBox::stateChanged, [&](int state)
	{
		EnablePreview(state == Qt::Checked);
	});

	layout->addRow(tr("Enable preview"), checkbox);
}

void ShaderNode::EnablePreview(bool enable)
{<commit_msg>ShaderNode: Add preview size option<commit_after>#include <ShaderNode/DataModels/ShaderNode.hpp>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QLabel>

ShaderNode::ShaderNode(ShaderGraph& graph) :
m_previewSize(64, 64),
m_pixmapLabel(nullptr),
m_graph(graph),
m_forceVariable(false),
m_isPreviewEnabled(false)
{
	m_pixmapLabel = new QLabel;
	m_pixmapLabel->setStyleSheet("background-color: rgba(0,0,0,0)");
}

void ShaderNode::BuildNodeEdition(QFormLayout* layout)
{
	QCheckBox* checkbox = new QCheckBox;
	checkbox->setCheckState((m_isPreviewEnabled) ? Qt::Checked : Qt::Unchecked);

	connect(checkbox, &QCheckBox::stateChanged, [&](int state)
	{
		EnablePreview(state == Qt::Checked);
	});

	layout->addRow(tr("Enable preview"), checkbox);

	QComboBox* previewSize = new QComboBox;

	int index = 0;
	for (int size : { 32, 64, 128, 256, 512 })
	{
		QString sizeStr = QString::number(size);
		previewSize->addItem(sizeStr + "x" + sizeStr, size);

		if (m_previewSize.x == size)
			previewSize->setCurrentIndex(index);

		index++;
	}
	
	connect(previewSize, qOverload<int>(&QComboBox::currentIndexChanged), [=](int index)
	{
		if (index < 0)
			return;

		int size = previewSize->itemData(index).toInt();
		SetPreviewSize({ size, size });
	});

	layout->addRow(tr("Preview size"), previewSize);
}

void ShaderNode::EnablePreview(bool enable)
{
{'fraction_non_alphanumeric': 0.1522707034728406, 'fraction_numerical': 0.013802315227070348, 'mean_word_length': 7.200729927007299, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 24, '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': '1355519', 'n_tokens_mistral': 840, 'n_tokens_neox': 789, 'n_words': 138}