gui_actions.cpp

changeset 79
f8917e9d07f6
child 80
fd61b467ff99
equal deleted inserted replaced
78:c190fe218506 79:f8917e9d07f6
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 Santeri `arezey` Piippo
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <qfiledialog.h>
20 #include <qmessagebox.h>
21 #include "gui.h"
22 #include "file.h"
23 #include "zz_newPartDialog.h"
24 #include "zz_configDialog.h"
25 #include "zz_addObjectDialog.h"
26
27 // =============================================================================
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
29 // =============================================================================
30 ACTION (newFile, "&New", "brick", "Create a new part model.", CTRL (N)) {
31 NewPartDialog::StaticDialog ();
32 }
33
34 // =============================================================================
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
36 // =============================================================================
37 ACTION (open, "&Open", "file-open", "Load a part model from a file.", CTRL (O)) {
38 str zName;
39 zName += QFileDialog::getOpenFileName (g_ForgeWindow, "Open File",
40 "", "LDraw files (*.dat *.ldr)");
41
42 if (~zName)
43 openMainFile (zName);
44 }
45
46 // =============================================================================
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
48 // =============================================================================
49 void doSaveAs () {
50 str zName;
51 zName += QFileDialog::getSaveFileName (g_ForgeWindow, "Save As",
52 "", "LDraw files (*.dat *.ldr)");
53
54 if (~zName && g_CurrentFile->save (zName))
55 g_CurrentFile->zFileName = zName;
56 }
57
58 // =============================================================================
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
60 // =============================================================================
61 ACTION (save, "&Save", "file-save", "Save the part model.", CTRL (S)) {
62 if (!~g_CurrentFile->zFileName) {
63 // If we don't have a file name, this is an anonymous file created
64 // with the new file command. We cannot save without a name so ask
65 // the user for one.
66 doSaveAs ();
67 return;
68 }
69
70 g_CurrentFile->save ();
71 }
72
73 // =============================================================================
74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
75 // =============================================================================
76 ACTION (saveAs, "Save &As", "file-save-as", "Save the part model to a specific file.", CTRL_SHIFT (S))
77 {
78 doSaveAs ();
79 }
80
81 // =============================================================================
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
83 // =============================================================================
84 ACTION (settings, "Settings", "settings", "Edit the settings of " APPNAME_DISPLAY ".", (0)) {
85 ConfigDialog::staticDialog (g_ForgeWindow);
86 }
87
88 // =============================================================================
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
90 // =============================================================================
91 ACTION (exit, "&Exit", "exit", "Close " APPNAME_DISPLAY ".", CTRL (Q)) {
92 exit (0);
93 }
94
95 // =============================================================================
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
97 // =============================================================================
98 ACTION (newSubfile, "New Subfile", "add-subfile", "Creates a new subfile reference.", 0) {
99
100 }
101
102 ACTION (newLine, "New Line", "add-line", "Creates a new line.", 0) {
103 AddObjectDialog::staticDialog (OBJ_Line, g_ForgeWindow);
104 }
105
106 ACTION (newTriangle, "New Triangle", "add-triangle", "Creates a new triangle.", 0) {
107 AddObjectDialog::staticDialog (OBJ_Triangle, g_ForgeWindow);
108 }
109
110 ACTION (newQuad, "New Quadrilateral", "add-quad", "Creates a new quadrilateral.", 0) {
111 AddObjectDialog::staticDialog (OBJ_Quad, g_ForgeWindow);
112 }
113
114 ACTION (newCondLine, "New Conditional Line", "add-condline", "Creates a new conditional line.", 0) {
115 AddObjectDialog::staticDialog (OBJ_CondLine, g_ForgeWindow);
116 }
117
118 ACTION (newComment, "New Comment", "add-comment", "Creates a new comment.", 0) {
119 AddObjectDialog::staticDialog (OBJ_Comment, g_ForgeWindow);
120 }
121 ACTION (newVertex, "New Vertex", "add-vertex", "Creates a new vertex.", 0) {
122 AddObjectDialog::staticDialog (OBJ_Vertex, g_ForgeWindow);
123 }
124
125 ACTION (help, "Help", "help", "Shows the " APPNAME_DISPLAY " help manual.", KEY (F1)) {
126
127 }
128
129 // =============================================================================
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
131 // =============================================================================
132 ACTION (about, "About" APPNAME_DISPLAY, "ldforge",
133 "Shows information about " APPNAME_DISPLAY ".", CTRL (F1))
134 {
135
136 }
137
138 ACTION (aboutQt, "About Qt", "aboutQt", "Shows information about Qt.", CTRL_SHIFT (F1)) {
139 QMessageBox::aboutQt (g_ForgeWindow);
140 }

mercurial