-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgcodeviewapplication.cpp
40 lines (33 loc) · 1.18 KB
/
gcodeviewapplication.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "gcodeviewapplication.h"
#include "mainwindow.h"
GCodeViewApplication::GCodeViewApplication(int argc, char *argv[]) :
QApplication(argc, argv)
{
setOrganizationName("MakerBot Industries");
setApplicationName("Toolpath Helper");
}
void GCodeViewApplication::LoadFile(QString fileName) {
MainWindow *targetWindow = NULL;
// First, check to see if we have an empty window (this should only happen at start?)
// If we do, just load the file into that one.
foreach (QWidget *widget, QApplication::topLevelWidgets()) {
MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
if (mainWin) {
if (!(mainWin->hasFile())) {
targetWindow = mainWin;
}
}
}
// If we weren't successful, just create a new window.
if (targetWindow == NULL) {
targetWindow = new MainWindow();
}
targetWindow->show();
targetWindow->loadFile(fileName);
// Update the window menus across the app.
foreach (QWidget *widget, QApplication::topLevelWidgets()) {
MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
if (mainWin)
mainWin->updateWindowMenu();
}
}