Thu, 07 Feb 2019 13:45:07 +0200
stuff
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 |
1326 | 3 | * Copyright (C) 2013 - 2018 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 | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
19 | #include <QMdiArea> |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
20 | #include <QMdiSubWindow> |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include <QMessageBox> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include <QContextMenuEvent> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QToolButton> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include <QFileDialog> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include <QPushButton> |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
26 | #include <QSettings> |
1249 | 27 | #include "generics/reverse.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | #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
|
29 | #include "canvas.h" |
962
a4b463a7ee82
Rename MainWindow files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
959
diff
changeset
|
30 | #include "mainwindow.h" |
1145
02264bf0108d
Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
31 | #include "lddocument.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" |
1318
568fcfc6da71
removed unnecessary files and includes
Teemu Piippo <teemu@hecknology.net>
parents:
1306
diff
changeset
|
43 | #include "editHistory.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 | // |
1322
d8935cdb24c0
renamed sink() to singleton()
Teemu Piippo <teemu@hecknology.net>
parents:
1319
diff
changeset
|
53 | MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) : |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
54 | QMainWindow (parent, flags), |
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
|
55 | 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
|
56 | m_grid(new Grid(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
|
57 | ui (*new Ui_MainWindow), |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
58 | m_externalPrograms (nullptr), |
997
1b49f34e533d
Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
988
diff
changeset
|
59 | 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
|
60 | m_currentDocument (nullptr) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | { |
1380
bc799b965418
added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents:
1379
diff
changeset
|
62 | connect( |
bc799b965418
added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents:
1379
diff
changeset
|
63 | &singleton<Printer>(), |
bc799b965418
added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents:
1379
diff
changeset
|
64 | &Printer::linePrinted, |
bc799b965418
added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents:
1379
diff
changeset
|
65 | [&](const QString& line) |
bc799b965418
added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents:
1379
diff
changeset
|
66 | { |
bc799b965418
added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents:
1379
diff
changeset
|
67 | this->statusBar()->showMessage(line, 5000); |
bc799b965418
added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents:
1379
diff
changeset
|
68 | } |
bc799b965418
added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents:
1379
diff
changeset
|
69 | ); |
bc799b965418
added a status bar and moved printed messages there
Teemu Piippo <teemu@hecknology.net>
parents:
1379
diff
changeset
|
70 | |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
71 | ui.setupUi (this); |
1335
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
72 | this->restoreGeometry(config::mainWindowGeometry()); |
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
73 | this->restoreState(config::mainWindowState()); |
1349
45d8eec8bd52
The border between the canvas and left tool box is now resizable
Teemu Piippo <teemu@hecknology.net>
parents:
1339
diff
changeset
|
74 | |
45d8eec8bd52
The border between the canvas and left tool box is now resizable
Teemu Piippo <teemu@hecknology.net>
parents:
1339
diff
changeset
|
75 | if (config::mainSplitterState().isEmpty()) |
45d8eec8bd52
The border between the canvas and left tool box is now resizable
Teemu Piippo <teemu@hecknology.net>
parents:
1339
diff
changeset
|
76 | this->ui.splitter->setSizes({this->width() * 2 / 3, this->width() / 3}); |
45d8eec8bd52
The border between the canvas and left tool box is now resizable
Teemu Piippo <teemu@hecknology.net>
parents:
1339
diff
changeset
|
77 | else |
45d8eec8bd52
The border between the canvas and left tool box is now resizable
Teemu Piippo <teemu@hecknology.net>
parents:
1339
diff
changeset
|
78 | this->ui.splitter->restoreState(config::mainSplitterState()); |
45d8eec8bd52
The border between the canvas and left tool box is now resizable
Teemu Piippo <teemu@hecknology.net>
parents:
1339
diff
changeset
|
79 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | m_updatingTabs = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | m_tabs = new QTabBar; |
798
88d4973cfe1a
- added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
82 | m_tabs->setTabsClosable (true); |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
83 | 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
|
84 | 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
|
85 | createBlankDocument(); |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
86 | getRendererForDocument(m_currentDocument); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
88 | 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
|
89 | connect (m_tabs, SIGNAL (tabCloseRequested (int)), this, SLOT (closeTab (int))); |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
90 | connect(m_documents, &DocumentManager::documentCreated, this, &MainWindow::newDocument); |
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
|
91 | connect(m_documents, SIGNAL(documentClosed(LDDocument*)), this, SLOT(documentClosed(LDDocument*))); |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
92 | connect(m_documents, &DocumentManager::mainModelLoaded, this, &MainWindow::mainModelLoaded); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
93 | connect(ui.viewport, &QMdiArea::subWindowActivated, this, &MainWindow::canvasActivated); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | |
815
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
808
diff
changeset
|
95 | updateActions(); |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
96 | |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
97 | // Connect all actions and save default sequences |
1353 | 98 | applyToActions([&](QAction* action) |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
99 | { |
1353 | 100 | connect(action, SIGNAL (triggered()), this, SLOT (actionTriggered())); |
101 | m_defaultShortcuts[action] = action->shortcut(); | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
102 | }); |
1291
9c570a30c98a
Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents:
1283
diff
changeset
|
103 | connect( |
9c570a30c98a
Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents:
1283
diff
changeset
|
104 | ui.header, |
9c570a30c98a
Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents:
1283
diff
changeset
|
105 | &HeaderEdit::descriptionChanged, |
9c570a30c98a
Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents:
1283
diff
changeset
|
106 | this, |
9c570a30c98a
Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents:
1283
diff
changeset
|
107 | &MainWindow::updateTitle |
9c570a30c98a
Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents:
1283
diff
changeset
|
108 | ); |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
109 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | updateGridToolBar(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | updateEditModeActions(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | updateRecentFilesMenu(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | updateColorToolbar(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | updateTitle(); |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
115 | loadShortcuts(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | setMinimumSize (300, 200); |
1417
ed39bfca7a67
refactored the segments/divisions editor in MainWindow to a new widget
Teemu Piippo <teemu@hecknology.net>
parents:
1390
diff
changeset
|
117 | connect(ui.circleToolSection, &CircularSectionEditor::sectionChanged, [&](){this->renderer()->update();}); |
896
4988666b5e3c
- now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents:
893
diff
changeset
|
118 | |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
119 | // 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
|
120 | m_toolsets = Toolset::createToolsets (this); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
121 | |
1154
a426a335e586
Some cleanup in mainwindow.cpp, use QSet<QString> for the 'ignore' variable.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
122 | QSet<QString> ignore; |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
123 | 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
|
124 | { |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
125 | 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
|
126 | 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
|
127 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
128 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
129 | for (Toolset* toolset : m_toolsets) |
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 | const QMetaObject* meta = toolset->metaObject(); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
132 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
133 | if (qobject_cast<ExtProgramToolset*> (toolset)) |
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
134 | 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
|
135 | |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
136 | 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
|
137 | { |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
138 | ToolInfo info; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
139 | info.method = meta->method (i); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
140 | info.object = toolset; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
141 | 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
|
142 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
143 | if (ignore.contains (methodName)) |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
144 | 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
|
145 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
146 | 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
|
147 | QAction* action = findChild<QAction*> (actionName); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
148 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
149 | if (action == nullptr) |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
150 | 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
|
151 | else |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
152 | m_toolmap[action] = info; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
153 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
154 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
155 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
156 | // 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
|
157 | // them to the profile tab, it's the most important form to fill in. |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
158 | if (config::firstStart()) |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
159 | { |
972
a34b73114823
Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
160 | ConfigDialog* dialog = new ConfigDialog (this, ConfigDialog::ProfileTab); |
a34b73114823
Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
161 | dialog->show(); |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
162 | config::setFirstStart (false); |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
163 | } |
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
|
164 | |
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 | QMetaObject::invokeMethod (this, "finishInitialization", Qt::QueuedConnection); |
1373
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
166 | |
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
167 | connect( |
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
168 | this->ui.objectList, |
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
169 | &QListView::doubleClicked, |
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
170 | [&](const QModelIndex& index) |
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
171 | { |
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
172 | LDObject* object = currentDocument()->lookup(index); |
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
173 | |
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
174 | if (object) |
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
175 | ::editObject(this, object); |
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
176 | } |
e1380c0d4326
readded object editing by double click in list view
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
177 | ); |
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
|
178 | } |
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
179 | |
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
180 | 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
|
181 | { |
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
182 | m_primitives->loadPrimitives(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | |
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
|
185 | 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
|
186 | { |
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
|
187 | 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
|
188 | 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
|
189 | 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
|
190 | |
1438 | 191 | for (QItemSelectionModel* model : m_selectionModels) |
192 | delete model; | |
193 | ||
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
|
194 | 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
|
195 | 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
|
196 | } |
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
852
diff
changeset
|
197 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
198 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | // |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
200 | void MainWindow::actionTriggered() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
201 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | // 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
|
203 | // 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
|
204 | QAction* action = qobject_cast<QAction*> (sender()); |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
205 | |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
206 | if (action) |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
207 | { |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
208 | if (m_toolmap.contains (action)) |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
209 | { |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
210 | const ToolInfo& info = m_toolmap[action]; |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
211 | 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
|
212 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
213 | else |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
214 | 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
|
215 | } |
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
216 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | endAction(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
219 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
220 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | void MainWindow::endAction() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
224 | m_currentDocument->addHistoryStep(); |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
225 | 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
|
226 | refresh(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
229 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
231 | void MainWindow::updateRecentFilesMenu() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
232 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | // 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
|
234 | for (QAction* recent : m_recentFiles) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | delete recent; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | m_recentFiles.clear(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
238 | |
984 | 239 | QAction* first = nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
241 | for (const QVariant& it : config::recentFiles()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
242 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
243 | 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
|
244 | QAction* recent = new QAction (getIcon ("open-recent"), file, this); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
245 | connect (recent, SIGNAL (triggered()), this, SLOT (recentFileClicked())); |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
246 | ui.menuOpenRecent->insertAction (first, recent); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
247 | m_recentFiles << recent; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | first = recent; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
252 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | void MainWindow::updateColorToolbar() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
256 | m_colorButtons.clear(); |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
257 | ui.toolBarColors->clear(); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
258 | ui.toolBarColors->addAction (ui.actionUncolor); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
259 | ui.toolBarColors->addSeparator(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
260 | |
1432
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
261 | for (LDColor entry : config::quickColorToolbar()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | { |
1432
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
263 | if (entry == LDColor::nullColor) |
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
|
264 | { |
1432
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
265 | // Null color is used as a separator |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
266 | 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
|
267 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | { |
1382
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
270 | QToolButton* colorButton = new QToolButton {this}; |
1432
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
271 | colorButton->setIcon(makeColorIcon(entry, 16)); |
1382
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
272 | colorButton->setIconSize({16, 16}); |
1432
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
273 | colorButton->setToolTip(entry.name()); |
1382
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
274 | colorButton->setStatusTip(format( |
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
275 | tr("Changes the color of selected objects to %1"), |
1432
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
276 | entry.name() |
1382
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
277 | )); |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
278 | ui.toolBarColors->addWidget (colorButton); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
279 | m_colorButtons << colorButton; |
1382
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
280 | connect(colorButton, |
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
281 | &QToolButton::clicked, |
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
282 | [&]() |
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
283 | { |
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
284 | for (LDObject* object : selectedObjects()) |
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
285 | { |
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
286 | if (object->isColored()) |
1432
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
287 | object->setColor(entry); |
1382
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
288 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
289 | |
1382
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
290 | endAction(); |
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
291 | } |
6f31a87006f2
refactored the quick color toolbar
Teemu Piippo <teemu@hecknology.net>
parents:
1381
diff
changeset
|
292 | ); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
293 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
296 | updateGridToolBar(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
297 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
299 | // --------------------------------------------------------------------------------------------------------------------- |
655
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 | void MainWindow::updateGridToolBar() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
302 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
303 | // Ensure that the current grid - and only the current grid - is selected. |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
304 | int grid = config::grid(); |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
305 | 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
|
306 | 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
|
307 | ui.actionGridFine->setChecked (grid == Grid::Fine); |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1162
diff
changeset
|
308 | 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
|
309 | emit gridChanged(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
312 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
313 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
314 | void MainWindow::updateTitle() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
315 | { |
1291
9c570a30c98a
Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents:
1283
diff
changeset
|
316 | QString title = APPNAME " " VERSION_STRING; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
317 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
318 | // 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
|
319 | if (m_currentDocument) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
320 | { |
744
bbe0e1834065
- removed rest of the uses of <anonymous>
Santeri Piippo <crimsondusk64@gmail.com>
parents:
739
diff
changeset
|
321 | title += ": "; |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
322 | title += m_currentDocument->getDisplayName(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
323 | |
1291
9c570a30c98a
Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents:
1283
diff
changeset
|
324 | if (not m_currentDocument->header.description.isEmpty()) |
9c570a30c98a
Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents:
1283
diff
changeset
|
325 | title += format (": %1", m_currentDocument->header.description); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
326 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
327 | if (m_currentDocument->hasUnsavedChanges()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
328 | title += '*'; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
329 | } |
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 | #ifdef DEBUG |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
332 | title += " [debug build]"; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | #elif BUILD_ID != BUILD_RELEASE |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | title += " [pre-release build]"; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | #endif // DEBUG |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
336 | |
948
3a91828475fd
Replaced updaterevision with a python script, more renames, clang fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
337 | if (strlen (commitTimeString())) |
3a91828475fd
Replaced updaterevision with a python script, more renames, clang fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
338 | title += format (" (%1)", QString::fromUtf8 (commitTimeString())); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
339 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
340 | setWindowTitle (title); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
341 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
342 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
343 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
345 | int MainWindow::deleteSelection() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
346 | { |
1249 | 347 | int count = 0; |
348 | QModelIndexList thingsToRemove = ui.objectList->selectionModel()->selectedIndexes(); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | |
1249 | 350 | for (QModelIndex index : reverse(thingsToRemove)) |
351 | { | |
352 | if (m_currentDocument->hasIndex(index.row(), index.column())) | |
353 | { | |
354 | m_currentDocument->removeAt(index); | |
355 | count += 1; | |
356 | } | |
357 | } | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
358 | |
1249 | 359 | return count; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
360 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
361 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
362 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
363 | // |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
364 | void MainWindow::recentFileClicked() |
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 | QAction* qAct = static_cast<QAction*> (sender()); |
998 | 367 | documents()->openMainModel (qAct->text()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
368 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
369 | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
370 | /* |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
371 | * This slot function is called when a subwindow of the MDI area is selected. |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
372 | */ |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
373 | void MainWindow::canvasActivated(QMdiSubWindow* window) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
374 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
375 | if (window != nullptr) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
376 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
377 | Q_ASSERT(window->mdiArea() == ui.viewport); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
378 | Canvas* const canvas = static_cast<Canvas*>(window->widget()); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
379 | LDDocument* const document = canvas->document(); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
380 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
381 | // Move the canvas to the top of its stack. |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
382 | m_renderers[document].removeOne(canvas); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
383 | m_renderers[document].append(canvas); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
384 | } |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
385 | } |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
386 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
387 | void MainWindow::mainModelLoaded(LDDocument* document) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
388 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
389 | openDocumentForEditing(document); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
390 | changeDocument(document); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
391 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
392 | for (Canvas* canvas : m_renderers[document]) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
393 | canvas->fullUpdate(); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
394 | } |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
395 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
396 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
397 | // |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
398 | // Returns the suggested position to place a new object at. |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
399 | // |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
400 | int MainWindow::suggestInsertPoint() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
401 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
402 | // 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
|
403 | // TODO: fix this properly! |
1258 | 404 | if (not selectedIndexes().isEmpty()) |
405 | return (*(selectedIndexes().end() - 1)).row() + 1; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
406 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
407 | // 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
|
408 | return m_currentDocument->size(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
409 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
410 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
411 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
412 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
413 | void MainWindow::doFullRefresh() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
414 | { |
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
|
415 | renderer()->update(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
416 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
417 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
418 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
419 | // |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
420 | // Updates all GL renderers. |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
421 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
422 | void MainWindow::refresh() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
423 | { |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
424 | auto iterator = createIterator(m_renderers); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
425 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
426 | while (iterator.hasNext()) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
427 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
428 | for (Canvas* canvas : iterator.next().value()) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
429 | canvas->update(); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
430 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
431 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
432 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
433 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
434 | // |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
435 | // 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
|
436 | // |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
437 | LDColor MainWindow::getUniformSelectedColor() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
438 | { |
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
|
439 | LDColor result; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
440 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
441 | for (LDObject* obj : selectedObjects()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
442 | { |
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
|
443 | if (not obj->isColored()) |
946 | 444 | 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
|
445 | |
946 | 446 | 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
|
447 | return LDColor::nullColor; // No consensus in object color |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
448 | |
946 | 449 | if (not result.isValid()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
450 | result = obj->color(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
451 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
452 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
453 | return result; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
454 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
455 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
456 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
457 | // |
1335
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
458 | void MainWindow::closeEvent(QCloseEvent* event) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
459 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
460 | // Check whether it's safe to close all files. |
1335
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
461 | if (m_documents->isSafeToCloseAll()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
462 | { |
1335
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
463 | // Store the state of the main window before closing. |
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
464 | config::setMainWindowGeometry(this->saveGeometry()); |
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
465 | config::setMainWindowState(this->saveState()); |
1349
45d8eec8bd52
The border between the canvas and left tool box is now resizable
Teemu Piippo <teemu@hecknology.net>
parents:
1339
diff
changeset
|
466 | config::setMainSplitterState(this->ui.splitter->saveState()); |
1335
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
467 | settingsObject().sync(); |
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
468 | event->accept(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
469 | } |
1335
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
470 | else |
896
4988666b5e3c
- now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents:
893
diff
changeset
|
471 | { |
1335
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
472 | event->ignore(); |
896
4988666b5e3c
- now remembers what toolbars are enabled and what are disabled in config
Teemu Piippo <crimsondusk64@gmail.com>
parents:
893
diff
changeset
|
473 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
474 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
475 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
476 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
477 | // |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1025
diff
changeset
|
478 | void MainWindow::spawnContextMenu (const QPoint& position) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
479 | { |
1065
c8ecddbd99e9
Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
480 | 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
|
481 | LDObject* singleObj = single ? *selectedObjects().begin() : nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
482 | |
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
|
483 | 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
|
484 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
485 | 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
|
486 | { |
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
|
487 | 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
|
488 | { |
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
|
489 | 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
|
490 | 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
|
491 | } |
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 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
494 | QMenu* contextMenu = new QMenu; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
495 | |
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
|
496 | if (single and singleObj->type() != LDObjectType::Empty) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
497 | { |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
498 | contextMenu->addAction (ui.actionEdit); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
499 | contextMenu->addSeparator(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
500 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
501 | |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
502 | contextMenu->addAction (ui.actionCut); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
503 | contextMenu->addAction (ui.actionCopy); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
504 | contextMenu->addAction (ui.actionPaste); |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
505 | contextMenu->addAction (ui.actionRemove); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
506 | contextMenu->addSeparator(); |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
507 | contextMenu->addAction (ui.actionSetColor); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
508 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
509 | if (single) |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
510 | contextMenu->addAction (ui.actionEditRaw); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
511 | |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
512 | contextMenu->addAction (ui.actionMakeBorders); |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
513 | contextMenu->addAction (ui.actionSetOverlay); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
514 | 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
|
515 | |
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
|
516 | 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
|
517 | { |
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
|
518 | contextMenu->addSeparator(); |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
519 | 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
|
520 | } |
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
|
521 | |
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
|
522 | contextMenu->addSeparator(); |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
523 | contextMenu->addAction (ui.actionModeSelect); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
524 | contextMenu->addAction (ui.actionModeDraw); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
525 | contextMenu->addAction (ui.actionModeCircle); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
526 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
527 | if (not selectedObjects().isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
528 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
529 | contextMenu->addSeparator(); |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
530 | contextMenu->addAction (ui.actionSubfileSelection); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
531 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
532 | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
533 | if (not renderer()->currentCamera().isModelview()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
534 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
535 | contextMenu->addSeparator(); |
1390
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1382
diff
changeset
|
536 | contextMenu->addAction(ui.actionSetDrawPlane); |
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1382
diff
changeset
|
537 | contextMenu->addAction(ui.actionClearDrawPlane); |
1369
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1353
diff
changeset
|
538 | contextMenu->addAction(ui.actionSetCullDepth); |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1353
diff
changeset
|
539 | contextMenu->addAction(ui.actionClearCullDepth); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
540 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
541 | |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1025
diff
changeset
|
542 | contextMenu->exec(position); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
543 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
544 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
545 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
546 | // |
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
|
547 | void MainWindow::deleteByColor (LDColor color) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
548 | { |
1162
94e12806d741
Replaced LDObjectList with QVector<LDObject*>
Teemu Piippo <teemu@hecknology.net>
parents:
1160
diff
changeset
|
549 | QVector<LDObject*> unwanted; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
550 | |
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
|
551 | for (LDObject* object : m_currentDocument->objects()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
552 | { |
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
|
553 | if (not object->isColored() or object->color() != color) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
554 | continue; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
555 | |
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
|
556 | unwanted.append(object); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
557 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
558 | |
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
|
559 | 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
|
560 | m_currentDocument->remove(obj); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
561 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
562 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
563 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
564 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
565 | void MainWindow::updateEditModeActions() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
566 | { |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
567 | const EditModeType mode = renderer()->currentEditModeType(); |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
568 | ui.actionModeSelect->setChecked (mode == EditModeType::Select); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
569 | ui.actionModeDraw->setChecked (mode == EditModeType::Draw); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
570 | ui.actionModeRectangle->setChecked (mode == EditModeType::Rectangle); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
571 | ui.actionModeCircle->setChecked (mode == EditModeType::Circle); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
572 | ui.actionModeMagicWand->setChecked (mode == EditModeType::MagicWand); |
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
573 | 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
|
574 | ui.actionModeCurve->setChecked (mode == EditModeType::Curve); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
575 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
576 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
577 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
578 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
579 | bool MainWindow::save (LDDocument* doc, bool saveAs) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
580 | { |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
581 | if (doc->isFrozen()) |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
582 | return false; |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
583 | |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
584 | 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
|
585 | qint64 savesize; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
586 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
587 | if (saveAs or path.isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
588 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
589 | QString name = doc->defaultName(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
590 | |
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
|
591 | if (not doc->fullPath().isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
592 | name = doc->fullPath(); |
967 | 593 | else if (not doc->name().isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
594 | name = doc->name(); |
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 | name.replace ("\\", "/"); |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
597 | path = QFileDialog::getSaveFileName (this, tr ("Save As"), |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
598 | name, tr ("LDraw files (*.dat *.ldr)")); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
599 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
600 | if (path.isEmpty()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
601 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
602 | // User didn't give a file name, abort. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
603 | return false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
604 | } |
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 | |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
830
diff
changeset
|
607 | if (doc->save (path, &savesize)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
608 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
609 | if (doc == m_currentDocument) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
610 | updateTitle(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
611 | |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1012
diff
changeset
|
612 | print ("Saved to %1 (%2)", path, formatFileSize (savesize)); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
613 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
614 | // Add it to recent files |
998 | 615 | m_documents->addRecentFile (path); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
616 | return true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
617 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
618 | |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
619 | 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
|
620 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
621 | // 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
|
622 | 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
|
623 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
624 | // Add a save-as button |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
625 | 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
|
626 | saveAsBtn->setIcon (getIcon ("file-save-as")); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
627 | dlg.addButton (saveAsBtn, QMessageBox::ActionRole); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
628 | dlg.setDefaultButton (QMessageBox::Close); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
629 | dlg.exec(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
630 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
631 | if (dlg.clickedButton() == saveAsBtn) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
632 | return save (doc, true); // yay recursion! |
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 | return false; |
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 | |
1157
1d6d244bdabd
Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents:
1156
diff
changeset
|
637 | /* |
1d6d244bdabd
Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents:
1156
diff
changeset
|
638 | * 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
|
639 | */ |
1d6d244bdabd
Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents:
1156
diff
changeset
|
640 | QPixmap MainWindow::getIcon(QString iconName) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
641 | { |
1157
1d6d244bdabd
Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents:
1156
diff
changeset
|
642 | return {format(":/icons/%1.png", iconName)}; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
643 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
644 | |
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
|
645 | // --------------------------------------------------------------------------------------------------------------------- |
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
646 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
647 | void MainWindow::updateDocumentList() |
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 | m_updatingTabs = true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
650 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
651 | while (m_tabs->count() > 0) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
652 | m_tabs->removeTab (0); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
653 | |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
654 | for (auto& document : *m_documents) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
655 | { |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
656 | if (not document->isFrozen()) |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
657 | { |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
658 | // 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
|
659 | // 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
|
660 | document->setTabIndex (m_tabs->addTab ("")); |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
661 | updateDocumentListItem(document.get()); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
662 | } |
655
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 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
665 | m_updatingTabs = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
666 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
667 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
668 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
669 | // |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
670 | // 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
|
671 | // |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
672 | void MainWindow::updateDocumentListItem (LDDocument* doc) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
673 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
674 | bool oldUpdatingTabs = m_updatingTabs; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
675 | m_updatingTabs = true; |
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 (doc->tabIndex() == -1) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
678 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
679 | // 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
|
680 | // exist yet or is out of date. Build the list now. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
681 | updateDocumentList(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
682 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
683 | } |
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 | // 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
|
686 | // the list. |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
687 | if (doc == m_currentDocument) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
688 | m_tabs->setCurrentIndex (doc->tabIndex()); |
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 | m_tabs->setTabText (doc->tabIndex(), doc->getDisplayName()); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
691 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
692 | // 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
|
693 | 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
|
694 | m_tabs->setTabData (doc->tabIndex(), doc->name()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
695 | m_updatingTabs = oldUpdatingTabs; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
696 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
697 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
698 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
699 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
700 | // 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
|
701 | // which file was picked and change to it. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
702 | // |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
703 | void MainWindow::tabSelected() |
655
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 | if (m_updatingTabs) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
706 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
707 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
708 | LDDocument* switchee = nullptr; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
709 | int tabIndex = m_tabs->currentIndex(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
710 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
711 | // Find the file pointer of the item that was selected. |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
712 | for (auto& document : *m_documents) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
713 | { |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
714 | if (not document->isFrozen() and document->tabIndex() == tabIndex) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
715 | { |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
716 | switchee = document.get(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
717 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
718 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
719 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
720 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
721 | if (switchee and switchee != m_currentDocument) |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
722 | changeDocument (switchee); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
723 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
724 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
725 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
726 | // |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
727 | // 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
|
728 | // on configuration, etc. |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
729 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
730 | void MainWindow::updateActions() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
731 | { |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
732 | 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
|
733 | { |
983
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
734 | 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
|
735 | int pos = his->position(); |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
963
diff
changeset
|
736 | ui.actionUndo->setEnabled (pos != -1); |
983
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
737 | 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
|
738 | } |
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
808
diff
changeset
|
739 | |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
740 | ui.actionWireframe->setChecked (config::drawWireframe()); |
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
741 | ui.actionAxes->setChecked (config::drawAxes()); |
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
742 | ui.actionBfcView->setChecked (config::bfcRedGreenView()); |
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
743 | ui.actionRandomColors->setChecked (config::randomColors()); |
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
744 | ui.actionDrawAngles->setChecked (config::drawAngles()); |
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
745 | ui.actionDrawSurfaces->setChecked (config::drawSurfaces()); |
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
746 | ui.actionDrawEdgeLines->setChecked (config::drawEdgeLines()); |
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
747 | ui.actionDrawConditionalLines->setChecked (config::drawConditionalLines()); |
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
748 | ui.actionLighting->setChecked(config::lighting()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
749 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
750 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
751 | // --------------------------------------------------------------------------------------------------------------------- |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
752 | // |
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
|
753 | 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
|
754 | { |
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
755 | 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
|
756 | } |
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
757 | |
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
758 | // --------------------------------------------------------------------------------------------------------------------- |
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
759 | // |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
760 | Canvas* MainWindow::renderer() |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
761 | { |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
762 | QMdiSubWindow* const currentSubWindow = ui.viewport->currentSubWindow(); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
763 | Q_ASSERT(currentSubWindow != nullptr); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
764 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
765 | if (currentSubWindow != nullptr) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
766 | return static_cast<Canvas*>(currentSubWindow->widget()); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
767 | else |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
768 | return nullptr; |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
769 | } |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
770 | |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
771 | // --------------------------------------------------------------------------------------------------------------------- |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
772 | // |
798
88d4973cfe1a
- added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
773 | void MainWindow::closeTab (int tabindex) |
88d4973cfe1a
- added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
774 | { |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
775 | auto iterator = m_documents->findDocumentByName(m_tabs->tabData (tabindex).toString()); |
798
88d4973cfe1a
- added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
776 | |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
777 | if (iterator != m_documents->end()) |
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
778 | (*iterator)->close(); |
798
88d4973cfe1a
- added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
779 | } |
88d4973cfe1a
- added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
780 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
781 | // --------------------------------------------------------------------------------------------------------------------- |
798
88d4973cfe1a
- added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
782 | // |
983
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
783 | void MainWindow::historyTraversed() |
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
784 | { |
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
785 | updateActions(); |
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
786 | refresh(); |
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
787 | } |
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
788 | |
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
789 | // --------------------------------------------------------------------------------------------------------------------- |
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
790 | // |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
791 | void MainWindow::loadShortcuts() |
806
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 | for (QAction* act : findChildren<QAction*>()) |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
794 | { |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1322
diff
changeset
|
795 | QKeySequence seq = settingsObject().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
|
796 | act->setShortcut (seq); |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
797 | } |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
798 | } |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
799 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
800 | // --------------------------------------------------------------------------------------------------------------------- |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
801 | // |
1353 | 802 | void MainWindow::applyToActions(function<void(QAction*)> function) |
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 | for (QAction* act : findChildren<QAction*>()) |
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 | if (not act->objectName().isEmpty()) |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
807 | function (act); |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
808 | } |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
809 | } |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
810 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
811 | // --------------------------------------------------------------------------------------------------------------------- |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
812 | // |
997
1b49f34e533d
Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
988
diff
changeset
|
813 | QKeySequence MainWindow::defaultShortcut (QAction* act) |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
814 | { |
998 | 815 | return m_defaultShortcuts[act]; |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
816 | } |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
798
diff
changeset
|
817 | |
1417
ed39bfca7a67
refactored the segments/divisions editor in MainWindow to a new widget
Teemu Piippo <teemu@hecknology.net>
parents:
1390
diff
changeset
|
818 | CircularSection MainWindow::circleToolSection() const |
866
4951b737f8cb
- now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents:
865
diff
changeset
|
819 | { |
1417
ed39bfca7a67
refactored the segments/divisions editor in MainWindow to a new widget
Teemu Piippo <teemu@hecknology.net>
parents:
1390
diff
changeset
|
820 | return ui.circleToolSection->section(); |
871
a860edb4210b
- display a label next to the spinbox showing the fraction
Teemu Piippo <crimsondusk64@gmail.com>
parents:
869
diff
changeset
|
821 | } |
866
4951b737f8cb
- now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents:
865
diff
changeset
|
822 | |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
823 | // --------------------------------------------------------------------------------------------------------------------- |
866
4951b737f8cb
- now able to spawn partial circular primitives
Teemu Piippo <crimsondusk64@gmail.com>
parents:
865
diff
changeset
|
824 | // |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
825 | void MainWindow::createBlankDocument() |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
826 | { |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
827 | // Create a new anonymous file and set it to our current |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
828 | LDDocument* document = m_documents->createNew(false); |
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
829 | document->setName (""); |
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
830 | document->setFrozen(false); |
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
831 | changeDocument (document); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
832 | updateActions(); |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
833 | } |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
834 | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
835 | /* |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
836 | * Creates a new camera of the specified type for the specified document. |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
837 | * The canvas is opened in a new MDI sub window. |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
838 | * The created canvas is returned. |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
839 | */ |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
840 | Canvas* MainWindow::createCameraForDocument(LDDocument* document, gl::CameraType cameraType) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
841 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
842 | Canvas* canvas = new Canvas {document, cameraType, this}; |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
843 | m_renderers[document].append(canvas); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
844 | QMdiSubWindow* const subWindow = ui.viewport->addSubWindow(canvas); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
845 | m_subWindows[canvas] = subWindow; |
1438 | 846 | connect(canvas, &gl::Renderer::closed, this, &MainWindow::canvasClosed); |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
847 | ui.viewport->setActiveSubWindow(subWindow); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
848 | return canvas; |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
849 | } |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
850 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
851 | // --------------------------------------------------------------------------------------------------------------------- |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
852 | // |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
853 | void MainWindow::newDocument(LDDocument* document, bool cache) |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
854 | { |
983
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
855 | connect (document->history(), SIGNAL (undone()), this, SLOT (historyTraversed())); |
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
856 | connect (document->history(), SIGNAL (redone()), this, SLOT (historyTraversed())); |
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
857 | connect (document->history(), SIGNAL (stepAdded()), this, SLOT (updateActions())); |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
858 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
859 | if (not cache) |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
860 | openDocumentForEditing(document); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
861 | } |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
862 | |
1432
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
863 | void MainWindow::settingsChanged() |
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
864 | { |
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
865 | m_documents->loadLogoedStuds(); |
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
866 | updateColorToolbar(); |
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
867 | renderer()->setBackground(); |
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
868 | doFullRefresh(); |
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
869 | updateDocumentList(); |
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
870 | } |
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
871 | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
872 | /* |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
873 | * When a canvas is closed, this clears any internal references to it. |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
874 | */ |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
875 | void MainWindow::canvasClosed() |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
876 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
877 | Canvas* canvas = qobject_cast<Canvas*>(sender()); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
878 | |
1438 | 879 | Q_ASSERT(canvas != nullptr); |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
880 | if (canvas != nullptr) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
881 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
882 | LDDocument* const document = canvas->document(); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
883 | m_renderers[document].removeAll(canvas); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
884 | m_subWindows.remove(canvas); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
885 | } |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
886 | } |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
887 | |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
888 | void MainWindow::openDocumentForEditing(LDDocument* document) |
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
889 | { |
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
890 | if (document->isFrozen()) |
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
891 | { |
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
892 | document->setFrozen(false); |
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
893 | print ("Opened %1", document->name()); |
1306
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
894 | Canvas* canvas = getRendererForDocument(document); |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
895 | updateDocumentList(); |
1306
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
896 | connect(document, &LDDocument::windingChanged, canvas, &Canvas::fullUpdate); |
1438 | 897 | |
898 | QItemSelectionModel* selection = new QItemSelectionModel; | |
899 | m_selectionModels[document] = selection; | |
900 | canvas->setSelectionModel(selection); | |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
901 | } |
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
902 | } |
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
903 | |
1378 | 904 | /* |
905 | * Returns the currently open document. | |
906 | */ | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
907 | LDDocument* MainWindow::currentDocument() |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
908 | { |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
909 | return m_currentDocument; |
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 | |
1378 | 912 | /* |
913 | * Changes the current document to the specified document. | |
914 | */ | |
915 | void MainWindow::changeDocument(LDDocument* document) | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
916 | { |
1378 | 917 | Q_ASSERT(document != nullptr); |
918 | ||
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
919 | // Implicit files were loaded for caching purposes and may never be switched to. |
1378 | 920 | if (document->isFrozen()) |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
921 | return; |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
922 | |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
923 | m_currentDocument = document; |
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 | if (document) |
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 | // 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
|
928 | updateDocumentListItem (document); |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
929 | updateTitle(); |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
930 | 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
|
931 | ui.objectList->setModel(document); |
1306
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
932 | ui.header->setDocument(document); |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
933 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
934 | for (Canvas* canvas : m_renderers[document]) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
935 | canvas->fullUpdate(); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
936 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
937 | QItemSelectionModel* selection = m_selectionModels.value(document); |
1438 | 938 | ui.objectList->setSelectionModel(selection); |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
939 | |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
940 | } |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
941 | } |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
942 | |
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
|
943 | /* |
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
|
944 | * 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
|
945 | */ |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
946 | 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
|
947 | { |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
948 | QStack<Canvas*>& renderers = m_renderers[document]; |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
949 | Canvas* canvas; |
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
|
950 | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
951 | if (renderers.empty()) |
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
|
952 | { |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
953 | canvas = createCameraForDocument(document, gl::FreeCamera); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
954 | } |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
955 | else |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
956 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
957 | canvas = renderers.top(); |
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
|
958 | } |
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
|
959 | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
960 | return canvas; |
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
|
961 | } |
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
|
962 | |
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
|
963 | 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
|
964 | { |
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
|
965 | 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
|
966 | 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
|
967 | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
968 | // If the current document was just close, we need to get a new one to show. |
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
|
969 | 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
|
970 | 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
|
971 | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
972 | for (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
|
973 | { |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
974 | ui.viewport->removeSubWindow(renderer); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
975 | m_subWindows.remove(renderer); |
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 | 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
|
977 | } |
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 | |
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 | m_renderers.remove(document); |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
980 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
981 | auto selectionModel = m_selectionModels.find(document); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
982 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
983 | if (selectionModel != m_selectionModels.end()) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
984 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
985 | delete *selectionModel; |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
986 | m_selectionModels.erase(selectionModel); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
987 | } |
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
|
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 | |
1250 | 990 | QModelIndexList MainWindow::selectedIndexes() const |
991 | { | |
992 | return this->ui.objectList->selectionModel()->selectedIndexes(); | |
993 | } | |
994 | ||
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
995 | // --------------------------------------------------------------------------------------------------------------------- |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
996 | // |
1250 | 997 | QSet<LDObject*> MainWindow::selectedObjects() const |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
998 | { |
1250 | 999 | QSet<LDObject*> result; |
1000 | ||
1001 | for (const QModelIndex& index : this->selectedIndexes()) | |
1002 | result.insert(m_currentDocument->lookup(index)); | |
1003 | ||
1004 | return result; | |
978
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 | |
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 | // |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1009 | void MainWindow::currentDocumentClosed() |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1010 | { |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1011 | LDDocument* old = currentDocument(); |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1012 | |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1013 | // Find a replacement document to use |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
1014 | for (auto &iterator : m_documents->allDocuments()) |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1015 | { |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
1016 | if (iterator.get() != old and not iterator->isFrozen()) |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1017 | { |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
1018 | changeDocument(iterator.get()); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1019 | break; |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1020 | } |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1021 | } |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1022 | |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1023 | if (currentDocument() == old) |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1024 | { |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1025 | // 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
|
1026 | createBlankDocument(); |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1027 | } |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1028 | } |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
975
diff
changeset
|
1029 | |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
1030 | ExtProgramToolset* MainWindow::externalPrograms() |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
1031 | { |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
1032 | return m_externalPrograms; |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
1033 | } |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
979
diff
changeset
|
1034 | |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1018
diff
changeset
|
1035 | 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
|
1036 | { |
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1018
diff
changeset
|
1037 | 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
|
1038 | } |
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1018
diff
changeset
|
1039 | |
1256
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1252
diff
changeset
|
1040 | void MainWindow::clearSelection() |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1252
diff
changeset
|
1041 | { |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1042 | m_selectionModels[m_currentDocument]->clear(); |
1256
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1252
diff
changeset
|
1043 | } |
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1252
diff
changeset
|
1044 | |
1257 | 1045 | void MainWindow::select(const QModelIndex &objectIndex) |
1046 | { | |
1047 | if (objectIndex.isValid() and objectIndex.model() == m_currentDocument) | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1048 | m_selectionModels[m_currentDocument]->select(objectIndex, QItemSelectionModel::Select); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1049 | } |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1050 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1051 | /* |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1052 | * Selects a camera of the specified type for the specified document. |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1053 | * If the camera does not exist, it will be created. |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1054 | * The selected canvas is returned. |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1055 | */ |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1056 | Canvas* MainWindow::selectCameraForDocument(LDDocument* document, gl::CameraType cameraType) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1057 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1058 | Canvas* const currentCanvas = renderer(); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1059 | QStack<Canvas*>& canvasStack = m_renderers[document]; |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1060 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1061 | if (canvasStack.empty()) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1062 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1063 | return createCameraForDocument(document, cameraType); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1064 | } |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1065 | else |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1066 | { |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1067 | Canvas* canvas = canvasStack.top(); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1068 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1069 | if (canvas == currentCanvas) |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1070 | canvas = canvasStack.front(); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1071 | |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1072 | QMdiSubWindow* const subWindow = m_subWindows[canvas]; |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1073 | ui.viewport->setActiveSubWindow(subWindow); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1074 | return canvas; |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1075 | } |
1257 | 1076 | } |
1077 | ||
1078 | QItemSelectionModel* MainWindow::currentSelectionModel() | |
1079 | { | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1080 | return m_selectionModels[m_currentDocument]; |
1257 | 1081 | } |
1082 | ||
1083 | void MainWindow::replaceSelection(const QItemSelection& selection) | |
1084 | { | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1436
diff
changeset
|
1085 | m_selectionModels[m_currentDocument]->select(selection, QItemSelectionModel::ClearAndSelect); |
1257 | 1086 | } |