#include "helpers.h"

QString wstringToQString(std::wstring & original) 
{
	return QString::fromUtf16(original.c_str());
}

void setButtonIcon(QPushButton * button, const std::string & filePath, unsigned int iconSize)
{
	QString applicationPath = QCoreApplication::applicationDirPath();
	QString picturePath = applicationPath + "/" + QString::fromUtf8(filePath.c_str());

	QPixmap pixmap(picturePath.toUtf8().data());
	QIcon icon(pixmap);

	QSize size(iconSize, iconSize);

	button->setIconSize(size);
	button->setIcon(icon);
}

void setButtonIconFromResources(QPushButton * button, const std::string & filePath, unsigned int iconSize)
{
	QIcon icon;
	icon.addFile(QString::fromUtf8(filePath.c_str()));
	QSize size(iconSize, iconSize);

	button->setIconSize(size);
	button->setIcon(icon);
}

QIcon getIcon(const std::string & filePath)
{
	QString applicationPath = QCoreApplication::applicationDirPath();
	QString picturePath = applicationPath + "/" + QString::fromUtf8(filePath.c_str());
	QPixmap pixmap(picturePath.toUtf8().data());
	return QIcon(pixmap);
}