-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_window.cpp
More file actions
29 lines (23 loc) · 847 Bytes
/
main_window.cpp
File metadata and controls
29 lines (23 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* Copyright (c) 2021, Eberty Alves
*/
#include "main_window.h"
MainWindow::MainWindow(const QString& filename) : ui_(new Ui::MainWindowLayout) {
ui_->setupUi(this);
resize(600, 500);
loadMesh(filename);
connect(ui_->open_button_, &QPushButton::clicked, this, &MainWindow::selectFile);
}
MainWindow::~MainWindow() { delete ui_; }
void MainWindow::selectFile() {
QString dir = QFile::exists(ui_->file_line_edit_->text()) ? ui_->file_line_edit_->text() : QString();
QString filename = QFileDialog::getOpenFileName(this, "Load OBJ file", dir, "OBJ file (*.obj)");
loadMesh(filename);
}
bool MainWindow::loadMesh(const QString& filename) {
if (!filename.isEmpty() && ui_->opengl_widget_->loadMesh(filename)) {
ui_->file_line_edit_->setText(QFileInfo(filename).canonicalFilePath());
return true;
}
return false;
}