Fix QProcess::splitCommand() dependency on Qt 5.15.
Fix shortcut for Open Map Scripts (Due to merge).
This commit is contained in:
parent
1d29a53237
commit
3a04f59cb0
5 changed files with 56 additions and 6 deletions
|
@ -63,6 +63,8 @@ public:
|
||||||
static QString &removeLineComments(QString &text, const QString &commentSymbol);
|
static QString &removeLineComments(QString &text, const QString &commentSymbol);
|
||||||
static QString &removeLineComments(QString &text, const QStringList &commentSymbols);
|
static QString &removeLineComments(QString &text, const QStringList &commentSymbols);
|
||||||
|
|
||||||
|
static QStringList splitShellCommand(QStringView command);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString root;
|
QString root;
|
||||||
QString text;
|
QString text;
|
||||||
|
|
|
@ -165,7 +165,7 @@ FORMS += forms/mainwindow.ui \
|
||||||
forms/aboutporymap.ui \
|
forms/aboutporymap.ui \
|
||||||
forms/newtilesetdialog.ui \
|
forms/newtilesetdialog.ui \
|
||||||
forms/mapimageexporter.ui \
|
forms/mapimageexporter.ui \
|
||||||
forms/shortcutseditor.ui
|
forms/shortcutseditor.ui \
|
||||||
forms/preferenceeditor.ui
|
forms/preferenceeditor.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
|
|
|
@ -487,3 +487,51 @@ QString &ParseUtil::removeLineComments(QString &text, const QStringList &comment
|
||||||
removeLineComments(text, commentSymbol);
|
removeLineComments(text, commentSymbol);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
|
QStringList ParseUtil::splitShellCommand(QStringView command) {
|
||||||
|
return QProcess::splitCommand(command);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// The source for QProcess::splitCommand() as of Qt 5.15.2
|
||||||
|
QStringList ParseUtil::splitShellCommand(QStringView command) {
|
||||||
|
QStringList args;
|
||||||
|
QString tmp;
|
||||||
|
int quoteCount = 0;
|
||||||
|
bool inQuote = false;
|
||||||
|
|
||||||
|
// handle quoting. tokens can be surrounded by double quotes
|
||||||
|
// "hello world". three consecutive double quotes represent
|
||||||
|
// the quote character itself.
|
||||||
|
for (int i = 0; i < command.size(); ++i) {
|
||||||
|
if (command.at(i) == QLatin1Char('"')) {
|
||||||
|
++quoteCount;
|
||||||
|
if (quoteCount == 3) {
|
||||||
|
// third consecutive quote
|
||||||
|
quoteCount = 0;
|
||||||
|
tmp += command.at(i);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (quoteCount) {
|
||||||
|
if (quoteCount == 1)
|
||||||
|
inQuote = !inQuote;
|
||||||
|
quoteCount = 0;
|
||||||
|
}
|
||||||
|
if (!inQuote && command.at(i).isSpace()) {
|
||||||
|
if (!tmp.isEmpty()) {
|
||||||
|
args += tmp;
|
||||||
|
tmp.clear();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tmp += command.at(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!tmp.isEmpty())
|
||||||
|
args += tmp;
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -2084,7 +2084,7 @@ bool Editor::startDetachedProcess(const QString &command, const QString &working
|
||||||
process.setNativeArguments("/c " + command);
|
process.setNativeArguments("/c " + command);
|
||||||
process.setWorkingDirectory(workingDirectory);
|
process.setWorkingDirectory(workingDirectory);
|
||||||
#else
|
#else
|
||||||
QStringList arguments = QProcess::splitCommand(command);
|
QStringList arguments = ParseUtil::splitShellCommand(command);
|
||||||
process.setProgram(arguments.takeFirst());
|
process.setProgram(arguments.takeFirst());
|
||||||
process.setArguments(arguments);
|
process.setArguments(arguments);
|
||||||
process.setWorkingDirectory(workingDirectory);
|
process.setWorkingDirectory(workingDirectory);
|
||||||
|
|
|
@ -144,9 +144,9 @@ void MainWindow::initExtraShortcuts() {
|
||||||
shortcutCollapse_All->setObjectName("shortcutCollapse_All");
|
shortcutCollapse_All->setObjectName("shortcutCollapse_All");
|
||||||
shortcutCollapse_All->setWhatsThis("Map List: Collapse all folders");
|
shortcutCollapse_All->setWhatsThis("Map List: Collapse all folders");
|
||||||
|
|
||||||
auto *shortcutNew_Event = new Shortcut(QKeySequence(), this, SLOT(on_toolButton_Open_Scripts_clicked()));
|
auto *shortcut_Open_Scripts = new Shortcut(QKeySequence(), ui->toolButton_Open_Scripts, SLOT(click()));
|
||||||
shortcutNew_Event->setObjectName("shortcut_Open_Scripts");
|
shortcut_Open_Scripts->setObjectName("shortcut_Open_Scripts");
|
||||||
shortcutNew_Event->setWhatsThis("Open Map Scripts");
|
shortcut_Open_Scripts->setWhatsThis("Open Map Scripts");
|
||||||
}
|
}
|
||||||
|
|
||||||
QObjectList MainWindow::shortcutableObjects() const {
|
QObjectList MainWindow::shortcutableObjects() const {
|
||||||
|
@ -231,7 +231,7 @@ void MainWindow::initEditor() {
|
||||||
connect(this->editor, SIGNAL(currentMetatilesSelectionChanged()), this, SLOT(currentMetatilesSelectionChanged()));
|
connect(this->editor, SIGNAL(currentMetatilesSelectionChanged()), this, SLOT(currentMetatilesSelectionChanged()));
|
||||||
connect(this->editor, SIGNAL(wildMonDataChanged()), this, SLOT(onWildMonDataChanged()));
|
connect(this->editor, SIGNAL(wildMonDataChanged()), this, SLOT(onWildMonDataChanged()));
|
||||||
connect(this->editor, &Editor::mapRulerStatusChanged, this, &MainWindow::onMapRulerStatusChanged);
|
connect(this->editor, &Editor::mapRulerStatusChanged, this, &MainWindow::onMapRulerStatusChanged);
|
||||||
connect(ui->toolButton_Open_Scripts, &QToolButton::pressed, this->editor, QOverload<>::of(&Editor::openMapScripts));
|
connect(ui->toolButton_Open_Scripts, &QToolButton::pressed, this->editor, &Editor::openMapScripts);
|
||||||
connect(ui->actionOpen_Project_in_Text_Editor, &QAction::triggered, this->editor, &Editor::openProjectInTextEditor);
|
connect(ui->actionOpen_Project_in_Text_Editor, &QAction::triggered, this->editor, &Editor::openProjectInTextEditor);
|
||||||
|
|
||||||
this->loadUserSettings();
|
this->loadUserSettings();
|
||||||
|
|
Loading…
Reference in a new issue