66 bool isSeparator() const; |
66 bool isSeparator() const; |
67 |
67 |
68 static LDQuickColor getSeparator(); |
68 static LDQuickColor getSeparator(); |
69 }; |
69 }; |
70 |
70 |
71 //! |
71 // |
72 //! Object list class for MainWindow |
72 // Object list class for MainWindow |
73 //! |
73 // |
74 class ObjectList : public QListWidget |
74 class ObjectList : public QListWidget |
75 { |
75 { |
76 Q_OBJECT |
76 Q_OBJECT |
77 |
77 |
78 protected: |
78 protected: |
79 void contextMenuEvent (QContextMenuEvent* ev); |
79 void contextMenuEvent (QContextMenuEvent* ev); |
80 }; |
80 }; |
81 |
81 |
82 //! |
82 // |
83 //! \brief The main window class. |
83 // LDForge's main GUI class. |
84 //! |
84 // |
85 //! The MainWindow is LDForge's main GUI. It hosts the renderer, the object list, |
|
86 //! the message log, etc. Contains \c slot_action(), which is what all actions |
|
87 //! connect to. |
|
88 //! |
|
89 class MainWindow : public QMainWindow |
85 class MainWindow : public QMainWindow |
90 { |
86 { |
91 Q_OBJECT |
87 Q_OBJECT |
92 |
88 |
93 public: |
89 public: |
94 //! Constructs the main window |
90 explicit MainWindow (QWidget* parent = null, Qt::WindowFlags flags = 0); |
95 explicit MainWindow (QWidget* parent = null, Qt::WindowFlags flags = 0); |
91 |
96 |
92 // Rebuilds the object list. |
97 //! Rebuilds the object list, located to the right of the GUI. |
93 void buildObjList(); |
98 void buildObjList(); |
94 |
99 |
95 // Updates the window title. |
100 //! Updates the window title. |
96 void updateTitle(); |
101 void updateTitle(); |
97 |
102 |
98 // Builds the object list and tells the GL renderer to init a full |
103 //! Builds the object list and tells the GL renderer to init a full |
99 // refresh. |
104 //! refresh. |
100 void doFullRefresh(); |
105 void doFullRefresh(); |
101 |
106 |
102 // Builds the object list and tells the GL renderer to do a soft update. |
107 //! Builds the object list and tells the GL renderer to do a soft update. |
103 void refresh(); |
108 void refresh(); |
104 |
109 |
105 // Returns the suggested position to place a new object at. |
110 //! \returns the suggested position to place a new object at. |
106 int getInsertionPoint(); |
111 int getInsertionPoint(); |
107 |
112 |
108 // Updates the quick color toolbar |
113 //! Updates the quick color toolbar |
109 void updateColorToolbar(); |
114 void updateColorToolbar(); |
110 |
115 |
111 // Rebuilds the recent files submenu |
116 //! Rebuilds the recent files submenu |
112 void updateRecentFilesMenu(); |
117 void updateRecentFilesMenu(); |
113 |
118 |
114 // Sets the selection based on what's selected in the object list. |
119 //! Sets the selection based on what's selected in the object list. |
115 void updateSelection(); |
120 void updateSelection(); |
116 |
121 |
117 // Updates the grids, selects the selected grid and deselects others. |
122 //! Updates the grids, selects the selected grid and deselects others. |
118 void updateGridToolBar(); |
123 void updateGridToolBar(); |
119 |
124 |
120 // Updates the edit modes, current one is selected and others are deselected. |
125 //! Updates the edit modes, current one is selected and others are deselected. |
121 void updateEditModeActions(); |
126 void updateEditModeActions(); |
122 |
127 |
123 // Rebuilds the document tab list. |
128 //! Rebuilds the document tab list. |
124 void updateDocumentList(); |
129 void updateDocumentList(); |
125 |
130 |
126 // Updates the document tab for \c doc. If no such tab exists, the |
131 //! Updates the document tab for \c doc. If no such tab exists, the |
127 // document list is rebuilt instead. |
132 //! document list is rebuilt instead. |
128 void updateDocumentListItem (LDDocumentPtr doc); |
133 void updateDocumentListItem (LDDocumentPtr doc); |
129 |
134 |
130 // Returns the uniform selected color (i.e. 4 if everything selected is |
135 //! \returns the uniform selected color (i.e. 4 if everything selected is |
131 // red), -1 if there is no such consensus. |
136 //! red), -1 if there is no such consensus. |
132 int getSelectedColor(); |
137 int getSelectedColor(); |
133 |
138 |
134 // Automatically scrolls the object list so that it points to the first |
139 //! Automatically scrolls the object list so that it points to the first |
135 // selected object. |
140 //! selected object. |
136 void scrollToSelection(); |
141 void scrollToSelection(); |
137 |
142 |
138 // Spawns the context menu at the given position. |
143 //! Spawns the context menu at the given position. |
139 void spawnContextMenu (const QPoint pos); |
144 void spawnContextMenu (const QPoint pos); |
140 |
145 |
141 // Deletes all selected objects, returns the count of deleted objects. |
146 //! Deletes all selected objects. |
142 int deleteSelection(); |
147 //! \returns the count of deleted objects. |
143 |
148 int deleteSelection(); |
144 // Deletes all objects by the given color number. |
149 |
145 void deleteByColor (int colnum); |
150 //! Deletes all objects by the given color number. |
146 |
151 void deleteByColor (int colnum); |
147 // Tries to save the given document. |
152 |
148 bool save (LDDocumentPtr doc, bool saveAs); |
153 //! Tries to save the given document. |
149 |
154 //! \param doc the document to save |
150 // Updates various actions, undo/redo are set enabled/disabled where |
155 //! \param saveAs if true, always ask for a file path |
151 // appropriate, togglable actions are updated based on configuration, |
156 //! \returns whether the save was successful |
152 // etc. |
157 bool save (LDDocumentPtr doc, bool saveAs); |
153 void updateActions(); |
158 |
154 |
159 //! Updates various actions, undo/redo are set enabled/disabled where |
155 // Returns a pointer to the renderer |
160 //! appropriate, togglable actions are updated based on configuration, |
156 inline GLRenderer* R() |
161 //! etc. |
157 { |
162 void updateActions(); |
158 return m_renderer; |
163 |
159 } |
164 //! \returns a pointer to the renderer |
160 |
165 inline GLRenderer* R() |
161 // Sets the quick color list to the given list of colors. |
166 { |
162 inline void setQuickColors (const QList<LDQuickColor>& colors) |
167 return m_renderer; |
163 { |
168 } |
164 m_quickColors = colors; |
169 |
165 updateColorToolbar(); |
170 //! Sets the quick color list to the given list of colors. |
166 } |
171 inline void setQuickColors (const QList<LDQuickColor>& colors) |
167 |
172 { |
168 // Adds a message to the renderer's message manager. |
173 m_quickColors = colors; |
169 void addMessage (QString msg); |
174 updateColorToolbar(); |
170 |
175 } |
171 // Updates the object list. Right now this just rebuilds it. |
176 |
172 void refreshObjectList(); |
177 //! Adds a message to the renderer's message manager. |
173 |
178 void addMessage (QString msg); |
174 // Updates all actions to ensure they have the correct shortcut as |
179 |
175 // defined in the configuration entries. |
180 //! Updates the object list. Right now this just rebuilds it. |
176 void updateActionShortcuts(); |
181 void refreshObjectList(); |
177 |
182 |
178 // Gets the shortcut configuration for the given \c action |
183 //! Updates all actions to ensure they have the correct shortcut as |
179 KeySequenceConfigEntry* shortcutForAction (QAction* action); |
184 //! defined in the configuration entries. |
180 |
185 void updateActionShortcuts(); |
181 void endAction(); |
186 |
182 |
187 //! Gets the shortcut configuration for the given \c action |
183 inline QTreeWidget* getPrimitivesTree() const |
188 KeySequenceConfigEntry* shortcutForAction (QAction* action); |
184 { |
189 |
185 return ui->primitives; |
190 void endAction(); |
186 } |
191 |
187 |
192 inline QTreeWidget* getPrimitivesTree() const |
188 public slots: |
193 { |
189 void updatePrimitives(); |
194 return ui->primitives; |
190 void changeCurrentFile(); |
195 } |
191 void slot_action(); |
196 |
192 void slot_actionNew(); |
197 public slots: |
193 void slot_actionNewFile(); |
198 void updatePrimitives(); |
194 void slot_actionOpen(); |
199 void changeCurrentFile(); |
195 void slot_actionDownloadFrom(); |
200 void slot_action(); |
196 void slot_actionSave(); |
201 void slot_actionNew(); |
197 void slot_actionSaveAs(); |
202 void slot_actionNewFile(); |
198 void slot_actionSaveAll(); |
203 void slot_actionOpen(); |
199 void slot_actionClose(); |
204 void slot_actionDownloadFrom(); |
200 void slot_actionCloseAll(); |
205 void slot_actionSave(); |
201 void slot_actionInsertFrom(); |
206 void slot_actionSaveAs(); |
202 void slot_actionExportTo(); |
207 void slot_actionSaveAll(); |
203 void slot_actionSettings(); |
208 void slot_actionClose(); |
204 void slot_actionSetLDrawPath(); |
209 void slot_actionCloseAll(); |
205 void slot_actionScanPrimitives(); |
210 void slot_actionInsertFrom(); |
206 void slot_actionExit(); |
211 void slot_actionExportTo(); |
207 void slot_actionResetView(); |
212 void slot_actionSettings(); |
208 void slot_actionAxes(); |
213 void slot_actionSetLDrawPath(); |
209 void slot_actionWireframe(); |
214 void slot_actionScanPrimitives(); |
210 void slot_actionBFCView(); |
215 void slot_actionExit(); |
211 void slot_actionSetOverlay(); |
216 void slot_actionResetView(); |
212 void slot_actionClearOverlay(); |
217 void slot_actionAxes(); |
213 void slot_actionScreenshot(); |
218 void slot_actionWireframe(); |
214 void slot_actionInsertRaw(); |
219 void slot_actionBFCView(); |
215 void slot_actionNewSubfile(); |
220 void slot_actionSetOverlay(); |
216 void slot_actionNewLine(); |
221 void slot_actionClearOverlay(); |
217 void slot_actionNewTriangle(); |
222 void slot_actionScreenshot(); |
218 void slot_actionNewQuad(); |
223 void slot_actionInsertRaw(); |
219 void slot_actionNewCLine(); |
224 void slot_actionNewSubfile(); |
220 void slot_actionNewComment(); |
225 void slot_actionNewLine(); |
221 void slot_actionNewBFC(); |
226 void slot_actionNewTriangle(); |
222 void slot_actionNewVertex(); |
227 void slot_actionNewQuad(); |
223 void slot_actionUndo(); |
228 void slot_actionNewCLine(); |
224 void slot_actionRedo(); |
229 void slot_actionNewComment(); |
225 void slot_actionCut(); |
230 void slot_actionNewBFC(); |
226 void slot_actionCopy(); |
231 void slot_actionNewVertex(); |
227 void slot_actionPaste(); |
232 void slot_actionUndo(); |
228 void slot_actionDelete(); |
233 void slot_actionRedo(); |
229 void slot_actionSelectAll(); |
234 void slot_actionCut(); |
230 void slot_actionSelectByColor(); |
235 void slot_actionCopy(); |
231 void slot_actionSelectByType(); |
236 void slot_actionPaste(); |
232 void slot_actionModeDraw(); |
237 void slot_actionDelete(); |
233 void slot_actionModeSelect(); |
238 void slot_actionSelectAll(); |
234 void slot_actionModeCircle(); |
239 void slot_actionSelectByColor(); |
235 void slot_actionSetDrawDepth(); |
240 void slot_actionSelectByType(); |
236 void slot_actionSetColor(); |
241 void slot_actionModeDraw(); |
237 void slot_actionAutocolor(); |
242 void slot_actionModeSelect(); |
238 void slot_actionUncolor(); |
243 void slot_actionModeCircle(); |
239 void slot_actionInline(); |
244 void slot_actionSetDrawDepth(); |
240 void slot_actionInlineDeep(); |
245 void slot_actionSetColor(); |
241 void slot_actionInvert(); |
246 void slot_actionAutocolor(); |
242 void slot_actionMakePrimitive(); |
247 void slot_actionUncolor(); |
243 void slot_actionSplitQuads(); |
248 void slot_actionInline(); |
244 void slot_actionEditRaw(); |
249 void slot_actionInlineDeep(); |
245 void slot_actionBorders(); |
250 void slot_actionInvert(); |
246 void slot_actionCornerVerts(); |
251 void slot_actionMakePrimitive(); |
247 void slot_actionRoundCoordinates(); |
252 void slot_actionSplitQuads(); |
248 void slot_actionVisibilityHide(); |
253 void slot_actionEditRaw(); |
249 void slot_actionVisibilityReveal(); |
254 void slot_actionBorders(); |
250 void slot_actionVisibilityToggle(); |
255 void slot_actionCornerVerts(); |
251 void slot_actionReplaceCoords(); |
256 void slot_actionRoundCoordinates(); |
252 void slot_actionFlip(); |
257 void slot_actionVisibilityHide(); |
253 void slot_actionDemote(); |
258 void slot_actionVisibilityReveal(); |
254 void slot_actionYtruder(); |
259 void slot_actionVisibilityToggle(); |
255 void slot_actionRectifier(); |
260 void slot_actionReplaceCoords(); |
256 void slot_actionIntersector(); |
261 void slot_actionFlip(); |
257 void slot_actionIsecalc(); |
262 void slot_actionDemote(); |
258 void slot_actionCoverer(); |
263 void slot_actionYtruder(); |
259 void slot_actionEdger2(); |
264 void slot_actionRectifier(); |
260 void slot_actionHelp(); |
265 void slot_actionIntersector(); |
261 void slot_actionAbout(); |
266 void slot_actionIsecalc(); |
262 void slot_actionAboutQt(); |
267 void slot_actionCoverer(); |
263 void slot_actionGridCoarse(); |
268 void slot_actionEdger2(); |
264 void slot_actionGridMedium(); |
269 void slot_actionHelp(); |
265 void slot_actionGridFine(); |
270 void slot_actionAbout(); |
266 void slot_actionEdit(); |
271 void slot_actionAboutQt(); |
267 void slot_actionMoveUp(); |
272 void slot_actionGridCoarse(); |
268 void slot_actionMoveDown(); |
273 void slot_actionGridMedium(); |
269 void slot_actionMoveXNeg(); |
274 void slot_actionGridFine(); |
270 void slot_actionMoveXPos(); |
275 void slot_actionEdit(); |
271 void slot_actionMoveYNeg(); |
276 void slot_actionMoveUp(); |
272 void slot_actionMoveYPos(); |
277 void slot_actionMoveDown(); |
273 void slot_actionMoveZNeg(); |
278 void slot_actionMoveXNeg(); |
274 void slot_actionMoveZPos(); |
279 void slot_actionMoveXPos(); |
275 void slot_actionRotateXNeg(); |
280 void slot_actionMoveYNeg(); |
276 void slot_actionRotateXPos(); |
281 void slot_actionMoveYPos(); |
277 void slot_actionRotateYNeg(); |
282 void slot_actionMoveZNeg(); |
278 void slot_actionRotateYPos(); |
283 void slot_actionMoveZPos(); |
279 void slot_actionRotateZNeg(); |
284 void slot_actionRotateXNeg(); |
280 void slot_actionRotateZPos(); |
285 void slot_actionRotateXPos(); |
281 void slot_actionRotationPoint(); |
286 void slot_actionRotateYNeg(); |
282 void slot_actionAddHistoryLine(); |
287 void slot_actionRotateYPos(); |
283 void slot_actionJumpTo(); |
288 void slot_actionRotateZNeg(); |
284 void slot_actionSubfileSelection(); |
289 void slot_actionRotateZPos(); |
285 void slot_actionDrawAngles(); |
290 void slot_actionRotationPoint(); |
286 void slot_actionRandomColors(); |
291 void slot_actionAddHistoryLine(); |
287 void slot_actionOpenSubfiles(); |
292 void slot_actionJumpTo(); |
288 |
293 void slot_actionSubfileSelection(); |
289 protected: |
294 void slot_actionDrawAngles(); |
290 void closeEvent (QCloseEvent* ev); |
295 void slot_actionRandomColors(); |
291 |
296 void slot_actionOpenSubfiles(); |
292 private: |
297 |
293 GLRenderer* m_renderer; |
298 protected: |
294 LDObjectList m_sel; |
299 void closeEvent (QCloseEvent* ev); |
295 QList<LDQuickColor> m_quickColors; |
300 |
296 QList<QToolButton*> m_colorButtons; |
301 private: |
297 QList<QAction*> m_recentFiles; |
302 GLRenderer* m_renderer; |
298 MessageManager* m_msglog; |
303 LDObjectList m_sel; |
299 Ui_LDForgeUI* ui; |
304 QList<LDQuickColor> m_quickColors; |
300 QTabBar* m_tabs; |
305 QList<QToolButton*> m_colorButtons; |
301 bool m_updatingTabs; |
306 QList<QAction*> m_recentFiles; |
302 |
307 MessageManager* m_msglog; |
303 private slots: |
308 Ui_LDForgeUI* ui; |
304 void slot_selectionChanged(); |
309 QTabBar* m_tabs; |
305 void slot_recentFile(); |
310 bool m_updatingTabs; |
306 void slot_quickColor(); |
311 |
307 void slot_lastSecondCleanup(); |
312 private slots: |
308 void slot_editObject (QListWidgetItem* listitem); |
313 void slot_selectionChanged(); |
|
314 void slot_recentFile(); |
|
315 void slot_quickColor(); |
|
316 void slot_lastSecondCleanup(); |
|
317 void slot_editObject (QListWidgetItem* listitem); |
|
318 }; |
309 }; |
319 |
310 |
320 //! Pointer to the instance of MainWindow. |
311 //! Pointer to the instance of MainWindow. |
321 extern MainWindow* g_win; |
312 extern MainWindow* g_win; |
322 |
313 |