Adding Open command to menu
This commit is contained in:
parent
f94a8de6c4
commit
8239cb87b7
3 changed files with 23 additions and 1 deletions
|
@ -11,6 +11,5 @@ int main(int argc, char *argv[])
|
|||
Window window;
|
||||
window.show();
|
||||
|
||||
window.load_stl("../../splitter/cayman.stl");
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -12,6 +12,9 @@ public:
|
|||
explicit Window(QWidget* parent=0);
|
||||
void load_stl(const QString& filename);
|
||||
|
||||
public slots:
|
||||
void on_open();
|
||||
|
||||
private:
|
||||
Canvas* canvas;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue