fix: can't execute bat file

This commit is contained in:
Roy Qu 2024-04-02 19:13:55 +08:00
parent 47c1fa21a0
commit bf245a7842
10 changed files with 264 additions and 201 deletions

View File

@ -1233,12 +1233,12 @@ void MainWindow::executeTool(PToolItem item)
case ToolItemInputOrigin::CurrentSelection:
e=mEditorList->getEditor();
if (e)
inputContent=e->selText().toUtf8();
inputContent=stringToByteArray(e->selText(), item->isUTF8);
break;
case ToolItemInputOrigin::WholeDocument:
e=mEditorList->getEditor();
if (e)
inputContent=e->text().toUtf8();
inputContent=stringToByteArray(e->text(), item->isUTF8);
break;
}
QString command;
@ -1253,8 +1253,10 @@ void MainWindow::executeTool(PToolItem item)
file.write(escapeCommandForPlatformShell(program, params).toLocal8Bit()
+ LINE_BREAKER);
file.close();
command = escapeCommandForPlatformShell(file.fileName(), params);
output = runAndGetOutput(file.fileName(), workDir, params, inputContent);
QString cmd="cmd";
QStringList args{"/C",file.fileName()};
command = escapeCommandForPlatformShell(cmd, args);
output = runAndGetOutput(cmd, workDir, args, inputContent);
}
} else {
command = escapeCommandForPlatformShell(program, params);
@ -1263,7 +1265,8 @@ void MainWindow::executeTool(PToolItem item)
switch(item->outputTarget) {
case ToolItemOutputTarget::RedirectToToolsOutputPanel:
logToolsOutput(tr(" - Command: %1").arg(command));
logToolsOutput(QString::fromUtf8(output));
logToolsOutput("");
logToolsOutput(byteArrayToString(output, item->isUTF8));
stretchMessagesPanel(true);
ui->tabMessages->setCurrentWidget(ui->tabToolsOutput);
break;
@ -1272,12 +1275,12 @@ void MainWindow::executeTool(PToolItem item)
case ToolItemOutputTarget::RepalceWholeDocument:
e=mEditorList->getEditor();
if (e)
e->replaceContent(QString::fromUtf8(output));
e->replaceContent(byteArrayToString(output, item->isUTF8));
break;
case ToolItemOutputTarget::ReplaceCurrentSelection:
e=mEditorList->getEditor();
if (e)
e->setSelText(QString::fromUtf8(output));
e->setSelText(byteArrayToString(output, item->isUTF8));
break;
}
}

View File

@ -73,6 +73,8 @@ ToolsGeneralWidget::ToolsGeneralWidget(const QString &name, const QString &group
this, &ToolsGeneralWidget::onEdited);
connect(ui->cbOutput, qOverload<int>(&QComboBox::currentIndexChanged),
this, &ToolsGeneralWidget::onEdited);
connect(ui->chkUTF8, &QCheckBox::stateChanged,
this, &ToolsGeneralWidget::onEdited);
}
ToolsGeneralWidget::~ToolsGeneralWidget()
@ -118,6 +120,7 @@ void ToolsGeneralWidget::finishEditing(bool askSave)
item->title = ui->txtTitle->text();
item->inputOrigin = static_cast<ToolItemInputOrigin>(ui->cbInput->currentIndex());
item->outputTarget = static_cast<ToolItemOutputTarget>(ui->cbOutput->currentIndex());
item->isUTF8 = ui->chkUTF8->isChecked();
mToolsModel.updateTool(mCurrentEditingRow, item);
}
@ -138,6 +141,7 @@ void ToolsGeneralWidget::prepareEdit(int row)
ui->txtTitle->setText(item->title);
ui->cbInput->setCurrentIndex(static_cast<int>(item->inputOrigin));
ui->cbOutput->setCurrentIndex(static_cast<int>(item->outputTarget));
ui->chkUTF8->setChecked(item->isUTF8);
showEditPanel(true);
ui->txtTitle->setFocus();
mEdited = false;
@ -290,6 +294,7 @@ void ToolsGeneralWidget::on_btnAdd_clicked()
item->title = tr("untitled");
item->inputOrigin = ToolItemInputOrigin::None;
item->outputTarget = ToolItemOutputTarget::RedirectToToolsOutputPanel;
item->isUTF8 = false;
mToolsModel.addTool(item);
int row = mToolsModel.tools().count() - 1;
QModelIndex index=mToolsModel.index(row);

View File

@ -142,7 +142,95 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="9" column="0" colspan="3">
<item row="1" column="2">
<widget class="QToolButton" name="btnBrowseProgram">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="btnBrowseWorkingDirectory">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="QComboBox" name="cbOutput"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Program</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Output To</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="txtProgram"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Parameters</string>
</property>
</widget>
</item>
<item row="11" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Redirect Input</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="txtTitle"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Working Directory</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="txtParameters"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Title</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="10" column="0" colspan="3">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
@ -183,34 +271,7 @@
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Parameters</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Program</string>
</property>
</widget>
</item>
<item row="10" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="11" column="0" colspan="3">
<item row="12" column="0" colspan="3">
<widget class="QWidget" name="widget_3" native="true">
<property name="minimumSize">
<size>
@ -261,66 +322,9 @@
</layout>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="txtTitle"/>
</item>
<item row="5" column="1" colspan="2">
<widget class="QComboBox" name="cbInput"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Working Directory</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="QComboBox" name="cbOutput"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Output To</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="txtDirectory"/>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="btnBrowseProgram">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="btnBrowseWorkingDirectory">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="txtProgram"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Redirect Input</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="txtParameters"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Title</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QLineEdit" name="txtDemo">
<property name="readOnly">
@ -331,10 +335,13 @@
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QComboBox" name="cbInput"/>
</item>
<item row="7" column="0" colspan="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QCheckBox" name="chkUTF8">
<property name="text">
<string>Use UTF8 as the encoding</string>
</property>
</widget>
</item>
@ -351,6 +358,7 @@
</widget>
<tabstops>
<tabstop>btnAdd</tabstop>
<tabstop>btnEdit</tabstop>
<tabstop>btnRemove</tabstop>
<tabstop>lstTools</tabstop>
<tabstop>txtTitle</tabstop>
@ -362,6 +370,7 @@
<tabstop>txtDemo</tabstop>
<tabstop>cbInput</tabstop>
<tabstop>cbOutput</tabstop>
<tabstop>chkUTF8</tabstop>
<tabstop>btnInsertMacro</tabstop>
<tabstop>cbMacros</tabstop>
<tabstop>btnEditOk</tabstop>

View File

@ -44,9 +44,10 @@ void ToolsManager::load()
item->program = "rm";
#endif
item->workingDirectory = "<SOURCEPATH>";
item->parameters = "<EXENAME>";
item->parameters = "/q /f <EXENAME>";
item->inputOrigin = ToolItemInputOrigin::None;
item->outputTarget = ToolItemOutputTarget::RedirectToToolsOutputPanel;
item->isUTF8 = false;
mTools.append(item);
//#ifdef Q_OS_WIN
// item = std::make_shared<ToolItem>();
@ -99,6 +100,7 @@ void ToolsManager::load()
item->parameters = object["parameters"].toString();
item->outputTarget = static_cast<ToolItemOutputTarget>(object["outputTarget"].toInt(0));
item->inputOrigin= static_cast<ToolItemInputOrigin>(object["inputOrigin"].toInt(0));
item->isUTF8 = object["isUTF8"].toBool(true);
mTools.append(item);
}
}
@ -124,6 +126,7 @@ void ToolsManager::save()
object["parameters"]=tool->parameters;
object["outputTarget"]=static_cast<int>(tool->outputTarget);
object["inputOrigin"]=static_cast<int>(tool->inputOrigin);
object["isUTF8"]=tool->isUTF8;
array.append(object);
}
QJsonDocument doc;

View File

@ -41,6 +41,7 @@ struct ToolItem {
QString parameters;
ToolItemInputOrigin inputOrigin;
ToolItemOutputTarget outputTarget;
bool isUTF8;
};
using PToolItem = std::shared_ptr<ToolItem>;

View File

@ -4276,7 +4276,7 @@
<name>MainWindow</name>
<message>
<location filename="../mainwindow.ui" line="+14"/>
<location filename="../mainwindow.cpp" line="+1322"/>
<location filename="../mainwindow.cpp" line="+1324"/>
<source>Red Panda C++</source>
<translation>Red Panda C++</translation>
</message>
@ -5483,13 +5483,13 @@
<translation>Ctrl+Shift+Down</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="-8403"/>
<location filename="../mainwindow.cpp" line="-8406"/>
<location line="+72"/>
<location line="+9"/>
<location line="+8"/>
<location line="+9"/>
<location line="+61"/>
<location line="+1356"/>
<location line="+1359"/>
<location line="+1799"/>
<location line="+117"/>
<location line="+1866"/>
@ -5501,7 +5501,7 @@
<translation>Erro</translation>
</message>
<message>
<location line="-9503"/>
<location line="-9506"/>
<source>New</source>
<translation>Novo</translation>
</message>
@ -5527,18 +5527,18 @@
</message>
<message>
<location line="+85"/>
<location line="+8307"/>
<location line="+8310"/>
<source>Problem Set %1</source>
<translation>Conjunto de problemas %1</translation>
</message>
<message>
<location line="-7660"/>
<location line="-7663"/>
<location line="+6"/>
<source>Load Theme Error</source>
<translation>Erro ao carregar tema</translation>
</message>
<message>
<location line="+322"/>
<location line="+325"/>
<location line="+2"/>
<location line="+30"/>
<location line="+2"/>
@ -5731,12 +5731,12 @@
<translation>Propriedades...</translation>
</message>
<message>
<location line="-1603"/>
<location line="-1604"/>
<source> - Command: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+323"/>
<location line="+324"/>
<source>Line: %1/%2 Col: %3 Sel: %4</source>
<translation type="unfinished"></translation>
</message>
@ -7018,7 +7018,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="-5170"/>
<location filename="../mainwindow.cpp" line="-5173"/>
<source>Exact</source>
<translation type="unfinished"></translation>
</message>
@ -7033,7 +7033,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7040"/>
<location line="+7043"/>
<source>Folder Not Empty</source>
<translation type="unfinished"></translation>
</message>
@ -8381,7 +8381,7 @@
<context>
<name>QFileSystemModel</name>
<message>
<location filename="../mainwindow.cpp" line="-1211"/>
<location filename="../mainwindow.cpp" line="-1214"/>
<source>&lt;b&gt;The name &quot;%1&quot; cannot be used.&lt;/b&gt;&lt;p&gt;Try using another name, with fewer characters or no punctuation marks.</source>
<translation type="unfinished"></translation>
</message>
@ -8681,7 +8681,7 @@
</message>
<message>
<location filename="../editorlist.cpp" line="+178"/>
<location filename="../mainwindow.cpp" line="+3224"/>
<location filename="../mainwindow.cpp" line="+3227"/>
<source>Save</source>
<translation>Salvar</translation>
</message>
@ -9000,7 +9000,7 @@
<translation type="vanished">Índice %1 fora dos limites</translation>
</message>
<message>
<location filename="../utils.cpp" line="+480"/>
<location filename="../utils.cpp" line="+488"/>
<source>bytes</source>
<translation>bytes</translation>
</message>
@ -10693,23 +10693,28 @@
<translation>Remover</translation>
</message>
<message>
<location line="+234"/>
<location line="+123"/>
<source>Output To</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+10"/>
<location line="+172"/>
<source>Use UTF8 as the encoding</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-196"/>
<location line="+7"/>
<source>Browse</source>
<translation>Navegar</translation>
</message>
<message>
<location line="-111"/>
<location line="+27"/>
<source>Parameters</source>
<translation>Parâmetros</translation>
</message>
<message>
<location line="+61"/>
<location line="+129"/>
<source>Ok</source>
<translation>Ok</translation>
</message>
@ -10719,12 +10724,12 @@
<translation>Cancelar</translation>
</message>
<message>
<location line="+53"/>
<location line="-116"/>
<source>Redirect Input</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+10"/>
<location line="+20"/>
<source>Title</source>
<translation>Título</translation>
</message>
@ -10733,22 +10738,22 @@
<translation type="vanished">Pausar a console após término do programa</translation>
</message>
<message>
<location line="-124"/>
<location line="-57"/>
<source>Program</source>
<translation>Programa</translation>
</message>
<message>
<location line="+77"/>
<location line="+47"/>
<source>Working Directory</source>
<translation>Pasta de trabalho</translation>
</message>
<message>
<location line="-110"/>
<location line="+39"/>
<source>Insert Macro</source>
<translation>Inserir macro</translation>
</message>
<message>
<location filename="../settingsdialog/toolsgeneralwidget.cpp" line="+108"/>
<location filename="../settingsdialog/toolsgeneralwidget.cpp" line="+110"/>
<source>Save Changes?</source>
<translation>Salvar alterações?</translation>
</message>
@ -10757,7 +10762,7 @@
<translation type="vanished">Quer salvar as alterações na ferramenta atual?</translation>
</message>
<message>
<location line="+246"/>
<location line="+249"/>
<source>Choose Folder</source>
<translation>Escolher pasta</translation>
</message>
@ -10771,7 +10776,7 @@
<translation type="vanished">Arquivos executáveis (*.exe)</translation>
</message>
<message>
<location line="-326"/>
<location line="-331"/>
<location line="+6"/>
<source>None</source>
<translation type="unfinished"></translation>
@ -10802,7 +10807,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+61"/>
<location line="+63"/>
<source>Do you want to save changes to &quot;%1&quot;?</source>
<translation type="unfinished"></translation>
</message>
@ -10817,7 +10822,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+186"/>
<location line="+188"/>
<source>untitled</source>
<translation type="unfinished">sem nome</translation>
</message>
@ -10873,7 +10878,7 @@
<translation>Remover compilado</translation>
</message>
<message>
<location line="+27"/>
<location line="+28"/>
<location line="+13"/>
<source>Read tools config failed</source>
<translation>Falha ao ler configurações de ferramentas</translation>
@ -10889,18 +10894,18 @@
<translation>Falha ao ler arquivo de configurações de ferramentas &apos;%1&apos;: %2</translation>
</message>
<message>
<location line="+31"/>
<location line="+21"/>
<location line="+32"/>
<location line="+22"/>
<source>Save tools config failed</source>
<translation>Falha ao salvar configurações de ferramentas</translation>
</message>
<message>
<location line="-20"/>
<location line="-21"/>
<source>Can&apos;t open tools config file &apos;%1&apos; for write.</source>
<translation>Impossível gravar o arquivo de configurações de ferramentas &apos;%1&apos;</translation>
</message>
<message>
<location line="+21"/>
<location line="+22"/>
<source>Write to tools config file &apos;%1&apos; failed.</source>
<translation>Falha ao gravar o arquivo de configurações &apos;%1&apos;.</translation>
</message>

View File

@ -4629,7 +4629,7 @@ p, li { white-space: pre-wrap; }
<name>MainWindow</name>
<message>
<location filename="../mainwindow.ui" line="+14"/>
<location filename="../mainwindow.cpp" line="+1322"/>
<location filename="../mainwindow.cpp" line="+1324"/>
<source>Red Panda C++</source>
<translation>C++</translation>
</message>
@ -4790,7 +4790,7 @@ p, li { white-space: pre-wrap; }
<translation type="vanished">2</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="-1704"/>
<location filename="../mainwindow.cpp" line="-1707"/>
<source>New</source>
<translation></translation>
</message>
@ -4923,7 +4923,7 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="+5"/>
<location filename="../mainwindow.cpp" line="+2704"/>
<location filename="../mainwindow.cpp" line="+2707"/>
<location line="+27"/>
<location line="+200"/>
<source>Copy</source>
@ -6202,12 +6202,12 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location line="-3405"/>
<location line="-3408"/>
<source>Recent Files</source>
<translation></translation>
</message>
<message>
<location line="+1066"/>
<location line="+1069"/>
<location line="+2"/>
<location line="+30"/>
<location line="+2"/>
@ -6529,7 +6529,7 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="-2912"/>
<location filename="../mainwindow.cpp" line="-2915"/>
<source>Export</source>
<translation></translation>
</message>
@ -6540,7 +6540,7 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="+85"/>
<location line="+8307"/>
<location line="+8310"/>
<source>Problem Set %1</source>
<translation>%1</translation>
</message>
@ -6599,12 +6599,12 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location line="-1656"/>
<location line="-1657"/>
<source> - Command: %1</source>
<translation>- : %1</translation>
</message>
<message>
<location line="+58"/>
<location line="+59"/>
<source> %1 Version</source>
<translation> %1</translation>
</message>
@ -7496,13 +7496,13 @@ p, li { white-space: pre-wrap; }
<translation>%1</translation>
</message>
<message>
<location line="-8551"/>
<location line="-8554"/>
<location line="+72"/>
<location line="+9"/>
<location line="+8"/>
<location line="+9"/>
<location line="+61"/>
<location line="+1356"/>
<location line="+1359"/>
<location line="+1799"/>
<location line="+117"/>
<location line="+1866"/>
@ -7514,7 +7514,7 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location line="-9481"/>
<location line="-9484"/>
<source>Recent Projects</source>
<translation></translation>
</message>
@ -7525,7 +7525,7 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location line="+450"/>
<location line="+453"/>
<location line="+22"/>
<source>Clear History</source>
<translation></translation>
@ -7589,7 +7589,7 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location line="-9582"/>
<location line="-9585"/>
<source>Exact</source>
<translation></translation>
</message>
@ -7608,7 +7608,7 @@ p, li { white-space: pre-wrap; }
<translation type="vanished">: %1 : %2 (%3) : %4</translation>
</message>
<message>
<location line="+2309"/>
<location line="+2312"/>
<location line="+123"/>
<location line="+2724"/>
<source>If you are using the Release compiler set, please use choose the Debug version from toolbar.</source>
@ -9057,7 +9057,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>QFileSystemModel</name>
<message>
<location filename="../mainwindow.cpp" line="-6537"/>
<location filename="../mainwindow.cpp" line="-6540"/>
<source>&lt;b&gt;The name &quot;%1&quot; cannot be used.&lt;/b&gt;&lt;p&gt;Try using another name, with fewer characters or no punctuation marks.</source>
<translation>&lt;b&gt; &quot;%1&quot; 使&lt;/b&gt;&lt;p&gt;使</translation>
</message>
@ -9066,7 +9066,7 @@ p, li { white-space: pre-wrap; }
<name>QObject</name>
<message>
<location filename="../editorlist.cpp" line="+178"/>
<location filename="../mainwindow.cpp" line="+3224"/>
<location filename="../mainwindow.cpp" line="+3227"/>
<source>Save</source>
<translation></translation>
</message>
@ -9551,7 +9551,7 @@ p, li { white-space: pre-wrap; }
<translation type="vanished">&quot;%1&quot;</translation>
</message>
<message>
<location filename="../utils.cpp" line="+480"/>
<location filename="../utils.cpp" line="+488"/>
<source>bytes</source>
<translation></translation>
</message>
@ -11589,23 +11589,28 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location line="+234"/>
<location line="+123"/>
<source>Output To</source>
<translation></translation>
</message>
<message>
<location line="+10"/>
<location line="+172"/>
<source>Use UTF8 as the encoding</source>
<translation>使UTF8文件编码</translation>
</message>
<message>
<location line="-196"/>
<location line="+7"/>
<source>Browse</source>
<translation></translation>
</message>
<message>
<location line="-111"/>
<location line="+27"/>
<source>Parameters</source>
<translation></translation>
</message>
<message>
<location line="+61"/>
<location line="+129"/>
<source>Ok</source>
<translation></translation>
</message>
@ -11615,12 +11620,12 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location line="+53"/>
<location line="-116"/>
<source>Redirect Input</source>
<translation></translation>
</message>
<message>
<location line="+10"/>
<location line="+20"/>
<source>Title</source>
<translation></translation>
</message>
@ -11629,22 +11634,22 @@ p, li { white-space: pre-wrap; }
<translation type="vanished"></translation>
</message>
<message>
<location line="-124"/>
<location line="-57"/>
<source>Program</source>
<translation></translation>
</message>
<message>
<location line="+77"/>
<location line="+47"/>
<source>Working Directory</source>
<translation></translation>
</message>
<message>
<location line="-110"/>
<location line="+39"/>
<source>Insert Macro</source>
<translation></translation>
</message>
<message>
<location filename="../settingsdialog/toolsgeneralwidget.cpp" line="+108"/>
<location filename="../settingsdialog/toolsgeneralwidget.cpp" line="+110"/>
<source>Save Changes?</source>
<translation></translation>
</message>
@ -11653,7 +11658,7 @@ p, li { white-space: pre-wrap; }
<translation type="vanished"></translation>
</message>
<message>
<location line="-69"/>
<location line="-71"/>
<location line="+6"/>
<source>None</source>
<translation></translation>
@ -11684,7 +11689,7 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location line="+61"/>
<location line="+63"/>
<source>Do you want to save changes to &quot;%1&quot;?</source>
<translation>&quot;%1&quot;</translation>
</message>
@ -11699,12 +11704,12 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location line="+186"/>
<location line="+188"/>
<source>untitled</source>
<translation></translation>
</message>
<message>
<location line="+64"/>
<location line="+65"/>
<source>Choose Folder</source>
<translation></translation>
</message>
@ -11777,7 +11782,7 @@ p, li { white-space: pre-wrap; }
<translation type="vanished"></translation>
</message>
<message>
<location line="+27"/>
<location line="+28"/>
<location line="+13"/>
<source>Read tools config failed</source>
<translation></translation>
@ -11793,18 +11798,18 @@ p, li { white-space: pre-wrap; }
<translation>&apos;%1&apos;:%2</translation>
</message>
<message>
<location line="+31"/>
<location line="+21"/>
<location line="+32"/>
<location line="+22"/>
<source>Save tools config failed</source>
<translation></translation>
</message>
<message>
<location line="-20"/>
<location line="-21"/>
<source>Can&apos;t open tools config file &apos;%1&apos; for write.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location line="+21"/>
<location line="+22"/>
<source>Write to tools config file &apos;%1&apos; failed.</source>
<oldsource>Write to tool config file &apos;%1&apos; failed.</oldsource>
<translation>&apos;%1&apos;</translation>

View File

@ -4061,7 +4061,7 @@
<name>MainWindow</name>
<message>
<location filename="../mainwindow.ui" line="+14"/>
<location filename="../mainwindow.cpp" line="+1322"/>
<location filename="../mainwindow.cpp" line="+1324"/>
<source>Red Panda C++</source>
<translation type="unfinished"></translation>
</message>
@ -5255,13 +5255,13 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="-8403"/>
<location filename="../mainwindow.cpp" line="-8406"/>
<location line="+72"/>
<location line="+9"/>
<location line="+8"/>
<location line="+9"/>
<location line="+61"/>
<location line="+1356"/>
<location line="+1359"/>
<location line="+1799"/>
<location line="+117"/>
<location line="+1866"/>
@ -5273,7 +5273,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-9503"/>
<location line="-9506"/>
<source>New</source>
<translation type="unfinished"></translation>
</message>
@ -5299,18 +5299,18 @@
</message>
<message>
<location line="+85"/>
<location line="+8307"/>
<location line="+8310"/>
<source>Problem Set %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-7660"/>
<location line="-7663"/>
<location line="+6"/>
<source>Load Theme Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+322"/>
<location line="+325"/>
<location line="+2"/>
<location line="+30"/>
<location line="+2"/>
@ -5444,12 +5444,12 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-1603"/>
<location line="-1604"/>
<source> - Command: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+323"/>
<location line="+324"/>
<source>Line: %1/%2 Col: %3 Sel: %4</source>
<translation type="unfinished"></translation>
</message>
@ -6711,7 +6711,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="-5170"/>
<location filename="../mainwindow.cpp" line="-5173"/>
<source>Exact</source>
<translation type="unfinished"></translation>
</message>
@ -6726,7 +6726,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7040"/>
<location line="+7043"/>
<source>Folder Not Empty</source>
<translation type="unfinished"></translation>
</message>
@ -7981,7 +7981,7 @@
<context>
<name>QFileSystemModel</name>
<message>
<location filename="../mainwindow.cpp" line="-1211"/>
<location filename="../mainwindow.cpp" line="-1214"/>
<source>&lt;b&gt;The name &quot;%1&quot; cannot be used.&lt;/b&gt;&lt;p&gt;Try using another name, with fewer characters or no punctuation marks.</source>
<translation type="unfinished"></translation>
</message>
@ -8274,7 +8274,7 @@
</message>
<message>
<location filename="../editorlist.cpp" line="+178"/>
<location filename="../mainwindow.cpp" line="+3224"/>
<location filename="../mainwindow.cpp" line="+3227"/>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
@ -8483,7 +8483,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../utils.cpp" line="+480"/>
<location filename="../utils.cpp" line="+488"/>
<source>bytes</source>
<translation type="unfinished"></translation>
</message>
@ -9924,23 +9924,28 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+234"/>
<location line="+123"/>
<source>Output To</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+10"/>
<location line="+172"/>
<source>Use UTF8 as the encoding</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-196"/>
<location line="+7"/>
<source>Browse</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-111"/>
<location line="+27"/>
<source>Parameters</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+61"/>
<location line="+129"/>
<source>Ok</source>
<translation type="unfinished"></translation>
</message>
@ -9950,37 +9955,37 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+53"/>
<location line="-116"/>
<source>Redirect Input</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+10"/>
<location line="+20"/>
<source>Title</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-124"/>
<location line="-57"/>
<source>Program</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+77"/>
<location line="+47"/>
<source>Working Directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-110"/>
<location line="+39"/>
<source>Insert Macro</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settingsdialog/toolsgeneralwidget.cpp" line="+108"/>
<location filename="../settingsdialog/toolsgeneralwidget.cpp" line="+110"/>
<source>Save Changes?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+246"/>
<location line="+249"/>
<source>Choose Folder</source>
<translation type="unfinished"></translation>
</message>
@ -9990,12 +9995,12 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-256"/>
<location line="-259"/>
<source>Do you want to save changes to &quot;%1&quot;?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-70"/>
<location line="-72"/>
<location line="+6"/>
<source>None</source>
<translation type="unfinished"></translation>
@ -10026,7 +10031,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+55"/>
<location line="+57"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
@ -10036,7 +10041,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+186"/>
<location line="+188"/>
<source>untitled</source>
<translation type="unfinished"></translation>
</message>
@ -10092,7 +10097,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+27"/>
<location line="+28"/>
<location line="+13"/>
<source>Read tools config failed</source>
<translation type="unfinished"></translation>
@ -10108,18 +10113,18 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+31"/>
<location line="+21"/>
<location line="+32"/>
<location line="+22"/>
<source>Save tools config failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-20"/>
<location line="-21"/>
<source>Can&apos;t open tools config file &apos;%1&apos; for write.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+21"/>
<location line="+22"/>
<source>Write to tools config file &apos;%1&apos; failed.</source>
<translation type="unfinished"></translation>
</message>

View File

@ -357,6 +357,7 @@ QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const
{
QProcess process;
QByteArray result;
bool errorOccurred = false;
if (env.isEmpty()) {
if (inheritEnvironment) {
process.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
@ -375,12 +376,19 @@ QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const
[&](){
result.append(process.readAllStandardOutput());
});
process.connect(&process, &QProcess::errorOccurred,
[&](){
errorOccurred= true;
});
process.start(cmd,arguments);
if (!inputContent.isEmpty()) {
process.write(inputContent);
}
process.closeWriteChannel();
process.waitForFinished();
if (errorOccurred) {
result += process.errorString().toUtf8();
}
return result;
}
@ -613,3 +621,19 @@ QString osArch()
return QSysInfo::currentCpuArchitecture();
#endif
}
QString byteArrayToString(const QByteArray &content, bool isUTF8)
{
if (isUTF8)
return QString::fromUtf8(content);
else
return QString::fromLocal8Bit(content);
}
QByteArray stringToByteArray(const QString &content, bool isUTF8)
{
if (isUTF8)
return content.toUtf8();
else
return content.toLocal8Bit();
}

View File

@ -173,6 +173,9 @@ QStringList platformCommandForTerminalArgsPreview();
QString appArch();
QString osArch();
QString byteArrayToString(const QByteArray &content, bool isUTF8);
QByteArray stringToByteArray(const QString& content, bool isUTF8);
#ifdef _MSC_VER
#define __builtin_unreachable() (__assume(0))
#endif