77 protected: |
77 protected: |
78 void contextMenuEvent (QContextMenuEvent* ev); |
78 void contextMenuEvent (QContextMenuEvent* ev); |
79 }; |
79 }; |
80 |
80 |
81 //! |
81 //! |
82 //! @brief The main window class. |
82 //! \brief The main window class. |
83 //! |
83 //! |
84 //! The MainWindow is LDForge's main GUI. It hosts the renderer, the object list, |
84 //! The MainWindow is LDForge's main GUI. It hosts the renderer, the object list, |
85 //! the message log, etc. Contains @c slot_action(), which is what all actions |
85 //! the message log, etc. Contains \c slot_action(), which is what all actions |
86 //! connect to. |
86 //! connect to. |
87 //! |
87 //! |
88 class MainWindow : public QMainWindow |
88 class MainWindow : public QMainWindow |
89 { |
89 { |
90 Q_OBJECT |
90 Q_OBJECT |
125 void updateEditModeActions(); |
125 void updateEditModeActions(); |
126 |
126 |
127 //! Rebuilds the document tab list. |
127 //! Rebuilds the document tab list. |
128 void updateDocumentList(); |
128 void updateDocumentList(); |
129 |
129 |
130 //! Updates the document tab for @c doc. If no such tab exists, the |
130 //! Updates the document tab for \c doc. If no such tab exists, the |
131 //! document list is rebuilt instead. |
131 //! document list is rebuilt instead. |
132 void updateDocumentListItem (LDDocument* doc); |
132 void updateDocumentListItem (LDDocument* doc); |
133 |
133 |
134 //! @returns the uniform selected color (i.e. 4 if everything selected is |
134 //! \returns the uniform selected color (i.e. 4 if everything selected is |
135 //! red), -1 if there is no such consensus. |
135 //! red), -1 if there is no such consensus. |
136 int getSelectedColor(); |
136 int getSelectedColor(); |
137 |
137 |
138 //! @returns the uniform selected type (i.e. @c LDObject::ELine if everything |
138 //! \returns the uniform selected type (i.e. \c LDObject::ELine if everything |
139 //! selected is a line), @c LDObject::EUnidentified if there is no such |
139 //! selected is a line), \c LDObject::EUnidentified if there is no such |
140 //! consensus. |
140 //! consensus. |
141 LDObject::Type getUniformSelectedType(); |
141 LDObject::Type getUniformSelectedType(); |
142 |
142 |
143 //! Automatically scrolls the object list so that it points to the first |
143 //! Automatically scrolls the object list so that it points to the first |
144 //! selected object. |
144 //! selected object. |
146 |
146 |
147 //! Spawns the context menu at the given position. |
147 //! Spawns the context menu at the given position. |
148 void spawnContextMenu (const QPoint pos); |
148 void spawnContextMenu (const QPoint pos); |
149 |
149 |
150 //! Deletes all selected objects. |
150 //! Deletes all selected objects. |
151 //! @returns the count of deleted objects. |
151 //! \returns the count of deleted objects. |
152 int deleteSelection(); |
152 int deleteSelection(); |
153 |
153 |
154 //! Deletes all objects by the given color number. |
154 //! Deletes all objects by the given color number. |
155 void deleteByColor (int colnum); |
155 void deleteByColor (int colnum); |
156 |
156 |
157 //! Tries to save the given document. |
157 //! Tries to save the given document. |
158 //! @param doc the document to save |
158 //! \param doc the document to save |
159 //! @param saveAs if true, always ask for a file path |
159 //! \param saveAs if true, always ask for a file path |
160 //! @returns whether the save was successful |
160 //! \returns whether the save was successful |
161 bool save (LDDocument* doc, bool saveAs); |
161 bool save (LDDocument* doc, bool saveAs); |
162 |
162 |
163 //! Updates various actions, undo/redo are set enabled/disabled where |
163 //! Updates various actions, undo/redo are set enabled/disabled where |
164 //! appropriate, togglable actions are updated based on configuration, |
164 //! appropriate, togglable actions are updated based on configuration, |
165 //! etc. |
165 //! etc. |
166 void updateActions(); |
166 void updateActions(); |
167 |
167 |
168 //! @returns a pointer to the renderer |
168 //! \returns a pointer to the renderer |
169 inline GLRenderer* R() |
169 inline GLRenderer* R() |
170 { |
170 { |
171 return m_renderer; |
171 return m_renderer; |
172 } |
172 } |
173 |
173 |
317 extern MainWindow* g_win; |
317 extern MainWindow* g_win; |
318 |
318 |
319 //! Get an icon by name from the resources directory. |
319 //! Get an icon by name from the resources directory. |
320 QPixmap getIcon (QString iconName); |
320 QPixmap getIcon (QString iconName); |
321 |
321 |
322 //! @returns a list of quick colors based on the configuration entry. |
322 //! \returns a list of quick colors based on the configuration entry. |
323 QList<LDQuickColor> quickColorsFromConfig(); |
323 QList<LDQuickColor> quickColorsFromConfig(); |
324 |
324 |
325 //! Asks the user a yes/no question with the given @c message and the given |
325 //! Asks the user a yes/no question with the given \c message and the given |
326 //! window @c title. |
326 //! window \c title. |
327 //! @returns true if the user answered yes, false if no. |
327 //! \returns true if the user answered yes, false if no. |
328 bool confirm (QString title, QString message); // Generic confirm prompt |
328 bool confirm (QString title, QString message); // Generic confirm prompt |
329 |
329 |
330 //! An overload of @c confirm(), this asks the user a yes/no question with the |
330 //! An overload of \c confirm(), this asks the user a yes/no question with the |
331 //! given @c message. |
331 //! given \c message. |
332 //! @returns true if the user answered yes, false if no. |
332 //! \returns true if the user answered yes, false if no. |
333 bool confirm (QString message); |
333 bool confirm (QString message); |
334 |
334 |
335 //! Displays an error prompt with the given @c message |
335 //! Displays an error prompt with the given \c message |
336 void critical (QString message); |
336 void critical (QString message); |
337 |
337 |
338 //! Makes an icon of @c size x @c size pixels to represent @c colinfo |
338 //! Makes an icon of \c size x \c size pixels to represent \c colinfo |
339 QIcon makeColorIcon (LDColor* colinfo, const int size); |
339 QIcon makeColorIcon (LDColor* colinfo, const int size); |
340 |
340 |
341 //! Fills the given combo-box with color information |
341 //! Fills the given combo-box with color information |
342 void makeColorComboBox (QComboBox* box); |
342 void makeColorComboBox (QComboBox* box); |
343 |
343 |
344 //! @returns a QImage from the given raw GL @c data |
344 //! \returns a QImage from the given raw GL \c data |
345 QImage imageFromScreencap (uchar* data, int w, int h); |
345 QImage imageFromScreencap (uchar* data, int w, int h); |
346 |
346 |
347 //! |
347 //! |
348 //! Takes in pairs of radio buttons and respective values and finds the first |
348 //! Takes in pairs of radio buttons and respective values and finds the first |
349 //! selected one. |
349 //! selected one. |
350 //! @returns returns the value of the first found radio button that was checked |
350 //! \returns returns the value of the first found radio button that was checked |
351 //! @returns by the user. |
351 //! \returns by the user. |
352 //! |
352 //! |
353 template<class T> |
353 template<class T> |
354 T radioSwitch (const T& defval, QList<pair<QRadioButton*, T>> haystack) |
354 T radioSwitch (const T& defval, QList<pair<QRadioButton*, T>> haystack) |
355 { |
355 { |
356 for (pair<QRadioButton*, const T&> i : haystack) |
356 for (pair<QRadioButton*, const T&> i : haystack) |