Core: Inline externaltoolconfig.ui

Also collapse Core::ExternalToolConfig and Core::Internal::ExternalToolConfig
translation contexts.

Change-Id: I5764a85d8cdb33158a8ff770d5a769a752a051af
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2022-09-23 16:46:51 +02:00
parent aed001650a
commit 2d203763e8
16 changed files with 243 additions and 500 deletions

View File

@@ -29535,7 +29535,7 @@ Místní přivedení nejsou použita na hlavní větev.</translation>
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Form</source> <source>Form</source>
<translation>Formulář</translation> <translation>Formulář</translation>

View File

@@ -7383,7 +7383,7 @@ Vil du dræbe den?</translation>
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Add tool.</source> <source>Add tool.</source>
<translation>Tilføj værktøj.</translation> <translation>Tilføj værktøj.</translation>

View File

@@ -13229,7 +13229,7 @@ Lokale Pull-Operationen werden nicht auf den Master-Branch angewandt.</translati
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Add</source> <source>Add</source>
<translation>Hinzufügen</translation> <translation>Hinzufügen</translation>

View File

@@ -32803,7 +32803,7 @@ Les pulls locaux ne sont pas appliqués à la branche maître. </translation>
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Form</source> <source>Form</source>
<translation>Formulaire</translation> <translation>Formulaire</translation>

View File

@@ -2123,7 +2123,7 @@ Međutim, korištenje opuštenih i proširenih pravila također znači da nije m
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Add tool.</source> <source>Add tool.</source>
<translation>Dodaj alat.</translation> <translation>Dodaj alat.</translation>

View File

@@ -1266,7 +1266,7 @@ Local pulls are not applied to the master branch.</source>
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Form</source> <source>Form</source>
<translation></translation> <translation></translation>
@@ -50467,26 +50467,6 @@ Output:
<extracomment>Sample external tool text</extracomment> <extracomment>Sample external tool text</extracomment>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Add Tool</source>
<translation></translation>
</message>
<message>
<source>Add Category</source>
<translation></translation>
</message>
<message>
<source>PATH=C:\dev\bin;${PATH}</source>
<translation>PATH=C:\dev\bin;${PATH}</translation>
</message>
<message>
<source>PATH=/opt/bin:${PATH}</source>
<translation>PATH=/opt/bin:${PATH}</translation>
</message>
<message>
<source>No changes to apply.</source>
<translation></translation>
</message>
<message> <message>
<source>External Tools</source> <source>External Tools</source>
<translation></translation> <translation></translation>

View File

@@ -14322,7 +14322,7 @@ Local pulls are not applied to the master branch.</source>
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Form</source> <source>Form</source>
<translation>Formularz</translation> <translation>Formularz</translation>

View File

@@ -10368,7 +10368,7 @@ Do you want to kill it?</source>
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Add</source> <source>Add</source>
<translation>Добавить</translation> <translation>Добавить</translation>

View File

@@ -18960,7 +18960,7 @@ Krajevnih potegov se v vejo »master« ne uveljavi.</translation>
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Form</source> <source>Form</source>
<translation>Obrazec</translation> <translation>Obrazec</translation>

View File

@@ -2514,7 +2514,7 @@ Continue?</source>
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Form</source> <source>Form</source>
<translation>Форма</translation> <translation>Форма</translation>

View File

@@ -30788,7 +30788,7 @@ Local pulls are not applied to the master branch.</source>
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Form</source> <source>Form</source>
<translation></translation> <translation></translation>

View File

@@ -18584,7 +18584,7 @@ Local pulls are not applied to the master branch.</source>
</message> </message>
</context> </context>
<context> <context>
<name>Core::Internal::ExternalToolConfig</name> <name>Core::ExternalToolConfig</name>
<message> <message>
<source>Form</source> <source>Form</source>
<translation></translation> <translation></translation>

View File

@@ -27,7 +27,7 @@ add_qtc_plugin(Core
designmode.cpp designmode.h designmode.cpp designmode.h
dialogs/addtovcsdialog.cpp dialogs/addtovcsdialog.h dialogs/addtovcsdialog.cpp dialogs/addtovcsdialog.h
dialogs/codecselector.cpp dialogs/codecselector.h dialogs/codecselector.cpp dialogs/codecselector.h
dialogs/externaltoolconfig.cpp dialogs/externaltoolconfig.h dialogs/externaltoolconfig.ui dialogs/externaltoolconfig.cpp dialogs/externaltoolconfig.h
dialogs/filepropertiesdialog.cpp dialogs/filepropertiesdialog.h dialogs/filepropertiesdialog.cpp dialogs/filepropertiesdialog.h
dialogs/ioptionspage.cpp dialogs/ioptionspage.h dialogs/ioptionspage.cpp dialogs/ioptionspage.h
dialogs/newdialog.cpp dialogs/newdialog.h dialogs/newdialog.cpp dialogs/newdialog.h

View File

@@ -203,7 +203,7 @@ Project {
files: [ files: [
"addtovcsdialog.cpp", "addtovcsdialog.h", "addtovcsdialog.cpp", "addtovcsdialog.h",
"codecselector.cpp", "codecselector.h", "codecselector.cpp", "codecselector.h",
"externaltoolconfig.cpp", "externaltoolconfig.h", "externaltoolconfig.ui", "externaltoolconfig.cpp", "externaltoolconfig.h",
"filepropertiesdialog.cpp", "filepropertiesdialog.h", "filepropertiesdialog.cpp", "filepropertiesdialog.h",
"ioptionspage.cpp", "ioptionspage.h", "ioptionspage.cpp", "ioptionspage.h",
"newdialog.cpp", "newdialog.h", "newdialog.cpp", "newdialog.h",

View File

@@ -4,14 +4,15 @@
#include "externaltoolconfig.h" #include "externaltoolconfig.h"
#include "ioptionspage.h" #include "ioptionspage.h"
#include "ui_externaltoolconfig.h"
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/environmentdialog.h> #include <utils/environmentdialog.h>
#include <utils/fancylineedit.h> #include <utils/fancylineedit.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/layoutbuilder.h>
#include <utils/macroexpander.h> #include <utils/macroexpander.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
#include <utils/variablechooser.h> #include <utils/variablechooser.h>
@@ -21,14 +22,21 @@
#include <coreplugin/externaltoolmanager.h> #include <coreplugin/externaltoolmanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <QCheckBox>
#include <QComboBox>
#include <QCoreApplication>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QDir> #include <QHeaderView>
#include <QFileInfo> #include <QLabel>
#include <QLineEdit>
#include <QMenu> #include <QMenu>
#include <QMimeData> #include <QMimeData>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QPushButton>
#include <QRandomGenerator> #include <QRandomGenerator>
#include <QScrollArea>
#include <QTextStream> #include <QTextStream>
#include <QTreeView>
using namespace Utils; using namespace Utils;
@@ -433,63 +441,196 @@ private:
void editEnvironmentChanges(); void editEnvironmentChanges();
void updateEnvironmentLabel(); void updateEnvironmentLabel();
Ui::ExternalToolConfig m_ui;
EnvironmentItems m_environment; EnvironmentItems m_environment;
ExternalToolModel m_model; ExternalToolModel m_model;
QTreeView *m_toolTree;
QPushButton *m_removeButton;
QPushButton *m_revertButton;
QWidget *m_infoWidget;
QLineEdit *m_description;
Utils::PathChooser *m_executable;
QLineEdit *m_arguments;
Utils::PathChooser *m_workingDirectory;
QComboBox *m_outputBehavior;
QLabel *m_environmentLabel;
QComboBox *m_errorOutputBehavior;
QCheckBox *m_modifiesDocumentCheckbox;
QPlainTextEdit *m_inputText;
QComboBox *m_baseEnvironment;
}; };
ExternalToolConfig::ExternalToolConfig() ExternalToolConfig::ExternalToolConfig()
{ {
m_ui.setupUi(this); m_toolTree = new QTreeView(this);
m_ui.executable->setExpectedKind(PathChooser::ExistingCommand); m_toolTree->setDragEnabled(true);
m_ui.scrollArea->viewport()->setAutoFillBackground(false); m_toolTree->setDragDropMode(QAbstractItemView::InternalMove);
m_ui.scrollAreaWidgetContents->setAutoFillBackground(false); m_toolTree->header()->setVisible(false);
m_ui.toolTree->setModel(&m_model); m_toolTree->header()->setDefaultSectionSize(21);
m_ui.toolTree->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);
connect(m_ui.toolTree->selectionModel(), &QItemSelectionModel::currentChanged, auto addButton = new QPushButton(tr("Add"));
addButton->setToolTip(tr("Add tool."));
m_removeButton = new QPushButton(tr("Remove"));
m_removeButton->setToolTip(tr("Remove tool."));
m_revertButton = new QPushButton(tr("Reset"));
m_revertButton->setToolTip(tr("Revert tool to default."));
auto scrollArea = new QScrollArea(this);
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy.setHorizontalStretch(10);
sizePolicy.setVerticalStretch(0);
scrollArea->setSizePolicy(sizePolicy);
scrollArea->setFrameShape(QFrame::NoFrame);
scrollArea->setFrameShadow(QFrame::Plain);
scrollArea->setLineWidth(0);
scrollArea->setWidgetResizable(true);
auto scrollAreaWidgetContents = new QWidget();
scrollAreaWidgetContents->setGeometry(QRect(0, 0, 396, 444));
m_infoWidget = new QWidget(scrollAreaWidgetContents);
QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy1.setHorizontalStretch(10);
sizePolicy1.setVerticalStretch(0);
m_infoWidget->setSizePolicy(sizePolicy1);
m_description = new QLineEdit(m_infoWidget);
m_executable = new PathChooser(m_infoWidget);
m_arguments = new QLineEdit(m_infoWidget);
m_workingDirectory = new PathChooser(m_infoWidget);
auto outputLabel = new QLabel(tr("Output:"));
outputLabel->setToolTip(tr("<html><head/><body>\n"
"<p>What to do with the executable's standard output.\n"
"<ul><li>Ignore: Do nothing with it.</li><li>Show in General Messages.</li>"
"<li>Replace selection: Replace the current selection in the current document with it.</li>"
"</ul></p></body></html>\n"));
m_outputBehavior = new QComboBox(m_infoWidget);
m_outputBehavior->addItem(tr("Ignore"));
m_outputBehavior->addItem(tr("Show in General Messages"));
m_outputBehavior->addItem(tr("Replace Selection"));
auto errorOutputLabel = new QLabel(tr("Error output:"));
errorOutputLabel->setToolTip(tr("<html><head><body>\n"
"<p >What to do with the executable's standard error output.</p>\n"
"<ul><li>Ignore: Do nothing with it.</li>\n"
"<li>Show in General Messages.</li>\n"
"<li>Replace selection: Replace the current selection in the current document with it.</li>\n"
"</ul></body></html>"));
m_errorOutputBehavior = new QComboBox(m_infoWidget);
m_errorOutputBehavior->addItem(tr("Ignore"));
m_errorOutputBehavior->addItem(tr("Show in General Messages"));
m_errorOutputBehavior->addItem(tr("Replace Selection"));
m_environmentLabel = new QLabel(tr("No changes to apply."));
m_environmentLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
auto environmentButton = new QPushButton(tr("Change..."));
m_modifiesDocumentCheckbox = new QCheckBox(tr("Modifies current document"));
m_modifiesDocumentCheckbox->setToolTip(tr("If the tool modifies the current document, "
"set this flag to ensure that the document is saved before "
"running the tool and is reloaded after the tool finished."));
auto inputLabel = new QLabel(tr("Input:"));
inputLabel->setToolTip(tr("Text to pass to the executable via standard input. Leave "
"empty if the executable should not receive any input."));
m_inputText = new QPlainTextEdit(m_infoWidget);
QSizePolicy sizePolicy3(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy3.setHorizontalStretch(0);
sizePolicy3.setVerticalStretch(10);
m_inputText->setSizePolicy(sizePolicy3);
m_inputText->setLineWrapMode(QPlainTextEdit::NoWrap);
m_baseEnvironment = new QComboBox(m_infoWidget);
m_baseEnvironment->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
scrollArea->setWidget(scrollAreaWidgetContents);
using namespace Layouting;
Form {
tr("Description:"), m_description, br,
tr("Executable:"), m_executable, br,
tr("Arguments:"), m_arguments, br,
tr("Working directory:"), m_workingDirectory, br,
outputLabel, m_outputBehavior, br,
errorOutputLabel, m_errorOutputBehavior, br,
tr("Base environment:"), m_baseEnvironment, br,
tr("Environment:"), m_environmentLabel, environmentButton, br,
empty, m_modifiesDocumentCheckbox, br,
inputLabel, m_inputText
}.attachTo(m_infoWidget, WithMargins);
Column {
m_infoWidget
}.attachTo(scrollAreaWidgetContents, WithoutMargins);
Row {
Column {
m_toolTree,
Row { addButton, m_removeButton, st, m_revertButton }
},
scrollArea
}.attachTo(this);
m_executable->setExpectedKind(PathChooser::ExistingCommand);
scrollArea->viewport()->setAutoFillBackground(false);
scrollAreaWidgetContents->setAutoFillBackground(false);
m_toolTree->setModel(&m_model);
m_toolTree->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);
connect(m_toolTree->selectionModel(), &QItemSelectionModel::currentChanged,
this, &ExternalToolConfig::handleCurrentChanged); this, &ExternalToolConfig::handleCurrentChanged);
auto chooser = new VariableChooser(this); auto chooser = new VariableChooser(this);
chooser->addSupportedWidget(m_ui.executable->lineEdit()); chooser->addSupportedWidget(m_executable->lineEdit());
chooser->addSupportedWidget(m_ui.arguments); chooser->addSupportedWidget(m_arguments);
chooser->addSupportedWidget(m_ui.workingDirectory->lineEdit()); chooser->addSupportedWidget(m_workingDirectory->lineEdit());
chooser->addSupportedWidget(m_ui.inputText); chooser->addSupportedWidget(m_inputText);
fillBaseEnvironmentComboBox(m_ui.baseEnvironment); fillBaseEnvironmentComboBox(m_baseEnvironment);
connect(m_ui.description, &QLineEdit::editingFinished, connect(m_description, &QLineEdit::editingFinished,
this, &ExternalToolConfig::updateCurrentItem); this, &ExternalToolConfig::updateCurrentItem);
connect(m_ui.executable, &PathChooser::editingFinished, connect(m_executable, &PathChooser::editingFinished,
this, &ExternalToolConfig::updateCurrentItem); this, &ExternalToolConfig::updateCurrentItem);
connect(m_ui.executable, &PathChooser::browsingFinished, connect(m_executable, &PathChooser::browsingFinished,
this, &ExternalToolConfig::updateCurrentItem); this, &ExternalToolConfig::updateCurrentItem);
connect(m_ui.arguments, &QLineEdit::editingFinished, connect(m_arguments, &QLineEdit::editingFinished,
this, &ExternalToolConfig::updateCurrentItem); this, &ExternalToolConfig::updateCurrentItem);
connect(m_ui.arguments, &QLineEdit::editingFinished, connect(m_arguments, &QLineEdit::editingFinished,
this, &ExternalToolConfig::updateEffectiveArguments); this, &ExternalToolConfig::updateEffectiveArguments);
connect(m_ui.workingDirectory, &PathChooser::editingFinished, connect(m_workingDirectory, &PathChooser::editingFinished,
this, &ExternalToolConfig::updateCurrentItem); this, &ExternalToolConfig::updateCurrentItem);
connect(m_ui.workingDirectory, &PathChooser::browsingFinished, connect(m_workingDirectory, &PathChooser::browsingFinished,
this, &ExternalToolConfig::updateCurrentItem); this, &ExternalToolConfig::updateCurrentItem);
connect(m_ui.environmentButton, &QAbstractButton::clicked, connect(environmentButton, &QAbstractButton::clicked,
this, &ExternalToolConfig::editEnvironmentChanges); this, &ExternalToolConfig::editEnvironmentChanges);
connect(m_ui.outputBehavior, &QComboBox::activated, connect(m_outputBehavior, &QComboBox::activated,
this, &ExternalToolConfig::updateCurrentItem); this, &ExternalToolConfig::updateCurrentItem);
connect(m_ui.errorOutputBehavior, &QComboBox::activated, connect(m_errorOutputBehavior, &QComboBox::activated,
this, &ExternalToolConfig::updateCurrentItem); this, &ExternalToolConfig::updateCurrentItem);
connect(m_ui.modifiesDocumentCheckbox, &QAbstractButton::clicked, connect(m_modifiesDocumentCheckbox, &QAbstractButton::clicked,
this, &ExternalToolConfig::updateCurrentItem); this, &ExternalToolConfig::updateCurrentItem);
connect(m_ui.inputText, &QPlainTextEdit::textChanged, connect(m_inputText, &QPlainTextEdit::textChanged,
this, &ExternalToolConfig::updateCurrentItem); this, &ExternalToolConfig::updateCurrentItem);
connect(m_ui.revertButton, &QAbstractButton::clicked, connect(m_revertButton, &QAbstractButton::clicked,
this, &ExternalToolConfig::revertCurrentItem); this, &ExternalToolConfig::revertCurrentItem);
connect(m_ui.removeButton, &QAbstractButton::clicked, connect(m_removeButton, &QAbstractButton::clicked,
this, &ExternalToolConfig::removeTool); this, &ExternalToolConfig::removeTool);
auto menu = new QMenu(m_ui.addButton); auto menu = new QMenu(addButton);
m_ui.addButton->setMenu(menu); addButton->setMenu(menu);
auto addTool = new QAction(tr("Add Tool"), this); auto addTool = new QAction(tr("Add Tool"), this);
menu->addAction(addTool); menu->addAction(addTool);
connect(addTool, &QAction::triggered, this, &ExternalToolConfig::addTool); connect(addTool, &QAction::triggered, this, &ExternalToolConfig::addTool);
@@ -514,7 +655,7 @@ void ExternalToolConfig::setTools(const QMap<QString, QList<ExternalTool *> > &t
if (!toolsCopy.contains(QString())) if (!toolsCopy.contains(QString()))
toolsCopy.insert(QString(), QList<ExternalTool *>()); toolsCopy.insert(QString(), QList<ExternalTool *>());
m_model.setTools(toolsCopy); m_model.setTools(toolsCopy);
m_ui.toolTree->expandAll(); m_toolTree->expandAll();
} }
void ExternalToolConfig::handleCurrentChanged(const QModelIndex &now, const QModelIndex &previous) void ExternalToolConfig::handleCurrentChanged(const QModelIndex &now, const QModelIndex &previous)
@@ -527,22 +668,22 @@ void ExternalToolConfig::updateButtons(const QModelIndex &index)
{ {
const ExternalTool *tool = ExternalToolModel::toolForIndex(index); const ExternalTool *tool = ExternalToolModel::toolForIndex(index);
if (!tool) { if (!tool) {
m_ui.removeButton->setEnabled(false); m_removeButton->setEnabled(false);
m_ui.revertButton->setEnabled(false); m_revertButton->setEnabled(false);
return; return;
} }
if (!tool->preset()) { if (!tool->preset()) {
m_ui.removeButton->setEnabled(true); m_removeButton->setEnabled(true);
m_ui.revertButton->setEnabled(false); m_revertButton->setEnabled(false);
} else { } else {
m_ui.removeButton->setEnabled(false); m_removeButton->setEnabled(false);
m_ui.revertButton->setEnabled((*tool) != (*(tool->preset()))); m_revertButton->setEnabled((*tool) != (*(tool->preset())));
} }
} }
void ExternalToolConfig::updateCurrentItem() void ExternalToolConfig::updateCurrentItem()
{ {
const QModelIndex index = m_ui.toolTree->selectionModel()->currentIndex(); const QModelIndex index = m_toolTree->selectionModel()->currentIndex();
updateItem(index); updateItem(index);
updateButtons(index); updateButtons(index);
} }
@@ -552,21 +693,21 @@ void ExternalToolConfig::updateItem(const QModelIndex &index)
ExternalTool *tool = ExternalToolModel::toolForIndex(index); ExternalTool *tool = ExternalToolModel::toolForIndex(index);
if (!tool) if (!tool)
return; return;
tool->setDescription(m_ui.description->text()); tool->setDescription(m_description->text());
FilePaths executables = tool->executables(); FilePaths executables = tool->executables();
if (executables.size() > 0) if (executables.size() > 0)
executables[0] = m_ui.executable->rawFilePath(); executables[0] = m_executable->rawFilePath();
else else
executables << m_ui.executable->rawFilePath(); executables << m_executable->rawFilePath();
tool->setExecutables(executables); tool->setExecutables(executables);
tool->setArguments(m_ui.arguments->text()); tool->setArguments(m_arguments->text());
tool->setWorkingDirectory(m_ui.workingDirectory->rawFilePath()); tool->setWorkingDirectory(m_workingDirectory->rawFilePath());
tool->setBaseEnvironmentProviderId(Id::fromSetting(m_ui.baseEnvironment->currentData())); tool->setBaseEnvironmentProviderId(Id::fromSetting(m_baseEnvironment->currentData()));
tool->setEnvironmentUserChanges(m_environment); tool->setEnvironmentUserChanges(m_environment);
tool->setOutputHandling(ExternalTool::OutputHandling(m_ui.outputBehavior->currentIndex())); tool->setOutputHandling(ExternalTool::OutputHandling(m_outputBehavior->currentIndex()));
tool->setErrorHandling(ExternalTool::OutputHandling(m_ui.errorOutputBehavior->currentIndex())); tool->setErrorHandling(ExternalTool::OutputHandling(m_errorOutputBehavior->currentIndex()));
tool->setModifiesCurrentDocument(m_ui.modifiesDocumentCheckbox->checkState()); tool->setModifiesCurrentDocument(m_modifiesDocumentCheckbox->checkState());
tool->setInput(m_ui.inputText->toPlainText()); tool->setInput(m_inputText->toPlainText());
} }
void ExternalToolConfig::showInfoForItem(const QModelIndex &index) void ExternalToolConfig::showInfoForItem(const QModelIndex &index)
@@ -574,36 +715,36 @@ void ExternalToolConfig::showInfoForItem(const QModelIndex &index)
updateButtons(index); updateButtons(index);
const ExternalTool *tool = ExternalToolModel::toolForIndex(index); const ExternalTool *tool = ExternalToolModel::toolForIndex(index);
if (!tool) { if (!tool) {
m_ui.description->clear(); m_description->clear();
m_ui.executable->setFilePath({}); m_executable->setFilePath({});
m_ui.arguments->clear(); m_arguments->clear();
m_ui.workingDirectory->setFilePath({}); m_workingDirectory->setFilePath({});
m_ui.inputText->clear(); m_inputText->clear();
m_ui.infoWidget->setEnabled(false); m_infoWidget->setEnabled(false);
m_environment.clear(); m_environment.clear();
return; return;
} }
m_ui.infoWidget->setEnabled(true); m_infoWidget->setEnabled(true);
m_ui.description->setText(tool->description()); m_description->setText(tool->description());
m_ui.executable->setFilePath(tool->executables().isEmpty() ? FilePath() m_executable->setFilePath(tool->executables().isEmpty() ? FilePath()
: tool->executables().constFirst()); : tool->executables().constFirst());
m_ui.arguments->setText(tool->arguments()); m_arguments->setText(tool->arguments());
m_ui.workingDirectory->setFilePath(tool->workingDirectory()); m_workingDirectory->setFilePath(tool->workingDirectory());
m_ui.outputBehavior->setCurrentIndex(int(tool->outputHandling())); m_outputBehavior->setCurrentIndex(int(tool->outputHandling()));
m_ui.errorOutputBehavior->setCurrentIndex(int(tool->errorHandling())); m_errorOutputBehavior->setCurrentIndex(int(tool->errorHandling()));
m_ui.modifiesDocumentCheckbox->setChecked(tool->modifiesCurrentDocument()); m_modifiesDocumentCheckbox->setChecked(tool->modifiesCurrentDocument());
const int baseEnvironmentIndex = m_ui.baseEnvironment->findData( const int baseEnvironmentIndex = m_baseEnvironment->findData(
tool->baseEnvironmentProviderId().toSetting()); tool->baseEnvironmentProviderId().toSetting());
m_ui.baseEnvironment->setCurrentIndex(std::max(0, baseEnvironmentIndex)); m_baseEnvironment->setCurrentIndex(std::max(0, baseEnvironmentIndex));
m_environment = tool->environmentUserChanges(); m_environment = tool->environmentUserChanges();
{ {
QSignalBlocker blocker(m_ui.inputText); QSignalBlocker blocker(m_inputText);
m_ui.inputText->setPlainText(tool->input()); m_inputText->setPlainText(tool->input());
} }
m_ui.description->setCursorPosition(0); m_description->setCursorPosition(0);
m_ui.arguments->setCursorPosition(0); m_arguments->setCursorPosition(0);
updateEnvironmentLabel(); updateEnvironmentLabel();
updateEffectiveArguments(); updateEffectiveArguments();
} }
@@ -668,7 +809,7 @@ static QString findUnusedId(const QString &proposal, const QMap<QString, QList<E
void ExternalToolConfig::apply() void ExternalToolConfig::apply()
{ {
QModelIndex index = m_ui.toolTree->selectionModel()->currentIndex(); QModelIndex index = m_toolTree->selectionModel()->currentIndex();
updateItem(index); updateItem(index);
updateButtons(index); updateButtons(index);
@@ -746,40 +887,40 @@ void ExternalToolConfig::apply()
void ExternalToolConfig::revertCurrentItem() void ExternalToolConfig::revertCurrentItem()
{ {
QModelIndex index = m_ui.toolTree->selectionModel()->currentIndex(); QModelIndex index = m_toolTree->selectionModel()->currentIndex();
m_model.revertTool(index); m_model.revertTool(index);
showInfoForItem(index); showInfoForItem(index);
} }
void ExternalToolConfig::addTool() void ExternalToolConfig::addTool()
{ {
QModelIndex currentIndex = m_ui.toolTree->selectionModel()->currentIndex(); QModelIndex currentIndex = m_toolTree->selectionModel()->currentIndex();
if (!currentIndex.isValid()) // default to Uncategorized if (!currentIndex.isValid()) // default to Uncategorized
currentIndex = m_model.index(0, 0); currentIndex = m_model.index(0, 0);
QModelIndex index = m_model.addTool(currentIndex); QModelIndex index = m_model.addTool(currentIndex);
m_ui.toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear); m_toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear);
m_ui.toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); m_toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent);
m_ui.toolTree->edit(index); m_toolTree->edit(index);
} }
void ExternalToolConfig::removeTool() void ExternalToolConfig::removeTool()
{ {
QModelIndex currentIndex = m_ui.toolTree->selectionModel()->currentIndex(); QModelIndex currentIndex = m_toolTree->selectionModel()->currentIndex();
m_ui.toolTree->selectionModel()->setCurrentIndex(QModelIndex(), QItemSelectionModel::Clear); m_toolTree->selectionModel()->setCurrentIndex(QModelIndex(), QItemSelectionModel::Clear);
m_model.removeTool(currentIndex); m_model.removeTool(currentIndex);
} }
void ExternalToolConfig::addCategory() void ExternalToolConfig::addCategory()
{ {
QModelIndex index = m_model.addCategory(); QModelIndex index = m_model.addCategory();
m_ui.toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear); m_toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear);
m_ui.toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); m_toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent);
m_ui.toolTree->edit(index); m_toolTree->edit(index);
} }
void ExternalToolConfig::updateEffectiveArguments() void ExternalToolConfig::updateEffectiveArguments()
{ {
m_ui.arguments->setToolTip(Utils::globalMacroExpander()->expandProcessArgs(m_ui.arguments->text())); m_arguments->setToolTip(Utils::globalMacroExpander()->expandProcessArgs(m_arguments->text()));
} }
void ExternalToolConfig::editEnvironmentChanges() void ExternalToolConfig::editEnvironmentChanges()
@@ -787,9 +928,9 @@ void ExternalToolConfig::editEnvironmentChanges()
const QString placeholderText = HostOsInfo::isWindowsHost() const QString placeholderText = HostOsInfo::isWindowsHost()
? tr("PATH=C:\\dev\\bin;${PATH}") ? tr("PATH=C:\\dev\\bin;${PATH}")
: tr("PATH=/opt/bin:${PATH}"); : tr("PATH=/opt/bin:${PATH}");
const auto newItems = EnvironmentDialog::getEnvironmentItems(m_ui.environmentLabel, const auto newItems = EnvironmentDialog::getEnvironmentItems(m_environmentLabel,
m_environment, m_environment,
placeholderText); placeholderText);
if (newItems) { if (newItems) {
m_environment = *newItems; m_environment = *newItems;
updateEnvironmentLabel(); updateEnvironmentLabel();
@@ -799,9 +940,9 @@ void ExternalToolConfig::editEnvironmentChanges()
void ExternalToolConfig::updateEnvironmentLabel() void ExternalToolConfig::updateEnvironmentLabel()
{ {
QString shortSummary = EnvironmentItem::toStringList(m_environment).join("; "); QString shortSummary = EnvironmentItem::toStringList(m_environment).join("; ");
QFontMetrics fm(m_ui.environmentLabel->font()); QFontMetrics fm(m_environmentLabel->font());
shortSummary = fm.elidedText(shortSummary, Qt::ElideRight, m_ui.environmentLabel->width()); shortSummary = fm.elidedText(shortSummary, Qt::ElideRight, m_environmentLabel->width());
m_ui.environmentLabel->setText(shortSummary.isEmpty() ? tr("No changes to apply.") : shortSummary); m_environmentLabel->setText(shortSummary.isEmpty() ? tr("No changes to apply.") : shortSummary);
} }
// ToolSettingsPage // ToolSettingsPage

View File

@@ -1,378 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Core::Internal::ExternalToolConfig</class>
<widget class="QWidget" name="Core::Internal::ExternalToolConfig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>725</width>
<height>468</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeView" name="toolTree">
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>21</number>
</attribute>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="addButton">
<property name="toolTip">
<string>Add tool.</string>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeButton">
<property name="toolTip">
<string>Remove tool.</string>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="revertButton">
<property name="toolTip">
<string>Revert tool to default.</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>10</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>396</width>
<height>444</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="infoWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>10</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="descriptionLabel">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="description"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="executableLabel">
<property name="text">
<string>Executable:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Utils::PathChooser" name="executable" native="true"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="argumentsLabel">
<property name="text">
<string>Arguments:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="arguments"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="workingDirectoryLabel">
<property name="text">
<string>Working directory:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Utils::PathChooser" name="workingDirectory" native="true"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="outputLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;
&lt;p&gt;What to do with the executable's standard output.
&lt;ul&gt;&lt;li&gt;Ignore: Do nothing with it.&lt;/li&gt;&lt;li&gt;Show in General Messages.&lt;/li&gt;&lt;li&gt;Replace selection: Replace the current selection in the current document with it.&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;
</string>
</property>
<property name="text">
<string>Output:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="outputBehavior">
<item>
<property name="text">
<string>Ignore</string>
</property>
</item>
<item>
<property name="text">
<string>Show in General Messages</string>
</property>
</item>
<item>
<property name="text">
<string>Replace Selection</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="errorOutputLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head&gt;&lt;body&gt;
&lt;p &gt;What to do with the executable's standard error output.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Ignore: Do nothing with it.&lt;/li&gt;
&lt;li&gt;Show in General Messages.&lt;/li&gt;
&lt;li&gt;Replace selection: Replace the current selection in the current document with it.&lt;/li&gt;
&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Error output:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="errorOutputBehavior">
<item>
<property name="text">
<string>Ignore</string>
</property>
</item>
<item>
<property name="text">
<string>Show in General Messages</string>
</property>
</item>
<item>
<property name="text">
<string>Replace Selection</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Environment:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="environmentLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>No changes to apply.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="environmentButton">
<property name="text">
<string>Change...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="modifiesDocumentCheckbox">
<property name="toolTip">
<string>If the tool modifies the current document, set this flag to ensure that the document is saved before running the tool and is reloaded after the tool finished.</string>
</property>
<property name="text">
<string>Modifies current document</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="inputLabel">
<property name="toolTip">
<string>Text to pass to the executable via standard input. Leave empty if the executable should not receive any input.</string>
</property>
<property name="text">
<string>Input:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QPlainTextEdit" name="inputText">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="baseEnvironmentLabel">
<property name="text">
<string>Base environment:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="baseEnvironment">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
<slots>
<signal>editingFinished()</signal>
<signal>browsingFinished()</signal>
</slots>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>toolTree</tabstop>
<tabstop>addButton</tabstop>
<tabstop>removeButton</tabstop>
<tabstop>revertButton</tabstop>
<tabstop>description</tabstop>
<tabstop>executable</tabstop>
<tabstop>arguments</tabstop>
<tabstop>workingDirectory</tabstop>
<tabstop>outputBehavior</tabstop>
<tabstop>errorOutputBehavior</tabstop>
<tabstop>environmentButton</tabstop>
<tabstop>modifiesDocumentCheckbox</tabstop>
<tabstop>inputText</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>