src/mainwindow.cpp

Sun, 02 Feb 2020 00:50:57 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 02 Feb 2020 00:50:57 +0200
changeset 43
08dc62e03a6d
parent 41
0abada2a9802
child 44
c6114b3af3a6
permissions
-rw-r--r--

made edges white in dark backgrounds

24
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
1 /*
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
2 * LDForge: LDraw parts authoring CAD
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
3 * Copyright (C) 2013 - 2020 Teemu Piippo
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
4 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
5 * This program is free software: you can redistribute it and/or modify
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
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: 23
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
8 * (at your option) any later version.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
9 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
10 * This program is distributed in the hope that it will be useful,
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
13 * GNU General Public License for more details.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
14 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
15 * You should have received a copy of the GNU General Public License
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
17 */
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 23
diff changeset
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
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24 #include "mainwindow.h"
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
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
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 12
diff changeset
29 #include "uiutilities.h"
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30
36
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
31 template<typename BaseType, typename MemberType, typename DataType>
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
32 struct MemberData
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
33 {
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
34 std::size_t member;
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
35 DataType payload;
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
36 constexpr MemberType memberInstance(BaseType* instance) const
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
37 {
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
38 return *reinterpret_cast<MemberType*>(reinterpret_cast<char*>(instance) + this->member);
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
39 }
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
40 };
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
41
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
42 static constexpr MemberData<Ui_MainWindow, QAction*, gl::RenderStyle> renderStyleButtons[] = {
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
43 { offsetof(Ui_MainWindow, actionRenderStyleNormal), gl::RenderStyle::Normal },
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
44 { offsetof(Ui_MainWindow, actionRenderStyleBfc), gl::RenderStyle::BfcRedGreen },
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
45 { offsetof(Ui_MainWindow, actionRenderStyleRandom), gl::RenderStyle::RandomColors },
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
41
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
48 class A : public QSettings
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
49 {
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
50 using QSettings::QSettings;
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
51 };
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
52
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
53 MainWindow::MainWindow(QWidget *parent) :
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
54 QMainWindow{parent},
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
55 ui{std::make_unique<Ui_MainWindow>()},
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
56 documents{this},
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
57 settings{},
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
58 libraries{this}
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
59 {
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
60 this->ui->setupUi(this);
16
Teemu Piippo <teemu@hecknology.net>
parents: 12
diff changeset
61 defaultKeyboardShortcuts = uiutilities::makeKeySequenceMap(uiutilities::collectActions(this));
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
62 connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newModel);
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
63 connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::openModel);
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
64 connect(ui->actionQuit, &QAction::triggered, this, &QMainWindow::close);
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
65 connect(ui->actionSettingsEditor, &QAction::triggered, this, &MainWindow::runSettingsEditor);
36
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
66 for (auto data : ::renderStyleButtons)
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
67 {
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
68 QAction* action = data.memberInstance(this->ui.get());
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
69 connect(action, &QAction::triggered, [this, data]()
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
70 {
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
71 this->setRenderStyle(data.payload);
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
72 });
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
73 }
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
74 this->updateTitle();
40
30cb5e836736 added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents: 39
diff changeset
75 this->restoreStartupSettings();
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
76 this->restoreSettings();
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
77 this->updateRenderPreferences();
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
78 this->newModel();
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
79 }
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
80
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
81 // 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
82 // 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
83 // being incomplete.
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
84 MainWindow::~MainWindow()
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
85 {
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
86 }
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
87
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
88 void MainWindow::newModel()
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
89 {
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
90 this->openModelForEditing(documents.newModel());
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
91 }
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
92
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
93 void MainWindow::openModel()
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
94 {
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
95 const QString path = QFileDialog::getOpenFileName(
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
96 this,
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
97 tr("Open model"),
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
98 "",
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
99 tr("LDraw models (*.ldr *.dat)"));
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
100 if (not path.isEmpty())
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
101 {
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
102 this->openModelFromPath(path);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
103 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
104 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
105
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
106 void MainWindow::openModelFromPath(const QString& path)
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
107 {
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
108 QString errorString;
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
109 QTextStream errorStream{&errorString};
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
110 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
111 if (not modelName.isEmpty())
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
112 {
23
3387a84ddaba fixed a pile of nonsense that caused subfiles to go haywire
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
113 this->documents.loadDependenciesForModel(modelName, path, this->libraries, errorStream);
12
fe67489523b5 added dependency loading
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
114 if (not errorString.isEmpty())
fe67489523b5 added dependency loading
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
115 {
fe67489523b5 added dependency loading
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
116 QMessageBox::warning(
fe67489523b5 added dependency loading
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
117 this,
fe67489523b5 added dependency loading
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
118 tr("Problem loading references"),
fe67489523b5 added dependency loading
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
119 errorString);
fe67489523b5 added dependency loading
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
120 }
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
121 this->openModelForEditing(modelName);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
122 this->addRecentlyOpenedFile(path);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
123 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
124 else
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
125 {
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
126 QMessageBox::critical(
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
127 this,
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
128 tr("Problem opening file"),
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
129 utility::format(
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
130 tr("Could not open %1: %2"),
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
131 path,
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
132 errorString));
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
133 }
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
134 }
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
135
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
136 /**
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
137 * @brief Changes the application language to the specified language
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
138 * @param localeCode Code of the locale to translate to
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
139 */
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
140 void MainWindow::changeLanguage(QString localeCode)
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
141 {
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
142 if (not localeCode.isEmpty() and localeCode != this->currentLanguage)
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
143 {
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
144 this->currentLanguage = localeCode;
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
145 if (localeCode == "system")
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
146 {
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
147 localeCode = QLocale::system().name();
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
148 }
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
149 QLocale::setDefault({localeCode});
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
150 qApp->removeTranslator(&this->translator);
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
151 const bool loadSuccessful = this->translator.load(pathToTranslation(localeCode));
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
152 if (loadSuccessful)
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
153 {
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
154 qApp->installTranslator(&this->translator);
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
155 }
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
156 }
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
157 }
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
158
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
159 void MainWindow::addRecentlyOpenedFile(const QString& path)
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
160 {
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
161 this->recentlyOpenedFiles.removeAll(path);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
162 this->recentlyOpenedFiles.insert(0, path);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
163 while (this->recentlyOpenedFiles.size() > maxRecentlyOpenedFiles)
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
164 {
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
165 this->recentlyOpenedFiles.removeLast();
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
166 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
167 this->saveSettings();
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
168 this->updateRecentlyOpenedDocumentsMenu();
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
169 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
170
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
171 void MainWindow::openModelForEditing(const QString& modelName)
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
172 {
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
173 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
174 document->setRenderPreferences(this->renderPreferences);
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
175 this->ui->tabs->addTab(document, modelName);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
176 this->ui->tabs->setCurrentWidget(document);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
177 document->restoreSplitterState(this->documentSplitterState);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
178 connect(document, &Document::splitterChanged, this, &MainWindow::handleDocumentSplitterChange);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
179 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
180
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
181 void MainWindow::runSettingsEditor()
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
182 {
16
Teemu Piippo <teemu@hecknology.net>
parents: 12
diff changeset
183 SettingsEditor settingsEditor{&this->settings, this->defaultKeyboardShortcuts, this};
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
184 const int result = settingsEditor.exec();
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
185 if (result == QDialog::Accepted)
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
186 {
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
187 this->restoreSettings();
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
188 }
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
189 }
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
190
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
191 void MainWindow::handleDocumentSplitterChange()
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 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
194 if (currentDocument != nullptr)
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
195 {
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
196 this->documentSplitterState = currentDocument->saveSplitterState();
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
197 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
198 {
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
199 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
200 if (document != nullptr and document != currentDocument)
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 document->restoreSplitterState(this->documentSplitterState);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
203 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
204 }
41
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
205 this->settings.setMainSplitterState(this->documentSplitterState);
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
206 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
207 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
208
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
209 void MainWindow::updateRecentlyOpenedDocumentsMenu()
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
210 {
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
211 this->ui->menuRecentFiles->clear();
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
212 for (const QString& path : this->recentlyOpenedFiles)
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
213 {
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
214 QAction* action = new QAction{path, this};
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
215 action->setData(path);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
216 this->ui->menuRecentFiles->addAction(action);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
217 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
218 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
219 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
220
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
221 void MainWindow::openRecentFile()
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
222 {
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
223 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
224 if (action != nullptr)
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
225 {
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
226 const QString path = action->data().toString();
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
227 this->openModelFromPath(path);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
228 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
229 }
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
230
36
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
231 void MainWindow::setRenderStyle(gl::RenderStyle renderStyle)
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
232 {
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
233 this->renderPreferences.style = renderStyle;
36
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
234 this->saveSettings();
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
235 this->updateRenderPreferences();
36
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
236 }
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
237
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
238 void MainWindow::changeEvent(QEvent* event)
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
239 {
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
240 if (event != nullptr)
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
241 {
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
242 switch (event->type())
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
243 {
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
244 case QEvent::LanguageChange:
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
245 this->ui->retranslateUi(this);
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
246 break;
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
247 default:
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
248 break;
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
249 }
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
250 }
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
251 QMainWindow::changeEvent(event);
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
252 }
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
253
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
254 /**
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
255 * @brief Handles closing the main window
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
256 * @param event Event information
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
257 */
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
258 void MainWindow::closeEvent(QCloseEvent* event)
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
259 {
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
260 saveSettings();
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
261 event->accept();
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
262 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
263
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
264 /**
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
265 * @brief Updates the title of the main window so to contain the app's name
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
266 * and version as well as the open document name.
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
267 */
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
268 void MainWindow::updateTitle()
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
269 {
1
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
270 QString title = ::appName;
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
271 title += " ";
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
272 title += fullVersionString();
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
273 setWindowTitle(title);
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
274 }
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
275
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
276 void MainWindow::updateRenderPreferences()
36
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
277 {
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
278 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
279 {
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
280 Document* document = qobject_cast<Document*>(this->ui->tabs->widget(i));
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
281 if (document != nullptr)
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
282 {
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
283 document->setRenderPreferences(this->renderPreferences);
36
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
284 }
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
285 }
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
286 for (auto data : ::renderStyleButtons)
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
287 {
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
288 QAction* action = data.memberInstance(this->ui.get());
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
289 action->setChecked(this->renderPreferences.style == data.payload);
36
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
290 }
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
291 }
bbb901b97404 added render style storage
Teemu Piippo <teemu@hecknology.net>
parents: 26
diff changeset
292
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
293 /**
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
294 * @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
295 */
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
296 void MainWindow::saveSettings()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
297 {
41
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
298 this->settings.setMainWindowGeometry(this->saveGeometry());
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
299 this->settings.setRecentFiles(this->recentlyOpenedFiles);
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
300 this->settings.setMainSplitterState(this->documentSplitterState);
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
301 this->settings.setRenderStyle(static_cast<int>(this->renderPreferences.style));
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
302 this->libraries.storeToSettings(&this->settings);
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
303 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
304
40
30cb5e836736 added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents: 39
diff changeset
305 void MainWindow::restoreStartupSettings()
30cb5e836736 added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents: 39
diff changeset
306 {
41
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
307 this->restoreGeometry(this->settings.mainWindowGeometry());
40
30cb5e836736 added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents: 39
diff changeset
308 }
30cb5e836736 added configurable background color
Teemu Piippo <teemu@hecknology.net>
parents: 39
diff changeset
309
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
310 /**
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
311 * @brief Restores saved settings relating to the main window
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
312 */
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
313 void MainWindow::restoreSettings()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
314 {
41
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
315 this->recentlyOpenedFiles = this->settings.recentFiles();
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
316 this->documentSplitterState = this->settings.mainSplitterState();
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
317 this->renderPreferences.style = static_cast<gl::RenderStyle>(this->settings.renderStyle());
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
318 this->renderPreferences.mainColor = this->settings.mainColor();
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
319 this->renderPreferences.backgroundColor = this->settings.backgroundColor();
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
320 const QString systemLocale = QLocale::system().name();
41
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
321 const QVariant defaultLocale = this->settings.locale();
0abada2a9802 added automated configuration collection
Teemu Piippo <teemu@hecknology.net>
parents: 40
diff changeset
322 this->changeLanguage(defaultLocale.toString());
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
323 this->libraries.restoreFromSettings(&this->settings);
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
324 this->updateRecentlyOpenedDocumentsMenu();
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
325 this->loadColors();
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
326 this->updateRenderPreferences();
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
327 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
328
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
329 QString MainWindow::pathToTranslation(const QString& localeCode)
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
330 {
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
331 QDir dir {":/locale"};
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
332 return dir.filePath(localeCode + ".qm");
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
333 }
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
334
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
335 void MainWindow::loadColors()
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
336 {
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
337 QTextStream errors;
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
338 this->colorTable = this->libraries.loadColorTable(errors);
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
339 }

mercurial