src/mainwindow.h

Sat, 14 Dec 2019 22:36:06 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 14 Dec 2019 22:36:06 +0200
changeset 19
ed9685f44ab3
parent 16
aeb5f203b3eb
child 24
1a0faaaceb84
permissions
-rw-r--r--

added missing files

0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #pragma once
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 #include <QMainWindow>
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
3 #include <QTranslator>
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
4 #include <QSettings>
16
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
5 #include <QKeySequence>
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
6 #include "documentmanager.h"
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
7 #include "libraries.h"
16
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
8 #include "uiutilities.h"
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 class MainWindow : public QMainWindow
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 {
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
12 Q_OBJECT
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 public:
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
14 MainWindow(QWidget *parent = nullptr);
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
15 ~MainWindow();
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
16 private slots:
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
17 void newModel();
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
18 void openModel();
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
19 void openModelFromPath(const QString& path);
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
20 void runSettingsEditor();
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
21 void handleDocumentSplitterChange();
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
22 void updateRecentlyOpenedDocumentsMenu();
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
23 void openRecentFile();
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
24 protected:
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
25 void changeEvent(QEvent* event) override;
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
26 void closeEvent(QCloseEvent* event) override;
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
27 private:
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents: 0
diff changeset
28 std::unique_ptr<class Ui_MainWindow> ui;
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
29 DocumentManager documents;
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
30 QMap<Model*, QWidget*> modelWidgets;
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
31 QString currentLanguage = "en";
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
32 QTranslator translator;
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
33 QSettings settings;
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
34 LibraryManager libraries;
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
35 QByteArray documentSplitterState;
16
Teemu Piippo <teemu@hecknology.net>
parents: 9
diff changeset
36 uiutilities::KeySequenceMap defaultKeyboardShortcuts;
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
37 static constexpr int maxRecentlyOpenedFiles = 10;
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
38 QStringList recentlyOpenedFiles;
5
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
39 void updateTitle();
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
40 void saveSettings();
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
41 void restoreSettings();
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
42 void changeLanguage(QString localeCode);
9
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
43 void addRecentlyOpenedFile(const QString& path);
8b9780700b5e added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
44 void openModelForEditing(const QString& modelName);
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 5
diff changeset
45 static QString pathToTranslation(const QString& localeCode);
0
f9f4d4d6f162 initial commit
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
46 };

mercurial