136 } |
137 } |
137 |
138 |
138 // ============================================================================= |
139 // ============================================================================= |
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
140 // ============================================================================= |
141 // ============================================================================= |
141 #define ADD_MENU_ITEM(MENU, ACT) q##MENU##Menu->addAction (ACTION_NAME (ACT)); |
|
142 |
|
143 void ForgeWindow::createMenus () { |
142 void ForgeWindow::createMenus () { |
|
143 qRecentFilesMenu = new QMenu (tr ("Open &Recent")); |
|
144 qRecentFilesMenu->setIcon (getIcon ("open-recent")); |
|
145 updateRecentFilesMenu (); |
|
146 |
144 // File menu |
147 // File menu |
145 qFileMenu = menuBar ()->addMenu (tr ("&File")); |
148 qFileMenu = menuBar ()->addMenu (tr ("&File")); |
146 ADD_MENU_ITEM (File, newFile) // New |
149 qFileMenu->addAction (ACTION_NAME (newFile)); // New |
147 ADD_MENU_ITEM (File, open) // Open |
150 qFileMenu->addAction (ACTION_NAME (open)); // Open |
148 ADD_MENU_ITEM (File, save) // Save |
151 qFileMenu->addMenu (qRecentFilesMenu); // Open Recent |
149 ADD_MENU_ITEM (File, saveAs) // Save As |
152 qFileMenu->addAction (ACTION_NAME (save)); // Save |
150 qFileMenu->addSeparator (); // ------- |
153 qFileMenu->addAction (ACTION_NAME (saveAs)); // Save As |
151 ADD_MENU_ITEM (File, settings) // Settings |
154 qFileMenu->addSeparator (); // ------- |
152 qFileMenu->addSeparator (); // ------- |
155 qFileMenu->addAction (ACTION_NAME (settings)); // Settings |
153 ADD_MENU_ITEM (File, exit) // Exit |
156 qFileMenu->addSeparator (); // ------- |
|
157 qFileMenu->addAction (ACTION_NAME (exit)); // Exit |
154 |
158 |
155 // Insert menu |
159 // Insert menu |
156 qInsertMenu = menuBar ()->addMenu (tr ("&Insert")); |
160 qInsertMenu = menuBar ()->addMenu (tr ("&Insert")); |
157 ADD_MENU_ITEM (Insert, newSubfile) // New Subfile |
161 qInsertMenu->addAction (ACTION_NAME (newSubfile)); // New Subfile |
158 ADD_MENU_ITEM (Insert, newLine) // New Line |
162 qInsertMenu->addAction (ACTION_NAME (newLine)); // New Line |
159 ADD_MENU_ITEM (Insert, newTriangle) // New Triangle |
163 qInsertMenu->addAction (ACTION_NAME (newTriangle)); // New Triangle |
160 ADD_MENU_ITEM (Insert, newQuad) // New Quad |
164 qInsertMenu->addAction (ACTION_NAME (newQuad)); // New Quad |
161 ADD_MENU_ITEM (Insert, newCondLine) // New Conditional Line |
165 qInsertMenu->addAction (ACTION_NAME (newCondLine)); // New Conditional Line |
162 ADD_MENU_ITEM (Insert, newComment) // New Comment |
166 qInsertMenu->addAction (ACTION_NAME (newComment)); // New Comment |
163 ADD_MENU_ITEM (Insert, newVertex) // New Vertex |
167 qInsertMenu->addAction (ACTION_NAME (newVertex)); // New Vertex |
164 |
168 |
165 // Edit menu |
169 // Edit menu |
166 qEditMenu = menuBar ()->addMenu (tr ("&Edit")); |
170 qEditMenu = menuBar ()->addMenu (tr ("&Edit")); |
167 ADD_MENU_ITEM (Edit, undo) // Undo |
171 qEditMenu->addAction (ACTION_NAME (undo)); // Undo |
168 ADD_MENU_ITEM (Edit, redo) // Redo |
172 qEditMenu->addAction (ACTION_NAME (redo)); // Redo |
169 qEditMenu->addSeparator (); // ----- |
173 qEditMenu->addSeparator (); // ----- |
170 ADD_MENU_ITEM (Edit, cut) // Cut |
174 qEditMenu->addAction (ACTION_NAME (cut)); // Cut |
171 ADD_MENU_ITEM (Edit, copy) // Copy |
175 qEditMenu->addAction (ACTION_NAME (copy)); // Copy |
172 ADD_MENU_ITEM (Edit, paste) // Paste |
176 qEditMenu->addAction (ACTION_NAME (paste)); // Paste |
173 ADD_MENU_ITEM (Edit, del) // Delete |
177 qEditMenu->addAction (ACTION_NAME (del)); // Delete |
174 qEditMenu->addSeparator (); // ----- |
178 qEditMenu->addSeparator (); // ----- |
175 ADD_MENU_ITEM (Edit, moveUp) // Move Up |
179 qEditMenu->addAction (ACTION_NAME (moveUp)); // Move Up |
176 ADD_MENU_ITEM (Edit, moveDown) // Move Down |
180 qEditMenu->addAction (ACTION_NAME (moveDown)); // Move Down |
177 qEditMenu->addSeparator (); // ----- |
181 qEditMenu->addSeparator (); // ----- |
178 ADD_MENU_ITEM (Edit, setColor) // Set Color |
182 qEditMenu->addAction (ACTION_NAME (setColor)); // Set Color |
179 ADD_MENU_ITEM (Edit, inlineContents) // Inline |
183 qEditMenu->addAction (ACTION_NAME (inlineContents)); // Inline |
180 ADD_MENU_ITEM (Edit, deepInline) // Deep Inline |
184 qEditMenu->addAction (ACTION_NAME (deepInline)); // Deep Inline |
181 ADD_MENU_ITEM (Edit, splitQuads) // Split Quads |
185 qEditMenu->addAction (ACTION_NAME (splitQuads)); // Split Quads |
182 ADD_MENU_ITEM (Edit, setContents) // Set Contents |
186 qEditMenu->addAction (ACTION_NAME (setContents)); // Set Contents |
183 ADD_MENU_ITEM (Edit, makeBorders) // Make Borders |
187 qEditMenu->addAction (ACTION_NAME (makeBorders)); // Make Borders |
184 |
188 |
185 // Control menu |
189 // Control menu |
186 qControlMenu = menuBar ()->addMenu (tr ("&Control")); |
190 qControlMenu = menuBar ()->addMenu (tr ("&Control")); |
187 ADD_MENU_ITEM (Control, showHistory) // Show History |
191 qControlMenu->addAction (ACTION_NAME (showHistory)); // Show History |
188 |
192 |
189 #ifndef RELEASE |
193 #ifndef RELEASE |
190 // Debug menu |
194 // Debug menu |
191 qDebugMenu = menuBar ()->addMenu (tr ("&Debug")); |
195 qDebugMenu = menuBar ()->addMenu (tr ("&Debug")); |
192 ADD_MENU_ITEM (Debug, addTestQuad) // Add Test Quad |
196 qDebugMenu->addAction (ACTION_NAME (addTestQuad)); // Add Test Quad |
193 #endif // RELEASE |
197 #endif // RELEASE |
194 |
198 |
195 // Help menu |
199 // Help menu |
196 qHelpMenu = menuBar ()->addMenu (tr ("&Help")); |
200 qHelpMenu = menuBar ()->addMenu (tr ("&Help")); |
197 ADD_MENU_ITEM (Help, help) // Help |
201 qHelpMenu->addAction (ACTION_NAME (help)); // Help |
198 qHelpMenu->addSeparator (); // ----- |
202 qHelpMenu->addSeparator (); // ----- |
199 ADD_MENU_ITEM (Help, about) // About |
203 qHelpMenu->addAction (ACTION_NAME (about)); // About |
200 ADD_MENU_ITEM (Help, aboutQt) // About Qt |
204 qHelpMenu->addAction (ACTION_NAME (aboutQt)); // About Qt |
|
205 } |
|
206 |
|
207 // ============================================================================= |
|
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
209 // ============================================================================= |
|
210 void ForgeWindow::updateRecentFilesMenu () { |
|
211 // First, clear any items in the recent files menu |
|
212 for (QAction* qRecent : qaRecentFiles) |
|
213 delete qRecent; |
|
214 qaRecentFiles.clear (); |
|
215 |
|
216 std::vector<str> zaFiles = io_recentfiles.value / "@"; |
|
217 for (long i = zaFiles.size() - 1; i >= 0; --i) { |
|
218 str zFile = zaFiles[i]; |
|
219 |
|
220 QAction* qRecent = new QAction (getIcon ("open-recent"), zFile, this); |
|
221 |
|
222 connect (qRecent, SIGNAL (triggered ()), this, SLOT (slot_recentFile ())); |
|
223 qRecentFilesMenu->addAction (qRecent); |
|
224 qaRecentFiles.push_back (qRecent); |
|
225 } |
201 } |
226 } |
202 |
227 |
203 // ============================================================================= |
228 // ============================================================================= |
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
205 // ============================================================================= |
230 // ============================================================================= |