MainWindow.cpp 1.81 KB
Newer Older
1
2
3
#include "..\Header\MainWindow.h"
#include "..\Header\OglViewerWidget.h"
#include <QSurfaceFormat>
Anakin's avatar
Anakin committed
4
5
6
7
#include <QMessageBox>
#include <QFileDialog>

#define WINDOW_NAME "Mesh Viewer"
8
9
10
11
12
13
14

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

Anakin's avatar
Anakin committed
15
16
17
18
19
20
21
22
23
	setWindowTitle(WINDOW_NAME);
	setWindowIcon(QIcon(":/images/icon.ico"));

	ui->statusBar->showMessage("pre-alpha");

	ui->mainToolBar->addAction("Open File", this, &MainWindow::openFile);
	ui->mainToolBar->addAction("About File", this, &MainWindow::aboutFile);
	ui->mainToolBar->addAction("Help", this, &MainWindow::aboutTool);

24
25
26
27
	QSurfaceFormat format;
	format.setDepthBufferSize(24);
	QSurfaceFormat::setDefaultFormat(format);

Anakin's avatar
Anakin committed
28
	setCentralWidget(new OglViewerWidget(this));
29
30
31
32
33
34

}

MainWindow::~MainWindow()
{
	delete ui;
Anakin's avatar
Anakin committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
}

void MainWindow::openFile()
{
	QString fileName = QFileDialog::getOpenFileName(this, "Open File", "../Release/Msh", "Mesh (*.msh)");
	dynamic_cast<OglViewerWidget*>(centralWidget())->openFile(fileName.toStdString().c_str());
}

void MainWindow::aboutFile()
{
	QMessageBox* dialog = new QMessageBox(QMessageBox::Information,
		WINDOW_NAME,
		"When i find some time, i'll add some information about\nthe file in the detailed text",
		QMessageBox::StandardButton::Close,
		this,
		Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
	dialog->setDetailedText("This is the cool detailed text\n");
	dialog->exec();
}

void MainWindow::aboutTool()
{
	QMessageBox* dialog = new QMessageBox(QMessageBox::Question,
		WINDOW_NAME,
		"This is the Pre-Alpha version of my Mesh Viewer\nCheck the detailed information",
		QMessageBox::StandardButton::Close,
		this,
		Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
	dialog->setDetailedText("left mouse - rotate\nright mouse - move\nscroll - zoom\nspace - reset view\nesc - close");
	dialog->exec();
65
}