src/mainwindow.cpp

Sun, 18 Mar 2018 12:33:29 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 18 Mar 2018 12:33:29 +0200
changeset 1298
dbc8bb2a4d84
parent 1291
9c570a30c98a
child 1306
be85306198a2
permissions
-rw-r--r--

fixed infinite recursion and integrated the subfilereference editor

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>
1249
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
25 #include "generics/reverse.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 #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
27 #include "canvas.h"
962
a4b463a7ee82 Rename MainWindow files
Teemu Piippo <crimsondusk64@gmail.com>
parents: 959
diff changeset
28 #include "mainwindow.h"
1145
02264bf0108d Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1135
diff changeset
29 #include "lddocument.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 #include "miscallenous.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 #include "messageLog.h"
963
c1526d1877d7 More through removal of the vertex object
Teemu Piippo <crimsondusk64@gmail.com>
parents: 962
diff changeset
32 #include "ui_mainwindow.h"
790
fe1b83f6ba82 - added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 789
diff changeset
33 #include "primitives.h"
830
a741a0b9df49 - updated filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents: 823
diff changeset
34 #include "editmodes/abstractEditMode.h"
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
35 #include "toolsets/toolset.h"
975
24ba5aa3393f Move ConfigDialog into src/dialogs/ subfolder
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
36 #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
37 #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
38 #include "guiutilities.h"
1146
bb728c124d47 Renamed glCompiler.cpp → glcompiler.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1145
diff changeset
39 #include "glcompiler.h"
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 988
diff changeset
40 #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
41 #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
42 #include "grid.h"
1025
4949da3fb4b3 Renamed ldObjectMath.cpp/.h to mathfunctions.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1024
diff changeset
43 #include "mathfunctions.h"
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44
1124
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
45 struct MainWindow::ToolInfo
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
46 {
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
47 QMetaMethod method;
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
48 Toolset* object;
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
49 };
bd151d5c42e6 Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 1123
diff changeset
50
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
51 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 //
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
53 MainWindow::MainWindow(class Configuration& config, QWidget* parent, Qt::WindowFlags flags) :
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
54 QMainWindow (parent, flags),
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
55 m_config(config),
974
b2fa5f89798a Added a GuiUtilities class to contain useful non-MainWindow-related GUI functions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 972
diff changeset
56 m_guiUtilities (new GuiUtilities (this)),
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
57 m_primitives(new PrimitiveManager(this)),
1023
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1018
diff changeset
58 m_grid(new Grid(this)),
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
59 m_mathFunctions(new MathFunctions(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
60 ui (*new Ui_MainWindow),
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
61 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
62 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
63 m_documents (new DocumentManager (this)),
1240
cebb7ef54f41 changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents: 1236
diff changeset
64 m_currentDocument (nullptr)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 {
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
66 m_messageLog = new MessageManager {this};
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
67 ui.setupUi (this);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 m_updatingTabs = false;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 m_tabs = new QTabBar;
798
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
70 m_tabs->setTabsClosable (true);
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
71 ui.verticalLayout->insertWidget (0, m_tabs);
1283
3c3a5eb965f7 added an MVC interface to the primitives tree
Teemu Piippo <teemu@hecknology.net>
parents: 1258
diff changeset
72 ui.primitives->setModel(m_primitives);
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
73 createBlankDocument();
1154
a426a335e586 Some cleanup in mainwindow.cpp, use QSet<QString> for the 'ignore' variable.
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
74 ui.rendererStack->setCurrentWidget(getRendererForDocument(m_currentDocument));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
76 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
77 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
78 connect(m_documents, SIGNAL(documentClosed(LDDocument*)), this, SLOT(documentClosed(LDDocument*)));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
80 m_quickColors = m_guiUtilities->loadQuickColorList();
815
efe34366e56a - added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents: 808
diff changeset
81 updateActions();
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
82
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
83 // Connect all actions and save default sequences
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
84 applyToActions ([&](QAction* act)
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
85 {
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
86 connect (act, SIGNAL (triggered()), this, SLOT (actionTriggered()));
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
87 m_defaultShortcuts[act] = act->shortcut();
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
88 });
1291
9c570a30c98a Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents: 1283
diff changeset
89 connect(
9c570a30c98a Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents: 1283
diff changeset
90 ui.header,
9c570a30c98a Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents: 1283
diff changeset
91 &HeaderEdit::descriptionChanged,
9c570a30c98a Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents: 1283
diff changeset
92 this,
9c570a30c98a Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents: 1283
diff changeset
93 &MainWindow::updateTitle
9c570a30c98a Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents: 1283
diff changeset
94 );
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
95
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 updateGridToolBar();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 updateEditModeActions();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 updateRecentFilesMenu();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 updateColorToolbar();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 updateTitle();
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
101 loadShortcuts();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 setMinimumSize (300, 200);
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
103 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
104 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
105 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
106
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
107 // 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
108 m_toolsets = Toolset::createToolsets (this);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
109
1154
a426a335e586 Some cleanup in mainwindow.cpp, use QSet<QString> for the 'ignore' variable.
Teemu Piippo <teemu@hecknology.net>
parents: 1146
diff changeset
110 QSet<QString> ignore;
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
111 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
112 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
113 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
114 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
115 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
116
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
117 for (Toolset* toolset : m_toolsets)
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
118 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
119 const QMetaObject* meta = toolset->metaObject();
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
120
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
121 if (qobject_cast<ExtProgramToolset*> (toolset))
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
122 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
123
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
124 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
125 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
126 ToolInfo info;
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
127 info.method = meta->method (i);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
128 info.object = toolset;
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
129 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
130
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
131 if (ignore.contains (methodName))
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
132 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
133
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
134 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
135 QAction* action = findChild<QAction*> (actionName);
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
136
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
137 if (action == nullptr)
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
138 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
139 else
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
140 m_toolmap[action] = info;
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
141 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
142 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
143
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
144 for (QVariant const& toolbarname : m_config.hiddenToolbars())
896
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
145 {
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
146 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
147
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
148 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
149 toolbar->hide();
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
150 }
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
151
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
152 // 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
153 // them to the profile tab, it's the most important form to fill in.
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
154 if (m_config.firstStart())
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
155 {
972
a34b73114823 Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 971
diff changeset
156 ConfigDialog* dialog = new ConfigDialog (this, ConfigDialog::ProfileTab);
a34b73114823 Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 971
diff changeset
157 dialog->show();
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
158 m_config.setFirstStart (false);
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
159 }
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
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 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
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
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
164 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
165 {
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
166 m_primitives->loadPrimitives();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168
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
169 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
170 {
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
171 delete m_guiUtilities;
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 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
173 delete m_grid;
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
174 delete m_mathFunctions;
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
175 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
176 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
177
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
178 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
179 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
180 }
e62983881460 - fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
181
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
182 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
184 void MainWindow::actionTriggered()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 // 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
187 // 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
188 QAction* action = qobject_cast<QAction*> (sender());
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
189
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
190 if (action)
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
191 {
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
192 if (m_toolmap.contains (action))
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 const ToolInfo& info = m_toolmap[action];
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
195 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
196 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
197 else
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
198 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
199 }
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
200
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 endAction();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
204 // ---------------------------------------------------------------------------------------------------------------------
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 void MainWindow::endAction()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 {
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
208 m_currentDocument->addHistoryStep();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
209 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
210 refresh();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
213 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215 void MainWindow::updateRecentFilesMenu()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
217 // First, clear any items in the recent files menu
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
218 for (QAction* recent : m_recentFiles)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219 delete recent;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
220
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221 m_recentFiles.clear();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222
984
a7b6f987d269 null -> nullptr
Teemu Piippo <crimsondusk64@gmail.com>
parents: 983
diff changeset
223 QAction* first = nullptr;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
224
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
225 for (const QVariant& it : m_config.recentFiles())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
226 {
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 788
diff changeset
227 QString file = it.toString();
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
228 QAction* recent = new QAction (getIcon ("open-recent"), file, this);
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
229 connect (recent, SIGNAL (triggered()), this, SLOT (recentFileClicked()));
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
230 ui.menuOpenRecent->insertAction (first, recent);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
231 m_recentFiles << recent;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
232 first = recent;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
233 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
234 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
235
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
236 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
237 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238 void MainWindow::updateColorToolbar()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
239 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 m_colorButtons.clear();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
241 ui.toolBarColors->clear();
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
242 ui.toolBarColors->addAction (ui.actionUncolor);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
243 ui.toolBarColors->addSeparator();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244
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
245 for (ColorToolbarItem& entry : m_quickColors)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247 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
248 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
249 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
250 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251 else
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 QToolButton* colorButton = new QToolButton;
1252
db1d4917626f refactor
Santeri Piippo
parents: 1251
diff changeset
254 colorButton->setIcon (makeColorIcon (entry.color(), 16));
729
dcd7e3e86374 - started work on new icon set
Santeri Piippo <crimsondusk64@gmail.com>
parents: 663
diff changeset
255 colorButton->setIconSize (QSize (16, 16));
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
256 colorButton->setToolTip (entry.color().name());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
257
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
258 connect (colorButton, SIGNAL (clicked()), this, SLOT (quickColorClicked()));
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
259 ui.toolBarColors->addWidget (colorButton);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260 m_colorButtons << colorButton;
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 entry.setToolButton (colorButton);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
263 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
265
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 updateGridToolBar();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
268
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
269 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
271 void MainWindow::updateGridToolBar()
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 // Ensure that the current grid - and only the current grid - is selected.
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
274 int grid = m_config.grid();
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
275 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
276 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
277 ui.actionGridFine->setChecked (grid == Grid::Fine);
1184
393babf1319d Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents: 1162
diff changeset
278 ui.actionPolarGrid->setChecked(m_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
279 emit gridChanged();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
280 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
281
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
282 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
284 void MainWindow::updateTitle()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285 {
1291
9c570a30c98a Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents: 1283
diff changeset
286 QString title = APPNAME " " VERSION_STRING;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
288 // 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
289 if (m_currentDocument)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
290 {
744
bbe0e1834065 - removed rest of the uses of <anonymous>
Santeri Piippo <crimsondusk64@gmail.com>
parents: 739
diff changeset
291 title += ": ";
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
292 title += m_currentDocument->getDisplayName();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293
1291
9c570a30c98a Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents: 1283
diff changeset
294 if (not m_currentDocument->header.description.isEmpty())
9c570a30c98a Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents: 1283
diff changeset
295 title += format (": %1", m_currentDocument->header.description);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
297 if (m_currentDocument->hasUnsavedChanges())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
298 title += '*';
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
299 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
301 #ifdef DEBUG
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
302 title += " [debug build]";
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303 #elif BUILD_ID != BUILD_RELEASE
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
304 title += " [pre-release build]";
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305 #endif // DEBUG
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306
948
3a91828475fd Replaced updaterevision with a python script, more renames, clang fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 946
diff changeset
307 if (strlen (commitTimeString()))
3a91828475fd Replaced updaterevision with a python script, more renames, clang fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 946
diff changeset
308 title += format (" (%1)", QString::fromUtf8 (commitTimeString()));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310 setWindowTitle (title);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
311 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
312
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
313 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
314 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315 int MainWindow::deleteSelection()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 {
1249
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
317 int count = 0;
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
318 QModelIndexList thingsToRemove = ui.objectList->selectionModel()->selectedIndexes();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319
1249
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
320 for (QModelIndex index : reverse(thingsToRemove))
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
321 {
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
322 if (m_currentDocument->hasIndex(index.row(), index.column()))
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
323 {
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
324 m_currentDocument->removeAt(index);
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
325 count += 1;
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
326 }
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
327 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328
1249
6a8f76f0f4d1 convert MainWindow::deleteSelection to mvc
Santeri Piippo
parents: 1246
diff changeset
329 return count;
655
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
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
332 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
333 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
334 void MainWindow::recentFileClicked()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
335 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336 QAction* qAct = static_cast<QAction*> (sender());
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
337 documents()->openMainModel (qAct->text());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
338 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
339
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
340 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
341 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
342 void MainWindow::quickColorClicked()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
343 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
344 QToolButton* button = static_cast<QToolButton*> (sender());
1114
ffd49a28f49e Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents: 1113
diff changeset
345 LDColor color = LDColor::nullColor;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346
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
347 for (const ColorToolbarItem& entry : m_quickColors)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
348 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
349 if (entry.toolButton() == button)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
350 {
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
351 color = entry.color();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
352 break;
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
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
356 if (not color.isValid())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
357 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
358
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
359 for (LDObject* obj : selectedObjects())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360 {
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
361 if (not obj->isColored())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
362 continue; // uncolored object
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
363
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
364 obj->setColor (color);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
365 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
366
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
367 endAction();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
368 refresh();
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
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
371 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
372 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
373 // Returns the suggested position to place a new object at.
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
374 //
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
375 int MainWindow::suggestInsertPoint()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
376 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
377 // 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
378 // TODO: fix this properly!
1258
f5921a474d57 removed LDObject::lineNumber
Santeri Piippo
parents: 1257
diff changeset
379 if (not selectedIndexes().isEmpty())
f5921a474d57 removed LDObject::lineNumber
Santeri Piippo
parents: 1257
diff changeset
380 return (*(selectedIndexes().end() - 1)).row() + 1;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
381
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
382 // 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
383 return m_currentDocument->size();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
384 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
385
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
386 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
387 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
388 void MainWindow::doFullRefresh()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
389 {
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
390 renderer()->update();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
391 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
392
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
393 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
394 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
395 // 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
396 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397 void MainWindow::refresh()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
398 {
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
399 renderer()->update();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
400 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
401
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
402 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
403 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
404 // 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
405 //
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
406 LDColor MainWindow::getUniformSelectedColor()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
407 {
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
408 LDColor result;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
410 for (LDObject* obj : selectedObjects())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
411 {
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
412 if (not obj->isColored())
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
413 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
414
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
415 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
416 return LDColor::nullColor; // No consensus in object color
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
417
946
9cbd658b63f9 Cleanup progresses
Teemu Piippo <crimsondusk64@gmail.com>
parents: 945
diff changeset
418 if (not result.isValid())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
419 result = obj->color();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
420 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
421
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
422 return result;
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 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
427 void MainWindow::closeEvent (QCloseEvent* ev)
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 // Check whether it's safe to close all files.
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
430 if (not m_documents->isSafeToCloseAll())
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 ev->ignore();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
433 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
434 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
435
896
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
436 // Save the toolbar set
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
437 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
438
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
439 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
440 {
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
441 if (toolbar->isHidden())
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
442 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
443 }
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
444
4988666b5e3c - now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents: 893
diff changeset
445 // Save the configuration before leaving.
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
446 m_config.setHiddenToolbars (hiddenToolbars);
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
447 syncSettings();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
448 ev->accept();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
449 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
450
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
451 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
452 //
1031
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1025
diff changeset
453 void MainWindow::spawnContextMenu (const QPoint& position)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
454 {
1065
c8ecddbd99e9 Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents: 1063
diff changeset
455 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
456 LDObject* singleObj = single ? *selectedObjects().begin() : nullptr;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
457
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
458 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
459
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
460 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
461 {
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
462 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
463 {
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
464 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
465 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
466 }
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
467 }
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
468
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
469 QMenu* contextMenu = new QMenu;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
470
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
471 if (single and singleObj->type() != LDObjectType::Empty)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
472 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
473 contextMenu->addAction (ui.actionEdit);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
474 contextMenu->addSeparator();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
475 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
476
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
477 contextMenu->addAction (ui.actionCut);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
478 contextMenu->addAction (ui.actionCopy);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
479 contextMenu->addAction (ui.actionPaste);
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
480 contextMenu->addAction (ui.actionRemove);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
481 contextMenu->addSeparator();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
482 contextMenu->addAction (ui.actionSetColor);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
483
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
484 if (single)
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
485 contextMenu->addAction (ui.actionEditRaw);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
486
969
b1742ee91d5b Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
487 contextMenu->addAction (ui.actionMakeBorders);
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
488 contextMenu->addAction (ui.actionSetOverlay);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
489 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
490
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
491 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
492 {
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
493 contextMenu->addSeparator();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
494 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
495 }
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
496
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
497 contextMenu->addSeparator();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
498 contextMenu->addAction (ui.actionModeSelect);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
499 contextMenu->addAction (ui.actionModeDraw);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
500 contextMenu->addAction (ui.actionModeCircle);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
501
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
502 if (not selectedObjects().isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
503 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
504 contextMenu->addSeparator();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
505 contextMenu->addAction (ui.actionSubfileSelection);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
506 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
507
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
508 if (renderer()->camera() != Camera::Free)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
509 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
510 contextMenu->addSeparator();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
511 contextMenu->addAction (ui.actionSetDrawDepth);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
512 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
513
1031
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1025
diff changeset
514 contextMenu->exec(position);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
515 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
516
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
517 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
518 //
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
519 void MainWindow::deleteByColor (LDColor color)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
520 {
1162
94e12806d741 Replaced LDObjectList with QVector<LDObject*>
Teemu Piippo <teemu@hecknology.net>
parents: 1160
diff changeset
521 QVector<LDObject*> unwanted;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
522
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
523 for (LDObject* object : m_currentDocument->objects())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
524 {
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
525 if (not object->isColored() or object->color() != color)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
526 continue;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
527
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
528 unwanted.append(object);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
529 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
530
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
531 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
532 m_currentDocument->remove(obj);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
533 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
534
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
535 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
536 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
537 void MainWindow::updateEditModeActions()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
538 {
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
539 const EditModeType mode = renderer()->currentEditModeType();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
540 ui.actionModeSelect->setChecked (mode == EditModeType::Select);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
541 ui.actionModeDraw->setChecked (mode == EditModeType::Draw);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
542 ui.actionModeRectangle->setChecked (mode == EditModeType::Rectangle);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
543 ui.actionModeCircle->setChecked (mode == EditModeType::Circle);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
544 ui.actionModeMagicWand->setChecked (mode == EditModeType::MagicWand);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
545 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
546 ui.actionModeCurve->setChecked (mode == EditModeType::Curve);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
547 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
548
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
549 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
550 //
945
c310073e4f22 More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents: 944
diff changeset
551 bool MainWindow::save (LDDocument* doc, bool saveAs)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
552 {
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
553 if (doc->isFrozen())
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
554 return false;
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
555
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 788
diff changeset
556 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
557 qint64 savesize;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
558
840
d077dd19bf9a - changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents: 834
diff changeset
559 if (saveAs or path.isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
560 {
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 788
diff changeset
561 QString name = doc->defaultName();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
562
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
563 if (not doc->fullPath().isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
564 name = doc->fullPath();
967
eb586d3e1a6a elif -> else if
Teemu Piippo <crimsondusk64@gmail.com>
parents: 966
diff changeset
565 else if (not doc->name().isEmpty())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
566 name = doc->name();
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 name.replace ("\\", "/");
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
569 path = QFileDialog::getSaveFileName (this, tr ("Save As"),
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
570 name, tr ("LDraw files (*.dat *.ldr)"));
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
571
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
572 if (path.isEmpty())
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
573 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
574 // User didn't give a file name, abort.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
575 return false;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
576 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
577 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
578
834
3e697ba996e8 - now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents: 830
diff changeset
579 if (doc->save (path, &savesize))
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
580 {
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
581 if (doc == m_currentDocument)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
582 updateTitle();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
583
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1012
diff changeset
584 print ("Saved to %1 (%2)", path, formatFileSize (savesize));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
585
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
586 // Add it to recent files
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
587 m_documents->addRecentFile (path);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
588 return true;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
589 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
590
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 788
diff changeset
591 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
592
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
593 // 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
594 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
595
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
596 // Add a save-as button
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
597 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
598 saveAsBtn->setIcon (getIcon ("file-save-as"));
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
599 dlg.addButton (saveAsBtn, QMessageBox::ActionRole);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
600 dlg.setDefaultButton (QMessageBox::Close);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
601 dlg.exec();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
602
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
603 if (dlg.clickedButton() == saveAsBtn)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
604 return save (doc, true); // yay recursion!
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
605
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
606 return false;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
607 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
608
1159
6ad8cdcd88d9 print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents: 1157
diff changeset
609 void MainWindow::addMessage(QString message)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
610 {
1159
6ad8cdcd88d9 print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents: 1157
diff changeset
611 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
612
6ad8cdcd88d9 print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents: 1157
diff changeset
613 // 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
614 fprint(stdout, "%1\n", message);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
615 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
616
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
617 /*
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
618 * 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
619 */
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
620 QPixmap MainWindow::getIcon(QString iconName)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
621 {
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
622 return {format(":/icons/%1.png", iconName)};
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
623 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
624
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
625 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
626 {
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
627 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
628 }
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
629
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
630 // ---------------------------------------------------------------------------------------------------------------------
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
631 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
632 void MainWindow::updateDocumentList()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
633 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
634 m_updatingTabs = true;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
635
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
636 while (m_tabs->count() > 0)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
637 m_tabs->removeTab (0);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
638
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
639 for (LDDocument* document : m_documents->allDocuments())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
640 {
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
641 if (not document->isFrozen())
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
642 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
643 // 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
644 // 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
645 document->setTabIndex (m_tabs->addTab (""));
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
646 updateDocumentListItem (document);
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
647 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
648 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
649
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
650 m_updatingTabs = false;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
651 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
652
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
653 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
654 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
655 // 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
656 //
945
c310073e4f22 More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents: 944
diff changeset
657 void MainWindow::updateDocumentListItem (LDDocument* doc)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
658 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
659 bool oldUpdatingTabs = m_updatingTabs;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
660 m_updatingTabs = true;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
661
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
662 if (doc->tabIndex() == -1)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
663 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
664 // 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
665 // exist yet or is out of date. Build the list now.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
666 updateDocumentList();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
667 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
668 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
669
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
670 // 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
671 // the list.
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
672 if (doc == m_currentDocument)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
673 m_tabs->setCurrentIndex (doc->tabIndex());
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 m_tabs->setTabText (doc->tabIndex(), doc->getDisplayName());
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
676
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
677 // 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
678 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
679 m_tabs->setTabData (doc->tabIndex(), doc->name());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
680 m_updatingTabs = oldUpdatingTabs;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
681 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
682
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
683 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
684 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
685 // 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
686 // which file was picked and change to it.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
687 //
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
688 void MainWindow::tabSelected()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
689 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
690 if (m_updatingTabs)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
691 return;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
692
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
693 LDDocument* switchee = nullptr;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
694 int tabIndex = m_tabs->currentIndex();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
695
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
696 // Find the file pointer of the item that was selected.
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
697 for (LDDocument* document : m_documents->allDocuments())
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
698 {
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
699 if (not document->isFrozen() and document->tabIndex() == tabIndex)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
700 {
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
701 switchee = document;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
702 break;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
703 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
704 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
705
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
706 if (switchee and switchee != m_currentDocument)
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
707 changeDocument (switchee);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
708 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
709
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
710 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
711 //
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
712 // 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
713 // on configuration, etc.
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
714 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
715 void MainWindow::updateActions()
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
716 {
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
717 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
718 {
983
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
719 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
720 int pos = his->position();
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
721 ui.actionUndo->setEnabled (pos != -1);
983
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
722 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
723 }
efe34366e56a - added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents: 808
diff changeset
724
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
725 ui.actionWireframe->setChecked (m_config.drawWireframe());
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
726 ui.actionAxes->setChecked (m_config.drawAxes());
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
727 ui.actionBfcView->setChecked (m_config.bfcRedGreenView());
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
728 ui.actionRandomColors->setChecked (m_config.randomColors());
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
729 ui.actionDrawAngles->setChecked (m_config.drawAngles());
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
730 ui.actionDrawSurfaces->setChecked (m_config.drawSurfaces());
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
731 ui.actionDrawEdgeLines->setChecked (m_config.drawEdgeLines());
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
732 ui.actionDrawConditionalLines->setChecked (m_config.drawConditionalLines());
1119
749fdf61b5cd Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents: 1117
diff changeset
733 ui.actionLighting->setChecked(m_config.lighting());
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
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
736 // ---------------------------------------------------------------------------------------------------------------------
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
737 //
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
738 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
739 {
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
740 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
741 }
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
742
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
743 // ---------------------------------------------------------------------------------------------------------------------
49358df9495b Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1017
diff changeset
744 //
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
745 Canvas* MainWindow::renderer()
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
746 {
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
747 return static_cast<Canvas*>(ui.rendererStack->currentWidget());
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
748 }
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
749
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
750 // ---------------------------------------------------------------------------------------------------------------------
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
751 //
1043
0091a761daf2 Refactor GuiUtilities
Teemu Piippo <teemu@hecknology.net>
parents: 1034
diff changeset
752 void MainWindow::setQuickColors (const QVector<ColorToolbarItem>& colors)
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
753 {
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
754 m_quickColors = colors;
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
755 updateColorToolbar();
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
756 }
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
757
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
758 // ---------------------------------------------------------------------------------------------------------------------
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
759 //
798
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
760 void MainWindow::closeTab (int tabindex)
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
761 {
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
762 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
763
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
764 if (doc)
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
765 doc->close();
798
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
766 }
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
767
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
768 // ---------------------------------------------------------------------------------------------------------------------
798
88d4973cfe1a - added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 795
diff changeset
769 //
983
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
770 void MainWindow::historyTraversed()
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
771 {
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
772 updateActions();
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
773 refresh();
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
774 }
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
775
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
776 // ---------------------------------------------------------------------------------------------------------------------
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
777 //
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
778 void MainWindow::loadShortcuts()
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
779 {
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
780 for (QAction* act : findChildren<QAction*>())
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
781 {
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
782 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
783 act->setShortcut (seq);
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
784 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
785 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
786
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
787 // ---------------------------------------------------------------------------------------------------------------------
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
788 //
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
789 void MainWindow::saveShortcuts()
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
790 {
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
791 applyToActions ([&](QAction* act)
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
792 {
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
793 QString const key = "shortcut_" + act->objectName();
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
794
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
795 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
796 m_settings->setValue (key, act->shortcut());
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
797 else
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
798 m_settings->remove (key);
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
799 });
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
800 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
801
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
802 // ---------------------------------------------------------------------------------------------------------------------
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
803 //
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
804 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
805 {
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
806 for (QAction* act : findChildren<QAction*>())
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
807 {
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
808 if (not act->objectName().isEmpty())
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
809 function (act);
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
810 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
811 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
812
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
813 // ---------------------------------------------------------------------------------------------------------------------
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
814 //
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 988
diff changeset
815 QKeySequence MainWindow::defaultShortcut (QAction* act)
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
816 {
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
817 return m_defaultShortcuts[act];
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
818 }
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
819
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
820 // ---------------------------------------------------------------------------------------------------------------------
806
4240f47aa2d4 - moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 798
diff changeset
821 //
865
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
822 bool MainWindow::ringToolHiRes() const
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
823 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
824 return ui.ringToolHiRes->isChecked();
865
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
825 }
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
826
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
827 // ---------------------------------------------------------------------------------------------------------------------
865
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
828 //
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
829 int MainWindow::ringToolSegments() const
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
830 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
831 return ui.ringToolSegments->value();
865
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
832 }
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
833
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
834 // ---------------------------------------------------------------------------------------------------------------------
865
6d68840fcb26 - circle mode can now do hi-res
Teemu Piippo <crimsondusk64@gmail.com>
parents: 861
diff changeset
835 //
866
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
836 void MainWindow::ringToolHiResClicked (bool checked)
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
837 {
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
838 if (checked)
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
839 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
840 ui.ringToolSegments->setMaximum (HighResolution);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
841 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
842 }
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
843 else
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
844 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
845 ui.ringToolSegments->setValue (ui.ringToolSegments->value() / 3);
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
846 ui.ringToolSegments->setMaximum (LowResolution);
866
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
847 }
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
848 }
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
849
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
850 // ---------------------------------------------------------------------------------------------------------------------
871
a860edb4210b - display a label next to the spinbox showing the fraction
Teemu Piippo <crimsondusk64@gmail.com>
parents: 869
diff changeset
851 //
a860edb4210b - display a label next to the spinbox showing the fraction
Teemu Piippo <crimsondusk64@gmail.com>
parents: 869
diff changeset
852 void MainWindow::circleToolSegmentsChanged()
a860edb4210b - display a label next to the spinbox showing the fraction
Teemu Piippo <crimsondusk64@gmail.com>
parents: 869
diff changeset
853 {
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
854 int numerator (ui.ringToolSegments->value());
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
855 int denominator (ui.ringToolHiRes->isChecked() ? HighResolution : LowResolution);
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1012
diff changeset
856 simplify (numerator, denominator);
965
d1b0aa40db91 MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents: 963
diff changeset
857 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
858 }
866
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
859
1157
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
860 /*
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
861 * 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
862 */
1d6d244bdabd Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents: 1156
diff changeset
863 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
864 {
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
865 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
866 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
867 }
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
868
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
869 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
870 //
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
871 void MainWindow::syncSettings()
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
872 {
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
873 m_settings->sync();
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
874 }
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
875
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
876 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
877 //
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
878 QVariant MainWindow::getConfigValue (QString name)
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
879 {
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
880 QVariant value = m_settings->value (name, m_config.defaultValueByName (name));
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
881 return value;
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
882 }
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
883
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
884 // ---------------------------------------------------------------------------------------------------------------------
866
4951b737f8cb - now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents: 865
diff changeset
885 //
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
886 void MainWindow::createBlankDocument()
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
887 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
888 // 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
889 LDDocument* f = newDocument();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
890 f->setName ("");
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
891 changeDocument (f);
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
892 closeInitialDocument();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
893 doFullRefresh();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
894 updateActions();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
895 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
896
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
897 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
898 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
899 LDDocument* MainWindow::newDocument (bool cache)
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
900 {
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
901 LDDocument* document = m_documents->createNew();
983
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
902 connect (document->history(), SIGNAL (undone()), this, SLOT (historyTraversed()));
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
903 connect (document->history(), SIGNAL (redone()), this, SLOT (historyTraversed()));
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
904 connect (document->history(), SIGNAL (stepAdded()), this, SLOT (updateActions()));
979
880d3fe9ac7c Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
905
880d3fe9ac7c Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
906 if (not cache)
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
907 openDocumentForEditing(document);
979
880d3fe9ac7c Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
908
983
05ba93066194 Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents: 981
diff changeset
909 return document;
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
910 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
911
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
912 void MainWindow::openDocumentForEditing(LDDocument* document)
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
913 {
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
914 if (document->isFrozen())
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
915 {
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
916 document->setFrozen(false);
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
917 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
918 getRendererForDocument(document);
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
919 updateDocumentList();
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
920 }
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
921 }
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
922
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
923 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
924 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
925 LDDocument* MainWindow::currentDocument()
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
926 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
927 return m_currentDocument;
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
928 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
929
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
930 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
931 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
932 // 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
933 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
934 void MainWindow::changeDocument (LDDocument* document)
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
935 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
936 // 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
937 if (document and document->isFrozen())
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
938 return;
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
939
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
940 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
941 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
942 ui.rendererStack->setCurrentWidget(renderer);
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
943
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
944 if (document)
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
945 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
946 // 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
947 updateDocumentListItem (document);
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
948 updateTitle();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
949 print ("Changed document to %1", document->getDisplayName());
1240
cebb7ef54f41 changed Model into an MVC list model and replaced the objects list with a view into the model
Santeri Piippo
parents: 1236
diff changeset
950 ui.objectList->setModel(document);
1291
9c570a30c98a Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents: 1283
diff changeset
951 ui.header->setHeader(&document->header);
1246
0054d13ed614 used mvc selection models
Santeri Piippo
parents: 1244
diff changeset
952 QItemSelectionModel* selection = m_selections.value(document);
0054d13ed614 used mvc selection models
Santeri Piippo
parents: 1244
diff changeset
953
0054d13ed614 used mvc selection models
Santeri Piippo
parents: 1244
diff changeset
954 if (selection == nullptr)
0054d13ed614 used mvc selection models
Santeri Piippo
parents: 1244
diff changeset
955 {
0054d13ed614 used mvc selection models
Santeri Piippo
parents: 1244
diff changeset
956 m_selections[document] = ui.objectList->selectionModel();
0054d13ed614 used mvc selection models
Santeri Piippo
parents: 1244
diff changeset
957 renderer->setSelectionModel(m_selections[document]);
0054d13ed614 used mvc selection models
Santeri Piippo
parents: 1244
diff changeset
958 }
0054d13ed614 used mvc selection models
Santeri Piippo
parents: 1244
diff changeset
959 else
0054d13ed614 used mvc selection models
Santeri Piippo
parents: 1244
diff changeset
960 {
0054d13ed614 used mvc selection models
Santeri Piippo
parents: 1244
diff changeset
961 ui.objectList->setSelectionModel(selection);
0054d13ed614 used mvc selection models
Santeri Piippo
parents: 1244
diff changeset
962 }
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
963 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
964 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
965
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
966 /*
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
967 * 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
968 */
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
969 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
970 {
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
971 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
972
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
973 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
974 {
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
975 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
976 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
977 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
978 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
979 }
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
980
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
981 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
982 }
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
983
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
984 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
985 {
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
986 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
987 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
988
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
989 // 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
990 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
991 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
992
1103
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents: 1098
diff changeset
993 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
994
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
995 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
996 {
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
997 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
998 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
999 }
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
1000
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
1001 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
1002 }
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
1003
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1004 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1005 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1006 // 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
1007 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1008 void MainWindow::closeInitialDocument()
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1009 {
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
1010 /*
1063
1f15c52c11f6 Replaced uses of 'x.size()' with 'length(x)'
Teemu Piippo <teemu@hecknology.net>
parents: 1045
diff changeset
1011 if (length(m_documents) == 2 and
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1012 m_documents[0]->name().isEmpty() and
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1013 not m_documents[1]->name().isEmpty() and
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1014 not m_documents[0]->hasUnsavedChanges())
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1015 {
979
880d3fe9ac7c Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
1016 m_documents.first()->close();
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1017 }
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
1018 */
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1019 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1020
1250
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1021 QModelIndexList MainWindow::selectedIndexes() const
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1022 {
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1023 return this->ui.objectList->selectionModel()->selectedIndexes();
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1024 }
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1025
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1026 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1027 //
1250
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1028 QSet<LDObject*> MainWindow::selectedObjects() const
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1029 {
1250
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1030 QSet<LDObject*> result;
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1031
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1032 for (const QModelIndex& index : this->selectedIndexes())
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1033 result.insert(m_currentDocument->lookup(index));
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1034
e2755ccf3667 more work on mvc
Santeri Piippo
parents: 1249
diff changeset
1035 return result;
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1036 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1037
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1038 // ---------------------------------------------------------------------------------------------------------------------
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1039 //
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1040 void MainWindow::currentDocumentClosed()
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 LDDocument* old = currentDocument();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1043
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1044 // Find a replacement document to use
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
1045 for (LDDocument* doc : m_documents->allDocuments())
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1046 {
1090
ed73c4f48ca4 The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents: 1086
diff changeset
1047 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
1048 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1049 changeDocument (doc);
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1050 break;
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1051 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1052 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1053
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1054 if (currentDocument() == old)
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1055 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1056 // 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
1057 createBlankDocument();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 975
diff changeset
1058 }
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
981
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1061 ExtProgramToolset* MainWindow::externalPrograms()
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1062 {
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1063 return m_externalPrograms;
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1064 }
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1065
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1066 GuiUtilities* MainWindow::guiUtilities()
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1067 {
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1068 return m_guiUtilities;
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1069 }
5d5d84ab2c48 Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 979
diff changeset
1070
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
1071 Configuration* MainWindow::config()
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
1072 {
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
1073 return &m_config;
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
1074 }
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1016
diff changeset
1075
1023
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1018
diff changeset
1076 Grid* MainWindow::grid()
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1018
diff changeset
1077 {
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1018
diff changeset
1078 return m_grid;
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1018
diff changeset
1079 }
9450ac3cd930 Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1018
diff changeset
1080
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
1081 MathFunctions* MainWindow::mathFunctions() const
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
1082 {
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
1083 return m_mathFunctions;
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
1084 }
67ba0ee049eb Moved rotation point handling to ldObjectMath.cpp and encapsulated it into new class MathFunctions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1023
diff changeset
1085
1256
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1252
diff changeset
1086 void MainWindow::clearSelection()
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1252
diff changeset
1087 {
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1252
diff changeset
1088 m_selections[m_currentDocument]->clear();
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1252
diff changeset
1089 }
3fea6bc1519b removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents: 1252
diff changeset
1090
1257
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1091 void MainWindow::select(const QModelIndex &objectIndex)
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1092 {
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1093 if (objectIndex.isValid() and objectIndex.model() == m_currentDocument)
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1094 m_selections[m_currentDocument]->select(objectIndex, QItemSelectionModel::Select);
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1095 }
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1096
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1097 QItemSelectionModel* MainWindow::currentSelectionModel()
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1098 {
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1099 return m_selections[m_currentDocument];
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1100 }
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1101
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1102 void MainWindow::replaceSelection(const QItemSelection& selection)
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1103 {
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1104 m_selections[m_currentDocument]->select(selection, QItemSelectionModel::ClearAndSelect);
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1105 }
0d42a1ebd954 more selection rework
Santeri Piippo
parents: 1256
diff changeset
1106
978
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 //
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
1109 ColorToolbarItem::ColorToolbarItem (LDColor color, QToolButton* toolButton) :
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1110 m_color (color),
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1111 m_toolButton (toolButton) {}
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1112
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
1113 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
1114 {
1114
ffd49a28f49e Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents: 1113
diff changeset
1115 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
1116 }
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
1117
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
1118 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
1119 {
1114
ffd49a28f49e Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents: 1113
diff changeset
1120 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
1121 }
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
1122
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
1123 LDColor ColorToolbarItem::color() const
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1124 {
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
1125 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
1126 }
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
1127
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
1128 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
1129 {
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
1130 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
1131 }
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
1132
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
1133 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
1134 {
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
1135 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
1136 }
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
1137
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
1138 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
1139 {
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
1140 m_toolButton = value;
1043
0091a761daf2 Refactor GuiUtilities
Teemu Piippo <teemu@hecknology.net>
parents: 1034
diff changeset
1141 }

mercurial