Merge branch 'close-empty-win-on-open' of git://github.com/OskarLinde/openscad into OskarLinde-close-empty-win-on-open

master
Marius Kintel 2014-05-12 16:22:44 -04:00
commit 71f8e62a15
1 changed files with 14 additions and 2 deletions

View File

@ -518,6 +518,18 @@ void MainWindow::report_func(const class AbstractNode*, void *vp, int mark)
#ifdef ENABLE_MDI
void MainWindow::requestOpenFile(const QString &filename)
{
// if we have an empty open window, use that one
QSetIterator<MainWindow *> i(*MainWindow::windows);
while (i.hasNext()) {
MainWindow *w = i.next();
if (w->editor->toPlainText().isEmpty()) {
w->openFile(filename);
return;
}
}
// otherwise, create a new one
new MainWindow(filename);
}
#else
@ -975,7 +987,7 @@ void MainWindow::actionOpen()
}
#ifdef ENABLE_MDI
if (!new_filename.isEmpty()) {
new MainWindow(new_filename);
openFile(new_filename);
}
#else
if (!new_filename.isEmpty()) {
@ -994,7 +1006,7 @@ void MainWindow::actionOpenRecent()
QAction *action = qobject_cast<QAction *>(sender());
#ifdef ENABLE_MDI
new MainWindow(action->data().toString());
openFile(action->data().toString());
#else
if (!maybeSave())
return;