/*
 * ImageDescriptionForm.cpp
 *
 *  Created on: Oct 11, 2011
 *      Author: Gapchich Vlad
 */

#include "OptionsForm.h"

#include <QCheckBox>
#include <QPushButton>
#include <QBoxLayout>
#include <QMessageBox>
#include <QApplication>
#include <QDesktopWidget>

OptionsForm::OptionsForm(QWidget *aParent)
	: QWidget(aParent)
{
	setWindowTitle(tr("Options"));

	layout_v_ = new QVBoxLayout(this);
	layout_h_ = new QHBoxLayout;

	auto_color_generation_ = new QCheckBox(this);
	auto_color_generation_->setText(tr("Automatic label color generation"));
	button_ok_ = new QPushButton(this);
	button_ok_->setText(tr("OK"));
	button_cancel_ = new QPushButton(this);
	button_cancel_->setText(tr("Cancel"));

	layout_v_->addWidget(auto_color_generation_);
	layout_v_->addLayout(layout_h_);

	layout_h_->addWidget(button_ok_);
	layout_h_->addWidget(button_cancel_);

	connect(
		button_ok_,
		SIGNAL(clicked()),
		this,
		SLOT(setOptions())
		);
	connect(
		button_cancel_,
		SIGNAL(clicked()),
		this,
		SLOT(hide())
		);

	adjustSize();
	move(QApplication::desktop()->screen()->rect().center() - rect().center());
}

OptionsForm::~OptionsForm()
{
	delete auto_color_generation_;
	delete button_ok_;
	delete button_cancel_;

	delete layout_v_;
}

void
OptionsForm::setOptions()
{
	emit optionsSet();
	hide();
}

bool
OptionsForm::autoColorGeneration()
{
	return auto_color_generation_->isChecked();
}

/*
 *
 */