Sun, 25 Jul 2021 20:39:21 +0300
use QT_NO_KEYWORDS
24 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2020 Teemu Piippo | |
4 | * | |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
19 | #include <QLabel> |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
20 | #include <QVBoxLayout> |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
21 | #include <QCloseEvent> |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
22 | #include <QFileDialog> |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
23 | #include <QMessageBox> |
0 | 24 | #include "mainwindow.h" |
25 | #include "ui_mainwindow.h" | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
26 | #include "settingseditor/settingseditor.h" |
1 | 27 | #include "version.h" |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
7
diff
changeset
|
28 | #include "document.h" |
16 | 29 | #include "uiutilities.h" |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
79
diff
changeset
|
30 | #include "widgets/colorselectdialog.h" |
96 | 31 | #include "tools/basetool.h" |
32 | #include "tools/drawtool.h" | |
33 | #include "tools/selecttool.h" | |
34 | ||
35 | static const QMetaObject* const toolMetaObjects[] = { | |
36 | &SelectTool::staticMetaObject, | |
37 | &DrawTool::staticMetaObject, | |
38 | }; | |
0 | 39 | |
36
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
40 | template<typename BaseType, typename MemberType, typename DataType> |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
41 | struct MemberData |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
42 | { |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
43 | std::size_t member; |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
44 | DataType payload; |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
45 | constexpr MemberType memberInstance(BaseType* instance) const |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
46 | { |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
47 | return *reinterpret_cast<MemberType*>(reinterpret_cast<char*>(instance) + this->member); |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
48 | } |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
49 | }; |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
50 | |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
51 | static constexpr MemberData<Ui_MainWindow, QAction*, gl::RenderStyle> renderStyleButtons[] = { |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
52 | { offsetof(Ui_MainWindow, actionRenderStyleNormal), gl::RenderStyle::Normal }, |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
53 | { offsetof(Ui_MainWindow, actionRenderStyleBfc), gl::RenderStyle::BfcRedGreen }, |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
54 | { offsetof(Ui_MainWindow, actionRenderStyleRandom), gl::RenderStyle::RandomColors }, |
79
5fe2dd4e161a
added a render style for pick scene
Teemu Piippo <teemu@hecknology.net>
parents:
48
diff
changeset
|
55 | { offsetof(Ui_MainWindow, actionRenderStylePickScene), gl::RenderStyle::PickScene }, |
36
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
56 | }; |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
57 | |
41
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
58 | class A : public QSettings |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
59 | { |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
60 | using QSettings::QSettings; |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
61 | }; |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
62 | |
0 | 63 | MainWindow::MainWindow(QWidget *parent) : |
3 | 64 | QMainWindow{parent}, |
5 | 65 | ui{std::make_unique<Ui_MainWindow>()}, |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
66 | documents{this}, |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
67 | settings{}, |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
68 | libraries{this} |
0 | 69 | { |
6 | 70 | this->ui->setupUi(this); |
16 | 71 | defaultKeyboardShortcuts = uiutilities::makeKeySequenceMap(uiutilities::collectActions(this)); |
5 | 72 | connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newModel); |
6 | 73 | connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::openModel); |
3 | 74 | connect(ui->actionQuit, &QAction::triggered, this, &QMainWindow::close); |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
75 | connect(ui->actionSettingsEditor, &QAction::triggered, this, &MainWindow::runSettingsEditor); |
36
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
76 | for (auto data : ::renderStyleButtons) |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
77 | { |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
78 | QAction* action = data.memberInstance(this->ui.get()); |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
79 | connect(action, &QAction::triggered, [this, data]() |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
80 | { |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
81 | this->setRenderStyle(data.payload); |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
82 | }); |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
83 | } |
6 | 84 | this->updateTitle(); |
40
30cb5e836736
added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents:
39
diff
changeset
|
85 | this->restoreStartupSettings(); |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
86 | this->restoreSettings(); |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
87 | this->updateRenderPreferences(); |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
88 | this->newModel(); |
96 | 89 | |
90 | for (const QMetaObject* const metaObject : ::toolMetaObjects) | |
91 | { | |
92 | QObject* const objectInstance = metaObject->newInstance(Q_ARG(QObject*, this)); | |
93 | BaseTool* const toolInstance = qobject_cast<BaseTool*>(objectInstance); | |
94 | if (toolInstance) | |
95 | { | |
96 | this->tools.append(toolInstance); | |
97 | 97 | QAction* action = new QAction{toolInstance->name(), this}; |
98 | action->setCheckable(true); | |
99 | this->toolActions[toolInstance] = action; | |
100 | action->setToolTip(toolInstance->toolTip()); | |
101 | connect(action, &QAction::triggered, this, &MainWindow::toolActionTriggered); | |
102 | this->ui->toolsBar->addAction(action); | |
96 | 103 | } |
104 | else | |
105 | { | |
106 | QMessageBox::critical(this, tr("Error"), tr("Unable to construct %1").arg(metaObject->className())); | |
107 | } | |
108 | } | |
97 | 109 | |
110 | this->selectTool(this->tools[0]); | |
5 | 111 | } |
112 | ||
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
113 | // MainWindow needs a destructor even if it is empty because otherwise the destructor of the |
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
114 | // std::unique_ptr is resolved in the header file, where it will complain about Ui_MainWindow |
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
115 | // being incomplete. |
5 | 116 | MainWindow::~MainWindow() |
117 | { | |
118 | } | |
119 | ||
120 | void MainWindow::newModel() | |
121 | { | |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
122 | this->openModelForEditing(documents.newModel()); |
5 | 123 | } |
124 | ||
125 | void MainWindow::openModel() | |
126 | { | |
127 | const QString path = QFileDialog::getOpenFileName( | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
128 | this, |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
129 | tr("Open model"), |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
130 | "", |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
131 | tr("LDraw models (*.ldr *.dat)")); |
5 | 132 | if (not path.isEmpty()) |
133 | { | |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
134 | this->openModelFromPath(path); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
135 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
136 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
137 | |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
138 | void MainWindow::openModelFromPath(const QString& path) |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
139 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
140 | QString errorString; |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
141 | QTextStream errorStream{&errorString}; |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
142 | QString modelName = this->documents.openModel(path, errorStream); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
143 | if (not modelName.isEmpty()) |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
144 | { |
23
3387a84ddaba
fixed a pile of nonsense that caused subfiles to go haywire
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
145 | this->documents.loadDependenciesForModel(modelName, path, this->libraries, errorStream); |
12 | 146 | if (not errorString.isEmpty()) |
147 | { | |
148 | QMessageBox::warning( | |
149 | this, | |
150 | tr("Problem loading references"), | |
151 | errorString); | |
152 | } | |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
153 | this->openModelForEditing(modelName); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
154 | this->addRecentlyOpenedFile(path); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
155 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
156 | else |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
157 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
158 | QMessageBox::critical( |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
159 | this, |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
160 | tr("Problem opening file"), |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
161 | utility::format( |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
162 | tr("Could not open %1: %2"), |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
163 | path, |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
164 | errorString)); |
5 | 165 | } |
166 | } | |
167 | ||
168 | /** | |
6 | 169 | * @brief Changes the application language to the specified language |
170 | * @param localeCode Code of the locale to translate to | |
171 | */ | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
172 | void MainWindow::changeLanguage(QString localeCode) |
6 | 173 | { |
174 | if (not localeCode.isEmpty() and localeCode != this->currentLanguage) | |
175 | { | |
176 | this->currentLanguage = localeCode; | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
177 | if (localeCode == "system") |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
178 | { |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
179 | localeCode = QLocale::system().name(); |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
180 | } |
6 | 181 | QLocale::setDefault({localeCode}); |
182 | qApp->removeTranslator(&this->translator); | |
183 | const bool loadSuccessful = this->translator.load(pathToTranslation(localeCode)); | |
184 | if (loadSuccessful) | |
185 | { | |
186 | qApp->installTranslator(&this->translator); | |
187 | } | |
188 | } | |
189 | } | |
190 | ||
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
191 | void MainWindow::addRecentlyOpenedFile(const QString& path) |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
192 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
193 | this->recentlyOpenedFiles.removeAll(path); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
194 | this->recentlyOpenedFiles.insert(0, path); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
195 | while (this->recentlyOpenedFiles.size() > maxRecentlyOpenedFiles) |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
196 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
197 | this->recentlyOpenedFiles.removeLast(); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
198 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
199 | this->saveSettings(); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
200 | this->updateRecentlyOpenedDocumentsMenu(); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
201 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
202 | |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
203 | void MainWindow::openModelForEditing(const QString& modelName) |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
204 | { |
26 | 205 | Document* document = new Document{this->documents.findModelByName(modelName), &this->documents, this->colorTable}; |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
206 | document->setRenderPreferences(this->renderPreferences); |
47 | 207 | connect(document, &Document::newStatusText, [&](const QString& newStatusText) |
208 | { | |
209 | this->statusBar()->showMessage(newStatusText); | |
210 | }); | |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
211 | this->ui->tabs->addTab(document, modelName); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
212 | this->ui->tabs->setCurrentWidget(document); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
213 | document->restoreSplitterState(this->documentSplitterState); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
214 | connect(document, &Document::splitterChanged, this, &MainWindow::handleDocumentSplitterChange); |
104 | 215 | connect(document, &Document::mouseClick, this, &MainWindow::canvasMouseReleased); |
108 | 216 | connect(document, &Document::mouseMove, this, &MainWindow::canvasMouseMoved); |
109
40a1cf2f38f5
replaced preview layers in favor of overpainting callback
Teemu Piippo <teemu@hecknology.net>
parents:
108
diff
changeset
|
217 | document->setCanvasOverpaintCallback([&](Canvas* canvas, QPainter* painter) |
40a1cf2f38f5
replaced preview layers in favor of overpainting callback
Teemu Piippo <teemu@hecknology.net>
parents:
108
diff
changeset
|
218 | { |
40a1cf2f38f5
replaced preview layers in favor of overpainting callback
Teemu Piippo <teemu@hecknology.net>
parents:
108
diff
changeset
|
219 | if (this->selectedTool != nullptr) |
40a1cf2f38f5
replaced preview layers in favor of overpainting callback
Teemu Piippo <teemu@hecknology.net>
parents:
108
diff
changeset
|
220 | { |
40a1cf2f38f5
replaced preview layers in favor of overpainting callback
Teemu Piippo <teemu@hecknology.net>
parents:
108
diff
changeset
|
221 | this->selectedTool->overpaint(canvas, painter); |
40a1cf2f38f5
replaced preview layers in favor of overpainting callback
Teemu Piippo <teemu@hecknology.net>
parents:
108
diff
changeset
|
222 | } |
40a1cf2f38f5
replaced preview layers in favor of overpainting callback
Teemu Piippo <teemu@hecknology.net>
parents:
108
diff
changeset
|
223 | }); |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
224 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
225 | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
226 | void MainWindow::runSettingsEditor() |
6 | 227 | { |
16 | 228 | SettingsEditor settingsEditor{&this->settings, this->defaultKeyboardShortcuts, this}; |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
229 | const int result = settingsEditor.exec(); |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
230 | if (result == QDialog::Accepted) |
6 | 231 | { |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
232 | this->restoreSettings(); |
6 | 233 | } |
234 | } | |
235 | ||
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
236 | void MainWindow::handleDocumentSplitterChange() |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
237 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
238 | Document* currentDocument = qobject_cast<Document*>(this->ui->tabs->currentWidget()); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
239 | if (currentDocument != nullptr) |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
240 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
241 | this->documentSplitterState = currentDocument->saveSplitterState(); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
242 | for (int i = 0; i < this->ui->tabs->count(); i += 1) |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
243 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
244 | Document* document = qobject_cast<Document*>(this->ui->tabs->widget(i)); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
245 | if (document != nullptr and document != currentDocument) |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
246 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
247 | document->restoreSplitterState(this->documentSplitterState); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
248 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
249 | } |
41
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
250 | this->settings.setMainSplitterState(this->documentSplitterState); |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
251 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
252 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
253 | |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
254 | void MainWindow::updateRecentlyOpenedDocumentsMenu() |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
255 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
256 | this->ui->menuRecentFiles->clear(); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
257 | for (const QString& path : this->recentlyOpenedFiles) |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
258 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
259 | QAction* action = new QAction{path, this}; |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
260 | action->setData(path); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
261 | this->ui->menuRecentFiles->addAction(action); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
262 | connect(action, &QAction::triggered, this, &MainWindow::openRecentFile); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
263 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
264 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
265 | |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
266 | void MainWindow::openRecentFile() |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
267 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
268 | QAction* action = qobject_cast<QAction*>(this->sender()); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
269 | if (action != nullptr) |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
270 | { |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
271 | const QString path = action->data().toString(); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
272 | this->openModelFromPath(path); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
273 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
274 | } |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
275 | |
36
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
276 | void MainWindow::setRenderStyle(gl::RenderStyle renderStyle) |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
277 | { |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
278 | this->renderPreferences.style = renderStyle; |
36
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
279 | this->saveSettings(); |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
280 | this->updateRenderPreferences(); |
36
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
281 | } |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
282 | |
6 | 283 | void MainWindow::changeEvent(QEvent* event) |
284 | { | |
285 | if (event != nullptr) | |
286 | { | |
287 | switch (event->type()) | |
288 | { | |
289 | case QEvent::LanguageChange: | |
290 | this->ui->retranslateUi(this); | |
291 | break; | |
292 | default: | |
293 | break; | |
294 | } | |
295 | } | |
296 | QMainWindow::changeEvent(event); | |
297 | } | |
298 | ||
299 | /** | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
300 | * @brief Handles closing the main window |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
301 | * @param event Event information |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
302 | */ |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
303 | void MainWindow::closeEvent(QCloseEvent* event) |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
304 | { |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
305 | saveSettings(); |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
306 | event->accept(); |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
307 | } |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
308 | |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
309 | /** |
5 | 310 | * @brief Updates the title of the main window so to contain the app's name |
311 | * and version as well as the open document name. | |
312 | */ | |
313 | void MainWindow::updateTitle() | |
314 | { | |
1 | 315 | QString title = ::appName; |
316 | title += " "; | |
317 | title += fullVersionString(); | |
318 | setWindowTitle(title); | |
0 | 319 | } |
6 | 320 | |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
321 | void MainWindow::updateRenderPreferences() |
36
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
322 | { |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
323 | for (int i = 0; i < this->ui->tabs->count(); i += 1) |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
324 | { |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
325 | Document* document = qobject_cast<Document*>(this->ui->tabs->widget(i)); |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
326 | if (document != nullptr) |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
327 | { |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
328 | document->setRenderPreferences(this->renderPreferences); |
36
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
329 | } |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
330 | } |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
331 | for (auto data : ::renderStyleButtons) |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
332 | { |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
333 | QAction* action = data.memberInstance(this->ui.get()); |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
334 | action->setChecked(this->renderPreferences.style == data.payload); |
36
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
335 | } |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
336 | } |
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
337 | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
338 | /** |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
339 | * @brief Stores the settings of the main window, storing geometry, etc |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
340 | */ |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
341 | void MainWindow::saveSettings() |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
342 | { |
41
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
343 | this->settings.setMainWindowGeometry(this->saveGeometry()); |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
344 | this->settings.setRecentFiles(this->recentlyOpenedFiles); |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
345 | this->settings.setMainSplitterState(this->documentSplitterState); |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
346 | this->settings.setRenderStyle(static_cast<int>(this->renderPreferences.style)); |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
347 | this->libraries.storeToSettings(&this->settings); |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
348 | } |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
349 | |
40
30cb5e836736
added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents:
39
diff
changeset
|
350 | void MainWindow::restoreStartupSettings() |
30cb5e836736
added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents:
39
diff
changeset
|
351 | { |
41
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
352 | this->restoreGeometry(this->settings.mainWindowGeometry()); |
40
30cb5e836736
added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents:
39
diff
changeset
|
353 | } |
30cb5e836736
added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents:
39
diff
changeset
|
354 | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
355 | /** |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
356 | * @brief Restores saved settings relating to the main window |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
357 | */ |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
358 | void MainWindow::restoreSettings() |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
359 | { |
41
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
360 | this->recentlyOpenedFiles = this->settings.recentFiles(); |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
361 | this->documentSplitterState = this->settings.mainSplitterState(); |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
362 | this->renderPreferences.style = static_cast<gl::RenderStyle>(this->settings.renderStyle()); |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
363 | this->renderPreferences.mainColor = this->settings.mainColor(); |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
364 | this->renderPreferences.backgroundColor = this->settings.backgroundColor(); |
44
c6114b3af3a6
added configurable line thickness
Teemu Piippo <teemu@hecknology.net>
parents:
41
diff
changeset
|
365 | this->renderPreferences.lineThickness = this->settings.lineThickness(); |
45
272c84c7c87e
added configurable line anti-aliasing
Teemu Piippo <teemu@hecknology.net>
parents:
44
diff
changeset
|
366 | this->renderPreferences.lineAntiAliasing = this->settings.lineAntiAliasing(); |
48
3c10f0e2fbe0
added selection highlighting
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
367 | this->renderPreferences.selectedColor = this->settings.selectedColor(); |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
368 | const QString systemLocale = QLocale::system().name(); |
41
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
369 | const QVariant defaultLocale = this->settings.locale(); |
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
370 | this->changeLanguage(defaultLocale.toString()); |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
371 | this->libraries.restoreFromSettings(&this->settings); |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
372 | this->updateRecentlyOpenedDocumentsMenu(); |
26 | 373 | this->loadColors(); |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
374 | this->updateRenderPreferences(); |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
375 | } |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
376 | |
6 | 377 | QString MainWindow::pathToTranslation(const QString& localeCode) |
378 | { | |
379 | QDir dir {":/locale"}; | |
380 | return dir.filePath(localeCode + ".qm"); | |
381 | } | |
26 | 382 | |
383 | void MainWindow::loadColors() | |
384 | { | |
385 | QTextStream errors; | |
386 | this->colorTable = this->libraries.loadColorTable(errors); | |
387 | } | |
97 | 388 | |
389 | void MainWindow::toolActionTriggered() | |
390 | { | |
391 | QAction* action = qobject_cast<QAction*>(sender()); | |
392 | if (action != nullptr) | |
393 | { | |
394 | BaseTool* tool = nullptr; | |
395 | for (auto&& pair : items(this->toolActions)) | |
396 | { | |
397 | if (pair.value == action) | |
398 | { | |
399 | tool = pair.key; | |
400 | } | |
401 | } | |
402 | this->selectTool(tool); | |
403 | } | |
404 | } | |
405 | ||
406 | void MainWindow::selectTool(BaseTool* tool) | |
407 | { | |
408 | if (tool != nullptr && tool != this->selectedTool) | |
409 | { | |
106 | 410 | if (this->selectedTool != nullptr) |
411 | { | |
412 | this->selectedTool->reset(); | |
413 | } | |
97 | 414 | this->selectedTool = tool; |
415 | for (auto&& pair : items(this->toolActions)) | |
416 | { | |
417 | pair.value->setChecked(pair.key == tool); | |
418 | } | |
419 | } | |
420 | } | |
103 | 421 | |
422 | void MainWindow::canvasMousePressed(QMouseEvent *event) | |
423 | { | |
105
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
424 | Q_UNUSED(event) |
103 | 425 | } |
426 | ||
111
1f42c03fafca
Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents:
109
diff
changeset
|
427 | void MainWindow::canvasMouseReleased(Document* document, Canvas* canvas) |
103 | 428 | { |
429 | if (this->selectedTool != nullptr) | |
430 | { | |
111
1f42c03fafca
Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents:
109
diff
changeset
|
431 | this->selectedTool->mouseClick(document, canvas); |
103 | 432 | } |
433 | } | |
434 | ||
105
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
435 | void MainWindow::canvasMouseDoubleClicked(QMouseEvent* event) |
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
436 | { |
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
437 | Q_UNUSED(event) |
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
438 | } |
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
439 | |
111
1f42c03fafca
Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents:
109
diff
changeset
|
440 | void MainWindow::canvasMouseMoved(Document* document, Canvas* canvas) |
105
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
441 | { |
108 | 442 | if (this->selectedTool != nullptr) |
443 | { | |
111
1f42c03fafca
Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents:
109
diff
changeset
|
444 | this->selectedTool->mouseMove(document, canvas); |
108 | 445 | } |
105
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
446 | } |
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
447 | |
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
448 | void MainWindow::canvasKeyReleased(QKeyEvent* event) |
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
449 | { |
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
450 | Q_UNUSED(event) |
6ca6e8c647d4
added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents:
104
diff
changeset
|
451 | } |