Use Qt built-in functionality for opening scripts with default editor
This commit is contained in:
parent
378d5bb660
commit
65adc2bdd0
1 changed files with 3 additions and 22 deletions
|
@ -20,6 +20,7 @@
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
|
@ -554,28 +555,8 @@ void MainWindow::redo() {
|
||||||
|
|
||||||
// Open current map scripts in system default editor for .inc files
|
// Open current map scripts in system default editor for .inc files
|
||||||
void MainWindow::openInTextEditor() {
|
void MainWindow::openInTextEditor() {
|
||||||
QProcess *process = new QProcess(this);
|
QString path = QDir::cleanPath(editor->project->root + QDir::separator() + "data/maps/" + editor->map->name + "/scripts.inc");
|
||||||
QSysInfo sysInfo;
|
QDesktopServices::openUrl(QUrl(path));
|
||||||
process->setWorkingDirectory(editor->project->root);
|
|
||||||
|
|
||||||
#ifdef Q_OS_DARWIN
|
|
||||||
QString cmd = "open ";
|
|
||||||
#elif defined Q_OS_LINUX
|
|
||||||
QString cmd = "xdg-open ";
|
|
||||||
#elif defined Q_OS_WIN
|
|
||||||
QString cmd = "cmd /c start \"";
|
|
||||||
#else
|
|
||||||
qDebug() << "Functionality is not available with this OS ("
|
|
||||||
<< sysInfo.productType() << ")";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cmd += "data/maps/" + editor->map->name + "/scripts.inc";
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
cmd += "\"";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
process->start(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_action_Save_triggered() {
|
void MainWindow::on_action_Save_triggered() {
|
||||||
|
|
Loading…
Reference in a new issue