MainWindow.cpp 1.55 KB
Newer Older
Anakin's avatar
Anakin committed
1 2 3 4
#include "MainWindow.h"
#include "OpenGlViewer.h"
#include "defines.h"
#include <QKeyEvent>
Anakin's avatar
Anakin committed
5
#include <QMessageBox>
Anakin's avatar
Anakin committed
6 7


Anakin's avatar
Anakin committed
8 9 10
/////////////////////////////////////////////////////////////////////////
// constructor/destructor

Anakin's avatar
Anakin committed
11 12 13 14 15 16 17 18 19 20 21 22
MainWindow::MainWindow(QWidget *parent)
	: QMainWindow(parent)
	, ui (new Ui::MainWindowClass)
{
	setupWindow();
}

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

Anakin's avatar
Anakin committed
23 24 25 26

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

Anakin's avatar
Anakin committed
27 28 29 30 31 32 33 34 35 36
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));

Anakin's avatar
Anakin committed
37 38
	ui->mainToolBar->addAction("File Info", this, &MainWindow::aboutFile);

Anakin's avatar
Anakin committed
39
	ui->statusBar->showMessage(DEFAULT_STATUS_MESSAGE);
Anakin's avatar
Anakin committed
40 41
}

Anakin's avatar
Anakin committed
42

Anakin's avatar
Anakin committed
43 44
/////////////////////////////////////////////////////////////////////////
// private slots
Anakin's avatar
Anakin committed
45

Anakin's avatar
Anakin committed
46 47 48 49 50 51 52 53 54 55 56
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();
Anakin's avatar
Anakin committed
57 58
}

Anakin's avatar
Anakin committed
59 60 61 62

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

Anakin's avatar
Anakin committed
63 64 65 66 67 68 69 70 71 72 73
void MainWindow::keyPressEvent(QKeyEvent * keyEvent)
{
	switch (keyEvent->key())
	{
	case Qt::Key::Key_Escape:
		close();
		break;
	}

	QMainWindow::keyPressEvent(keyEvent);
}