Connect custom script editor to shortcuts editor
This commit is contained in:
parent
a5a864926a
commit
1c081f2011
4 changed files with 18 additions and 12 deletions
|
@ -387,6 +387,7 @@ private:
|
||||||
void initTilesetEditor();
|
void initTilesetEditor();
|
||||||
bool initRegionMapEditor(bool silent = false);
|
bool initRegionMapEditor(bool silent = false);
|
||||||
void initShortcutsEditor();
|
void initShortcutsEditor();
|
||||||
|
void initCustomScriptsEditor();
|
||||||
void connectSubEditorsToShortcutsEditor();
|
void connectSubEditorsToShortcutsEditor();
|
||||||
|
|
||||||
bool isProjectOpen();
|
bool isProjectOpen();
|
||||||
|
|
|
@ -24,6 +24,9 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void reloadScriptEngine();
|
void reloadScriptEngine();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void applyUserShortcuts();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::CustomScriptsEditor *ui;
|
Ui::CustomScriptsEditor *ui;
|
||||||
|
|
||||||
|
@ -46,7 +49,6 @@ private:
|
||||||
void restoreWindowState();
|
void restoreWindowState();
|
||||||
void initShortcuts();
|
void initShortcuts();
|
||||||
QObjectList shortcutableObjects() const;
|
QObjectList shortcutableObjects() const;
|
||||||
void applyUserShortcuts();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void dialogButtonClicked(QAbstractButton *button);
|
void dialogButtonClicked(QAbstractButton *button);
|
||||||
|
|
|
@ -1811,6 +1811,11 @@ void MainWindow::connectSubEditorsToShortcutsEditor() {
|
||||||
if (regionMapEditor)
|
if (regionMapEditor)
|
||||||
connect(shortcutsEditor, &ShortcutsEditor::shortcutsSaved,
|
connect(shortcutsEditor, &ShortcutsEditor::shortcutsSaved,
|
||||||
regionMapEditor, &RegionMapEditor::applyUserShortcuts);
|
regionMapEditor, &RegionMapEditor::applyUserShortcuts);
|
||||||
|
|
||||||
|
if (!customScriptsEditor)
|
||||||
|
initCustomScriptsEditor();
|
||||||
|
connect(shortcutsEditor, &ShortcutsEditor::shortcutsSaved,
|
||||||
|
customScriptsEditor, &CustomScriptsEditor::applyUserShortcuts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionPencil_triggered()
|
void MainWindow::on_actionPencil_triggered()
|
||||||
|
@ -2734,15 +2739,18 @@ void MainWindow::on_actionProject_Settings_triggered() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionCustom_Scripts_triggered() {
|
void MainWindow::on_actionCustom_Scripts_triggered() {
|
||||||
if (!this->customScriptsEditor) {
|
if (!this->customScriptsEditor)
|
||||||
this->customScriptsEditor = new CustomScriptsEditor(this);
|
initCustomScriptsEditor();
|
||||||
connect(this->customScriptsEditor, &CustomScriptsEditor::reloadScriptEngine,
|
|
||||||
this, &MainWindow::reloadScriptEngine);
|
|
||||||
}
|
|
||||||
|
|
||||||
openSubWindow(this->customScriptsEditor);
|
openSubWindow(this->customScriptsEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::initCustomScriptsEditor() {
|
||||||
|
this->customScriptsEditor = new CustomScriptsEditor(this);
|
||||||
|
connect(this->customScriptsEditor, &CustomScriptsEditor::reloadScriptEngine,
|
||||||
|
this, &MainWindow::reloadScriptEngine);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::reloadScriptEngine() {
|
void MainWindow::reloadScriptEngine() {
|
||||||
Scripting::init(this);
|
Scripting::init(this);
|
||||||
this->ui->graphicsView_Map->clearOverlayMap();
|
this->ui->graphicsView_Map->clearOverlayMap();
|
||||||
|
|
|
@ -44,8 +44,7 @@ void CustomScriptsEditor::initShortcuts() {
|
||||||
shortcut_remove->setObjectName("shortcut_remove");
|
shortcut_remove->setObjectName("shortcut_remove");
|
||||||
shortcut_remove->setWhatsThis("Remove Selected Scripts");
|
shortcut_remove->setWhatsThis("Remove Selected Scripts");
|
||||||
|
|
||||||
// TODO: Prevent ambiguity with MainWindow
|
auto *shortcut_open = new Shortcut(QKeySequence(), this, SLOT(openSelectedScripts()));
|
||||||
auto *shortcut_open = new Shortcut(QKeySequence("Ctrl+O"), this, SLOT(openSelectedScripts()));
|
|
||||||
shortcut_open->setObjectName("shortcut_open");
|
shortcut_open->setObjectName("shortcut_open");
|
||||||
shortcut_open->setWhatsThis("Open Selected Scripts");
|
shortcut_open->setWhatsThis("Open Selected Scripts");
|
||||||
|
|
||||||
|
@ -57,9 +56,6 @@ void CustomScriptsEditor::initShortcuts() {
|
||||||
shortcut_reload->setObjectName("shortcut_reload");
|
shortcut_reload->setObjectName("shortcut_reload");
|
||||||
shortcut_reload->setWhatsThis("Reload Scripts");
|
shortcut_reload->setWhatsThis("Reload Scripts");
|
||||||
|
|
||||||
//connect(new QShortcut(QKeySequence("Backspace"), this), &QShortcut::activated, this, &CustomScriptsEditor::removeSelectedScripts);
|
|
||||||
//connect(new QShortcut(QKeySequence("Ctrl+O"), this), &QShortcut::activated, this, &CustomScriptsEditor::openSelectedScripts);
|
|
||||||
|
|
||||||
shortcutsConfig.load();
|
shortcutsConfig.load();
|
||||||
shortcutsConfig.setDefaultShortcuts(shortcutableObjects());
|
shortcutsConfig.setDefaultShortcuts(shortcutableObjects());
|
||||||
applyUserShortcuts();
|
applyUserShortcuts();
|
||||||
|
@ -78,7 +74,6 @@ QObjectList CustomScriptsEditor::shortcutableObjects() const {
|
||||||
return shortcutable_objects;
|
return shortcutable_objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Connect to shorcuts editor
|
|
||||||
void CustomScriptsEditor::applyUserShortcuts() {
|
void CustomScriptsEditor::applyUserShortcuts() {
|
||||||
for (auto *action : findChildren<QAction *>())
|
for (auto *action : findChildren<QAction *>())
|
||||||
if (!action->objectName().isEmpty())
|
if (!action->objectName().isEmpty())
|
||||||
|
|
Loading…
Reference in a new issue