34 createMenus (); |
35 createMenus (); |
35 createToolbars (); |
36 createToolbars (); |
36 |
37 |
37 slot_selectionChanged (); |
38 slot_selectionChanged (); |
38 |
39 |
|
40 setWindowIcon (QIcon ("icons/ldforge.png")); |
39 setTitle (); |
41 setTitle (); |
40 setMinimumSize (320, 200); |
42 setMinimumSize (320, 200); |
41 resize (800, 600); |
43 resize (800, 600); |
42 } |
44 } |
43 |
45 |
44 #define MAKE_ACTION(OBJECT, DISPLAYNAME, IMAGENAME, DESCR) \ |
46 #define MAKE_ACTION(OBJECT, DISPLAYNAME, IMAGENAME, DESCR) \ |
45 qAct_##OBJECT = new QAction (QIcon ("./icons/" IMAGENAME ".png"), tr (DISPLAYNAME), this); \ |
47 qAct_##OBJECT = new QAction (QIcon ("./icons/" IMAGENAME ".png"), tr (DISPLAYNAME), this); \ |
46 qAct_##OBJECT->setStatusTip (tr (DESCR)); \ |
48 qAct_##OBJECT->setStatusTip (tr (DESCR)); \ |
47 connect (qAct_##OBJECT, SIGNAL (triggered ()), this, SLOT (slot_##OBJECT ())); |
49 connect (qAct_##OBJECT, SIGNAL (triggered ()), this, SLOT (slot_##OBJECT ())); |
48 |
50 |
|
51 // ============================================================================= |
|
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
53 // ============================================================================= |
49 void ForgeWindow::createMenuActions () { |
54 void ForgeWindow::createMenuActions () { |
50 // Long menu names go here so my cool action definition table doesn't get out of proportions |
55 // Long menu names go here so my cool action definition table doesn't get out of proportions |
51 const char* sNewCdLineText = "New Conditional Line", |
56 char const* sNewCdLineText = "New Conditional Line", |
52 *sNewQuadText = "New Quadrilateral", |
57 *sNewQuadText = "New Quadrilateral", |
53 *sAboutText = "About " APPNAME_DISPLAY; |
58 *sAboutText = "About " APPNAME_DISPLAY; |
54 |
59 |
55 MAKE_ACTION (new, "&New", "file-new", "Create a new part model.") |
60 MAKE_ACTION (new, "&New", "file-new", "Create a new part model.") |
56 MAKE_ACTION (open, "&Open", "file-open", "Load a part model from a file.") |
61 MAKE_ACTION (open, "&Open", "file-open", "Load a part model from a file.") |
59 MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME_DISPLAY ".") |
64 MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME_DISPLAY ".") |
60 |
65 |
61 MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.") |
66 MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.") |
62 MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.") |
67 MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.") |
63 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.") |
68 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.") |
64 MAKE_ACTION (about, sAboutText, "about", "Shows information about " APPNAME_DISPLAY ".") |
|
65 MAKE_ACTION (aboutQt, "About Qt", "aboutQt", "Shows information about Qt.") |
|
66 |
69 |
67 MAKE_ACTION (inline, "Inline", "inline", "Inline selected subfiles.") |
70 MAKE_ACTION (inline, "Inline", "inline", "Inline selected subfiles.") |
68 MAKE_ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.") |
71 MAKE_ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.") |
69 MAKE_ACTION (setContents, "Set Contents", "set-contents", "Set the raw code of this object.") |
72 MAKE_ACTION (setContents, "Set Contents", "set-contents", "Set the raw code of this object.") |
70 |
73 |
74 MAKE_ACTION (newQuad, sNewQuadText, "add-quad", "Creates a new quadrilateral.") |
77 MAKE_ACTION (newQuad, sNewQuadText, "add-quad", "Creates a new quadrilateral.") |
75 MAKE_ACTION (newCondLine, sNewCdLineText, "add-condline", "Creates a new conditional line."); |
78 MAKE_ACTION (newCondLine, sNewCdLineText, "add-condline", "Creates a new conditional line."); |
76 MAKE_ACTION (newComment, "New Comment", "add-comment", "Creates a new comment."); |
79 MAKE_ACTION (newComment, "New Comment", "add-comment", "Creates a new comment."); |
77 MAKE_ACTION (newVector, "New Vector", "add-vector", "Creates a new vector.") |
80 MAKE_ACTION (newVector, "New Vector", "add-vector", "Creates a new vector.") |
78 MAKE_ACTION (newVertex, "New Vertex", "add-vertex", "Creates a new vertex.") |
81 MAKE_ACTION (newVertex, "New Vertex", "add-vertex", "Creates a new vertex.") |
|
82 |
|
83 MAKE_ACTION (settings, "Settings", "settings", "Edit the settings of " APPNAME_DISPLAY ".") |
|
84 |
|
85 MAKE_ACTION (about, sAboutText, "ldforge", "Shows information about " APPNAME_DISPLAY ".") |
|
86 MAKE_ACTION (aboutQt, "About Qt", "aboutQt", "Shows information about Qt.") |
79 |
87 |
80 // Keyboard shortcuts |
88 // Keyboard shortcuts |
81 qAct_new->setShortcut (Qt::CTRL | Qt::Key_N); |
89 qAct_new->setShortcut (Qt::CTRL | Qt::Key_N); |
82 qAct_open->setShortcut (Qt::CTRL | Qt::Key_O); |
90 qAct_open->setShortcut (Qt::CTRL | Qt::Key_O); |
83 qAct_save->setShortcut (Qt::CTRL | Qt::Key_S); |
91 qAct_save->setShortcut (Qt::CTRL | Qt::Key_S); |
105 |
113 |
106 for (ushort i = 0; i < sizeof qaDisabledActions / sizeof *qaDisabledActions; ++i) |
114 for (ushort i = 0; i < sizeof qaDisabledActions / sizeof *qaDisabledActions; ++i) |
107 qaDisabledActions[i]->setEnabled (false); |
115 qaDisabledActions[i]->setEnabled (false); |
108 } |
116 } |
109 |
117 |
|
118 // ============================================================================= |
|
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
120 // ============================================================================= |
110 void ForgeWindow::createMenus () { |
121 void ForgeWindow::createMenus () { |
111 // File menu |
122 // File menu |
112 qFileMenu = menuBar ()->addMenu (tr ("&File")); |
123 qFileMenu = menuBar ()->addMenu (tr ("&File")); |
113 qFileMenu->addAction (qAct_new); // New |
124 qFileMenu->addAction (qAct_new); // New |
114 qFileMenu->addAction (qAct_open); // Open |
125 qFileMenu->addAction (qAct_open); // Open |
115 qFileMenu->addAction (qAct_save); // Save |
126 qFileMenu->addAction (qAct_save); // Save |
116 qFileMenu->addAction (qAct_saveAs); // Save As |
127 qFileMenu->addAction (qAct_saveAs); // Save As |
|
128 qFileMenu->addSeparator (); // ------- |
|
129 qFileMenu->addAction (qAct_settings); // Settings |
117 qFileMenu->addSeparator (); // ------- |
130 qFileMenu->addSeparator (); // ------- |
118 qFileMenu->addAction (qAct_exit); // Exit |
131 qFileMenu->addAction (qAct_exit); // Exit |
119 |
132 |
120 // Edit menu |
133 // Edit menu |
121 qInsertMenu = menuBar ()->addMenu (tr ("&Insert")); |
134 qInsertMenu = menuBar ()->addMenu (tr ("&Insert")); |
141 qHelpMenu = menuBar ()->addMenu (tr ("&Help")); |
154 qHelpMenu = menuBar ()->addMenu (tr ("&Help")); |
142 qHelpMenu->addAction (qAct_about); // About |
155 qHelpMenu->addAction (qAct_about); // About |
143 qHelpMenu->addAction (qAct_aboutQt); // About Qt |
156 qHelpMenu->addAction (qAct_aboutQt); // About Qt |
144 } |
157 } |
145 |
158 |
|
159 // ============================================================================= |
|
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
161 // ============================================================================= |
146 void ForgeWindow::createToolbars () { |
162 void ForgeWindow::createToolbars () { |
147 qFileToolBar = new QToolBar ("File"); |
163 qFileToolBar = new QToolBar ("File"); |
148 qFileToolBar->addAction (qAct_new); |
164 qFileToolBar->addAction (qAct_new); |
149 qFileToolBar->addAction (qAct_open); |
165 qFileToolBar->addAction (qAct_open); |
150 qFileToolBar->addAction (qAct_save); |
166 qFileToolBar->addAction (qAct_save); |
170 qEditToolBar->addAction (qAct_splitQuads); |
186 qEditToolBar->addAction (qAct_splitQuads); |
171 qEditToolBar->addAction (qAct_setContents); |
187 qEditToolBar->addAction (qAct_setContents); |
172 addToolBar (qEditToolBar); |
188 addToolBar (qEditToolBar); |
173 } |
189 } |
174 |
190 |
|
191 // ============================================================================= |
|
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
193 // ============================================================================= |
175 void ForgeWindow::setTitle () { |
194 void ForgeWindow::setTitle () { |
176 str zTitle = APPNAME_DISPLAY " v" VERSION_STRING; |
195 str zTitle = APPNAME_DISPLAY " v" VERSION_STRING; |
177 |
196 |
178 // Append our current file if we have one |
197 // Append our current file if we have one |
179 if (g_CurrentFile) { |
198 if (g_CurrentFile) { |
288 |
311 |
289 void ForgeWindow::slot_splitQuads () { |
312 void ForgeWindow::slot_splitQuads () { |
290 if (qObjList->selectedItems().size() == 0) |
313 if (qObjList->selectedItems().size() == 0) |
291 return; |
314 return; |
292 |
315 |
293 const QList<QTreeWidgetItem*> qaItems = qObjList->selectedItems(); |
316 QList<QTreeWidgetItem*> const qaItems = qObjList->selectedItems(); |
294 |
317 |
295 for (ulong i = 0; i < g_CurrentFile->objects.size(); ++i) { |
318 for (ulong i = 0; i < g_CurrentFile->objects.size(); ++i) { |
296 LDObject* obj = g_CurrentFile->objects[i]; |
319 LDObject* obj = g_CurrentFile->objects[i]; |
297 |
320 |
298 // Don't even consider non-quads |
321 // Don't even consider non-quads |
341 return; |
364 return; |
342 |
365 |
343 Dialog_SetContents::staticDialog (obj, this); |
366 Dialog_SetContents::staticDialog (obj, this); |
344 } |
367 } |
345 |
368 |
|
369 // ============================================================================= |
|
370 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
371 // ============================================================================= |
346 static QIcon IconForObjectType (LDObject* obj) { |
372 static QIcon IconForObjectType (LDObject* obj) { |
347 switch (obj->getType ()) { |
373 switch (obj->getType ()) { |
348 case OBJ_Empty: |
374 case OBJ_Empty: |
349 return QIcon ("icons/empty.png"); |
375 return QIcon ("icons/empty.png"); |
350 |
376 |
469 } |
498 } |
470 |
499 |
471 qObjList->insertTopLevelItems (0, qaItems); |
500 qObjList->insertTopLevelItems (0, qaItems); |
472 } |
501 } |
473 |
502 |
|
503 // ============================================================================= |
|
504 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
505 // ============================================================================= |
474 void ForgeWindow::slot_selectionChanged () { |
506 void ForgeWindow::slot_selectionChanged () { |
475 // If the selection isn't 1 exact, disable setting contents |
507 // If the selection isn't 1 exact, disable setting contents |
476 qAct_setContents->setEnabled (qObjList->selectedItems().size() == 1); |
508 qAct_setContents->setEnabled (qObjList->selectedItems().size() == 1); |
477 |
509 |
478 // If we have no selection, disable splitting quads |
510 // If we have no selection, disable splitting quads |