src/gui.cpp

Thu, 05 Dec 2013 23:20:50 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 05 Dec 2013 23:20:50 +0200
changeset 539
72ad83a67165
parent 538
2f85d4d286e5
child 540
0334789cb4d7
permissions
-rw-r--r--

- upgraded the PROPERTY macro, resulting in a major code refactor

183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
4 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
9 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
14 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
19 #include <QGridLayout>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
20 #include <QMessageBox>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
21 #include <QEvent>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
22 #include <QContextMenuEvent>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
23 #include <QMenuBar>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
24 #include <QStatusBar>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
25 #include <QSplitter>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
26 #include <QListWidget>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
27 #include <QToolButton>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
28 #include <QComboBox>
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
29 #include <QDialogButtonBox>
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 195
diff changeset
30 #include <QToolBar>
290
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
31 #include <QProgressBar>
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
32 #include <QLabel>
310
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
33 #include <QFileDialog>
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
34 #include <QPushButton>
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
35 #include <QCoreApplication>
290
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
36 #include <QTimer>
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
37
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 #include "common.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 #include "gldraw.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 #include "gui.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 #include "file.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 #include "config.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 #include "misc.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 #include "colors.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 #include "history.h"
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
46 #include "widgets.h"
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
47 #include "addObjectDialog.h"
351
6fdd32c4886c uh, stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 348
diff changeset
48 #include "messagelog.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 #include "config.h"
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
50 #include "ui_ldforge.h"
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
51 #include "moc_gui.cpp"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
53 static bool g_isSelectionLocked = false;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
55 cfg (Bool, lv_colorize, true);
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
56 cfg (String, gui_colortoolbar, "16:24:|:1:2:4:14:0:15:|:33:34:36:46");
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
57 cfg (Bool, gui_implicitfiles, false);
467
59549731151a Added ListConfig type, using it in recent files now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
58 extern_cfg (List, io_recentfiles);
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
59 extern_cfg (Bool, gl_axes);
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
60 extern_cfg (String, gl_maincolor);
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
61 extern_cfg (Float, gl_maincolor_alpha);
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
62 extern_cfg (Bool, gl_wireframe);
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
63 extern_cfg (Bool, gl_colorbfc);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
65 #define act(N) extern_cfg (KeySequence, key_##N);
385
b136331072a0 Shortcuts are now properly loaded again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 384
diff changeset
66 #include "actions.h"
b136331072a0 Shortcuts are now properly loaded again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 384
diff changeset
67
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
69 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
70 ForgeWindow::ForgeWindow()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
71 { g_win = this;
412
064b0467c8de more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 411
diff changeset
72 m_renderer = new GLRenderer;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
73
412
064b0467c8de more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 411
diff changeset
74 ui = new Ui_LDForgeUI;
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
75 ui->setupUi (this);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
76
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
77 // Stuff the renderer into its frame
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
78 QVBoxLayout* rendererLayout = new QVBoxLayout (ui->rendererFrame);
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
79 rendererLayout->addWidget (R());
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
80
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
81 connect (ui->objectList, SIGNAL (itemSelectionChanged()), this, SLOT (slot_selectionChanged()));
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
82 connect (ui->objectList, SIGNAL (itemDoubleClicked (QListWidgetItem*)), this, SLOT (slot_editObject (QListWidgetItem*)));
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
83 connect (ui->fileList, SIGNAL (currentItemChanged (QListWidgetItem*, QListWidgetItem*)), this, SLOT (changeCurrentFile()));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
84
412
064b0467c8de more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 411
diff changeset
85 // Init message log manager
064b0467c8de more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 411
diff changeset
86 m_msglog = new MessageManager;
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
87 m_msglog->setRenderer (R());
412
064b0467c8de more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 411
diff changeset
88 m_renderer->setMessageLog (m_msglog);
064b0467c8de more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 411
diff changeset
89 m_quickColors = quickColorsFromConfig();
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
90 slot_selectionChanged();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 setStatusBar (new QStatusBar);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
92
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
93 // Init primitive loader task stuff
412
064b0467c8de more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 411
diff changeset
94 m_primLoaderBar = new QProgressBar;
064b0467c8de more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 411
diff changeset
95 m_primLoaderWidget = new QWidget;
290
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
96 QHBoxLayout* primLoaderLayout = new QHBoxLayout (m_primLoaderWidget);
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
97 primLoaderLayout->addWidget (new QLabel ("Loading primitives:"));
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
98 primLoaderLayout->addWidget (m_primLoaderBar);
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
99 statusBar()->addPermanentWidget (m_primLoaderWidget);
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
100 m_primLoaderWidget->hide();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
101
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
102 // Make certain actions checkable
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
103 ui->actionAxes->setChecked (gl_axes);
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
104 ui->actionWireframe->setChecked (gl_wireframe);
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
105 ui->actionBFCView->setChecked (gl_colorbfc);
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
106 updateGridToolBar();
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
107 updateEditModeActions();
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
108 updateRecentFilesMenu();
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
109 updateToolBars();
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
110 updateTitle();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
111
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
112 setMinimumSize (300, 200);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
113
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
114 connect (qApp, SIGNAL (aboutToQuit()), this, SLOT (slot_lastSecondCleanup()));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
115
385
b136331072a0 Shortcuts are now properly loaded again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 384
diff changeset
116 // Connect all actions and set shortcuts
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
117 #define act(N) \
385
b136331072a0 Shortcuts are now properly loaded again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 384
diff changeset
118 connect (ui->action##N, SIGNAL (triggered()), this, SLOT (slot_action())); \
b136331072a0 Shortcuts are now properly loaded again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 384
diff changeset
119 ui->action##N->setShortcut (key_##N);
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
120 #include "actions.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
123 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
124 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
125 void ForgeWindow::slot_action()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
126 { // Find out which action triggered this
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
127 #define act(N) if (sender() == ui->action##N) invokeAction (ui->action##N, &actiondef_##N);
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
128 #include "actions.h"
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
129 }
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
130
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
131 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
132 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
133 void ForgeWindow::invokeAction (QAction* act, void (*func) ())
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
134 { beginAction (act);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
135 (*func) ();
384
f4622b79133d updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents: 383
diff changeset
136 endAction();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
140 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
141 void ForgeWindow::slot_lastSecondCleanup()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
142 { delete m_renderer;
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
143 delete ui;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
147 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
148 void ForgeWindow::updateRecentFilesMenu()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
149 { // First, clear any items in the recent files menu
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
150 for (QAction * recent : m_recentFiles)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 delete recent;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
152
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
153 m_recentFiles.clear();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
154
467
59549731151a Added ListConfig type, using it in recent files now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
155 QAction* first = null;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
156
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
157 for (const QVariant & it : io_recentfiles)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
158 { str file = it.toString();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
159 QAction* recent = new QAction (getIcon ("open-recent"), file, this);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
160
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
161 connect (recent, SIGNAL (triggered()), this, SLOT (slot_recentFile()));
467
59549731151a Added ListConfig type, using it in recent files now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
162 ui->menuOpenRecent->insertAction (first, recent);
252
3f9067022d74 Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
163 m_recentFiles << recent;
467
59549731151a Added ListConfig type, using it in recent files now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
164 first = recent;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
169 // -----------------------------------------------------------------------------
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 500
diff changeset
170 QList<LDQuickColor> quickColorsFromConfig()
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 500
diff changeset
171 { QList<LDQuickColor> colors;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
172
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
173 for (str colorname : gui_colortoolbar.value.split (":"))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
174 { if (colorname == "|")
480
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
175 colors << LDQuickColor::getSeparator();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
176 else
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
177 { LDColor* col = getColor (colorname.toLong());
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
178
480
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
179 if (col != null)
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
180 colors << LDQuickColor (col, null);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
183
395
5210bcb1d7e0 Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 393
diff changeset
184 return colors;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
188 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
189 void ForgeWindow::updateToolBars()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
190 { m_colorButtons.clear();
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
191 ui->colorToolbar->clear();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
192
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
193 for (LDQuickColor & entry : m_quickColors)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
194 { if (entry.isSeparator())
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
195 ui->colorToolbar->addSeparator();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
196 else
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
197 { QToolButton* colorButton = new QToolButton;
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
198 colorButton->setIcon (makeColorIcon (entry.getColor(), 22));
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
199 colorButton->setIconSize (QSize (22, 22));
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
200 colorButton->setToolTip (entry.getColor()->name);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
201
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
202 connect (colorButton, SIGNAL (clicked()), this, SLOT (slot_quickColor()));
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
203 ui->colorToolbar->addWidget (colorButton);
252
3f9067022d74 Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
204 m_colorButtons << colorButton;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
205
480
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
206 entry.setToolButton (colorButton);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
209
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
210 updateGridToolBar();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
214 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
215 void ForgeWindow::updateGridToolBar()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
216 { // Ensure that the current grid - and only the current grid - is selected.
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
217 ui->actionGridCoarse->setChecked (grid == Grid::Coarse);
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
218 ui->actionGridMedium->setChecked (grid == Grid::Medium);
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
219 ui->actionGridFine->setChecked (grid == Grid::Fine);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
220 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
223 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
224 void ForgeWindow::updateTitle()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
225 { str title = fmt (APPNAME " %1", fullVersionString());
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
226
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
227 // Append our current file if we have one
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
228 if (LDFile::current())
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
229 { if (LDFile::current()->getName().length() > 0)
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
230 title += fmt (": %1", basename (LDFile::current()->getName()));
227
e13cd69b16dd Update the part's Name: field when saving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
231 else
e13cd69b16dd Update the part's Name: field when saving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
232 title += fmt (": <anonymous>");
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
233
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
234 if (LDFile::current()->getObjectCount() > 0 &&
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
235 LDFile::current()->getObject (0)->getType() == LDObject::Comment)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
236 { // Append title
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
237 LDComment* comm = static_cast<LDComment*> (LDFile::current()->getObject (0));
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
238 title += fmt (": %1", comm->text);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
239 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
240
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
241 if (LDFile::current()->getHistory()->getPosition() != LDFile::current()->getSavePosition())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242 title += '*';
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
244
515
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 508
diff changeset
245 #ifdef DEBUG
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 508
diff changeset
246 title += " [debug build]";
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 508
diff changeset
247 #elif BUILD_ID != BUILD_RELEASE
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 508
diff changeset
248 title += " [release build]";
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 508
diff changeset
249 #endif // DEBUG
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 508
diff changeset
250
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251 setWindowTitle (title);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
255 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
256 int ForgeWindow::deleteSelection()
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
257 { if (selection().isEmpty())
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 328
diff changeset
258 return 0;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
259
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
260 QList<LDObject*> selCopy = selection();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
261
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262 // Delete the objects that were being selected
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
263 for (LDObject* obj : selCopy)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264 delete obj;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
265
344
55fcf67230fd Further verbosity, #ifdef the test axle pic out of release builds
Santeri Piippo <crimsondusk64@gmail.com>
parents: 328
diff changeset
266 refresh();
528
e38d199ef9aa fixed: deleting objects would trigger a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 526
diff changeset
267 return selCopy.size();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
268 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
271 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
272 void ForgeWindow::buildObjList()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
273 { if (!LDFile::current())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
274 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
275
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276 // Lock the selection while we do this so that refreshing the object list
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
277 // doesn't trigger selection updating so that the selection doesn't get lost
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278 // while this is done.
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
279 g_isSelectionLocked = true;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
280
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
281 for (int i = 0; i < ui->objectList->count(); ++i)
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
282 delete ui->objectList->item (i);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
283
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
284 ui->objectList->clear();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
285
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
286 for (LDObject* obj : LDFile::current()->getObjects())
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
287 { str descr;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
288
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
289 switch (obj->getType())
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
290 { case LDObject::Comment:
508
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
291 { descr = static_cast<LDComment*> (obj)->text;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
292
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
293 // Remove leading whitespace
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
294 while (descr[0] == ' ')
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
295 descr.remove (0, 1);
508
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
296 } break;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
297
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
298 case LDObject::Empty:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
299 break; // leave it empty
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
300
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
301 case LDObject::Line:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
302 case LDObject::Triangle:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
303 case LDObject::Quad:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
304 case LDObject::CndLine:
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
305 { for (int i = 0; i < obj->vertices(); ++i)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
306 { if (i != 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
307 descr += ", ";
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
308
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
309 descr += obj->getVertex (i).stringRep (true);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
310 }
508
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
311 } break;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
312
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
313 case LDObject::Error:
508
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
314 { descr = fmt ("ERROR: %1", obj->raw());
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
315 } break;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
316
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
317 case LDObject::Vertex:
508
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
318 { descr = static_cast<LDVertex*> (obj)->pos.stringRep (true);
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
319 } break;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
320
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
321 case LDObject::Subfile:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
322 { LDSubfile* ref = static_cast<LDSubfile*> (obj);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
323
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
324 descr = fmt ("%1 %2, (", ref->getFileInfo()->getName(), ref->position().stringRep (true));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
325
508
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
326 for (int i = 0; i < 9; ++i)
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
327 descr += fmt ("%1%2", ref->getTransform()[i], (i != 8) ? " " : "");
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
328
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
329 descr += ')';
508
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
330 } break;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
331
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
332 case LDObject::BFC:
508
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
333 { descr = LDBFC::statements[static_cast<LDBFC*> (obj)->type];
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
334 } break;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
335
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
336 case LDObject::Overlay:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
337 { LDOverlay* ovl = static_cast<LDOverlay*> (obj);
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
338 descr = fmt ("[%1] %2 (%3, %4), %5 x %6", g_CameraNames[ovl->getCamera()],
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
339 basename (ovl->getFileName()), ovl->getX(), ovl->getY(),
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
340 ovl->getWidth(), ovl->getHeight());
316
b4fefda58f43 Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents: 310
diff changeset
341 }
b4fefda58f43 Made overlay data be contained in the part files, still wip
Santeri Piippo <crimsondusk64@gmail.com>
parents: 310
diff changeset
342 break;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
343
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
344 default:
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
345 { descr = obj->getTypeName();
508
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
346 } break;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
347 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
348
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
349 QListWidgetItem* item = new QListWidgetItem (descr);
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
350 item->setIcon (getIcon (obj->getTypeName()));
530
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 528
diff changeset
351
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 528
diff changeset
352 // Use italic font if hidden
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
353 if (obj->isHidden())
530
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 528
diff changeset
354 { QFont font = item->font();
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 528
diff changeset
355 font.setItalic (true);
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 528
diff changeset
356 item->setFont (font);
f9476dbd87ec - Added new actions "Hide" and "Reveal" which allow direct setting of objects' visibility setting instead of toggling it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 528
diff changeset
357 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
358
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
359 // Color gibberish orange on red so it stands out.
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
360 if (obj->getType() == LDObject::Error)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
361 { item->setBackground (QColor ("#AA0000"));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
362 item->setForeground (QColor ("#FFAA00"));
508
7ace3537a560 removed some custom functions in favor of Qt implementations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
363 }
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
364 elif (lv_colorize && obj->isColored() && obj->getColor() != maincolor && obj->getColor() != edgecolor)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
365 { // If the object isn't in the main or edge color, draw this
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
366 // list entry in said color.
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
367 LDColor* col = getColor (obj->getColor());
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
368
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
369 if (col)
189
ac2d3e8dd110 Rewrote the string class with a simpler version. The old one was more than probably leaking water like a boat with an elephant on board...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 188
diff changeset
370 item->setForeground (col->faceColor);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
372
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
373 obj->qObjListEntry = item;
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
374 ui->objectList->insertItem (ui->objectList->count(), item);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
375 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
376
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
377 g_isSelectionLocked = false;
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
378 updateSelection();
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
379 scrollToSelection();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
380 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
381
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
382 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
383 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
384 void ForgeWindow::scrollToSelection()
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
385 { if (selection().isEmpty())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
386 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
387
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
388 LDObject* obj = selection().last();
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
389 ui->objectList->scrollToItem (obj->qObjListEntry);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
390 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
391
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
392 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
393 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
394 void ForgeWindow::slot_selectionChanged()
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
395 { if (g_isSelectionLocked == true || LDFile::current() == null)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
396 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
397
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
398 // Update the shared selection array, though don't do this if this was
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
399 // called during GL picking, in which case the GL renderer takes care
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
400 // of the selection.
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
401 if (m_renderer->isPicking())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
402 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
403
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
404 QList<LDObject*> priorSelection = selection();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
405
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
406 // Get the objects from the object list selection
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
407 LDFile::current()->clearSelection();
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
408 const QList<QListWidgetItem*> items = ui->objectList->selectedItems();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
409
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
410 for (LDObject* obj : LDFile::current()->getObjects())
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
411 { for (QListWidgetItem* item : items)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
412 { if (item == obj->qObjListEntry)
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
413 { obj->select();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
414 break;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
415 }
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
416 }
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
417 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
418
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
419 // Update the GL renderer
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
420 QList<LDObject*> compound = priorSelection + selection();
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
421 removeDuplicates (compound);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
422
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
423 for (LDObject* obj : compound)
242
d0a27d56559f Fixed: selecting objects in list view didn't update the GL view properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 240
diff changeset
424 m_renderer->compileObject (obj);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
425
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
426 m_renderer->update();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
427 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
428
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
430 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
431 void ForgeWindow::slot_recentFile()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
432 { QAction* qAct = static_cast<QAction*> (sender());
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
433 openMainFile (qAct->text());
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
434 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
435
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
436 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
437 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
438 void ForgeWindow::slot_quickColor()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
439 { beginAction (null);
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
440 QToolButton* button = static_cast<QToolButton*> (sender());
364
7c3af0a6f8ab Renamed the color class to LDColor for clarity
Santeri Piippo <crimsondusk64@gmail.com>
parents: 360
diff changeset
441 LDColor* col = null;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
442
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
443 for (const LDQuickColor & entry : m_quickColors)
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
444 { if (entry.getToolButton() == button)
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
445 { col = entry.getColor();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
446 break;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
447 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
448 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
449
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
450 if (col == null)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
451 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
452
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
453 int newColor = col->index;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
454
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
455 for (LDObject* obj : selection())
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
456 { if (obj->isColored() == false)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
457 continue; // uncolored object
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
458
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
459 obj->setColor (newColor);
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 417
diff changeset
460 R()->compileObject (obj);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
461 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
462
413
a52c30a4c041 Don't recompile everything when using quick colors, this speeds things up a little
Santeri Piippo <crimsondusk64@gmail.com>
parents: 412
diff changeset
463 refresh();
391
beef61ce962a Finalized multi-file behavior. The future is here! :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 388
diff changeset
464 endAction();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
465 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
466
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
467 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
468 // -----------------------------------------------------------------------------
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
469 int ForgeWindow::getInsertionPoint()
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
470 { // If we have a selection, put the item after it.
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
471 if (!selection().isEmpty())
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
472 return selection().last()->getIndex() + 1;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
473
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
474 // Otherwise place the object at the end.
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
475 return LDFile::current()->getObjectCount();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
476 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
477
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
478 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
479 // -----------------------------------------------------------------------------
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
480 void ForgeWindow::doFullRefresh()
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
481 { buildObjList();
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
482 m_renderer->hardRefresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
483 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
484
480
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
485 // =============================================================================
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
486 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
487 void ForgeWindow::refresh()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
488 { buildObjList();
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
489 m_renderer->update();
192
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
490 }
c414924a647c Split inverting into methods into LDObject and its subclasses, fixed a rather severe memory leak issue (GL display lists weren't being removed properly)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
491
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
492 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
493 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
494 void ForgeWindow::updateSelection()
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
495 { g_isSelectionLocked = true;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
496
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
497 for (LDObject* obj : LDFile::current()->getObjects())
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
498 obj->setSelected (false);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
499
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
500 ui->objectList->clearSelection();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
501
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
502 for (LDObject* obj : selection())
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
503 { if (obj->qObjListEntry == null)
360
77f08db90249 when inlining (as an action), reinterpret the inlinees so that there's not any pointer mess-ups
Santeri Piippo <crimsondusk64@gmail.com>
parents: 357
diff changeset
504 continue;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
505
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
506 obj->qObjListEntry->setSelected (true);
185
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
507 obj->setSelected (true);
6fea53f1ffc2 Speed up picking - no need to rebuild the object list as its contents do not change while picking. Fixed transparent stuff always being opaque (although it still appears messed up for some reason)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
508 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
509
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
510 g_isSelectionLocked = false;
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
511 slot_selectionChanged();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
512 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
513
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
514 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
515 // -----------------------------------------------------------------------------
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
516 int ForgeWindow::getSelectedColor()
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
517 { int result = -1;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
518
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
519 for (LDObject* obj : selection())
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
520 { if (obj->isColored() == false)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
521 continue; // doesn't use color
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
522
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
523 if (result != -1 && obj->getColor() != result)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
524 return -1; // No consensus in object color
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
525
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
526 if (result == -1)
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
527 result = obj->getColor();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
528 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
529
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
530 return result;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
531 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
532
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
533 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
534 // -----------------------------------------------------------------------------
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
535 LDObject::Type ForgeWindow::getUniformSelectedType()
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
536 { LDObject::Type result = LDObject::Unidentified;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
537
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
538 for (LDObject * obj : selection())
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
539 { if (result != LDObject::Unidentified && obj->getColor() != result)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
540 return LDObject::Unidentified;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
541
219
70eb948a2b02 Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 218
diff changeset
542 if (result == LDObject::Unidentified)
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
543 result = obj->getType();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
544 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
545
219
70eb948a2b02 Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 218
diff changeset
546 return result;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
547 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
548
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
549 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
550 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
551 void ForgeWindow::closeEvent (QCloseEvent* ev)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
552 { // Check whether it's safe to close all files.
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
553 if (!safeToCloseAll())
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
554 { ev->ignore();
226
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 224
diff changeset
555 return;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
556 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
557
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
558 // Save the configuration before leaving so that, for instance, grid choice
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
559 // is preserved across instances.
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
560 Config::save();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
561
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
562 ev->accept();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
563 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
564
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
565 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
566 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
567 void ForgeWindow::spawnContextMenu (const QPoint pos)
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
568 { const bool single = (selection().size() == 1);
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
569 LDObject* singleObj = (single) ? selection()[0] : null;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
570
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
571 QMenu* contextMenu = new QMenu;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
572
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
573 if (single && singleObj->getType() != LDObject::Empty)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
574 { contextMenu->addAction (ACTION (Edit));
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
575 contextMenu->addSeparator();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
576 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
577
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
578 contextMenu->addAction (ACTION (Cut));
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
579 contextMenu->addAction (ACTION (Copy));
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
580 contextMenu->addAction (ACTION (Paste));
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
581 contextMenu->addAction (ACTION (Delete));
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
582 contextMenu->addSeparator();
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
583 contextMenu->addAction (ACTION (SetColor));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
584
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
585 if (single)
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
586 contextMenu->addAction (ACTION (EditRaw));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
587
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
588 contextMenu->addAction (ACTION (Borders));
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
589 contextMenu->addAction (ACTION (SetOverlay));
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
590 contextMenu->addAction (ACTION (ClearOverlay));
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
591 contextMenu->addAction (ACTION (ModeSelect));
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
592 contextMenu->addAction (ACTION (ModeDraw));
492
e964085e6913 Added a new editing mode for drawing circles.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 491
diff changeset
593 contextMenu->addAction (ACTION (ModeCircle));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
594
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
595 if (R()->camera() != GL::Free)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
596 { contextMenu->addSeparator();
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
597 contextMenu->addAction (ACTION (SetDrawDepth));
219
70eb948a2b02 Added ability to set the depth value to something else than 0.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 218
diff changeset
598 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
599
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
600 contextMenu->exec (pos);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
601 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
602
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
603 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
604 // -----------------------------------------------------------------------------
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
605 void ForgeWindow::deleteObjects (QList<LDObject*> objs)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
606 { for (LDObject * obj : objs)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
607 { LDFile::current()->forgetObject (obj);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
608 delete obj;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
609 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
610 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
611
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
612 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
613 // -----------------------------------------------------------------------------
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
614 void ForgeWindow::deleteByColor (const int colnum)
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 500
diff changeset
615 { QList<LDObject*> objs;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
616
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
617 for (LDObject* obj : LDFile::current()->getObjects())
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
618 { if (!obj->isColored() || obj->getColor() != colnum)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
619 continue;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
620
252
3f9067022d74 Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
621 objs << obj;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
622 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
623
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 530
diff changeset
624 deleteObjects (objs);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
625 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
626
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
627 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
628 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
629 void ForgeWindow::updateEditModeActions()
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
630 { const EditMode mode = R()->getEditMode();
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
631 ACTION (ModeSelect)->setChecked (mode == Select);
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
632 ACTION (ModeDraw)->setChecked (mode == Draw);
492
e964085e6913 Added a new editing mode for drawing circles.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 491
diff changeset
633 ACTION (ModeCircle)->setChecked (mode == CircleMode);
207
e8c47e51e03d Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
634 }
e8c47e51e03d Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
635
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
636 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
637 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
638 void ForgeWindow::slot_editObject (QListWidgetItem* listitem)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
639 { LDObject* obj = null;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
640
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
641 for (LDObject* it : LDFile::current()->getObjects())
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
642 { if (it->qObjListEntry == listitem)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
643 { obj = it;
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
644 break;
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
645 }
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
646 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
647
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
648 AddObjectDialog::staticDialog (obj->getType(), obj);
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
649 }
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
650
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
651 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
652 // -----------------------------------------------------------------------------
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
653 void ForgeWindow::primitiveLoaderStart (int max)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
654 { m_primLoaderWidget->show();
290
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
655 m_primLoaderBar->setRange (0, max);
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
656 m_primLoaderBar->setValue (0);
306
fef00a6cbff0 minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 301
diff changeset
657 m_primLoaderBar->setFormat ("%p%");
290
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
658 }
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
659
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
660 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
661 // -----------------------------------------------------------------------------
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
662 void ForgeWindow::primitiveLoaderUpdate (int prog)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
663 { m_primLoaderBar->setValue (prog);
290
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
664 }
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
665
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
666 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
667 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
668 void ForgeWindow::primitiveLoaderEnd()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
669 { QTimer* hidetimer = new QTimer;
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
670 connect (hidetimer, SIGNAL (timeout()), m_primLoaderWidget, SLOT (hide()));
290
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
671 hidetimer->setSingleShot (true);
306
fef00a6cbff0 minor improvements to primitive handling
Santeri Piippo <crimsondusk64@gmail.com>
parents: 301
diff changeset
672 hidetimer->start (1500);
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 417
diff changeset
673 m_primLoaderBar->setFormat (tr ("Done"));
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
674 log (tr ("Primitives scanned: %1 primitives listed"), m_primLoaderBar->value());
290
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
675 }
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
676
310
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
677 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
678 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
679 void ForgeWindow::save (LDFile* f, bool saveAs)
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
680 { str path = f->getName();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
681
497
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
682 if (saveAs || path.isEmpty())
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
683 { path = QFileDialog::getSaveFileName (g_win, tr ("Save As"),
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
684 (f->getName().isEmpty()) ? f->getName() : f->getDefaultName(),
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
685 tr ("LDraw files (*.dat *.ldr)"));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
686
497
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
687 if (path.isEmpty())
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
688 { // User didn't give a file name, abort.
310
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
689 return;
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
690 }
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
691 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
692
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
693 if (f->save (path))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
694 { f->setName (path);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
695
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
696 if (f == LDFile::current())
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
697 g_win->updateTitle();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
698
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 364
diff changeset
699 log ("Saved to %1.", path);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
700
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 364
diff changeset
701 // Add it to recent files
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 364
diff changeset
702 addRecentFile (path);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
703 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
704 else
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
705 { str message = fmt (tr ("Failed to save to %1: %2"), path, strerror (errno));
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
706
310
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
707 // Tell the user the save failed, and give the option for saving as with it.
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
708 QMessageBox dlg (QMessageBox::Critical, tr ("Save Failure"), message, QMessageBox::Close, g_win);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
709
310
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
710 // Add a save-as button
376
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 364
diff changeset
711 QPushButton* saveAsBtn = new QPushButton (tr ("Save As"));
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 364
diff changeset
712 saveAsBtn->setIcon (getIcon ("file-save-as"));
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 364
diff changeset
713 dlg.addButton (saveAsBtn, QMessageBox::ActionRole);
4a89dd47535f Reformatting..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 364
diff changeset
714 dlg.setDefaultButton (QMessageBox::Close);
310
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
715 dlg.exec();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
716
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
717 if (dlg.clickedButton() == saveAsBtn)
310
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
718 save (f, true); // yay recursion!
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
719 }
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
720 }
c62edce5668c Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents: 307
diff changeset
721
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
722 void ForgeWindow::addMessage (str msg)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
723 { m_msglog->addLine (msg);
322
5e701c3c3d8e Re-added the message log, now draws into the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
724 }
5e701c3c3d8e Re-added the message log, now draws into the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents: 321
diff changeset
725
283
c5401af41685 Objects can now be edited by double-clicking on them in the object list view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
726 // ============================================================================
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
727 void ObjectList::contextMenuEvent (QContextMenuEvent* ev)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
728 { g_win->spawnContextMenu (ev->globalPos());
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
729 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
730
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
731 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
732 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
733 QPixmap getIcon (str iconName)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
734 { return (QPixmap (fmt (":/icons/%1.png", iconName)));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
735 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
736
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
737 // =============================================================================
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
738 bool confirm (str msg)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
739 { return confirm (ForgeWindow::tr ("Confirm"), msg);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
740 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
741
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
742 bool confirm (str title, str msg)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
743 { return QMessageBox::question (g_win, title, msg,
500
cad8cdc42a64 Finally got the ringfinder working! Working on integrating it to ring drawing...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 498
diff changeset
744 (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
745 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
746
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
747 // =============================================================================
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
748 void critical (str msg)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
749 { QMessageBox::critical (g_win, ForgeWindow::tr ("Error"), msg,
500
cad8cdc42a64 Finally got the ringfinder working! Working on integrating it to ring drawing...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 498
diff changeset
750 (QMessageBox::Close), QMessageBox::Close);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
751 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
752
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
753 // =============================================================================
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
754 QIcon makeColorIcon (LDColor* colinfo, const int size)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
755 { // Create an image object and link a painter to it.
186
a130960bb220 Make quick color toolbar use QToolButtons, make color selector's process of making color icons a method and use that for generic color icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
756 QImage img (size, size, QImage::Format_ARGB32);
a130960bb220 Make quick color toolbar use QToolButtons, make color selector's process of making color icons a method and use that for generic color icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
757 QPainter paint (&img);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
758
189
ac2d3e8dd110 Rewrote the string class with a simpler version. The old one was more than probably leaking water like a boat with an elephant on board...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 188
diff changeset
759 QColor col = colinfo->faceColor;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
760
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
761 if (colinfo->index == maincolor)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
762 { // Use the user preferences for main color here
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
763 col = gl_maincolor.value;
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
764 col.setAlphaF (gl_maincolor_alpha);
186
a130960bb220 Make quick color toolbar use QToolButtons, make color selector's process of making color icons a method and use that for generic color icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
765 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
766
186
a130960bb220 Make quick color toolbar use QToolButtons, make color selector's process of making color icons a method and use that for generic color icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
767 // Paint the icon
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
768 paint.fillRect (QRect (0, 0, size, size), colinfo->edgeColor);
186
a130960bb220 Make quick color toolbar use QToolButtons, make color selector's process of making color icons a method and use that for generic color icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
769 paint.drawPixmap (QRect (1, 1, size - 2, size - 2), getIcon ("checkerboard"), QRect (0, 0, 8, 8));
a130960bb220 Make quick color toolbar use QToolButtons, make color selector's process of making color icons a method and use that for generic color icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
770 paint.fillRect (QRect (1, 1, size - 2, size - 2), col);
a130960bb220 Make quick color toolbar use QToolButtons, make color selector's process of making color icons a method and use that for generic color icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
771 return QIcon (QPixmap::fromImage (img));
a130960bb220 Make quick color toolbar use QToolButtons, make color selector's process of making color icons a method and use that for generic color icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
772 }
a130960bb220 Make quick color toolbar use QToolButtons, make color selector's process of making color icons a method and use that for generic color icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
773
a130960bb220 Make quick color toolbar use QToolButtons, make color selector's process of making color icons a method and use that for generic color icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
774 // =============================================================================
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
775 void makeColorComboBox (QComboBox* box)
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
776 { std::map<int, int> counts;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
777
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
778 for (LDObject * obj : LDFile::current()->getObjects())
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
779 { if (!obj->isColored())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
780 continue;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
781
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
782 if (counts.find (obj->getColor()) == counts.end())
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
783 counts[obj->getColor()] = 1;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
784 else
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
785 counts[obj->getColor()]++;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
786 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
787
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
788 box->clear();
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
789 int row = 0;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
790
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
791 for (const auto & pair : counts)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
792 { LDColor* col = getColor (pair.first);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
793 assert (col != null);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
794
186
a130960bb220 Make quick color toolbar use QToolButtons, make color selector's process of making color icons a method and use that for generic color icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 185
diff changeset
795 QIcon ico = makeColorIcon (col, 16);
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 283
diff changeset
796 box->addItem (ico, fmt ("[%1] %2 (%3 object%4)",
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
797 pair.first, col->name, pair.second, plural (pair.second)));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
798 box->setItemData (row, pair.first);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
799
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
800 ++row;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
801 }
190
82f784cf2ce5 Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
802 }
82f784cf2ce5 Added tool for replacing coordinate values
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
803
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
804 void ForgeWindow::setStatusBarText (str text)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
805 { statusBar()->showMessage (text);
237
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 236
diff changeset
806 }
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 236
diff changeset
807
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
808 Ui_LDForgeUI* ForgeWindow::interface() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
809 { return ui;
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
810 }
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
811
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
812 #define act(N) QAction* ForgeWindow::action##N() { return ui->action##N; }
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
813 #include "actions.h"
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
814
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
815 void ForgeWindow::updateFileList()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
816 { ui->fileList->clear();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
817
526
b29b6fc45ba9 style corrections
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
818 for (LDFile* f : g_loadedFiles)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
819 { // Don't list implicit files unless explicitly desired.
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
820 if (f->isImplicit() && !gui_implicitfiles)
383
10e60ae9ed58 File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
821 continue;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
822
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
823 // Add an item to the list for this file and store a pointer to it in
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
824 // the file, so we can find files by the list item.
383
10e60ae9ed58 File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
825 ui->fileList->addItem ("");
10e60ae9ed58 File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
826 QListWidgetItem* item = ui->fileList->item (ui->fileList->count() - 1);
10e60ae9ed58 File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
827 f->setListItem (item);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
828
383
10e60ae9ed58 File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
829 updateFileListItem (f);
10e60ae9ed58 File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
830 }
10e60ae9ed58 File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
831 }
10e60ae9ed58 File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
832
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
833 void ForgeWindow::updateFileListItem (LDFile* f)
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
834 { if (f->getListItem() == null)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
835 { // We don't have a list item for this file, so the list either doesn't
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
836 // exist yet or is out of date. Build the list now.
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
837 updateFileList();
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
838 return;
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
839 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
840
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
841 // If this is the current file, it also needs to be the selected item on
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
842 // the list.
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
843 if (f == LDFile::current())
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
844 ui->fileList->setCurrentItem (f->getListItem());
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
845
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
846 // If we list implicit files, draw them with a shade of gray to make them
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
847 // distinct.
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
848 if (f->isImplicit())
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
849 f->getListItem()->setForeground (QColor (96, 96, 96));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
850
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
851 f->getListItem()->setText (f->getShortName());
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
852
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
853 // If the file has unsaved changes, draw a little icon next to it to mark that.
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
854 f->getListItem()->setIcon (f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon());
383
10e60ae9ed58 File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
855 }
10e60ae9ed58 File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
856
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
857 void ForgeWindow::beginAction (QAction* act)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
858 { // Open the history so we can record the edits done during this action.
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
859 if (act == ACTION (Undo) || act == ACTION (Redo) || act == ACTION (Open))
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
860 LDFile::current()->getHistory()->setIgnoring (true);
384
f4622b79133d updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents: 383
diff changeset
861 }
f4622b79133d updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents: 383
diff changeset
862
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
863 void ForgeWindow::endAction()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
864 { // Close the history now.
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
865 LDFile::current()->addHistoryStep();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
866
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
867 // Update the list item of the current file - we may need to draw an icon
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
868 // now that marks it as having unsaved changes.
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
869 updateFileListItem (LDFile::current());
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
870 }
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
871
417
14bfeed046f3 Added an option for listing implicit files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 416
diff changeset
872 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
873 // A file is selected from the list of files on the left of the screen. Find out
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
874 // which file was picked and change to it.
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
875 void ForgeWindow::changeCurrentFile()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
876 { LDFile* f = null;
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
877 QListWidgetItem* item = ui->fileList->currentItem();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
878
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
879 // Find the file pointer of the item that was selected.
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
880 for (LDFile* it : g_loadedFiles)
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
881 { if (it->getListItem() == item)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
882 { f = it;
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
883 break;
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
884 }
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
885 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
886
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
887 // If we picked the same file we're currently on, we don't need to do
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 438
diff changeset
888 // anything.
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
889 if (!f || f == LDFile::current())
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
890 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
891
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
892 LDFile::setCurrent (f);
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
893 }
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
894
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
895 void ForgeWindow::refreshObjectList()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
896 {
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
897 #if 0
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
898 ui->objectList->clear();
409
8da2563c645a Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents: 402
diff changeset
899 LDFile* f = LDFile::current();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
900
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
901 for (LDObject * obj : *f)
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
902 ui->objectList->addItem (obj->qObjListEntry);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
903
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
904 #endif
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
905
388
7ff483614aa1 Multiple file support works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 385
diff changeset
906 buildObjList();
384
f4622b79133d updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents: 383
diff changeset
907 }
f4622b79133d updates on file list
Santeri Piippo <crimsondusk64@gmail.com>
parents: 383
diff changeset
908
498
791c831c8020 further cleansing - removed most uses of unsigned ints, removed list reversers
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
909 QImage imageFromScreencap (uchar* data, int w, int h)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
910 { // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well.
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
911 return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored();
410
a5aebcf4a1c8 Include the moc files in the source cpp files to reduce compile time
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
912 }
a5aebcf4a1c8 Include the moc files in the source cpp files to reduce compile time
Santeri Piippo <crimsondusk64@gmail.com>
parents: 409
diff changeset
913
480
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
914 // =============================================================================
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
915 // -----------------------------------------------------------------------------
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
916 LDQuickColor::LDQuickColor (LDColor* color, QToolButton* toolButton) :
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
917 m_Color (color),
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
918 m_ToolButton (toolButton) {}
480
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
919
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
920 LDQuickColor LDQuickColor::getSeparator()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
921 { return LDQuickColor (null, null);
480
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
922 }
ee5a4c5d4461 rework quick color code a tad
Santeri Piippo <crimsondusk64@gmail.com>
parents: 475
diff changeset
923
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 492
diff changeset
924 bool LDQuickColor::isSeparator() const
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
925 { return getColor() == null;
491
7d1b5ecd76c0 it's LDForge's 1st birthday!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
926 }

mercurial