src/mainwindow.cpp

Mon, 06 Mar 2017 12:15:33 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 06 Mar 2017 12:15:33 +0200
changeset 1203
7e34dd7559ce
parent 1199
613a981223a6
child 1206
743dc95e0be6
permissions
-rw-r--r--

Configuration changes can now be detected with signals.

655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
1072
9ce9496427f2 Happy new year 2017!
Teemu Piippo <teemu@hecknology.net>
parents: 1068
diff changeset
3 * Copyright (C) 2013 - 2017 Teemu Piippo
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <QMessageBox>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <QContextMenuEvent>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include <QToolButton>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include <QFileDialog>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include <QPushButton>
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
24 #include <QSettings>
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include "main.h"
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
26 #include "canvas.h"
962
a4b463a7ee82 Rename MainWindow files
Teemu Piippo <crimsondusk64@gmail.com>
parents: 959
diff changeset
27 #include "mainwindow.h"
1145
02264bf0108d Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
28 #include "lddocument.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 #include "miscallenous.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 #include "messageLog.h"
963
c1526d1877d7 More through removal of the vertex object
Teemu Piippo <crimsondusk64@gmail.com>
parents: 962
diff changeset
31 #include "ui_mainwindow.h"
790
fe1b83f6ba82 - added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
32 #include "primitives.h"
830
a741a0b9df49 - updated filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents: 823
diff changeset
33 #include "editmodes/abstractEditMode.h"
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
34 #include "toolsets/toolset.h"
975
24ba5aa3393f Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
35 #include "dialogs/configdialog.h"
1117
efcb47c64a72 Moved LDComment and LDEmpty into their own source file pairs.
Teemu Piippo <teemu@hecknology.net>
parents: 1114
diff changeset
36 #include "linetypes/comment.h"
974
b2fa5f89798a Added a GuiUtilities class to contain useful non-MainWindow-related GUI functions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 972
diff changeset
37 #include "guiutilities.h"
1146
bb728c124d47 Renamed glCompiler.cpp → glcompiler.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1145
diff changeset
38 #include "glcompiler.h"
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 988
diff changeset
39 #include "documentmanager.h"
1005
a88cf5a32246 Subject Bézier curve fineness to the grid. By default, the coarse grid uses 8 segments, medium 16 and fine 32. Moved rasterization from demoting to inlining, it feels more sensible for it to be there.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1004
diff changeset
40 #include "ldobjectiterator.h"
1023
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1018
diff changeset
41 #include "grid.h"
1025
4949da3fb4b3 Renamed ldObjectMath.cpp/.h to mathfunctions.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1024
diff changeset
42 #include "mathfunctions.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43
1124
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
44 struct MainWindow::ToolInfo
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
45 {
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
46 QMetaMethod method;
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
47 Toolset* object;
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
48 };
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
49
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
50 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 //
1192
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
52 MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) :
1194
99085cfaeabd GuiUtilities is now a namespace.
Teemu Piippo <teemu@hecknology.net>
parents: 1193
diff changeset
53 QMainWindow (parent, flags),
1199
613a981223a6 Grid is now a namespace.
Teemu Piippo <teemu@hecknology.net>
parents: 1198
diff changeset
54 m_primitives(new PrimitiveManager(this)),
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 969
diff changeset
55 ui (*new Ui_MainWindow),
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
56 m_externalPrograms (nullptr),
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
57 m_settings (makeSettings (this)),
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 988
diff changeset
58 m_documents (new DocumentManager (this)),
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
59 m_currentDocument (nullptr),
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
60 m_isSelectionLocked (false)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 {
1097
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
62 m_messageLog = new MessageManager {this};
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
63 ui.setupUi (this);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 m_updatingTabs = false;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 m_tabs = new QTabBar;
798
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
66 m_tabs->setTabsClosable (true);
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
67 ui.verticalLayout->insertWidget (0, m_tabs);
1005
a88cf5a32246 Subject Bézier curve fineness to the grid. By default, the coarse grid uses 8 segments, medium 16 and fine 32. Moved rasterization from demoting to inlining, it feels more sensible for it to be there.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1004
diff changeset
68 createBlankDocument();
1154
a426a335e586 Some cleanup in mainwindow.cpp, use QSet<QString> for the 'ignore' variable.
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
69 ui.rendererStack->setCurrentWidget(getRendererForDocument(m_currentDocument));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
71 connect (ui.objectList, SIGNAL (itemSelectionChanged()), this, SLOT (selectionChanged()));
1016
3b279b5e57d3 Fixed line length warnings
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1015
diff changeset
72 connect (ui.objectList, SIGNAL (itemDoubleClicked (QListWidgetItem*)), this,
3b279b5e57d3 Fixed line length warnings
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1015
diff changeset
73 SLOT (objectListDoubleClicked (QListWidgetItem*)));
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
74 connect (m_tabs, SIGNAL (currentChanged(int)), this, SLOT (tabSelected()));
798
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
75 connect (m_tabs, SIGNAL (tabCloseRequested (int)), this, SLOT (closeTab (int)));
1097
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
76 connect(m_documents, SIGNAL(documentClosed(LDDocument*)), this, SLOT(documentClosed(LDDocument*)));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77
1018
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
78 if (m_primitives->activeScanner())
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
79 connect (m_primitives->activeScanner(), SIGNAL (workDone()), this, SLOT (updatePrimitives()));
790
fe1b83f6ba82 - added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
80 else
fe1b83f6ba82 - added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
81 updatePrimitives();
fe1b83f6ba82 - added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
82
1194
99085cfaeabd GuiUtilities is now a namespace.
Teemu Piippo <teemu@hecknology.net>
parents: 1193
diff changeset
83 m_quickColors = GuiUtilities::loadQuickColorList();
815
efe34366e56a - added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents: 808
diff changeset
84 updateActions();
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
85
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
86 // Connect all actions and save default sequences
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
87 applyToActions ([&](QAction* act)
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
88 {
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
89 connect (act, SIGNAL (triggered()), this, SLOT (actionTriggered()));
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
90 m_defaultShortcuts[act] = act->shortcut();
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
91 });
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
92
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 updateGridToolBar();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 updateEditModeActions();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 updateRecentFilesMenu();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 updateColorToolbar();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 updateTitle();
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
98 loadShortcuts();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 setMinimumSize (300, 200);
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
100 connect (ui.ringToolHiRes, SIGNAL (clicked (bool)), this, SLOT (ringToolHiResClicked (bool)));
1015
92c6ec099075 Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
101 connect (ui.ringToolSegments, SIGNAL (valueChanged (int)), this, SLOT (circleToolSegmentsChanged()));
871
a860edb4210b - display a label next to the spinbox showing the fraction
Teemu Piippo <crimsondusk64@gmail.com>
parents: 869
diff changeset
102 circleToolSegmentsChanged(); // invoke it manually for initial label text
896
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
103
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
104 // Examine the toolsets and make a dictionary of tools
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
105 m_toolsets = Toolset::createToolsets (this);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
106
1154
a426a335e586 Some cleanup in mainwindow.cpp, use QSet<QString> for the 'ignore' variable.
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
107 QSet<QString> ignore;
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
108 for (int i = 0; i < Toolset::staticMetaObject.methodCount(); ++i)
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
109 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
110 QMetaMethod method = Toolset::staticMetaObject.method (i);
1154
a426a335e586 Some cleanup in mainwindow.cpp, use QSet<QString> for the 'ignore' variable.
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
111 ignore.insert(QString::fromUtf8(method.name()));
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
112 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
113
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
114 for (Toolset* toolset : m_toolsets)
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
115 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
116 const QMetaObject* meta = toolset->metaObject();
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
117
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
118 if (qobject_cast<ExtProgramToolset*> (toolset))
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
119 m_externalPrograms = static_cast<ExtProgramToolset*> (toolset);
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 969
diff changeset
120
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
121 for (int i = 0; i < meta->methodCount(); ++i)
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
122 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
123 ToolInfo info;
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
124 info.method = meta->method (i);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
125 info.object = toolset;
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
126 QString methodName = QString::fromUtf8 (info.method.name());
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
127
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
128 if (ignore.contains (methodName))
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
129 continue; // The method was inherited from base classes
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
130
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
131 QString actionName = "action" + methodName.left (1).toUpper() + methodName.mid (1);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
132 QAction* action = findChild<QAction*> (actionName);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
133
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
134 if (action == nullptr)
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
135 print ("No action for %1::%2 (looked for %3)\n", meta->className(), methodName, actionName);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
136 else
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
137 m_toolmap[action] = info;
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
138 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
139 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
140
1192
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
141 for (QVariant const& toolbarname : configuration().hiddenToolbars())
896
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
142 {
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
143 QToolBar* toolbar = findChild<QToolBar*> (toolbarname.toString());
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
144
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
145 if (toolbar)
896
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
146 toolbar->hide();
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
147 }
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
148
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
149 // If this is the first start, get the user to configuration. Especially point
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
150 // them to the profile tab, it's the most important form to fill in.
1192
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
151 if (configuration().firstStart())
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
152 {
972
a34b73114823 Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 971
diff changeset
153 ConfigDialog* dialog = new ConfigDialog (this, ConfigDialog::ProfileTab);
a34b73114823 Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 971
diff changeset
154 dialog->show();
1192
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
155 configuration().setFirstStart (false);
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
156 }
1018
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
157
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
158 QMetaObject::invokeMethod (this, "finishInitialization", Qt::QueuedConnection);
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
159 }
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
160
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
161 void MainWindow::finishInitialization()
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
162 {
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
163 m_primitives->loadPrimitives();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165
857
e62983881460 - fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
166 MainWindow::~MainWindow()
e62983881460 - fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
167 {
1024
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
168 delete m_primitives;
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
169 delete &ui;
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
170 delete m_settings;
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
171
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
172 for (Toolset* toolset : m_toolsets)
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
173 delete toolset;
857
e62983881460 - fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
174 }
e62983881460 - fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
175
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
176 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
178 void MainWindow::actionTriggered()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 // Get the name of the sender object and use it to compose the slot name,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 // then invoke this slot to call the action.
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
182 QAction* action = qobject_cast<QAction*> (sender());
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
183
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
184 if (action)
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
185 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
186 if (m_toolmap.contains (action))
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
187 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
188 const ToolInfo& info = m_toolmap[action];
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
189 info.method.invoke (info.object, Qt::DirectConnection);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
190 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
191 else
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
192 print ("No tool info for %1!\n", action->objectName());
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
193 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
194
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 endAction();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
198 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 void MainWindow::endAction()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 {
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
202 m_currentDocument->addHistoryStep();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
203 updateDocumentListItem (m_currentDocument);
869
7184f3bae695 - circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents: 866
diff changeset
204 refresh();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
207 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 void MainWindow::updateRecentFilesMenu()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 m_recentFiles.clear();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212
1185
c2e0db52ea07 Added a new type ResourceVector which manages object lifetimes, and used it to remove a bit of memory management.
Teemu Piippo <teemu@hecknology.net>
parents: 1184
diff changeset
213 QAction* previous = nullptr;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214
1192
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
215 for (const QVariant& it : configuration().recentFiles())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 {
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 788
diff changeset
217 QString file = it.toString();
1185
c2e0db52ea07 Added a new type ResourceVector which manages object lifetimes, and used it to remove a bit of memory management.
Teemu Piippo <teemu@hecknology.net>
parents: 1184
diff changeset
218 QAction* recentFileAction = m_recentFiles.append(getIcon("open-recent"), file, this);
c2e0db52ea07 Added a new type ResourceVector which manages object lifetimes, and used it to remove a bit of memory management.
Teemu Piippo <teemu@hecknology.net>
parents: 1184
diff changeset
219 connect(recentFileAction, SIGNAL(triggered()), this, SLOT(recentFileClicked()));
c2e0db52ea07 Added a new type ResourceVector which manages object lifetimes, and used it to remove a bit of memory management.
Teemu Piippo <teemu@hecknology.net>
parents: 1184
diff changeset
220 ui.menuOpenRecent->insertAction(previous, recentFileAction);
c2e0db52ea07 Added a new type ResourceVector which manages object lifetimes, and used it to remove a bit of memory management.
Teemu Piippo <teemu@hecknology.net>
parents: 1184
diff changeset
221 previous = recentFileAction;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
223 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
224
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
225 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
226 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
227 void MainWindow::updateColorToolbar()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
229 m_colorButtons.clear();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
230 ui.toolBarColors->clear();
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
231 ui.toolBarColors->addAction (ui.actionUncolor);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
232 ui.toolBarColors->addSeparator();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
233
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
234 for (ColorToolbarItem& entry : m_quickColors)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
235 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
236 if (entry.isSeparator())
888
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
237 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
238 ui.toolBarColors->addSeparator();
888
7ad8fb667084 - improved part downloader: now asks for the path instead of just directing the user to settings. auto-fix download now configurable and opt-in
Teemu Piippo <crimsondusk64@gmail.com>
parents: 882
diff changeset
239 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 else
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242 QToolButton* colorButton = new QToolButton;
1194
99085cfaeabd GuiUtilities is now a namespace.
Teemu Piippo <teemu@hecknology.net>
parents: 1193
diff changeset
243 colorButton->setIcon(GuiUtilities::makeColorIcon(entry.color(), 16));
99085cfaeabd GuiUtilities is now a namespace.
Teemu Piippo <teemu@hecknology.net>
parents: 1193
diff changeset
244 colorButton->setIconSize({16, 16});
99085cfaeabd GuiUtilities is now a namespace.
Teemu Piippo <teemu@hecknology.net>
parents: 1193
diff changeset
245 colorButton->setToolTip(entry.color().name());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246
1194
99085cfaeabd GuiUtilities is now a namespace.
Teemu Piippo <teemu@hecknology.net>
parents: 1193
diff changeset
247 connect(colorButton, SIGNAL (clicked()), this, SLOT (quickColorClicked()));
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
248 ui.toolBarColors->addWidget (colorButton);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
249 m_colorButtons << colorButton;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251 entry.setToolButton (colorButton);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255 updateGridToolBar();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
257
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
258 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
259 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260 void MainWindow::updateGridToolBar()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262 // Ensure that the current grid - and only the current grid - is selected.
1192
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
263 int grid = configuration().grid();
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
264 ui.actionGridCoarse->setChecked (grid == Grid::Coarse);
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
265 ui.actionGridMedium->setChecked (grid == Grid::Medium);
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
266 ui.actionGridFine->setChecked (grid == Grid::Fine);
1199
613a981223a6 Grid is now a namespace.
Teemu Piippo <teemu@hecknology.net>
parents: 1198
diff changeset
267 ui.actionPolarGrid->setChecked(Grid::type() == Grid::Polar);
1113
5f3139c802bf Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
268 emit gridChanged();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
271 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
273 void MainWindow::updateTitle()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
274 {
948
3a91828475fd Replaced updaterevision with a python script, more renames, clang fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 946
diff changeset
275 QString title = format (APPNAME " " VERSION_STRING);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
277 // Append our current file if we have one
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
278 if (m_currentDocument)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
279 {
744
bbe0e1834065 - removed rest of the uses of <anonymous>
Santeri Piippo <crimsondusk64@gmail.com>
parents: 739
diff changeset
280 title += ": ";
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
281 title += m_currentDocument->getDisplayName();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282
1083
5903cfa6b4d9 Removed LDDocument::getObjectCount (superceded by Model::size)
Teemu Piippo <teemu@hecknology.net>
parents: 1075
diff changeset
283 if (m_currentDocument->size() > 0 and
1123
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1119
diff changeset
284 m_currentDocument->getObject(0)->type() == LDObjectType::Comment)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286 // Append title
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
287 LDComment* comm = static_cast <LDComment*> (m_currentDocument->getObject (0));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
288 title += format (": %1", comm->text());
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
289 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
290
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
291 if (m_currentDocument->hasUnsavedChanges())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
292 title += '*';
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
295 #ifdef DEBUG
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 title += " [debug build]";
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297 #elif BUILD_ID != BUILD_RELEASE
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
298 title += " [pre-release build]";
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
299 #endif // DEBUG
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300
948
3a91828475fd Replaced updaterevision with a python script, more renames, clang fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 946
diff changeset
301 if (strlen (commitTimeString()))
3a91828475fd Replaced updaterevision with a python script, more renames, clang fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 946
diff changeset
302 title += format (" (%1)", QString::fromUtf8 (commitTimeString()));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
304 setWindowTitle (title);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
307 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
308 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309 int MainWindow::deleteSelection()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310 {
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
311 if (selectedObjects().isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
312 return 0;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
314 QSet<LDObject*> selectionCopy = selectedObjects();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 // Delete the objects that were being selected
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
317 for (LDObject* object : selectionCopy)
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
318 m_currentDocument->remove(object);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320 refresh();
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
321 return countof(selectionCopy);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
322 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
323
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
324 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
325 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
326 void MainWindow::buildObjectList()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327 {
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
328 if (not m_currentDocument)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
329 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
330
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331 // Lock the selection while we do this so that refreshing the object list
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332 // doesn't trigger selection updating so that the selection doesn't get lost
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
333 // while this is done.
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
334 m_isSelectionLocked = true;
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 986
diff changeset
335 m_objectsInList.clear();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
337 for (int i = 0; i < ui.objectList->count(); ++i)
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
338 delete ui.objectList->item (i);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
339
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
340 ui.objectList->clear();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
341
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
342 for (LDObject* obj : m_currentDocument->objects())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
343 {
1084
63daaf652454 Split object list representation into virtual methods
Teemu Piippo <teemu@hecknology.net>
parents: 1083
diff changeset
344 QListWidgetItem* item = new QListWidgetItem {obj->objectListText()};
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
345 item->setIcon (getIcon (obj->typeName()));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
347 // Use italic font if hidden
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
348 if (obj->isHidden())
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
349 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
350 QFont font = item->font();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
351 font.setItalic (true);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
352 item->setFont (font);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
353 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
354
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
355 // Color gibberish orange on red so it stands out.
1123
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1119
diff changeset
356 if (obj->type() == LDObjectType::Error)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
357 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
358 item->setBackground (QColor ("#AA0000"));
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
359 item->setForeground (QColor ("#FFAA00"));
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360 }
1192
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
361 else if (configuration().colorizeObjectsList()
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 969
diff changeset
362 and obj->isColored()
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 969
diff changeset
363 and obj->color().isValid()
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 969
diff changeset
364 and obj->color() != MainColor
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 969
diff changeset
365 and obj->color() != EdgeColor)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
366 {
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
367 // If the object isn't in the main or edge color, draw this list entry in that color.
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
368 item->setForeground (obj->color().faceColor());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
369 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 986
diff changeset
371 m_objectsInList.insert (obj, item);
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
372 ui.objectList->insertItem (ui.objectList->count(), item);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
373 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
374
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
375 m_isSelectionLocked = false;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
376 updateSelection();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
377 scrollToSelection();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
378 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
379
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
380 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
381 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
382 // Scrolls the object list so that it points to the first selected object.
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
383 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
384 void MainWindow::scrollToSelection()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
385 {
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
386 if (selectedObjects().isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
387 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
388
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
389 // TODO: Need a way to properly figure out the first selected object!
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
390 LDObject* obj = *selectedObjects().begin();
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 986
diff changeset
391 ui.objectList->scrollToItem (m_objectsInList[obj]);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
392 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
393
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
394 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
395 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
396 void MainWindow::selectionChanged()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397 {
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
398 if (m_isSelectionLocked == true or m_currentDocument == nullptr)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
399 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
400
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
401 QSet<LDObject*> priorSelection = selectedObjects();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
402
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
403 // Get the objects from the object list selection
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
404 m_currentDocument->clearSelection();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
405 const QList<QListWidgetItem*> items = ui.objectList->selectedItems();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
406
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
407 for (LDObject* obj : m_currentDocument->objects())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
408 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409 for (QListWidgetItem* item : items)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410 {
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 986
diff changeset
411 if (item == m_objectsInList[obj])
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
412 {
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
413 m_currentDocument->addToSelection(obj);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
414 break;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
415 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
416 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
417 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
418
776
624131d0163d - selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents: 774
diff changeset
419 // The select() method calls may have selected additional items (i.e. invertnexts)
624131d0163d - selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents: 774
diff changeset
420 // Update it all now.
624131d0163d - selecting an invertnext'd object now also selects the invertnext
Santeri Piippo <crimsondusk64@gmail.com>
parents: 774
diff changeset
421 updateSelection();
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
422 renderer()->update();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
423 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
424
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
425 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
426 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
427 void MainWindow::recentFileClicked()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
428 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429 QAction* qAct = static_cast<QAction*> (sender());
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
430 documents()->openMainModel (qAct->text());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
431 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
432
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
433 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
434 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
435 void MainWindow::quickColorClicked()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
436 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
437 QToolButton* button = static_cast<QToolButton*> (sender());
1114
ffd49a28f49e Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents: 1113
diff changeset
438 LDColor color = LDColor::nullColor;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
439
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
440 for (const ColorToolbarItem& entry : m_quickColors)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
441 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
442 if (entry.toolButton() == button)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
443 {
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
444 color = entry.color();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
445 break;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
446 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
447 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
448
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
449 if (not color.isValid())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
450 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
451
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
452 for (LDObject* obj : selectedObjects())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
453 {
662
2f1bd9112408 - use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
454 if (not obj->isColored())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
455 continue; // uncolored object
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
456
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
457 obj->setColor (color);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
458 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
459
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
460 endAction();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
461 refresh();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
462 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
463
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
464 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
465 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
466 // Returns the suggested position to place a new object at.
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
467 //
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
468 int MainWindow::suggestInsertPoint()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
469 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
470 // If we have a selection, put the item after it.
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
471 // TODO: fix this properly!
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
472 if (not selectedObjects().isEmpty())
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
473 return (*(selectedObjects().end() - 1))->lineNumber() + 1;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
474
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
475 // Otherwise place the object at the end.
1083
5903cfa6b4d9 Removed LDDocument::getObjectCount (superceded by Model::size)
Teemu Piippo <teemu@hecknology.net>
parents: 1075
diff changeset
476 return m_currentDocument->size();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
477 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
478
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
479 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
480 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
481 void MainWindow::doFullRefresh()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
482 {
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
483 buildObjectList();
1113
5f3139c802bf Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
484 renderer()->update();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
485 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
486
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
487 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
488 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
489 // Builds the object list and tells the GL renderer to do a soft update.
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
490 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
491 void MainWindow::refresh()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
492 {
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
493 buildObjectList();
1097
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
494 renderer()->update();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
495 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
496
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
497 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
498 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
499 void MainWindow::updateSelection()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
500 {
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
501 m_isSelectionLocked = true;
892
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
502 QItemSelection itemselect;
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
503 int top = -1;
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
504 int bottom = -1;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
505
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
506 for (LDObject* obj : selectedObjects())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
507 {
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 986
diff changeset
508 QListWidgetItem** itempointer = m_objectsInList.find (obj);
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 986
diff changeset
509
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 986
diff changeset
510 if (not itempointer)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
511 continue;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
512
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 986
diff changeset
513 int row = ui.objectList->row (*itempointer);
892
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
514
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
515 if (top == -1)
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
516 {
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
517 top = bottom = row;
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
518 }
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
519 else
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
520 {
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
521 if (row != bottom + 1)
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
522 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
523 itemselect.select (ui.objectList->model()->index (top, 0),
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
524 ui.objectList->model()->index (bottom, 0));
892
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
525 top = -1;
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
526 }
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
527
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
528 bottom = row;
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
529 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
530 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
531
892
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
532 if (top != -1)
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
533 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
534 itemselect.select (ui.objectList->model()->index (top, 0),
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
535 ui.objectList->model()->index (bottom, 0));
892
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
536 }
49afb6b98253 - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before
Teemu Piippo <crimsondusk64@gmail.com>
parents: 888
diff changeset
537
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 986
diff changeset
538 // Select multiple objects at once for performance reasons
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
539 ui.objectList->selectionModel()->select (itemselect, QItemSelectionModel::ClearAndSelect);
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
540 m_isSelectionLocked = false;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
541 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
542
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
543 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
544 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
545 // Returns the uniform selected color (i.e. 4 if everything selected is red), -1 if there is no such consensus.
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
546 //
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
547 LDColor MainWindow::getUniformSelectedColor()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
548 {
795
195fa1fff9c3 - changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
549 LDColor result;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
550
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
551 for (LDObject* obj : selectedObjects())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
552 {
662
2f1bd9112408 - use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
553 if (not obj->isColored())
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
554 continue; // This one doesn't use color so it doesn't have a say
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
555
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
556 if (result.isValid() and obj->color() != result)
1114
ffd49a28f49e Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents: 1113
diff changeset
557 return LDColor::nullColor; // No consensus in object color
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
558
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
559 if (not result.isValid())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
560 result = obj->color();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
561 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
562
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
563 return result;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
564 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
565
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
566 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
567 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
568 void MainWindow::closeEvent (QCloseEvent* ev)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
569 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
570 // Check whether it's safe to close all files.
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
571 if (not m_documents->isSafeToCloseAll())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
572 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
573 ev->ignore();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
574 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
575 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
576
896
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
577 // Save the toolbar set
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
578 QStringList hiddenToolbars;
896
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
579
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
580 for (QToolBar* toolbar : findChildren<QToolBar*>())
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
581 {
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
582 if (toolbar->isHidden())
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
583 hiddenToolbars << toolbar->objectName();
896
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
584 }
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
585
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
586 // Save the configuration before leaving.
1192
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
587 configuration().setHiddenToolbars (hiddenToolbars);
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
588 syncSettings();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
589 ev->accept();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
590 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
591
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
592 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
593 //
1031
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1025
diff changeset
594 void MainWindow::spawnContextMenu (const QPoint& position)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
595 {
1065
c8ecddbd99e9 Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents: 1063
diff changeset
596 const bool single = (countof(selectedObjects()) == 1);
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
597 LDObject* singleObj = single ? *selectedObjects().begin() : nullptr;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
598
788
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
599 bool hasSubfiles = false;
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
600
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
601 for (LDObject* obj : selectedObjects())
788
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
602 {
1123
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1119
diff changeset
603 if (obj->type() == LDObjectType::SubfileReference)
788
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
604 {
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
605 hasSubfiles = true;
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
606 break;
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
607 }
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
608 }
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
609
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
610 QMenu* contextMenu = new QMenu;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
611
1123
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1119
diff changeset
612 if (single and singleObj->type() != LDObjectType::Empty)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
613 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
614 contextMenu->addAction (ui.actionEdit);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
615 contextMenu->addSeparator();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
616 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
617
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
618 contextMenu->addAction (ui.actionCut);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
619 contextMenu->addAction (ui.actionCopy);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
620 contextMenu->addAction (ui.actionPaste);
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
621 contextMenu->addAction (ui.actionRemove);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
622 contextMenu->addSeparator();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
623 contextMenu->addAction (ui.actionSetColor);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
624
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
625 if (single)
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
626 contextMenu->addAction (ui.actionEditRaw);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
627
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
628 contextMenu->addAction (ui.actionMakeBorders);
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
629 contextMenu->addAction (ui.actionSetOverlay);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
630 contextMenu->addAction (ui.actionClearOverlay);
788
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
631
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
632 if (hasSubfiles)
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
633 {
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
634 contextMenu->addSeparator();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
635 contextMenu->addAction (ui.actionOpenSubfiles);
788
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
636 }
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
637
c9d1dad83ad0 - added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 787
diff changeset
638 contextMenu->addSeparator();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
639 contextMenu->addAction (ui.actionModeSelect);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
640 contextMenu->addAction (ui.actionModeDraw);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
641 contextMenu->addAction (ui.actionModeCircle);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
642
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
643 if (not selectedObjects().isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
644 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
645 contextMenu->addSeparator();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
646 contextMenu->addAction (ui.actionSubfileSelection);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
647 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
648
1123
15e46ea3151f Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents: 1119
diff changeset
649 if (renderer()->camera() != Camera::Free)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
650 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
651 contextMenu->addSeparator();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
652 contextMenu->addAction (ui.actionSetDrawDepth);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
653 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
654
1031
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1025
diff changeset
655 contextMenu->exec(position);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
656 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
657
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
658 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
659 //
795
195fa1fff9c3 - changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 790
diff changeset
660 void MainWindow::deleteByColor (LDColor color)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
661 {
1162
94e12806d741 Replaced LDObjectList with QVector<LDObject*>
Teemu Piippo <teemu@hecknology.net>
parents: 1160
diff changeset
662 QVector<LDObject*> unwanted;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
663
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
664 for (LDObject* object : m_currentDocument->objects())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
665 {
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
666 if (not object->isColored() or object->color() != color)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
667 continue;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
668
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
669 unwanted.append(object);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
670 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
671
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
672 for (LDObject* obj : unwanted)
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
673 m_currentDocument->remove(obj);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
674 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
675
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
676 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
677 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
678 void MainWindow::updateEditModeActions()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
679 {
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
680 const EditModeType mode = renderer()->currentEditModeType();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
681 ui.actionModeSelect->setChecked (mode == EditModeType::Select);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
682 ui.actionModeDraw->setChecked (mode == EditModeType::Draw);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
683 ui.actionModeRectangle->setChecked (mode == EditModeType::Rectangle);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
684 ui.actionModeCircle->setChecked (mode == EditModeType::Circle);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
685 ui.actionModeMagicWand->setChecked (mode == EditModeType::MagicWand);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
686 ui.actionModeLinePath->setChecked (mode == EditModeType::LinePath);
1005
a88cf5a32246 Subject Bézier curve fineness to the grid. By default, the coarse grid uses 8 segments, medium 16 and fine 32. Moved rasterization from demoting to inlining, it feels more sensible for it to be there.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1004
diff changeset
687 ui.actionModeCurve->setChecked (mode == EditModeType::Curve);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
688 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
689
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
690 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
691 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
692 void MainWindow::objectListDoubleClicked (QListWidgetItem* listitem)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
693 {
1075
711c5fff384d Removed the AddObjectDialog. Garbage code that absolutely needs to be reimplemented.
Teemu Piippo <teemu@hecknology.net>
parents: 1073
diff changeset
694 LDObject* object = m_objectsInList.reverseLookup(listitem);
711c5fff384d Removed the AddObjectDialog. Garbage code that absolutely needs to be reimplemented.
Teemu Piippo <teemu@hecknology.net>
parents: 1073
diff changeset
695 // TODO: ...
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
696 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
697
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
698 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
699 //
945
c310073e4f22 More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents: 944
diff changeset
700 bool MainWindow::save (LDDocument* doc, bool saveAs)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
701 {
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
702 if (doc->isFrozen())
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
703 return false;
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
704
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 788
diff changeset
705 QString path = doc->fullPath();
1135
8e0691be0b6f Removed the intXX type aliases and removed uses of intXX_t in favor of qintXX
Teemu Piippo <teemu@hecknology.net>
parents: 1125
diff changeset
706 qint64 savesize;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
707
840
d077dd19bf9a - changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents: 834
diff changeset
708 if (saveAs or path.isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
709 {
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 788
diff changeset
710 QString name = doc->defaultName();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
711
662
2f1bd9112408 - use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
712 if (not doc->fullPath().isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
713 name = doc->fullPath();
967
eb586d3e1a6a elif -> else if
Teemu Piippo <crimsondusk64@gmail.com>
parents: 966
diff changeset
714 else if (not doc->name().isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
715 name = doc->name();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
716
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
717 name.replace ("\\", "/");
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
718 path = QFileDialog::getSaveFileName (this, tr ("Save As"),
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
719 name, tr ("LDraw files (*.dat *.ldr)"));
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
720
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
721 if (path.isEmpty())
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
722 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
723 // User didn't give a file name, abort.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
724 return false;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
725 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
726 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
727
834
3e697ba996e8 - now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents: 830
diff changeset
728 if (doc->save (path, &savesize))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
729 {
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
730 if (doc == m_currentDocument)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
731 updateTitle();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
732
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1012
diff changeset
733 print ("Saved to %1 (%2)", path, formatFileSize (savesize));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
734
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
735 // Add it to recent files
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
736 m_documents->addRecentFile (path);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
737 return true;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
738 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
739
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 788
diff changeset
740 QString message = format (tr ("Failed to save to %1: %2"), path, strerror (errno));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
741
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
742 // Tell the user the save failed, and give the option for saving as with it.
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
743 QMessageBox dlg (QMessageBox::Critical, tr ("Save Failure"), message, QMessageBox::Close, this);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
744
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
745 // Add a save-as button
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
746 QPushButton* saveAsBtn = new QPushButton (tr ("Save As"));
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
747 saveAsBtn->setIcon (getIcon ("file-save-as"));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
748 dlg.addButton (saveAsBtn, QMessageBox::ActionRole);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
749 dlg.setDefaultButton (QMessageBox::Close);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
750 dlg.exec();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
751
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
752 if (dlg.clickedButton() == saveAsBtn)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
753 return save (doc, true); // yay recursion!
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
754
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
755 return false;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
756 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
757
1159
6ad8cdcd88d9 print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents: 1157
diff changeset
758 void MainWindow::addMessage(QString message)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
759 {
1159
6ad8cdcd88d9 print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents: 1157
diff changeset
760 messageLog()->addLine(message);
6ad8cdcd88d9 print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents: 1157
diff changeset
761
6ad8cdcd88d9 print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents: 1157
diff changeset
762 // Also print it to stdout
6ad8cdcd88d9 print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents: 1157
diff changeset
763 fprint(stdout, "%1\n", message);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
764 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
765
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
766 /*
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
767 * Returns an icon from built-in resources.
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
768 */
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
769 QPixmap MainWindow::getIcon(QString iconName)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
770 {
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
771 return {format(":/icons/%1.png", iconName)};
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
772 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
773
1097
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
774 MessageManager* MainWindow::messageLog() const
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
775 {
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
776 return m_messageLog;
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
777 }
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
778
1018
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
779 // ---------------------------------------------------------------------------------------------------------------------
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
780 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
781 void MainWindow::updateDocumentList()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
782 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
783 m_updatingTabs = true;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
784
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
785 while (m_tabs->count() > 0)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
786 m_tabs->removeTab (0);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
787
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
788 for (LDDocument* document : m_documents->allDocuments())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
789 {
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
790 if (not document->isFrozen())
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
791 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
792 // Add an item to the list for this file and store the tab index
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
793 // in the document so we can find documents by tab index.
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
794 document->setTabIndex (m_tabs->addTab (""));
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
795 updateDocumentListItem (document);
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
796 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
797 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
798
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
799 m_updatingTabs = false;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
800 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
801
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
802 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
803 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
804 // Update the given document's tab. If no such tab exists, the document list is rebuilt.
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
805 //
945
c310073e4f22 More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents: 944
diff changeset
806 void MainWindow::updateDocumentListItem (LDDocument* doc)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
807 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
808 bool oldUpdatingTabs = m_updatingTabs;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
809 m_updatingTabs = true;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
810
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
811 if (doc->tabIndex() == -1)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
812 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
813 // We don't have a list item for this file, so the list either doesn't
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
814 // exist yet or is out of date. Build the list now.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
815 updateDocumentList();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
816 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
817 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
818
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
819 // If this is the current file, it also needs to be the selected item on
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
820 // the list.
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
821 if (doc == m_currentDocument)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
822 m_tabs->setCurrentIndex (doc->tabIndex());
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
823
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
824 m_tabs->setTabText (doc->tabIndex(), doc->getDisplayName());
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
825
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
826 // If the document.has unsaved changes, draw a little icon next to it to mark that.
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
827 m_tabs->setTabIcon (doc->tabIndex(), doc->hasUnsavedChanges() ? getIcon ("file-save") : QIcon());
798
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
828 m_tabs->setTabData (doc->tabIndex(), doc->name());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
829 m_updatingTabs = oldUpdatingTabs;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
830 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
831
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
832 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
833 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
834 // A file is selected from the list of files on the left of the screen. Find out
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
835 // which file was picked and change to it.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
836 //
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
837 void MainWindow::tabSelected()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
838 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
839 if (m_updatingTabs)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
840 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
841
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
842 LDDocument* switchee = nullptr;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
843 int tabIndex = m_tabs->currentIndex();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
844
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
845 // Find the file pointer of the item that was selected.
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
846 for (LDDocument* document : m_documents->allDocuments())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
847 {
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
848 if (not document->isFrozen() and document->tabIndex() == tabIndex)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
849 {
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
850 switchee = document;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
851 break;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
852 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
853 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
854
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
855 if (switchee and switchee != m_currentDocument)
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
856 changeDocument (switchee);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
857 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
858
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
859 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
860 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
861 // Updates the object list. Right now this just rebuilds it.
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
862 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
863 void MainWindow::refreshObjectList()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
864 {
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
865 buildObjectList();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
866 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
867
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
868 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
869 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
870 // Updates various actions, undo/redo are set enabled/disabled where appropriate, togglable actions are updated based
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
871 // on configuration, etc.
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
872 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
873 void MainWindow::updateActions()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
874 {
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
875 if (m_currentDocument and m_currentDocument->history())
815
efe34366e56a - added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents: 808
diff changeset
876 {
983
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
877 EditHistory* his = m_currentDocument->history();
815
efe34366e56a - added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents: 808
diff changeset
878 int pos = his->position();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
879 ui.actionUndo->setEnabled (pos != -1);
983
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
880 ui.actionRedo->setEnabled (pos < (long) his->size() - 1);
815
efe34366e56a - added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents: 808
diff changeset
881 }
efe34366e56a - added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents: 808
diff changeset
882
1192
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
883 ui.actionWireframe->setChecked (configuration().drawWireframe());
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
884 ui.actionAxes->setChecked (configuration().drawAxes());
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
885 ui.actionBfcView->setChecked (configuration().bfcRedGreenView());
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
886 ui.actionRandomColors->setChecked (configuration().randomColors());
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
887 ui.actionDrawAngles->setChecked (configuration().drawAngles());
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
888 ui.actionDrawSurfaces->setChecked (configuration().drawSurfaces());
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
889 ui.actionDrawEdgeLines->setChecked (configuration().drawEdgeLines());
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
890 ui.actionDrawConditionalLines->setChecked (configuration().drawConditionalLines());
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
891 ui.actionLighting->setChecked(configuration().lighting());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
892 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
893
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
894 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
895 //
1018
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
896 PrimitiveManager* MainWindow::primitives()
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
897 {
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
898 return m_primitives;
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
899 }
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
900
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
901 // ---------------------------------------------------------------------------------------------------------------------
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
902 //
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
903 Canvas* MainWindow::renderer()
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
904 {
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
905 return static_cast<Canvas*>(ui.rendererStack->currentWidget());
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
906 }
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
907
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
908 // ---------------------------------------------------------------------------------------------------------------------
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
909 //
1043
0091a761daf2 Refactor GuiUtilities
Teemu Piippo <teemu@hecknology.net>
parents: 1034
diff changeset
910 void MainWindow::setQuickColors (const QVector<ColorToolbarItem>& colors)
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
911 {
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
912 m_quickColors = colors;
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
913 updateColorToolbar();
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
914 }
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
915
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
916 // ---------------------------------------------------------------------------------------------------------------------
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
917 //
790
fe1b83f6ba82 - added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
918 void MainWindow::updatePrimitives()
fe1b83f6ba82 - added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
919 {
1018
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
920 m_primitives->populateTreeWidget(ui.primitives);
790
fe1b83f6ba82 - added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
921 }
fe1b83f6ba82 - added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
922
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
923 // ---------------------------------------------------------------------------------------------------------------------
790
fe1b83f6ba82 - added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
924 //
798
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
925 void MainWindow::closeTab (int tabindex)
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
926 {
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
927 LDDocument* doc = m_documents->findDocumentByName (m_tabs->tabData (tabindex).toString());
798
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
928
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
929 if (doc)
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
930 doc->close();
798
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
931 }
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
932
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
933 // ---------------------------------------------------------------------------------------------------------------------
798
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
934 //
983
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
935 void MainWindow::historyTraversed()
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
936 {
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
937 updateActions();
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
938 refresh();
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
939 }
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
940
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
941 // ---------------------------------------------------------------------------------------------------------------------
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
942 //
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
943 void MainWindow::loadShortcuts()
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
944 {
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
945 for (QAction* act : findChildren<QAction*>())
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
946 {
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
947 QKeySequence seq = m_settings->value ("shortcut_" + act->objectName(), act->shortcut()).value<QKeySequence>();
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
948 act->setShortcut (seq);
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
949 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
950 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
951
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
952 // ---------------------------------------------------------------------------------------------------------------------
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
953 //
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
954 void MainWindow::saveShortcuts()
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
955 {
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
956 applyToActions ([&](QAction* act)
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
957 {
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
958 QString const key = "shortcut_" + act->objectName();
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
959
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
960 if (m_defaultShortcuts[act] != act->shortcut())
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
961 m_settings->setValue (key, act->shortcut());
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
962 else
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
963 m_settings->remove (key);
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
964 });
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
965 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
966
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
967 // ---------------------------------------------------------------------------------------------------------------------
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
968 //
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
969 void MainWindow::applyToActions (std::function<void(QAction*)> function)
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
970 {
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
971 for (QAction* act : findChildren<QAction*>())
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
972 {
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
973 if (not act->objectName().isEmpty())
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
974 function (act);
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
975 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
976 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
977
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
978 // ---------------------------------------------------------------------------------------------------------------------
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
979 //
963
c1526d1877d7 More through removal of the vertex object
Teemu Piippo <crimsondusk64@gmail.com>
parents: 962
diff changeset
980 QTreeWidget* MainWindow::getPrimitivesTree() const
c1526d1877d7 More through removal of the vertex object
Teemu Piippo <crimsondusk64@gmail.com>
parents: 962
diff changeset
981 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
982 return ui.primitives;
963
c1526d1877d7 More through removal of the vertex object
Teemu Piippo <crimsondusk64@gmail.com>
parents: 962
diff changeset
983 }
c1526d1877d7 More through removal of the vertex object
Teemu Piippo <crimsondusk64@gmail.com>
parents: 962
diff changeset
984
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
985 // ---------------------------------------------------------------------------------------------------------------------
963
c1526d1877d7 More through removal of the vertex object
Teemu Piippo <crimsondusk64@gmail.com>
parents: 962
diff changeset
986 //
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 988
diff changeset
987 QKeySequence MainWindow::defaultShortcut (QAction* act)
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
988 {
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
989 return m_defaultShortcuts[act];
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
990 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
991
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
992 // ---------------------------------------------------------------------------------------------------------------------
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
993 //
865
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
994 bool MainWindow::ringToolHiRes() const
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
995 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
996 return ui.ringToolHiRes->isChecked();
865
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
997 }
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
998
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
999 // ---------------------------------------------------------------------------------------------------------------------
865
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
1000 //
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
1001 int MainWindow::ringToolSegments() const
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
1002 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
1003 return ui.ringToolSegments->value();
865
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
1004 }
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
1005
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1006 // ---------------------------------------------------------------------------------------------------------------------
865
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
1007 //
866
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1008 void MainWindow::ringToolHiResClicked (bool checked)
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1009 {
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1010 if (checked)
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1011 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
1012 ui.ringToolSegments->setMaximum (HighResolution);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
1013 ui.ringToolSegments->setValue (ui.ringToolSegments->value() * 3);
866
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1014 }
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1015 else
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1016 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
1017 ui.ringToolSegments->setValue (ui.ringToolSegments->value() / 3);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
1018 ui.ringToolSegments->setMaximum (LowResolution);
866
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1019 }
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1020 }
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1021
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1022 // ---------------------------------------------------------------------------------------------------------------------
871
a860edb4210b - display a label next to the spinbox showing the fraction
Teemu Piippo <crimsondusk64@gmail.com>
parents: 869
diff changeset
1023 //
a860edb4210b - display a label next to the spinbox showing the fraction
Teemu Piippo <crimsondusk64@gmail.com>
parents: 869
diff changeset
1024 void MainWindow::circleToolSegmentsChanged()
a860edb4210b - display a label next to the spinbox showing the fraction
Teemu Piippo <crimsondusk64@gmail.com>
parents: 869
diff changeset
1025 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
1026 int numerator (ui.ringToolSegments->value());
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
1027 int denominator (ui.ringToolHiRes->isChecked() ? HighResolution : LowResolution);
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1012
diff changeset
1028 simplify (numerator, denominator);
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
1029 ui.ringToolSegmentsLabel->setText (format ("%1 / %2", numerator, denominator));
871
a860edb4210b - display a label next to the spinbox showing the fraction
Teemu Piippo <crimsondusk64@gmail.com>
parents: 869
diff changeset
1030 }
866
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1031
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
1032 /*
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
1033 * Returns a settings object that interfaces the ini file.
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
1034 */
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
1035 QSettings* MainWindow::makeSettings(QObject* parent)
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 969
diff changeset
1036 {
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 969
diff changeset
1037 QString path = qApp->applicationDirPath() + "/" UNIXNAME ".ini";
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
1038 return new QSettings {path, QSettings::IniFormat, parent};
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 969
diff changeset
1039 }
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 969
diff changeset
1040
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1041 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1042 //
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1043 void MainWindow::syncSettings()
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1044 {
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1045 m_settings->sync();
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1046 }
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1047
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1048 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1049 //
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1050 QVariant MainWindow::getConfigValue (QString name)
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1051 {
1192
317f4ce38f3f Made configuration a global singleton. I think I can give in at least that much because it makes solving a lot of problems easier.
Teemu Piippo <teemu@hecknology.net>
parents: 1185
diff changeset
1052 QVariant value = m_settings->value (name, configuration().defaultValueByName (name));
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1053 return value;
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1054 }
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1055
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
1056 // ---------------------------------------------------------------------------------------------------------------------
866
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
1057 //
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1058 void MainWindow::createBlankDocument()
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1059 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1060 // Create a new anonymous file and set it to our current
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1061 LDDocument* f = newDocument();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1062 f->setName ("");
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1063 changeDocument (f);
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1064 closeInitialDocument();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1065 doFullRefresh();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1066 updateActions();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1067 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1068
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1069 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1070 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1071 LDDocument* MainWindow::newDocument (bool cache)
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1072 {
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
1073 LDDocument* document = m_documents->createNew();
983
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
1074 connect (document->history(), SIGNAL (undone()), this, SLOT (historyTraversed()));
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
1075 connect (document->history(), SIGNAL (redone()), this, SLOT (historyTraversed()));
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
1076 connect (document->history(), SIGNAL (stepAdded()), this, SLOT (updateActions()));
979
880d3fe9ac7c Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
1077
880d3fe9ac7c Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
1078 if (not cache)
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1079 openDocumentForEditing(document);
979
880d3fe9ac7c Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
1080
983
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
1081 return document;
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1082 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1083
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1084 void MainWindow::openDocumentForEditing(LDDocument* document)
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1085 {
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1086 if (document->isFrozen())
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1087 {
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1088 document->setFrozen(false);
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1089 print ("Opened %1", document->name());
1113
5f3139c802bf Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
1090 getRendererForDocument(document);
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1091 updateDocumentList();
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1092 }
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1093 }
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1094
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1095 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1096 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1097 LDDocument* MainWindow::currentDocument()
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1098 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1099 return m_currentDocument;
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1100 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1101
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1102 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1103 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1104 // TODO: document may be null, this shouldn't be the case
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1105 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1106 void MainWindow::changeDocument (LDDocument* document)
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1107 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1108 // Implicit files were loaded for caching purposes and may never be switched to.
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1109 if (document and document->isFrozen())
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1110 return;
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1111
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1112 m_currentDocument = document;
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
1113 Canvas* renderer = getRendererForDocument(document);
1097
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1114 ui.rendererStack->setCurrentWidget(renderer);
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1115
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1116 if (document)
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1117 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1118 // A ton of stuff needs to be updated
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1119 updateDocumentListItem (document);
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1120 buildObjectList();
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1121 updateTitle();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1122 print ("Changed document to %1", document->getDisplayName());
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1123 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1124 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1125
1097
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1126 /*
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1127 * Returns the associated renderer for the given document
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1128 */
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
1129 Canvas* MainWindow::getRendererForDocument(LDDocument *document)
1097
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1130 {
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
1131 Canvas* renderer = m_renderers.value(document);
1097
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1132
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1133 if (not renderer)
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1134 {
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1135 print("MainWindow: Couldn't find a renderer for %1, creating one now", document->getDisplayName());
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
1136 renderer = new Canvas {document, this};
1097
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1137 print("Created renderer: %1", renderer);
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1138 m_renderers[document] = renderer;
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1139 ui.rendererStack->addWidget(renderer);
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1140 connect(m_messageLog, SIGNAL(changed()), renderer, SLOT(update()));
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1141 }
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1142
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1143 return renderer;
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1144 }
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1145
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1146 void MainWindow::documentClosed(LDDocument *document)
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1147 {
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1148 print ("Closed %1", document->name());
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1149 updateDocumentList();
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1150
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1151 // If the current document just became implicit (i.e. user closed it), we need to get a new one to show.
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1152 if (currentDocument() == document)
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1153 currentDocumentClosed();
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1154
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
1155 Canvas* renderer = m_renderers.value(document);
1097
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1156
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1157 if (renderer)
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1158 {
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1159 ui.rendererStack->removeWidget(renderer);
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1160 renderer->deleteLater();
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1161 }
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1162
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1163 m_renderers.remove(document);
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1164 }
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1090
diff changeset
1165
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1166 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1167 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1168 // This little beauty closes the initial file that was open at first when opening a new file over it.
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1169 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1170 void MainWindow::closeInitialDocument()
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1171 {
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
1172 /*
1063
1f15c52c11f6 Replaced uses of 'x.size()' with 'length(x)'
Teemu Piippo <teemu@hecknology.net>
parents: 1045
diff changeset
1173 if (length(m_documents) == 2 and
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1174 m_documents[0]->name().isEmpty() and
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1175 not m_documents[1]->name().isEmpty() and
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1176 not m_documents[0]->hasUnsavedChanges())
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1177 {
979
880d3fe9ac7c Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
1178 m_documents.first()->close();
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1179 }
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
1180 */
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1181 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1182
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1183 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1184 //
1073
a0a0d581309b Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents: 1072
diff changeset
1185 const QSet<LDObject*>& MainWindow::selectedObjects()
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1186 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1187 return m_currentDocument->getSelection();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1188 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1189
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1190 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1191 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1192 void MainWindow::currentDocumentClosed()
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1193 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1194 LDDocument* old = currentDocument();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1195
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1196 // Find a replacement document to use
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
1197 for (LDDocument* doc : m_documents->allDocuments())
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1198 {
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1199 if (doc != old and not doc->isFrozen())
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1200 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1201 changeDocument (doc);
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1202 break;
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1203 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1204 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1205
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1206 if (currentDocument() == old)
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1207 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1208 // Failed to change to a suitable document, open a new one.
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1209 createBlankDocument();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1210 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1211 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1212
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1213 ExtProgramToolset* MainWindow::externalPrograms()
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1214 {
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1215 return m_externalPrograms;
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1216 }
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1217
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1218 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1219 //
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1220 ColorToolbarItem::ColorToolbarItem (LDColor color, QToolButton* toolButton) :
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1221 m_color (color),
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1222 m_toolButton (toolButton) {}
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1223
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1224 ColorToolbarItem ColorToolbarItem::makeSeparator()
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1225 {
1114
ffd49a28f49e Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents: 1113
diff changeset
1226 return ColorToolbarItem (LDColor::nullColor, nullptr);
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1227 }
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1228
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1229 bool ColorToolbarItem::isSeparator() const
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1230 {
1114
ffd49a28f49e Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents: 1113
diff changeset
1231 return color() == LDColor::nullColor;
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1232 }
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1233
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1234 LDColor ColorToolbarItem::color() const
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1235 {
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1236 return m_color;
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1237 }
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1238
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1239 void ColorToolbarItem::setColor (LDColor color)
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1240 {
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1241 m_color = color;
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1242 }
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1243
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1244 QToolButton* ColorToolbarItem::toolButton() const
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1245 {
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1246 return m_toolButton;
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1247 }
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1248
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1249 void ColorToolbarItem::setToolButton (QToolButton* value)
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1250 {
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1005
diff changeset
1251 m_toolButton = value;
1043
0091a761daf2 Refactor GuiUtilities
Teemu Piippo <teemu@hecknology.net>
parents: 1034
diff changeset
1252 }

mercurial