#include "inputDialog.h"	
#include "softProj\settings.h"

void InputDialog::submitButtonClickedSlot(bool checked) {
	emit submitSignal();
	accept();
}

void InputDialog::cancelButtonClickedSlot(bool checked) {
	emit cancelSignal();
	reject();
}

InputDialog::InputDialog(QWidget * parent) : QDialog(parent) {
	ui_.setupUi(this);

	bool connected = true;

	connected = connected && QObject::connect(ui_.submitButton, SIGNAL(clicked(bool)), this, SLOT(submitButtonClickedSlot(bool)));
	connected = connected && QObject::connect(ui_.cancelButton, SIGNAL(clicked(bool)), this, SLOT(cancelButtonClickedSlot(bool)));

	assert(connected && "Signals not connected");
}

void InputDialog::setTitle(const std::wstring & value) {
	ui_.titleLabel->setText(QString::fromUtf16(value.c_str()));
} /**< Sets dialog title. */

void InputDialog::setTitle(const std::string & value) {
	ui_.titleLabel->setText(QString::fromUtf8(value.c_str()));
} /**< Sets dialog title. */

void InputDialog::setMessage(const std::wstring & value) {
	ui_.messageLabel->setText(QString::fromUtf16(value.c_str()));
} /**< Sets dialog message. */

void InputDialog::setMessage(const std::string & value) {
	ui_.messageLabel->setText(QString::fromUtf8(value.c_str()));
} /**< Sets dialog message. */

void InputDialog::setInputLabel(const std::wstring & value) {
	ui_.inputLabel->setText(QString::fromUtf16(value.c_str()));
} /**< Sets input label in dialog. */

void InputDialog::setIcon(const std::string & iconKey) {
	ui_.imageButton->setIcon(Settings::instance().getGameIcon(iconKey));
}

std::string InputDialog::getInputString() const {
	return ui_.inputEdit->text().toUtf8().data();
}