Merge pull request #24 from garakmon/open-scripts

"Open Map Scripts" button
This commit is contained in:
Marcus Huderle 2018-09-13 16:41:38 -05:00 committed by GitHub
commit 4313662200
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 13 deletions

View file

@ -15,8 +15,12 @@
#include <QSpacerItem>
#include <QFont>
#include <QScrollBar>
#include <QPushButton>
#include <QMessageBox>
#include <QDialogButtonBox>
#include <QProcess>
#include <QSysInfo>
#include <QDesktopServices>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
@ -549,6 +553,12 @@ void MainWindow::redo() {
editor->redo();
}
// Open current map scripts in system default editor for .inc files
void MainWindow::openInTextEditor() {
QString path = QDir::cleanPath("file://" + editor->project->root + QDir::separator() + "data/maps/" + editor->map->name + "/scripts.inc");
QDesktopServices::openUrl(QUrl(path));
}
void MainWindow::on_action_Save_triggered() {
editor->save();
updateMapList();
@ -881,6 +891,11 @@ void MainWindow::on_toolButton_deleteObject_clicked()
}
}
void MainWindow::on_toolButton_Open_Scripts_clicked()
{
openInTextEditor();
}
void MainWindow::on_toolButton_Paint_clicked()
{
editor->map_edit_mode = "paint";

View file

@ -37,6 +37,8 @@ private slots:
void undo();
void redo();
void openInTextEditor();
void onLoadMapRequested(QString, QString);
void onMapChanged(Map *map);
void onMapNeedsRedrawing(Map *map);
@ -59,6 +61,7 @@ private slots:
void on_actionRedo_triggered();
void on_toolButton_deleteObject_clicked();
void on_toolButton_Open_Scripts_clicked();
void addNewEvent(QString);
void updateSelectedObjects();

View file

@ -334,8 +334,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>429</width>
<height>620</height>
<width>462</width>
<height>599</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_8">
@ -708,7 +708,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>315</width>
<width>252</width>
<height>86</height>
</rect>
</property>
@ -812,10 +812,10 @@
</property>
<property name="geometry">
<rect>
<x>0</x>
<x>8</x>
<y>0</y>
<width>365</width>
<height>405</height>
<width>323</width>
<height>368</height>
</rect>
</property>
<property name="sizePolicy">
@ -1050,8 +1050,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>381</width>
<height>657</height>
<width>371</width>
<height>643</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_7">
@ -1216,8 +1216,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>584</height>
<width>410</width>
<height>560</height>
</rect>
</property>
<property name="sizePolicy">
@ -1330,6 +1330,29 @@
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton_Open_Scripts">
<property name="text">
<string>Open Map Scripts</string>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_20">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
@ -1849,8 +1872,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>826</width>
<height>557</height>
<width>818</width>
<height>539</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_14">
@ -2022,7 +2045,7 @@
<x>0</x>
<y>0</y>
<width>1117</width>
<height>21</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">