Fri, 27 Aug 2021 14:38:56 +0300
refactor
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 | ||
0 | 19 | #pragma once |
20 | #include <QMainWindow> | |
6 | 21 | #include <QTranslator> |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
22 | #include <QSettings> |
16 | 23 | #include <QKeySequence> |
41
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
24 | #include "configuration.h" |
5 | 25 | #include "documentmanager.h" |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
26 | #include "libraries.h" |
16 | 27 | #include "uiutilities.h" |
104 | 28 | #include "ui/canvas.h" |
0 | 29 | |
111
1f42c03fafca
Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents:
108
diff
changeset
|
30 | class Document; |
1f42c03fafca
Draw tool actually adds objects now
Teemu Piippo <teemu@hecknology.net>
parents:
108
diff
changeset
|
31 | |
0 | 32 | class MainWindow : public QMainWindow |
33 | { | |
3 | 34 | Q_OBJECT |
0 | 35 | public: |
3 | 36 | MainWindow(QWidget *parent = nullptr); |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
37 | ~MainWindow() override; |
112 | 38 | private Q_SLOTS: |
5 | 39 | void newModel(); |
40 | void openModel(); | |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
41 | void openModelFromPath(const QString& path); |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
42 | void runSettingsEditor(); |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
43 | void handleDocumentSplitterChange(); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
44 | void updateRecentlyOpenedDocumentsMenu(); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
45 | void openRecentFile(); |
36
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
46 | void setRenderStyle(gl::RenderStyle renderStyle); |
6 | 47 | protected: |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
48 | void changeEvent(QEvent* event) override; |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
49 | void closeEvent(QCloseEvent* event) override; |
0 | 50 | private: |
3 | 51 | std::unique_ptr<class Ui_MainWindow> ui; |
5 | 52 | DocumentManager documents; |
53 | QMap<Model*, QWidget*> modelWidgets; | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
54 | QString currentLanguage = "en"; |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
55 | QTranslator translator; |
41
0abada2a9802
added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents:
40
diff
changeset
|
56 | Configuration settings; |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
57 | LibraryManager libraries; |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
58 | QByteArray documentSplitterState; |
16 | 59 | uiutilities::KeySequenceMap defaultKeyboardShortcuts; |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
60 | static constexpr int maxRecentlyOpenedFiles = 10; |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
61 | QStringList recentlyOpenedFiles; |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
62 | ldraw::ColorTable colorTable; |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
63 | gl::RenderPreferences renderPreferences; |
96 | 64 | QVector<class BaseTool*> tools; |
65 | BaseTool* selectedTool = nullptr; | |
97 | 66 | QMap<BaseTool*, QAction*> toolActions; |
5 | 67 | void updateTitle(); |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
36
diff
changeset
|
68 | void updateRenderPreferences(); |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
69 | void saveSettings(); |
40
30cb5e836736
added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents:
39
diff
changeset
|
70 | void restoreStartupSettings(); |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
71 | void restoreSettings(); |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
72 | void changeLanguage(QString localeCode); |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
73 | void addRecentlyOpenedFile(const QString& path); |
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
74 | void openModelForEditing(const QString& modelName); |
6 | 75 | static QString pathToTranslation(const QString& localeCode); |
26 | 76 | void loadColors(); |
97 | 77 | Q_SLOT void toolActionTriggered(); |
78 | void selectTool(BaseTool* tool); | |
112 | 79 | private Q_SLOTS: |
103 | 80 | void canvasMousePressed(QMouseEvent* event); |
121
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
112
diff
changeset
|
81 | void canvasMouseReleased(Document *document, Canvas *canvas, QMouseEvent *event); |
103 | 82 | void canvasMouseDoubleClicked(QMouseEvent* event); |
121
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
112
diff
changeset
|
83 | void canvasMouseMoved(Document *document, Canvas *canvas, QMouseEvent *event); |
103 | 84 | void canvasKeyReleased(QKeyEvent*); |
0 | 85 | }; |