#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QBoxLayout>
#include <QColorDialog>
#include <QActionGroup>

namespace {
    Viewer* view;
}

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
	ui(new Ui::MainWindow),
    colordialog(new QColorDialog)
{
    ui->setupUi(this);

    lightTypeGroup = new QActionGroup(this);
    lightTypeGroup->addAction(ui->actionGouraud);
    lightTypeGroup->addAction(ui->actionPhong);

	connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(onColorPickerActivate()));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::addViewer(Viewer* viewer)
{
    QLayout *layout = new QHBoxLayout;
    layout->addWidget(viewer);
    ui->frame->setLayout(layout);

    // actionGouraud shouldn't need one, since they are mutual
    connect(ui->actionPhong, SIGNAL(toggled(bool)), viewer, SLOT(setPhong(bool)));
}

void MainWindow::onColorPickerActivate(){
	colordialog->open();
}
