gui.cpp

changeset 163
46955613626d
parent 161
c9fba92c4e35
child 164
8c93d8e38494
equal deleted inserted replaced
162:b7d65e89861a 163:46955613626d
32 #include "misc.h" 32 #include "misc.h"
33 #include "colors.h" 33 #include "colors.h"
34 #include "history.h" 34 #include "history.h"
35 #include "config.h" 35 #include "config.h"
36 36
37 EXTERN_ACTION (newFile)
38 EXTERN_ACTION (open)
39 EXTERN_ACTION (save)
40 EXTERN_ACTION (saveAs)
41 EXTERN_ACTION (settings)
42 EXTERN_ACTION (exit)
43 EXTERN_ACTION (cut)
44 EXTERN_ACTION (copy)
45 EXTERN_ACTION (paste)
46 EXTERN_ACTION (del)
47 EXTERN_ACTION (setColor)
48 EXTERN_ACTION (inlineContents)
49 EXTERN_ACTION (deepInline)
50 EXTERN_ACTION (splitQuads)
51 EXTERN_ACTION (setContents)
52 EXTERN_ACTION (makeBorders)
53 EXTERN_ACTION (makeCornerVerts)
54 EXTERN_ACTION (moveUp)
55 EXTERN_ACTION (moveDown)
56 EXTERN_ACTION (newSubfile)
57 EXTERN_ACTION (newLine)
58 EXTERN_ACTION (newCondLine)
59 EXTERN_ACTION (newTriangle)
60 EXTERN_ACTION (newQuad)
61 EXTERN_ACTION (newComment)
62 EXTERN_ACTION (newBFC)
63 EXTERN_ACTION (newVertex)
64 EXTERN_ACTION (newRadial)
65 EXTERN_ACTION (help)
66 EXTERN_ACTION (about)
67 EXTERN_ACTION (aboutQt)
68 EXTERN_ACTION (undo)
69 EXTERN_ACTION (redo)
70 EXTERN_ACTION (showHistory)
71 EXTERN_ACTION (selectAll)
72 EXTERN_ACTION (selectByColor)
73 EXTERN_ACTION (selectByType)
74 EXTERN_ACTION (moveXNeg)
75 EXTERN_ACTION (moveYNeg)
76 EXTERN_ACTION (moveZNeg)
77 EXTERN_ACTION (moveXPos)
78 EXTERN_ACTION (moveYPos)
79 EXTERN_ACTION (moveZPos)
80 EXTERN_ACTION (invert)
81 EXTERN_ACTION (rotateXNeg)
82 EXTERN_ACTION (rotateYNeg)
83 EXTERN_ACTION (rotateZNeg)
84 EXTERN_ACTION (rotateXPos)
85 EXTERN_ACTION (rotateYPos)
86 EXTERN_ACTION (rotateZPos)
87 EXTERN_ACTION (roundCoords)
88 EXTERN_ACTION (gridCoarse)
89 EXTERN_ACTION (gridMedium)
90 EXTERN_ACTION (gridFine)
91 EXTERN_ACTION (resetView)
92 EXTERN_ACTION (insertFrom)
93 EXTERN_ACTION (insertRaw)
94 EXTERN_ACTION (screencap)
95 EXTERN_ACTION (editObject)
96 EXTERN_ACTION (uncolorize)
97 EXTERN_ACTION (axes)
98
99 #ifndef RELEASE
100 EXTERN_ACTION (addTestQuad)
101 EXTERN_ACTION (addTestRadial)
102 #endif // RELEASE
103
104 vector<actionmeta> g_ActionMeta; 37 vector<actionmeta> g_ActionMeta;
105 38
106 static bool g_bSelectionLocked = false; 39 static bool g_bSelectionLocked = false;
107 40
108 cfg (bool, lv_colorize, true); 41 cfg (bool, lv_colorize, true);
173 106
174 connect (qAct, SIGNAL (triggered ()), this, SLOT (slot_action ())); 107 connect (qAct, SIGNAL (triggered ()), this, SLOT (slot_action ()));
175 } 108 }
176 109
177 // Grid actions and axes are checkable 110 // Grid actions and axes are checkable
178 ACTION (gridCoarse)->setCheckable (true); 111 findAction ("gridCoarse")->setCheckable (true);
179 ACTION (gridMedium)->setCheckable (true); 112 findAction ("gridMedium")->setCheckable (true);
180 ACTION (gridFine)->setCheckable (true); 113 findAction ("gridFine")->setCheckable (true);
181 114
182 ACTION (axes)->setCheckable (true); 115 findAction ("axes")->setCheckable (true);
183 ACTION (axes)->setChecked (gl_axes); 116 findAction ("axes")->setChecked (gl_axes);
184 117
185 // things not implemented yet 118 // things not implemented yet
186 QAction* const qaDisabledActions[] = { 119 findAction ("help")->setEnabled (false);
187 ACTION (help),
188 };
189
190 for (QAction* act : qaDisabledActions)
191 act->setEnabled (false);
192 120
193 History::updateActions (); 121 History::updateActions ();
194 } 122 }
195 123
196 // ============================================================================= 124 // =============================================================================
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
126 // =============================================================================
127 QMenu* g_CurrentMenu;
128
129 void ForgeWindow::initMenu (const char* name) {
130 g_CurrentMenu = menuBar ()->addMenu (tr (name));
131 }
132
133 void ForgeWindow::addMenuAction (const char* name) {
134 g_CurrentMenu->addAction (findAction (name));
135 }
136
137
198 // ============================================================================= 138 // =============================================================================
199 void ForgeWindow::createMenus () { 139 void ForgeWindow::createMenus () {
200 m_recentFilesMenu = new QMenu (tr ("Open &Recent")); 140 m_recentFilesMenu = new QMenu (tr ("Open &Recent"));
201 m_recentFilesMenu->setIcon (getIcon ("open-recent")); 141 m_recentFilesMenu->setIcon (getIcon ("open-recent"));
202 updateRecentFilesMenu (); 142 updateRecentFilesMenu ();
203 143
144 QMenu*& menu = g_CurrentMenu;
145
204 // File menu 146 // File menu
205 QMenu* qFileMenu = menuBar ()->addMenu (tr ("&File")); 147 initMenu ("&File");
206 qFileMenu->addAction (ACTION (newFile)); // New 148 addMenuAction ("newFile"); // New
207 qFileMenu->addAction (ACTION (open)); // Open 149 addMenuAction ("open"); // Open
208 qFileMenu->addMenu (m_recentFilesMenu); // Open Recent 150 menu->addMenu (m_recentFilesMenu); // Open Recent
209 qFileMenu->addAction (ACTION (save)); // Save 151 addMenuAction ("save"); // Save
210 qFileMenu->addAction (ACTION (saveAs)); // Save As 152 addMenuAction ("saveAs"); // Save As
211 qFileMenu->addSeparator (); // ------- 153 menu->addSeparator (); // -------
212 qFileMenu->addAction (ACTION (settings)); // Settings 154 addMenuAction ("settings"); // Settings
213 qFileMenu->addSeparator (); // ------- 155 menu->addSeparator (); // -------
214 qFileMenu->addAction (ACTION (exit)); // Exit 156 addMenuAction ("exit"); // Exit
215 157
216 // View menu 158 // View menu
217 QMenu* qViewMenu = menuBar ()->addMenu (tr ("&View")); 159 initMenu ("&View");
218 qViewMenu->addAction (ACTION (resetView)); // Reset View 160 addMenuAction ("resetView"); // Reset View
219 qViewMenu->addAction (ACTION (axes)); // Draw Axes 161 addMenuAction ("axes"); // Draw Axes
220 qViewMenu->addSeparator (); // ----- 162 menu->addSeparator (); // -----
221 qViewMenu->addAction (ACTION (screencap)); // Screencap Part 163 addMenuAction ("screencap"); // Screencap Part
222 qViewMenu->addAction (ACTION (showHistory)); // Edit History 164 addMenuAction ("showHistory"); // Edit History
223 165
224 // Insert menu 166 // Insert menu
225 QMenu* qInsertMenu = menuBar ()->addMenu (tr ("&Insert")); 167 initMenu ("&Insert");
226 qInsertMenu->addAction (ACTION (insertFrom)); // Insert from File 168 addMenuAction ("insertFrom"); // Insert from File
227 qInsertMenu->addAction (ACTION (insertRaw)); // Insert Raw 169 addMenuAction ("insertRaw"); // Insert Raw
228 qInsertMenu->addSeparator (); // ------- 170 menu->addSeparator (); // -------
229 qInsertMenu->addAction (ACTION (newSubfile)); // New Subfile 171 addMenuAction ("newSubfile"); // New Subfile
230 qInsertMenu->addAction (ACTION (newLine)); // New Line 172 addMenuAction ("newLine"); // New Line
231 qInsertMenu->addAction (ACTION (newTriangle)); // New Triangle 173 addMenuAction ("newTriangle"); // New Triangle
232 qInsertMenu->addAction (ACTION (newQuad)); // New Quad 174 addMenuAction ("newQuad"); // New Quad
233 qInsertMenu->addAction (ACTION (newCondLine)); // New Conditional Line 175 addMenuAction ("newCondLine"); // New Conditional Line
234 qInsertMenu->addAction (ACTION (newComment)); // New Comment 176 addMenuAction ("newComment"); // New Comment
235 qInsertMenu->addAction (ACTION (newBFC)); // New BFC Statment 177 addMenuAction ("newBFC"); // New BFC Statment
236 qInsertMenu->addAction (ACTION (newVertex)); // New Vertex 178 addMenuAction ("newVertex"); // New Vertex
237 qInsertMenu->addAction (ACTION (newRadial)); // New Radial 179 addMenuAction ("newRadial"); // New Radial
180 menu->addSeparator (); // -----
181 addMenuAction ("beginDraw"); // Begin Drawing
182 addMenuAction ("doneDraw"); // Cancel Drawing
183 addMenuAction ("cancelDraw"); // Done Drawing
238 184
239 // Edit menu 185 // Edit menu
240 QMenu* qEditMenu = menuBar ()->addMenu (tr ("&Edit")); 186 initMenu ("&Edit");
241 qEditMenu->addAction (ACTION (undo)); // Undo 187 addMenuAction ("undo"); // Undo
242 qEditMenu->addAction (ACTION (redo)); // Redo 188 addMenuAction ("redo"); // Redo
243 qEditMenu->addSeparator (); // ----- 189 menu->addSeparator (); // -----
244 qEditMenu->addAction (ACTION (cut)); // Cut 190 addMenuAction ("cut"); // Cut
245 qEditMenu->addAction (ACTION (copy)); // Copy 191 addMenuAction ("copy"); // Copy
246 qEditMenu->addAction (ACTION (paste)); // Paste 192 addMenuAction ("paste"); // Paste
247 qEditMenu->addAction (ACTION (del)); // Delete 193 addMenuAction ("del"); // Delete
248 qEditMenu->addSeparator (); // ----- 194 menu->addSeparator (); // -----
249 qEditMenu->addAction (ACTION (selectAll)); // Select All 195 addMenuAction ("selectAll"); // Select All
250 qEditMenu->addAction (ACTION (selectByColor)); // Select by Color 196 addMenuAction ("selectByColor"); // Select by Color
251 qEditMenu->addAction (ACTION (selectByType)); // Select by Type 197 addMenuAction ("selectByType"); // Select by Type
252 qEditMenu->addSeparator (); // ----- 198
253 199 initMenu ("&Tools");
254 QMenu* toolsMenu = menuBar ()->addMenu (tr ("&Tools")); 200 addMenuAction ("setColor"); // Set Color
255 toolsMenu->addAction (ACTION (setColor)); // Set Color 201 addMenuAction ("invert"); // Invert
256 toolsMenu->addAction (ACTION (invert)); // Invert 202 addMenuAction ("inlineContents"); // Inline
257 toolsMenu->addAction (ACTION (inlineContents)); // Inline 203 addMenuAction ("deepInline"); // Deep Inline
258 toolsMenu->addAction (ACTION (deepInline)); // Deep Inline 204 addMenuAction ("splitQuads"); // Split Quads
259 toolsMenu->addAction (ACTION (splitQuads)); // Split Quads 205 addMenuAction ("setContents"); // Set Contents
260 toolsMenu->addAction (ACTION (setContents)); // Set Contents 206 addMenuAction ("makeBorders"); // Make Borders
261 toolsMenu->addAction (ACTION (makeBorders)); // Make Borders 207 addMenuAction ("makeCornerVerts"); // Make Corner Vertices
262 toolsMenu->addAction (ACTION (makeCornerVerts)); // Make Corner Vertices 208 addMenuAction ("roundCoords"); // Round Coordinates
263 toolsMenu->addAction (ACTION (roundCoords)); // Round Coordinates 209 addMenuAction ("uncolorize"); // Uncolorize
264 toolsMenu->addAction (ACTION (uncolorize)); // Uncolorize
265 210
266 // Move menu 211 // Move menu
267 QMenu* qMoveMenu = menuBar ()->addMenu (tr ("&Move")); 212 initMenu ("&Move");
268 qMoveMenu->addAction (ACTION (moveUp)); // Move Up 213 addMenuAction ("moveUp"); // Move Up
269 qMoveMenu->addAction (ACTION (moveDown)); // Move Down 214 addMenuAction ("moveDown"); // Move Down
270 qMoveMenu->addSeparator (); // ----- 215 menu->addSeparator (); // -----
271 qMoveMenu->addAction (ACTION (gridCoarse)); // Coarse Grid 216 addMenuAction ("gridCoarse"); // Coarse Grid
272 qMoveMenu->addAction (ACTION (gridMedium)); // Medium Grid 217 addMenuAction ("gridMedium"); // Medium Grid
273 qMoveMenu->addAction (ACTION (gridFine)); // Fine Grid 218 addMenuAction ("gridFine"); // Fine Grid
274 qMoveMenu->addSeparator (); // ----- 219 menu->addSeparator (); // -----
275 qMoveMenu->addAction (ACTION (moveXPos)); // Move +X 220 addMenuAction ("moveXPos"); // Move +X
276 qMoveMenu->addAction (ACTION (moveXNeg)); // Move -X 221 addMenuAction ("moveXNeg"); // Move -X
277 qMoveMenu->addAction (ACTION (moveYPos)); // Move +Y 222 addMenuAction ("moveYPos"); // Move +Y
278 qMoveMenu->addAction (ACTION (moveYNeg)); // Move -Y 223 addMenuAction ("moveYNeg"); // Move -Y
279 qMoveMenu->addAction (ACTION (moveZPos)); // Move +Z 224 addMenuAction ("moveZPos"); // Move +Z
280 qMoveMenu->addAction (ACTION (moveZNeg)); // Move -Z 225 addMenuAction ("moveZNeg"); // Move -Z
281 qMoveMenu->addSeparator (); // ----- 226 menu->addSeparator (); // -----
282 qMoveMenu->addAction (ACTION (rotateXPos)); // Rotate +X 227 addMenuAction ("rotateXPos"); // Rotate +X
283 qMoveMenu->addAction (ACTION (rotateXNeg)); // Rotate -X 228 addMenuAction ("rotateXNeg"); // Rotate -X
284 qMoveMenu->addAction (ACTION (rotateYPos)); // Rotate +Y 229 addMenuAction ("rotateYPos"); // Rotate +Y
285 qMoveMenu->addAction (ACTION (rotateYNeg)); // Rotate -Y 230 addMenuAction ("rotateYNeg"); // Rotate -Y
286 qMoveMenu->addAction (ACTION (rotateZPos)); // Rotate +Z 231 addMenuAction ("rotateZPos"); // Rotate +Z
287 qMoveMenu->addAction (ACTION (rotateZNeg)); // Rotate -Z 232 addMenuAction ("rotateZNeg"); // Rotate -Z
288 233
289 #ifndef RELEASE 234 #ifndef RELEASE
290 // Debug menu 235 // Debug menu
291 QMenu* qDebugMenu = menuBar ()->addMenu (tr ("&Debug")); 236 initMenu ("&Debug");
292 qDebugMenu->addAction (ACTION (addTestQuad)); // Add Test Quad 237 addMenuAction ("addTestQuad"); // Add Test Quad
293 qDebugMenu->addAction (ACTION (addTestRadial)); // Add Test Radial 238 addMenuAction ("addTestRadial"); // Add Test Radial
294 #endif // RELEASE 239 #endif // RELEASE
295 240
296 // Help menu 241 // Help menu
297 QMenu* qHelpMenu = menuBar ()->addMenu (tr ("&Help")); 242 initMenu ("&Help");
298 qHelpMenu->addAction (ACTION (help)); // Help 243 addMenuAction ("help"); // Help
299 qHelpMenu->addSeparator (); // ----- 244 menu->addSeparator (); // -----
300 qHelpMenu->addAction (ACTION (about)); // About 245 addMenuAction ("about"); // About
301 qHelpMenu->addAction (ACTION (aboutQt)); // About Qt 246 addMenuAction ("aboutQt"); // About Qt
302 } 247 }
303 248
304 // ============================================================================= 249 // =============================================================================
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
306 // ============================================================================= 251 // =============================================================================
307 void ForgeWindow::updateRecentFilesMenu () { 252 void ForgeWindow::updateRecentFilesMenu () {
308 // First, clear any items in the recent files menu 253 // First, clear any items in the recent files menu
309 for (QAction* qRecent : m_recentFiles) 254 for (QAction* recent : m_recentFiles)
310 delete qRecent; 255 delete recent;
311 m_recentFiles.clear (); 256 m_recentFiles.clear ();
312 257
313 std::vector<str> zaFiles = io_recentfiles.value / "@"; 258 std::vector<str> files = io_recentfiles.value / "@";
314 for (long i = zaFiles.size() - 1; i >= 0; --i) { 259 for (long i = files.size() - 1; i >= 0; --i) {
315 str zFile = zaFiles[i]; 260 str file = files[i];
316 261
317 QAction* qRecent = new QAction (getIcon ("open-recent"), zFile, this); 262 QAction* recent = new QAction (getIcon ("open-recent"), file, this);
318 263
319 connect (qRecent, SIGNAL (triggered ()), this, SLOT (slot_recentFile ())); 264 connect (recent, SIGNAL (triggered ()), this, SLOT (slot_recentFile ()));
320 m_recentFilesMenu->addAction (qRecent); 265 m_recentFilesMenu->addAction (recent);
321 m_recentFiles.push_back (qRecent); 266 m_recentFiles.push_back (recent);
322 } 267 }
323 } 268 }
324 269
325 // ============================================================================= 270 // =============================================================================
326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
327 // ============================================================================= 272 // =============================================================================
328 static QToolBar* g_CurrentToolBar; 273 static QToolBar* g_CurrentToolBar;
329 static Qt::ToolBarArea g_ToolBarArea = Qt::TopToolBarArea; 274 static Qt::ToolBarArea g_ToolBarArea = Qt::TopToolBarArea;
330 275
331 void ForgeWindow::initSingleToolBar (const char* sName) { 276 void ForgeWindow::initSingleToolBar (const char* name) {
332 QToolBar* toolbar = new QToolBar (sName); 277 QToolBar* toolbar = new QToolBar (name);
333 addToolBar (g_ToolBarArea, toolbar); 278 addToolBar (g_ToolBarArea, toolbar);
334 m_toolBars.push_back (toolbar); 279 m_toolBars.push_back (toolbar);
335 280
336 g_CurrentToolBar = toolbar; 281 g_CurrentToolBar = toolbar;
337 } 282 }
338 283
284 // =============================================================================
285 void ForgeWindow::addToolBarAction (const char* name) {
286 g_CurrentToolBar->addAction (findAction (name));
287 }
288
289 // =============================================================================
339 void ForgeWindow::createToolbars () { 290 void ForgeWindow::createToolbars () {
340 initSingleToolBar ("File"); 291 initSingleToolBar ("File");
341 g_CurrentToolBar->addAction (ACTION (newFile)); 292 addToolBarAction ("newFile");
342 g_CurrentToolBar->addAction (ACTION (open)); 293 addToolBarAction ("open");
343 g_CurrentToolBar->addAction (ACTION (save)); 294 addToolBarAction ("save");
344 g_CurrentToolBar->addAction (ACTION (saveAs)); 295 addToolBarAction ("saveAs");
345 296
346 // ========================================== 297 // ==========================================
347 initSingleToolBar ("Insert"); 298 initSingleToolBar ("Insert");
348 g_CurrentToolBar->addAction (ACTION (newSubfile)); 299 addToolBarAction ("newSubfile");
349 g_CurrentToolBar->addAction (ACTION (newLine)); 300 addToolBarAction ("newLine");
350 g_CurrentToolBar->addAction (ACTION (newTriangle)); 301 addToolBarAction ("newTriangle");
351 g_CurrentToolBar->addAction (ACTION (newQuad)); 302 addToolBarAction ("newQuad");
352 g_CurrentToolBar->addAction (ACTION (newCondLine)); 303 addToolBarAction ("newCondLine");
353 g_CurrentToolBar->addAction (ACTION (newComment)); 304 addToolBarAction ("newComment");
354 g_CurrentToolBar->addAction (ACTION (newBFC)); 305 addToolBarAction ("newBFC");
355 g_CurrentToolBar->addAction (ACTION (newVertex)); 306 addToolBarAction ("newVertex");
356 g_CurrentToolBar->addAction (ACTION (newRadial)); 307 addToolBarAction ("newRadial");
357 308
358 // ========================================== 309 // ==========================================
359 initSingleToolBar ("Edit"); 310 initSingleToolBar ("Edit");
360 g_CurrentToolBar->addAction (ACTION (undo)); 311 addToolBarAction ("undo");
361 g_CurrentToolBar->addAction (ACTION (redo)); 312 addToolBarAction ("redo");
362 g_CurrentToolBar->addAction (ACTION (cut)); 313 addToolBarAction ("cut");
363 g_CurrentToolBar->addAction (ACTION (copy)); 314 addToolBarAction ("copy");
364 g_CurrentToolBar->addAction (ACTION (paste)); 315 addToolBarAction ("paste");
365 g_CurrentToolBar->addAction (ACTION (del)); 316 addToolBarAction ("del");
366 317
367 // ========================================== 318 // ==========================================
368 initSingleToolBar ("Select"); 319 initSingleToolBar ("Select");
369 g_CurrentToolBar->addAction (ACTION (selectAll)); 320 addToolBarAction ("selectAll");
370 g_CurrentToolBar->addAction (ACTION (selectByColor)); 321 addToolBarAction ("selectByColor");
371 g_CurrentToolBar->addAction (ACTION (selectByType)); 322 addToolBarAction ("selectByType");
372 323
373 addToolBarBreak (Qt::TopToolBarArea); 324 addToolBarBreak (Qt::TopToolBarArea);
374 325
375 // ========================================== 326 // ==========================================
376 initSingleToolBar ("Move"); 327 initSingleToolBar ("Move");
377 g_CurrentToolBar->addAction (ACTION (moveUp)); 328 addToolBarAction ("moveUp");
378 g_CurrentToolBar->addAction (ACTION (moveDown)); 329 addToolBarAction ("moveDown");
379 g_CurrentToolBar->addAction (ACTION (moveXPos)); 330 addToolBarAction ("moveXPos");
380 g_CurrentToolBar->addAction (ACTION (moveXNeg)); 331 addToolBarAction ("moveXNeg");
381 g_CurrentToolBar->addAction (ACTION (moveYPos)); 332 addToolBarAction ("moveYPos");
382 g_CurrentToolBar->addAction (ACTION (moveYNeg)); 333 addToolBarAction ("moveYNeg");
383 g_CurrentToolBar->addAction (ACTION (moveZPos)); 334 addToolBarAction ("moveZPos");
384 g_CurrentToolBar->addAction (ACTION (moveZNeg)); 335 addToolBarAction ("moveZNeg");
385 336
386 // ========================================== 337 // ==========================================
387 initSingleToolBar ("Rotate"); 338 initSingleToolBar ("Rotate");
388 g_CurrentToolBar->addAction (ACTION (rotateXPos)); 339 addToolBarAction ("rotateXPos");
389 g_CurrentToolBar->addAction (ACTION (rotateXNeg)); 340 addToolBarAction ("rotateXNeg");
390 g_CurrentToolBar->addAction (ACTION (rotateYPos)); 341 addToolBarAction ("rotateYPos");
391 g_CurrentToolBar->addAction (ACTION (rotateYNeg)); 342 addToolBarAction ("rotateYNeg");
392 g_CurrentToolBar->addAction (ACTION (rotateZPos)); 343 addToolBarAction ("rotateZPos");
393 g_CurrentToolBar->addAction (ACTION (rotateZNeg)); 344 addToolBarAction ("rotateZNeg");
394 345
395 // ========================================== 346 // ==========================================
396 // Grid toolbar 347 // Grid toolbar
397 initSingleToolBar ("Grids"); 348 initSingleToolBar ("Grids");
398 g_CurrentToolBar->addAction (ACTION (gridCoarse)); 349 addToolBarAction ("gridCoarse");
399 g_CurrentToolBar->addAction (ACTION (gridMedium)); 350 addToolBarAction ("gridMedium");
400 g_CurrentToolBar->addAction (ACTION (gridFine)); 351 addToolBarAction ("gridFine");
401 addToolBarBreak (Qt::TopToolBarArea); 352 addToolBarBreak (Qt::TopToolBarArea);
402 353
403 // ========================================== 354 // ==========================================
404 initSingleToolBar ("View"); 355 initSingleToolBar ("View");
405 g_CurrentToolBar->addAction (ACTION (axes)); 356 addToolBarAction ("axes");
406 357
407 // ========================================== 358 // ==========================================
408 // Color toolbar 359 // Color toolbar
409 m_colorToolBar = new QToolBar ("Quick Colors"); 360 m_colorToolBar = new QToolBar ("Quick Colors");
410 addToolBar (Qt::RightToolBarArea, m_colorToolBar); 361 addToolBar (Qt::RightToolBarArea, m_colorToolBar);
411 362
412 // ========================================== 363 // ==========================================
413 // Left area toolbars 364 // Left area toolbars
414 //g_ToolBarArea = Qt::LeftToolBarArea; 365 //g_ToolBarArea = Qt::LeftToolBarArea;
415 initSingleToolBar ("Tools"); 366 initSingleToolBar ("Tools");
416 g_CurrentToolBar->addAction (ACTION (setColor)); 367 addToolBarAction ("setColor");
417 g_CurrentToolBar->addAction (ACTION (invert)); 368 addToolBarAction ("invert");
418 g_CurrentToolBar->addAction (ACTION (inlineContents)); 369 addToolBarAction ("inlineContents");
419 g_CurrentToolBar->addAction (ACTION (deepInline)); 370 addToolBarAction ("deepInline");
420 g_CurrentToolBar->addAction (ACTION (splitQuads)); 371 addToolBarAction ("splitQuads");
421 g_CurrentToolBar->addAction (ACTION (setContents)); 372 addToolBarAction ("setContents");
422 g_CurrentToolBar->addAction (ACTION (makeBorders)); 373 addToolBarAction ("makeBorders");
423 g_CurrentToolBar->addAction (ACTION (makeCornerVerts)); 374 addToolBarAction ("makeCornerVerts");
424 g_CurrentToolBar->addAction (ACTION (roundCoords)); 375 addToolBarAction ("roundCoords");
425 g_CurrentToolBar->addAction (ACTION (screencap)); 376 addToolBarAction ("screencap");
426 g_CurrentToolBar->addAction (ACTION (uncolorize)); 377 addToolBarAction ("uncolorize");
427 378
428 379
429 updateToolBars (); 380 updateToolBars ();
430 } 381 }
431 382
486 // ============================================================================= 437 // =============================================================================
487 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 438 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
488 // ============================================================================= 439 // =============================================================================
489 void ForgeWindow::updateGridToolBar () { 440 void ForgeWindow::updateGridToolBar () {
490 // Ensure that the current grid - and only the current grid - is selected. 441 // Ensure that the current grid - and only the current grid - is selected.
491 ACTION (gridCoarse)->setChecked (grid == Grid::Coarse); 442 findAction ("gridCoarse")->setChecked (grid == Grid::Coarse);
492 ACTION (gridMedium)->setChecked (grid == Grid::Medium); 443 findAction ("gridMedium")->setChecked (grid == Grid::Medium);
493 ACTION (gridFine)->setChecked (grid == Grid::Fine); 444 findAction ("gridFine")->setChecked (grid == Grid::Fine);
494 } 445 }
495 446
496 // ============================================================================= 447 // =============================================================================
497 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 448 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
498 // ============================================================================= 449 // =============================================================================
729 if (g_bSelectionLocked == true || g_curfile == null) 680 if (g_bSelectionLocked == true || g_curfile == null)
730 return; 681 return;
731 682
732 /* 683 /*
733 // If the selection isn't 1 exact, disable setting contents 684 // If the selection isn't 1 exact, disable setting contents
734 ACTION (setContents)->setEnabled (qObjList->selectedItems().size() == 1); 685 findAction ("setContents")->setEnabled (qObjList->selectedItems().size() == 1);
735 686
736 // If we have no selection, disable splitting quads 687 // If we have no selection, disable splitting quads
737 ACTION (splitQuads)->setEnabled (qObjList->selectedItems().size() > 0); 688 findAction ("splitQuads")->setEnabled (qObjList->selectedItems().size() > 0);
738 */ 689 */
739 690
740 // Update the shared selection array, though don't do this if this was 691 // Update the shared selection array, though don't do this if this was
741 // called during GL picking, in which case the GL renderer takes care 692 // called during GL picking, in which case the GL renderer takes care
742 // of the selection. 693 // of the selection.
920 const bool single = (g_win->sel ().size () == 1); 871 const bool single = (g_win->sel ().size () == 1);
921 872
922 QMenu* contextMenu = new QMenu; 873 QMenu* contextMenu = new QMenu;
923 874
924 if (single) { 875 if (single) {
925 contextMenu->addAction (ACTION (editObject)); 876 contextMenu->addAction (findAction ("editObject"));
926 contextMenu->addSeparator (); 877 contextMenu->addSeparator ();
927 } 878 }
928 879
929 contextMenu->addAction (ACTION (cut)); 880 contextMenu->addAction (findAction ("cut"));
930 contextMenu->addAction (ACTION (copy)); 881 contextMenu->addAction (findAction ("copy"));
931 contextMenu->addAction (ACTION (paste)); 882 contextMenu->addAction (findAction ("paste"));
932 contextMenu->addAction (ACTION (del)); 883 contextMenu->addAction (findAction ("del"));
933 contextMenu->addSeparator (); 884 contextMenu->addSeparator ();
934 contextMenu->addAction (ACTION (setColor)); 885 contextMenu->addAction (findAction ("setColor"));
935 if (single) 886 if (single)
936 contextMenu->addAction (ACTION (setContents)); 887 contextMenu->addAction (findAction ("setContents"));
937 contextMenu->addAction (ACTION (makeBorders)); 888 contextMenu->addAction (findAction ("makeBorders"));
938 889
939 contextMenu->exec (pos); 890 contextMenu->exec (pos);
940 } 891 }
941 892
942 // ============================================================================= 893 // =============================================================================
1021 break; 972 break;
1022 } 973 }
1023 974
1024 m_msglog->setHtml (log); 975 m_msglog->setHtml (log);
1025 } 976 }
977
978 // =============================================================================
979 QAction* const& findAction (str name) {
980 for (actionmeta& meta : g_ActionMeta)
981 if (name == meta.name)
982 return *meta.qAct;
983
984 return null;
985 }

mercurial