fix open button
This commit is contained in:
parent
31a97e7c2e
commit
e56eed0a16
14
src/main.cpp
14
src/main.cpp
@ -31,11 +31,15 @@ int main(int argc, char *argv[]) {
|
||||
} else if (argc == 2) {
|
||||
mesh_processor = new MeshProcessor(argv[1]);
|
||||
}
|
||||
// QObject::connect(&main_window, &MainWindow::open,
|
||||
// [&](const QString &path) {
|
||||
// if (mesh_processor) delete mesh_processor;
|
||||
// mesh_processor = new MeshProcessor(path);
|
||||
// });
|
||||
QObject::connect(&main_window, &MainWindow::open,
|
||||
[&](const QString &path) {
|
||||
if (mesh_processor) {
|
||||
mesh_viewer->removeMesh(mesh_processor->mesh);
|
||||
delete mesh_processor;
|
||||
}
|
||||
mesh_processor = new MeshProcessor(path);
|
||||
mesh_viewer->addMesh(mesh_processor->mesh);
|
||||
});
|
||||
main_window.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -7,9 +7,11 @@
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
:QMainWindow(parent),
|
||||
mesh_viewer(this),
|
||||
toolbar(this) {
|
||||
connect(&mesh_viewer, &MeshViewer::initialized, this, &MainWindow::meshViewerInitialized);
|
||||
toolbar(this),
|
||||
mesh_viewer(this) {
|
||||
connect(&mesh_viewer, &MeshViewer::initialized, [&]() {
|
||||
open_action->setEnabled(true);
|
||||
});
|
||||
setCentralWidget(&mesh_viewer);
|
||||
addToolBar(Qt::RightToolBarArea, &toolbar);
|
||||
open_action = toolbar.addAction("Ouvrir…", [&](){
|
||||
@ -31,8 +33,3 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
a->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::meshViewerInitialized() {
|
||||
open_action->setEnabled(true);
|
||||
}
|
||||
|
@ -15,9 +15,6 @@ class MainWindow : public QMainWindow {
|
||||
QAction *open_action;
|
||||
QList<QAction *> toolbar_actions;
|
||||
|
||||
private slots:
|
||||
void meshViewerInitialized();
|
||||
|
||||
signals:
|
||||
void open(const QString &path);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user