src/mainwindow.h

Sun, 25 Jul 2021 16:26:38 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 25 Jul 2021 16:26:38 +0300
changeset 109
40a1cf2f38f5
parent 108
94c92c923713
child 111
1f42c03fafca
permissions
-rw-r--r--

replaced preview layers in favor of overpainting callback

24
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
1 /*
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
2 * LDForge: LDraw parts authoring CAD
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
3 * Copyright (C) 2013 - 2020 Teemu Piippo
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
4 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
5 * This program is free software: you can redistribute it and/or modify
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
6 * it under the terms of the GNU General Public License as published by
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
8 * (at your option) any later version.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
9 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
10 * This program is distributed in the hope that it will be useful,
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
13 * GNU General Public License for more details.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
14 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
15 * You should have received a copy of the GNU General Public License
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
17 */
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 16
diff changeset
18
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 #pragma once
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 #include <QMainWindow>
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
21 #include <QTranslator>
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
22 #include <QSettings>
16
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
23 #include <QKeySequence>
41
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
24 #include "configuration.h"
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
25 #include "documentmanager.h"
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
26 #include "libraries.h"
16
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
27 #include "uiutilities.h"
104
cd4df75924b7 Add connections
Teemu Piippo <teemu@hecknology.net>
parents: 103
diff changeset
28 #include "ui/canvas.h"
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30 class MainWindow : public QMainWindow
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
31 {
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
32 Q_OBJECT
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33 public:
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
34 MainWindow(QWidget *parent = nullptr);
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
35 ~MainWindow() override;
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
36 private slots:
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
37 void newModel();
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
38 void openModel();
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
39 void openModelFromPath(const QString& path);
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
40 void runSettingsEditor();
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
41 void handleDocumentSplitterChange();
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
42 void updateRecentlyOpenedDocumentsMenu();
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
43 void openRecentFile();
36
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 35
diff changeset
44 void setRenderStyle(gl::RenderStyle renderStyle);
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
45 protected:
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
46 void changeEvent(QEvent* event) override;
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
47 void closeEvent(QCloseEvent* event) override;
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
48 private:
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
49 std::unique_ptr<class Ui_MainWindow> ui;
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
50 DocumentManager documents;
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
51 QMap<Model*, QWidget*> modelWidgets;
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
52 QString currentLanguage = "en";
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
53 QTranslator translator;
41
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
54 Configuration settings;
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
55 LibraryManager libraries;
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
56 QByteArray documentSplitterState;
16
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
57 uiutilities::KeySequenceMap defaultKeyboardShortcuts;
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
58 static constexpr int maxRecentlyOpenedFiles = 10;
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
59 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
60 ldraw::ColorTable colorTable;
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
61 gl::RenderPreferences renderPreferences;
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents: 41
diff changeset
62 QVector<class BaseTool*> tools;
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents: 41
diff changeset
63 BaseTool* selectedTool = nullptr;
97
d9a3b153f679 work on tools
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
64 QMap<BaseTool*, QAction*> toolActions;
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
65 void updateTitle();
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
66 void updateRenderPreferences();
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
67 void saveSettings();
40
30cb5e836736 added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents: 39
diff changeset
68 void restoreStartupSettings();
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
69 void restoreSettings();
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
70 void changeLanguage(QString localeCode);
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
71 void addRecentlyOpenedFile(const QString& path);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
72 void openModelForEditing(const QString& modelName);
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
73 static QString pathToTranslation(const QString& localeCode);
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
74 void loadColors();
97
d9a3b153f679 work on tools
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
75 Q_SLOT void toolActionTriggered();
d9a3b153f679 work on tools
Teemu Piippo <teemu@hecknology.net>
parents: 96
diff changeset
76 void selectTool(BaseTool* tool);
103
Teemu Piippo <teemu@hecknology.net>
parents: 97
diff changeset
77 private slots:
Teemu Piippo <teemu@hecknology.net>
parents: 97
diff changeset
78 void canvasMousePressed(QMouseEvent* event);
104
cd4df75924b7 Add connections
Teemu Piippo <teemu@hecknology.net>
parents: 103
diff changeset
79 void canvasMouseReleased(const Canvas::MouseClickInfo& info);
103
Teemu Piippo <teemu@hecknology.net>
parents: 97
diff changeset
80 void canvasMouseDoubleClicked(QMouseEvent* event);
108
94c92c923713 work on editing tools
Teemu Piippo <teemu@hecknology.net>
parents: 104
diff changeset
81 void canvasMouseMoved(const Canvas::MouseMoveInfo& info);
103
Teemu Piippo <teemu@hecknology.net>
parents: 97
diff changeset
82 void canvasKeyReleased(QKeyEvent*);
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
83 };

mercurial