src/gui.h

changeset 587
507e5d5c348c
parent 575
59c0b57e843b
child 590
7aec744ce97b
equal deleted inserted replaced
586:89d1161197d3 587:507e5d5c348c
23 #include <QAction> 23 #include <QAction>
24 #include <QListWidget> 24 #include <QListWidget>
25 #include <QRadioButton> 25 #include <QRadioButton>
26 #include "config.h" 26 #include "config.h"
27 #include "ldtypes.h" 27 #include "ldtypes.h"
28 #include "ui_ldforge.h"
28 29
29 class MessageManager; 30 class MessageManager;
30 class ForgeWindow; 31 class ForgeWindow;
31 class LDColor; 32 class LDColor;
32 class QToolButton; 33 class QToolButton;
39 // Stuff for dialogs 40 // Stuff for dialogs
40 #define IMPLEMENT_DIALOG_BUTTONS \ 41 #define IMPLEMENT_DIALOG_BUTTONS \
41 bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); \ 42 bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); \
42 connect (bbx_buttons, SIGNAL (accepted()), this, SLOT (accept())); \ 43 connect (bbx_buttons, SIGNAL (accepted()), this, SLOT (accept())); \
43 connect (bbx_buttons, SIGNAL (rejected()), this, SLOT (reject())); \ 44 connect (bbx_buttons, SIGNAL (rejected()), this, SLOT (reject())); \
44 45
45 // ============================================================================= 46 // =============================================================================
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
47 // ============================================================================= 48 // =============================================================================
48 #define DEFINE_ACTION(NAME, DEFSHORTCUT) \ 49 #define DEFINE_ACTION(NAME, DEFSHORTCUT) \
49 cfg (KeySequence, key_##NAME, DEFSHORTCUT); \ 50 cfg (KeySequence, key_action##NAME, DEFSHORTCUT); \
50 void actiondef_##NAME() 51 void ForgeWindow::slot_action##NAME()
51
52 #define ACTION(N) g_win->action##N()
53 52
54 // Convenience macros for key sequences. 53 // Convenience macros for key sequences.
55 #define KEY(N) (Qt::Key_##N) 54 #define KEY(N) (Qt::Key_##N)
56 #define CTRL(N) (Qt::CTRL | Qt::Key_##N) 55 #define CTRL(N) (Qt::CTRL | Qt::Key_##N)
57 #define SHIFT(N) (Qt::SHIFT | Qt::Key_##N) 56 #define SHIFT(N) (Qt::SHIFT | Qt::Key_##N)
88 // slot_action, which is what all actions connect to. Manages menus and toolbars. 87 // slot_action, which is what all actions connect to. Manages menus and toolbars.
89 // Large and in charge. 88 // Large and in charge.
90 // ============================================================================= 89 // =============================================================================
91 class ForgeWindow : public QMainWindow 90 class ForgeWindow : public QMainWindow
92 { Q_OBJECT 91 { Q_OBJECT
92
93 typedefs:
94 using ActionMethodType = void (ForgeWindow::*)();
93 95
94 public: 96 public:
95 ForgeWindow(); 97 ForgeWindow();
96 void buildObjList(); 98 void buildObjList();
97 void updateTitle(); 99 void updateTitle();
123 { m_quickColors = colors; 125 { m_quickColors = colors;
124 } 126 }
125 127
126 void setStatusBarText (str text); 128 void setStatusBarText (str text);
127 void addMessage (str msg); 129 void addMessage (str msg);
128 Ui_LDForgeUI* interface() const; 130 Ui_LDForgeUI* getInterface() const;
129 void refreshObjectList(); 131 void refreshObjectList();
130 void beginAction (QAction* act); 132 void updateActionShortcuts();
133 KeySequenceConfig& shortcutForAction (QAction* act);
131 void endAction(); 134 void endAction();
132
133 #define act(N) QAction* action##N();
134 #include "actions.h"
135 135
136 public slots: 136 public slots:
137 #if 0 137 #if 0
138 void primitiveLoaderStart (int max); 138 void primitiveLoaderStart (int max);
139 void primitiveLoaderUpdate (int prog); 139 void primitiveLoaderUpdate (int prog);
140 void primitiveLoaderEnd(); 140 void primitiveLoaderEnd();
141 #endif // 0 141 #endif // 0
142 void changeCurrentFile();
142 void slot_action(); 143 void slot_action();
143 void changeCurrentFile(); 144 void slot_actionNew();
145 void slot_actionNewFile();
146 void slot_actionOpen();
147 void slot_actionDownloadFrom();
148 void slot_actionSave();
149 void slot_actionSaveAs();
150 void slot_actionSaveAll();
151 void slot_actionClose();
152 void slot_actionCloseAll();
153 void slot_actionInsertFrom();
154 void slot_actionExportTo();
155 void slot_actionSettings();
156 void slot_actionSetLDrawPath();
157 void slot_actionScanPrimitives();
158 void slot_actionExit();
159 void slot_actionResetView();
160 void slot_actionAxes();
161 void slot_actionWireframe();
162 void slot_actionBFCView();
163 void slot_actionSetOverlay();
164 void slot_actionClearOverlay();
165 void slot_actionScreenshot();
166 void slot_actionInsertRaw();
167 void slot_actionNewSubfile();
168 void slot_actionNewLine();
169 void slot_actionNewTriangle();
170 void slot_actionNewQuad();
171 void slot_actionNewCLine();
172 void slot_actionNewComment();
173 void slot_actionNewBFC();
174 void slot_actionNewVertex();
175 void slot_actionUndo();
176 void slot_actionRedo();
177 void slot_actionCut();
178 void slot_actionCopy();
179 void slot_actionPaste();
180 void slot_actionDelete();
181 void slot_actionSelectAll();
182 void slot_actionSelectByColor();
183 void slot_actionSelectByType();
184 void slot_actionModeDraw();
185 void slot_actionModeSelect();
186 void slot_actionModeCircle();
187 void slot_actionSetDrawDepth();
188 void slot_actionSetColor();
189 void slot_actionAutocolor();
190 void slot_actionUncolorize();
191 void slot_actionInline();
192 void slot_actionInlineDeep();
193 void slot_actionInvert();
194 void slot_actionMakePrimitive();
195 void slot_actionSplitQuads();
196 void slot_actionEditRaw();
197 void slot_actionBorders();
198 void slot_actionCornerVerts();
199 void slot_actionRoundCoordinates();
200 void slot_actionVisibilityHide();
201 void slot_actionVisibilityReveal();
202 void slot_actionVisibilityToggle();
203 void slot_actionReplaceCoords();
204 void slot_actionFlip();
205 void slot_actionDemote();
206 void slot_actionYtruder();
207 void slot_actionRectifier();
208 void slot_actionIntersector();
209 void slot_actionIsecalc();
210 void slot_actionCoverer();
211 void slot_actionEdger2();
212 void slot_actionHelp();
213 void slot_actionAbout();
214 void slot_actionAboutQt();
215 void slot_actionGridCoarse();
216 void slot_actionGridMedium();
217 void slot_actionGridFine();
218 void slot_actionEdit();
219 void slot_actionMoveUp();
220 void slot_actionMoveDown();
221 void slot_actionMoveXNeg();
222 void slot_actionMoveXPos();
223 void slot_actionMoveYNeg();
224 void slot_actionMoveYPos();
225 void slot_actionMoveZNeg();
226 void slot_actionMoveZPos();
227 void slot_actionRotateXNeg();
228 void slot_actionRotateXPos();
229 void slot_actionRotateYNeg();
230 void slot_actionRotateYPos();
231 void slot_actionRotateZNeg();
232 void slot_actionRotateZPos();
233 void slot_actionRotationPoint();
234 void slot_actionAddHistoryLine();
235 void slot_actionJumpTo();
236 void slot_actionSubfileSelection();
237 void slot_actionDrawAngles();
144 238
145 protected: 239 protected:
146 void closeEvent (QCloseEvent* ev); 240 void closeEvent (QCloseEvent* ev);
147 241
148 private: 242 private:
154 QList<QToolButton*> m_colorButtons; 248 QList<QToolButton*> m_colorButtons;
155 QList<QAction*> m_recentFiles; 249 QList<QAction*> m_recentFiles;
156 MessageManager* m_msglog; 250 MessageManager* m_msglog;
157 Ui_LDForgeUI* ui; 251 Ui_LDForgeUI* ui;
158 252
159 void invokeAction (QAction* act, void (*func)());
160
161
162 private slots: 253 private slots:
163 void slot_selectionChanged(); 254 void slot_selectionChanged();
164 void slot_recentFile(); 255 void slot_recentFile();
165 void slot_quickColor(); 256 void slot_quickColor();
166 void slot_lastSecondCleanup(); 257 void slot_lastSecondCleanup();
167 void slot_editObject (QListWidgetItem* listitem); 258 void slot_editObject (QListWidgetItem* listitem);
168 }; 259 };
169
170 #define INVOKE_ACTION(N) actiondef_##N();
171 #define act(N) void actiondef_##N();
172 #include "actions.h"
173 260
174 // ----------------------------------------------------------------------------- 261 // -----------------------------------------------------------------------------
175 // Pointer to the instance of ForgeWindow. 262 // Pointer to the instance of ForgeWindow.
176 extern ForgeWindow* g_win; 263 extern ForgeWindow* g_win;
177 264

mercurial