Switch to new connection syntax and lambda function
This commit is contained in:
parent
06c048eb72
commit
7b05a4faa3
2 changed files with 16 additions and 31 deletions
|
@ -24,17 +24,17 @@ Window::Window(QWidget *parent) :
|
||||||
|
|
||||||
open_action = new QAction("Open", this);
|
open_action = new QAction("Open", this);
|
||||||
open_action->setShortcut(QKeySequence::Open);
|
open_action->setShortcut(QKeySequence::Open);
|
||||||
QObject::connect(open_action, SIGNAL(triggered()),
|
QObject::connect(open_action, &QAction::triggered,
|
||||||
this, SLOT(on_open()));
|
this, &Window::on_open);
|
||||||
|
|
||||||
quit_action = new QAction("Quit", this);
|
quit_action = new QAction("Quit", this);
|
||||||
quit_action->setShortcut(QKeySequence::Quit);
|
quit_action->setShortcut(QKeySequence::Quit);
|
||||||
QObject::connect(quit_action, SIGNAL(triggered()),
|
QObject::connect(quit_action, &QAction::triggered,
|
||||||
this, SLOT(close()));
|
this, &Window::on_open);
|
||||||
|
|
||||||
about_action = new QAction("About", this);
|
about_action = new QAction("About", this);
|
||||||
QObject::connect(about_action, SIGNAL(triggered()),
|
QObject::connect(about_action, &QAction::triggered,
|
||||||
this, SLOT(on_about()));
|
this, &Window::on_open);
|
||||||
|
|
||||||
auto file_menu = menuBar()->addMenu("File");
|
auto file_menu = menuBar()->addMenu("File");
|
||||||
file_menu->addAction(open_action);
|
file_menu->addAction(open_action);
|
||||||
|
@ -68,31 +68,18 @@ void Window::on_about()
|
||||||
" style=\"color: #93a1a1;\">matt.j.keeter@gmail.com</a></p>");
|
" style=\"color: #93a1a1;\">matt.j.keeter@gmail.com</a></p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
void Window::load_stl(const QString &filename)
|
||||||
{
|
{
|
||||||
Loader* loader = new Loader(this, filename);
|
Loader* loader = new Loader(this, filename);
|
||||||
connect(loader, SIGNAL(started()),
|
connect(loader, &Loader::started,
|
||||||
this, SLOT(disable_open_action()));
|
[=](){ open_action->setEnabled(false); });
|
||||||
connect(loader, SIGNAL(got_mesh(Mesh*)),
|
connect(loader, &Loader::got_mesh,
|
||||||
canvas, SLOT(load_mesh(Mesh*)));
|
canvas, &Canvas::load_mesh);
|
||||||
connect(loader, SIGNAL(finished()),
|
connect(loader, &Loader::finished,
|
||||||
loader, SLOT(deleteLater()));
|
loader, &Loader::deleteLater);
|
||||||
connect(loader, SIGNAL(finished()),
|
connect(loader, &Loader::finished,
|
||||||
this, SLOT(enable_open_action()));
|
[=](){ open_action->setEnabled(true); });
|
||||||
connect(loader, SIGNAL(loaded_file(QString)),
|
connect(loader, &Loader::loaded_file,
|
||||||
this, SLOT(setWindowTitle(QString)));
|
this, &Window::setWindowTitle);
|
||||||
loader->start();
|
loader->start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,6 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void on_open();
|
void on_open();
|
||||||
void on_about();
|
void on_about();
|
||||||
void disable_open_action();
|
|
||||||
void enable_open_action();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAction* open_action;
|
QAction* open_action;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue