X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fwindow.cpp;h=280dad5fb70747fd498b98936c45a17d81e37f73;hb=907a76b4adfdaa36db28bb1b780f3074a0abbdcf;hp=eb4d9dc862ca5c452065cbb3afe887f393653284;hpb=8239cb87b70c0661a3f576f08c63183a6dcfeb3c;p=fstl diff --git a/src/window.cpp b/src/window.cpp index eb4d9dc..280dad5 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "window.h" @@ -10,6 +11,10 @@ Window::Window(QWidget *parent) : { setWindowTitle("fstl"); + QFile styleFile( ":/style.qss" ); + styleFile.open( QFile::ReadOnly ); + setStyleSheet(styleFile.readAll()); + QGLFormat format; format.setVersion(2, 1); format.setSampleBuffers(true); @@ -17,12 +22,26 @@ Window::Window(QWidget *parent) : canvas = new Canvas(format, this); setCentralWidget(canvas); - QAction* open_action = new QAction("Open", this); + open_action = new QAction("Open", this); open_action->setShortcut(QKeySequence::Open); QObject::connect(open_action, SIGNAL(triggered()), this, SLOT(on_open())); + + quit_action = new QAction("Quit", this); + quit_action->setShortcut(QKeySequence::Quit); + QObject::connect(quit_action, SIGNAL(triggered()), + this, SLOT(close())); + + about_action = new QAction("About", this); + QObject::connect(about_action, SIGNAL(triggered()), + this, SLOT(on_about())); + auto file_menu = menuBar()->addMenu("File"); file_menu->addAction(open_action); + file_menu->addAction(quit_action); + + auto help_menu = menuBar()->addMenu("Help"); + help_menu->addAction(about_action); resize(600, 400); } @@ -37,12 +56,40 @@ void Window::on_open() } } +void Window::on_about() +{ + QMessageBox::about(this, "", "

fstl

" + "

A fast viewer for .stl files.
" + "https://github.com/mkeeter/fstl

" + "

© 2014 Matthew Keeter
" + "matt.j.keeter@gmail.com

"); +} + + +void Window::enable_open_action() +{ + open_action->setEnabled(true); +} + + +void Window::disable_open_action() +{ + open_action->setEnabled(false); +} + + void Window::load_stl(const QString &filename) { Loader* loader = new Loader(this, filename); + connect(loader, SIGNAL(started()), + this, SLOT(disable_open_action())); connect(loader, SIGNAL(got_mesh(Mesh*)), canvas, SLOT(load_mesh(Mesh*))); connect(loader, SIGNAL(finished()), loader, SLOT(deleteLater())); + connect(loader, SIGNAL(finished()), + this, SLOT(enable_open_action())); + connect(loader, SIGNAL(loaded_file(QString)), + this, SLOT(setWindowTitle(QString))); loader->start(); }