6 #include "mainwindow.h" |
6 #include "mainwindow.h" |
7 #include "ui_mainwindow.h" |
7 #include "ui_mainwindow.h" |
8 #include "settingseditor/settingseditor.h" |
8 #include "settingseditor/settingseditor.h" |
9 #include "version.h" |
9 #include "version.h" |
10 #include "document.h" |
10 #include "document.h" |
|
11 #include "uiutilities.h" |
11 |
12 |
12 MainWindow::MainWindow(QWidget *parent) : |
13 MainWindow::MainWindow(QWidget *parent) : |
13 QMainWindow{parent}, |
14 QMainWindow{parent}, |
14 ui{std::make_unique<Ui_MainWindow>()}, |
15 ui{std::make_unique<Ui_MainWindow>()}, |
15 documents{this}, |
16 documents{this}, |
16 settings{}, |
17 settings{}, |
17 libraries{this} |
18 libraries{this} |
18 { |
19 { |
19 this->ui->setupUi(this); |
20 this->ui->setupUi(this); |
|
21 defaultKeyboardShortcuts = uiutilities::makeKeySequenceMap(uiutilities::collectActions(this)); |
20 connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newModel); |
22 connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newModel); |
21 connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::openModel); |
23 connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::openModel); |
22 connect(ui->actionQuit, &QAction::triggered, this, &QMainWindow::close); |
24 connect(ui->actionQuit, &QAction::triggered, this, &QMainWindow::close); |
23 connect(ui->actionSettingsEditor, &QAction::triggered, this, &MainWindow::runSettingsEditor); |
25 connect(ui->actionSettingsEditor, &QAction::triggered, this, &MainWindow::runSettingsEditor); |
24 this->updateTitle(); |
26 this->updateTitle(); |
122 connect(document, &Document::splitterChanged, this, &MainWindow::handleDocumentSplitterChange); |
124 connect(document, &Document::splitterChanged, this, &MainWindow::handleDocumentSplitterChange); |
123 } |
125 } |
124 |
126 |
125 void MainWindow::runSettingsEditor() |
127 void MainWindow::runSettingsEditor() |
126 { |
128 { |
127 SettingsEditor settingsEditor{&this->settings, this}; |
129 SettingsEditor settingsEditor{&this->settings, this->defaultKeyboardShortcuts, this}; |
128 const int result = settingsEditor.exec(); |
130 const int result = settingsEditor.exec(); |
129 if (result == QDialog::Accepted) |
131 if (result == QDialog::Accepted) |
130 { |
132 { |
131 this->restoreSettings(); |
133 this->restoreSettings(); |
132 } |
134 } |