#include "..\Header\MainWindow.h"
#include "..\Header\OpenGlViewer.h"
#include "..\Header\defines.h"
#include <QKeyEvent>
#include <QMessageBox>


/////////////////////////////////////////////////////////////////////////
// constructor/destructor

MainWindow::MainWindow(QWidget *parent)
	: QMainWindow(parent)
	, ui (new Ui::MainWindowClass)
{
	setupWindow();
}

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


/////////////////////////////////////////////////////////////////////////
// private functions

void MainWindow::setupWindow()
{
	ui->setupUi(this);

	this->setWindowTitle(WINDOW_NAME);
	this->setWindowIcon(QIcon(":/MainWindow/icon.ico"));
	this->resize(WINDOW_WIDTH, WINDOW_HEIGHT);

	this->setCentralWidget(new OpenGlViewer(this));

	ui->mainToolBar->addAction("File Info", this, &MainWindow::aboutFile);

	ui->statusBar->showMessage(DEFAULT_STATUS_MESSAGE);
}


/////////////////////////////////////////////////////////////////////////
// private slots

void MainWindow::openFile()
{
	//TODO: Open file
}

void MainWindow::aboutFile()
{
	//TODO: Open Window with file information
	QMessageBox* dialog = new QMessageBox(QMessageBox::Information, WINDOW_NAME, "File Info", QMessageBox::StandardButton::Close, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
	dialog->setDetailedText("This is the cool detailed text\n");
	dialog->exec();
}


/////////////////////////////////////////////////////////////////////////
// events

void MainWindow::keyPressEvent(QKeyEvent * keyEvent)
{
	switch (keyEvent->key())
	{
	case Qt::Key::Key_Escape:
		close();
		break;
	}

	QMainWindow::keyPressEvent(keyEvent);
}
