Adding Open command to menu

This commit is contained in:
Matt Keeter 2014-03-07 11:17:09 -06:00
parent f94a8de6c4
commit 8239cb87b7
3 changed files with 23 additions and 1 deletions

View file

@ -1,3 +1,6 @@
#include <QMenuBar>
#include <QFileDialog>
#include "window.h"
#include "canvas.h"
#include "loader.h"
@ -14,9 +17,26 @@ Window::Window(QWidget *parent) :
canvas = new Canvas(format, this);
setCentralWidget(canvas);
QAction* open_action = new QAction("Open", this);
open_action->setShortcut(QKeySequence::Open);
QObject::connect(open_action, SIGNAL(triggered()),
this, SLOT(on_open()));
auto file_menu = menuBar()->addMenu("File");
file_menu->addAction(open_action);
resize(600, 400);
}
void Window::on_open()
{
QString filename = QFileDialog::getOpenFileName(
this, "Load .stl file", QString(), "*.stl");
if (not filename.isNull())
{
load_stl(filename);
}
}
void Window::load_stl(const QString &filename)
{
Loader* loader = new Loader(this, filename);