2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-01-06 18:26:09 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-01-06 18:26:09 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-01-06 18:26:09 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-01-06 18:26:09 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-01-06 18:26:09 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-01-06 18:26:09 +01:00
|
|
|
|
|
|
|
|
#include "externaltoolconfig.h"
|
|
|
|
|
#include "ui_externaltoolconfig.h"
|
|
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2019-02-09 07:33:37 +01:00
|
|
|
#include <utils/environment.h>
|
|
|
|
|
#include <utils/environmentdialog.h>
|
|
|
|
|
#include <utils/fancylineedit.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2014-10-13 18:49:44 +02:00
|
|
|
#include <utils/macroexpander.h>
|
2011-01-21 10:58:06 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2012-12-30 22:02:44 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2011-01-21 10:58:06 +01:00
|
|
|
|
2011-02-01 15:55:40 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2011-03-03 20:50:25 +01:00
|
|
|
#include <coreplugin/variablechooser.h>
|
2011-02-01 15:55:40 +01:00
|
|
|
|
2015-01-06 16:41:44 +01:00
|
|
|
#include <QDialogButtonBox>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QMenu>
|
2019-02-09 07:33:37 +01:00
|
|
|
#include <QMimeData>
|
2015-01-06 16:41:44 +01:00
|
|
|
#include <QPlainTextEdit>
|
2019-02-09 07:33:37 +01:00
|
|
|
#include <QTextStream>
|
2011-01-06 18:26:09 +01:00
|
|
|
|
2011-02-01 15:55:40 +01:00
|
|
|
using namespace Core;
|
2011-01-06 18:26:09 +01:00
|
|
|
using namespace Core::Internal;
|
|
|
|
|
|
2011-02-08 12:28:35 +01:00
|
|
|
static const Qt::ItemFlags TOOLSMENU_ITEM_FLAGS = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;
|
|
|
|
|
static const Qt::ItemFlags CATEGORY_ITEM_FLAGS = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable;
|
2011-02-08 17:11:00 +01:00
|
|
|
static const Qt::ItemFlags TOOL_ITEM_FLAGS = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsEditable;
|
2011-02-08 12:28:35 +01:00
|
|
|
|
|
|
|
|
ExternalToolModel::ExternalToolModel(QObject *parent)
|
|
|
|
|
: QAbstractItemModel(parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExternalToolModel::~ExternalToolModel()
|
|
|
|
|
{
|
|
|
|
|
QMapIterator<QString, QList<ExternalTool *> > it(m_tools);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
qDeleteAll(it.value());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-08 17:11:00 +01:00
|
|
|
Qt::DropActions ExternalToolModel::supportedDropActions() const
|
|
|
|
|
{
|
|
|
|
|
return Qt::MoveAction;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-08 12:28:35 +01:00
|
|
|
int ExternalToolModel::columnCount(const QModelIndex &parent) const
|
|
|
|
|
{
|
2012-03-08 09:25:37 +01:00
|
|
|
bool categoryFound;
|
|
|
|
|
categoryForIndex(parent, &categoryFound);
|
|
|
|
|
if (!parent.isValid() || toolForIndex(parent) || categoryFound)
|
2011-02-08 12:28:35 +01:00
|
|
|
return 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant ExternalToolModel::data(const QModelIndex &index, int role) const
|
|
|
|
|
{
|
|
|
|
|
if (ExternalTool *tool = toolForIndex(index))
|
|
|
|
|
return data(tool, role);
|
2012-03-08 09:25:37 +01:00
|
|
|
bool found;
|
|
|
|
|
QString category = categoryForIndex(index, &found);
|
|
|
|
|
if (found)
|
2012-03-08 08:56:01 +01:00
|
|
|
return data(category, role);
|
|
|
|
|
return QVariant();
|
2011-02-08 12:28:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant ExternalToolModel::data(ExternalTool *tool, int role) const
|
|
|
|
|
{
|
|
|
|
|
switch (role) {
|
|
|
|
|
case Qt::DisplayRole:
|
|
|
|
|
case Qt::EditRole:
|
|
|
|
|
return tool->displayName();
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant ExternalToolModel::data(const QString &category, int role) const
|
|
|
|
|
{
|
|
|
|
|
switch (role) {
|
|
|
|
|
case Qt::DisplayRole:
|
|
|
|
|
case Qt::EditRole:
|
2012-03-08 08:56:01 +01:00
|
|
|
return category.isEmpty() ? tr("Uncategorized") : category;
|
2011-03-03 18:33:43 +01:00
|
|
|
case Qt::ToolTipRole:
|
2012-03-08 08:56:01 +01:00
|
|
|
return category.isEmpty() ? tr("Tools that will appear directly under the External Tools menu.") : QVariant();
|
2011-02-08 12:28:35 +01:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-08 17:11:00 +01:00
|
|
|
QMimeData *ExternalToolModel::mimeData(const QModelIndexList &indexes) const
|
|
|
|
|
{
|
|
|
|
|
if (indexes.isEmpty())
|
2018-07-21 21:11:46 +02:00
|
|
|
return nullptr;
|
2011-02-08 17:11:00 +01:00
|
|
|
QModelIndex modelIndex = indexes.first();
|
|
|
|
|
ExternalTool *tool = toolForIndex(modelIndex);
|
2018-07-21 21:11:46 +02:00
|
|
|
QTC_ASSERT(tool, return nullptr);
|
2012-03-08 09:25:37 +01:00
|
|
|
bool found;
|
|
|
|
|
QString category = categoryForIndex(modelIndex.parent(), &found);
|
2018-07-21 21:11:46 +02:00
|
|
|
QTC_ASSERT(found, return nullptr);
|
|
|
|
|
auto md = new QMimeData();
|
2011-02-08 17:11:00 +01:00
|
|
|
QByteArray ba;
|
|
|
|
|
QDataStream stream(&ba, QIODevice::WriteOnly);
|
|
|
|
|
stream << category << m_tools.value(category).indexOf(tool);
|
2019-02-09 07:33:37 +01:00
|
|
|
md->setData("application/qtcreator-externaltool-config", ba);
|
2011-02-08 17:11:00 +01:00
|
|
|
return md;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ExternalToolModel::dropMimeData(const QMimeData *data,
|
|
|
|
|
Qt::DropAction action,
|
|
|
|
|
int row,
|
|
|
|
|
int column,
|
|
|
|
|
const QModelIndex &parent)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(column)
|
|
|
|
|
if (action != Qt::MoveAction || !data)
|
|
|
|
|
return false;
|
2012-03-08 09:25:37 +01:00
|
|
|
bool found;
|
|
|
|
|
QString toCategory = categoryForIndex(parent, &found);
|
|
|
|
|
QTC_ASSERT(found, return false);
|
2019-02-09 07:33:37 +01:00
|
|
|
QByteArray ba = data->data("application/qtcreator-externaltool-config");
|
2011-02-08 17:11:00 +01:00
|
|
|
if (ba.isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
QDataStream stream(&ba, QIODevice::ReadOnly);
|
|
|
|
|
QString category;
|
|
|
|
|
int pos = -1;
|
|
|
|
|
stream >> category;
|
|
|
|
|
stream >> pos;
|
|
|
|
|
QList<ExternalTool *> &items = m_tools[category];
|
|
|
|
|
QTC_ASSERT(pos >= 0 && pos < items.count(), return false);
|
2012-03-08 08:56:01 +01:00
|
|
|
beginRemoveRows(index(m_tools.keys().indexOf(category), 0), pos, pos);
|
2011-02-08 17:11:00 +01:00
|
|
|
ExternalTool *tool = items.takeAt(pos);
|
|
|
|
|
endRemoveRows();
|
|
|
|
|
if (row < 0)
|
|
|
|
|
row = m_tools.value(toCategory).count();
|
2012-03-08 08:56:01 +01:00
|
|
|
beginInsertRows(index(m_tools.keys().indexOf(toCategory), 0), row, row);
|
2011-02-08 17:11:00 +01:00
|
|
|
m_tools[toCategory].insert(row, tool);
|
|
|
|
|
endInsertRows();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList ExternalToolModel::mimeTypes() const
|
|
|
|
|
{
|
2017-02-07 16:59:21 +01:00
|
|
|
return QStringList("application/qtcreator-externaltool-config");
|
2011-02-08 17:11:00 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-08 12:28:35 +01:00
|
|
|
QModelIndex ExternalToolModel::index(int row, int column, const QModelIndex &parent) const
|
|
|
|
|
{
|
|
|
|
|
if (column == 0 && parent.isValid()) {
|
2012-03-08 09:25:37 +01:00
|
|
|
bool found;
|
|
|
|
|
QString category = categoryForIndex(parent, &found);
|
|
|
|
|
if (found) {
|
2011-02-08 12:28:35 +01:00
|
|
|
QList<ExternalTool *> items = m_tools.value(category);
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (row < items.count())
|
2011-02-08 12:28:35 +01:00
|
|
|
return createIndex(row, 0, items.at(row));
|
|
|
|
|
}
|
2017-10-19 10:26:45 +02:00
|
|
|
} else if (column == 0 && row < m_tools.size()) {
|
2011-02-08 17:11:00 +01:00
|
|
|
return createIndex(row, 0);
|
2011-02-28 12:46:58 +01:00
|
|
|
}
|
2011-02-08 17:11:00 +01:00
|
|
|
return QModelIndex();
|
2011-02-08 12:28:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QModelIndex ExternalToolModel::parent(const QModelIndex &child) const
|
|
|
|
|
{
|
|
|
|
|
if (ExternalTool *tool = toolForIndex(child)) {
|
2012-03-08 08:56:01 +01:00
|
|
|
int categoryIndex = 0;
|
2011-02-08 12:28:35 +01:00
|
|
|
QMapIterator<QString, QList<ExternalTool *> > it(m_tools);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
if (it.value().contains(tool))
|
2012-03-08 08:56:01 +01:00
|
|
|
return index(categoryIndex, 0);
|
|
|
|
|
++categoryIndex;
|
2011-02-08 12:28:35 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QModelIndex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ExternalToolModel::rowCount(const QModelIndex &parent) const
|
|
|
|
|
{
|
|
|
|
|
if (!parent.isValid())
|
2017-10-19 10:26:45 +02:00
|
|
|
return m_tools.size();
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (toolForIndex(parent))
|
2011-02-08 12:28:35 +01:00
|
|
|
return 0;
|
2012-03-08 09:25:37 +01:00
|
|
|
bool found;
|
|
|
|
|
QString category = categoryForIndex(parent, &found);
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (found)
|
2011-02-08 12:28:35 +01:00
|
|
|
return m_tools.value(category).count();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt::ItemFlags ExternalToolModel::flags(const QModelIndex &index) const
|
|
|
|
|
{
|
|
|
|
|
if (toolForIndex(index))
|
|
|
|
|
return TOOL_ITEM_FLAGS;
|
2012-03-08 09:25:37 +01:00
|
|
|
bool found;
|
|
|
|
|
QString category = categoryForIndex(index, &found);
|
|
|
|
|
if (found) {
|
2012-03-08 08:56:01 +01:00
|
|
|
if (category.isEmpty())
|
2011-02-08 12:28:35 +01:00
|
|
|
return TOOLSMENU_ITEM_FLAGS;
|
|
|
|
|
return CATEGORY_ITEM_FLAGS;
|
|
|
|
|
}
|
2018-07-21 21:11:46 +02:00
|
|
|
return nullptr;
|
2011-02-08 12:28:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ExternalToolModel::setData(const QModelIndex &modelIndex, const QVariant &value, int role)
|
|
|
|
|
{
|
|
|
|
|
if (role != Qt::EditRole)
|
|
|
|
|
return false;
|
|
|
|
|
QString string = value.toString();
|
|
|
|
|
if (ExternalTool *tool = toolForIndex(modelIndex)) {
|
|
|
|
|
if (string.isEmpty() || tool->displayName() == string)
|
|
|
|
|
return false;
|
|
|
|
|
// rename tool
|
|
|
|
|
tool->setDisplayName(string);
|
|
|
|
|
emit dataChanged(modelIndex, modelIndex);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
2012-03-08 09:25:37 +01:00
|
|
|
bool found;
|
|
|
|
|
QString category = categoryForIndex(modelIndex, &found);
|
|
|
|
|
if (found) {
|
2011-02-08 12:28:35 +01:00
|
|
|
if (string.isEmpty() || m_tools.contains(string))
|
|
|
|
|
return false;
|
|
|
|
|
// rename category
|
|
|
|
|
QList<QString> categories = m_tools.keys();
|
2012-03-08 08:56:01 +01:00
|
|
|
int previousIndex = categories.indexOf(category);
|
2011-02-08 17:11:00 +01:00
|
|
|
categories.removeAt(previousIndex);
|
2011-02-08 12:28:35 +01:00
|
|
|
categories.append(string);
|
2014-06-16 18:25:52 +04:00
|
|
|
Utils::sort(categories);
|
2011-02-08 12:28:35 +01:00
|
|
|
int newIndex = categories.indexOf(string);
|
2011-03-02 14:33:45 +01:00
|
|
|
if (newIndex != previousIndex) {
|
|
|
|
|
// we have same parent so we have to do special stuff for beginMoveRows...
|
|
|
|
|
int beginMoveRowsSpecialIndex = (previousIndex < newIndex ? newIndex + 1 : newIndex);
|
|
|
|
|
beginMoveRows(QModelIndex(), previousIndex, previousIndex, QModelIndex(), beginMoveRowsSpecialIndex);
|
|
|
|
|
}
|
2011-02-08 12:28:35 +01:00
|
|
|
QList<ExternalTool *> items = m_tools.take(category);
|
|
|
|
|
m_tools.insert(string, items);
|
2011-02-08 17:11:00 +01:00
|
|
|
if (newIndex != previousIndex)
|
|
|
|
|
endMoveRows();
|
2011-02-08 12:28:35 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExternalToolModel::setTools(const QMap<QString, QList<ExternalTool *> > &tools)
|
|
|
|
|
{
|
|
|
|
|
beginResetModel();
|
|
|
|
|
m_tools = tools;
|
|
|
|
|
endResetModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMap<QString, QList<ExternalTool *> > ExternalToolModel::tools() const
|
|
|
|
|
{
|
|
|
|
|
return m_tools;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExternalTool *ExternalToolModel::toolForIndex(const QModelIndex &index) const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<ExternalTool *>(index.internalPointer());
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-08 09:25:37 +01:00
|
|
|
QString ExternalToolModel::categoryForIndex(const QModelIndex &index, bool *found) const
|
2011-02-08 12:28:35 +01:00
|
|
|
{
|
|
|
|
|
if (index.isValid() && !index.parent().isValid() && index.column() == 0 && index.row() >= 0) {
|
|
|
|
|
const QList<QString> &keys = m_tools.keys();
|
2012-03-08 09:25:37 +01:00
|
|
|
if (index.row() < keys.count()) {
|
|
|
|
|
if (found) *found = true;
|
2011-02-08 12:28:35 +01:00
|
|
|
return keys.at(index.row());
|
2012-03-08 09:25:37 +01:00
|
|
|
}
|
2011-02-08 12:28:35 +01:00
|
|
|
}
|
2012-03-08 09:25:37 +01:00
|
|
|
if (found) *found = false;
|
2011-02-08 12:28:35 +01:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExternalToolModel::revertTool(const QModelIndex &modelIndex)
|
|
|
|
|
{
|
|
|
|
|
ExternalTool *tool = toolForIndex(modelIndex);
|
|
|
|
|
QTC_ASSERT(tool, return);
|
|
|
|
|
QTC_ASSERT(tool->preset() && !tool->preset()->fileName().isEmpty(), return);
|
2019-02-09 07:33:37 +01:00
|
|
|
auto resetTool = new ExternalTool(tool->preset().data());
|
2011-02-08 12:28:35 +01:00
|
|
|
resetTool->setPreset(tool->preset());
|
|
|
|
|
(*tool) = (*resetTool);
|
|
|
|
|
delete resetTool;
|
|
|
|
|
emit dataChanged(modelIndex, modelIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QModelIndex ExternalToolModel::addCategory()
|
|
|
|
|
{
|
2011-03-21 16:16:19 +01:00
|
|
|
const QString &categoryBase = tr("New Category");
|
2011-02-08 12:28:35 +01:00
|
|
|
QString category = categoryBase;
|
|
|
|
|
int count = 0;
|
|
|
|
|
while (m_tools.contains(category)) {
|
|
|
|
|
++count;
|
|
|
|
|
category = categoryBase + QString::number(count);
|
|
|
|
|
}
|
|
|
|
|
QList<QString> categories = m_tools.keys();
|
|
|
|
|
categories.append(category);
|
2014-06-16 18:25:52 +04:00
|
|
|
Utils::sort(categories);
|
2011-02-08 12:28:35 +01:00
|
|
|
int pos = categories.indexOf(category);
|
|
|
|
|
|
|
|
|
|
beginInsertRows(QModelIndex(), pos, pos);
|
|
|
|
|
m_tools.insert(category, QList<ExternalTool *>());
|
|
|
|
|
endInsertRows();
|
|
|
|
|
return index(pos, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QModelIndex ExternalToolModel::addTool(const QModelIndex &atIndex)
|
|
|
|
|
{
|
2012-03-08 09:25:37 +01:00
|
|
|
bool found;
|
|
|
|
|
QString category = categoryForIndex(atIndex, &found);
|
|
|
|
|
if (!found)
|
|
|
|
|
category = categoryForIndex(atIndex.parent(), &found);
|
2011-02-08 12:28:35 +01:00
|
|
|
|
2018-07-21 21:11:46 +02:00
|
|
|
auto tool = new ExternalTool;
|
2011-02-10 10:03:46 +01:00
|
|
|
tool->setDisplayCategory(category);
|
2011-03-21 16:16:19 +01:00
|
|
|
tool->setDisplayName(tr("New Tool"));
|
2011-02-08 12:28:35 +01:00
|
|
|
tool->setDescription(tr("This tool prints a line of useful text"));
|
2011-12-22 14:44:14 +01:00
|
|
|
//: Sample external tool text
|
|
|
|
|
const QString text = tr("Useful text");
|
2012-08-23 15:53:58 +02:00
|
|
|
if (Utils::HostOsInfo::isWindowsHost()) {
|
2019-02-09 07:33:37 +01:00
|
|
|
tool->setExecutables({"cmd"});
|
|
|
|
|
tool->setArguments("/c echo " + text);
|
2012-08-23 15:53:58 +02:00
|
|
|
} else {
|
2019-02-09 07:33:37 +01:00
|
|
|
tool->setExecutables({"echo"});
|
2012-08-23 15:53:58 +02:00
|
|
|
tool->setArguments(text);
|
|
|
|
|
}
|
2011-02-08 12:28:35 +01:00
|
|
|
|
|
|
|
|
int pos;
|
|
|
|
|
QModelIndex parent;
|
|
|
|
|
if (atIndex.parent().isValid()) {
|
|
|
|
|
pos = atIndex.row() + 1;
|
|
|
|
|
parent = atIndex.parent();
|
|
|
|
|
} else {
|
|
|
|
|
pos = m_tools.value(category).count();
|
|
|
|
|
parent = atIndex;
|
|
|
|
|
}
|
|
|
|
|
beginInsertRows(parent, pos, pos);
|
|
|
|
|
m_tools[category].insert(pos, tool);
|
|
|
|
|
endInsertRows();
|
|
|
|
|
return index(pos, 0, parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExternalToolModel::removeTool(const QModelIndex &modelIndex)
|
|
|
|
|
{
|
|
|
|
|
ExternalTool *tool = toolForIndex(modelIndex);
|
|
|
|
|
QTC_ASSERT(tool, return);
|
|
|
|
|
QTC_ASSERT(!tool->preset(), return);
|
|
|
|
|
// remove the tool and the tree item
|
|
|
|
|
int categoryIndex = 0;
|
|
|
|
|
QMutableMapIterator<QString, QList<ExternalTool *> > it(m_tools);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
QList<ExternalTool *> &items = it.value();
|
|
|
|
|
int pos = items.indexOf(tool);
|
|
|
|
|
if (pos != -1) {
|
|
|
|
|
beginRemoveRows(index(categoryIndex, 0), pos, pos);
|
|
|
|
|
items.removeAt(pos);
|
|
|
|
|
endRemoveRows();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++categoryIndex;
|
|
|
|
|
}
|
|
|
|
|
delete tool;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-25 13:56:46 +02:00
|
|
|
static void fillBaseEnvironmentComboBox(QComboBox *box)
|
|
|
|
|
{
|
|
|
|
|
box->clear();
|
|
|
|
|
box->addItem(ExternalTool::tr("System Environment"), QByteArray());
|
|
|
|
|
for (const Utils::EnvironmentProvider &provider : Utils::EnvironmentProvider::providers())
|
|
|
|
|
box->addItem(provider.displayName, Id::fromName(provider.id).toSetting());
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-06 18:26:09 +01:00
|
|
|
ExternalToolConfig::ExternalToolConfig(QWidget *parent) :
|
|
|
|
|
QWidget(parent),
|
2011-02-08 12:28:35 +01:00
|
|
|
ui(new Ui::ExternalToolConfig),
|
|
|
|
|
m_model(new ExternalToolModel(this))
|
2011-01-06 18:26:09 +01:00
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
2019-02-09 07:12:06 +01:00
|
|
|
ui->executable->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
2018-12-18 09:19:54 +01:00
|
|
|
ui->scrollArea->viewport()->setAutoFillBackground(false);
|
|
|
|
|
ui->scrollAreaWidgetContents->setAutoFillBackground(false);
|
2011-02-08 12:28:35 +01:00
|
|
|
ui->toolTree->setModel(m_model);
|
2011-01-21 10:58:06 +01:00
|
|
|
ui->toolTree->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);
|
2011-02-08 12:28:35 +01:00
|
|
|
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(ui->toolTree->selectionModel(), &QItemSelectionModel::currentChanged,
|
|
|
|
|
this, &ExternalToolConfig::handleCurrentChanged);
|
2011-02-08 12:28:35 +01:00
|
|
|
|
2014-10-13 18:49:44 +02:00
|
|
|
auto chooser = new VariableChooser(this);
|
|
|
|
|
chooser->addSupportedWidget(ui->executable->lineEdit());
|
|
|
|
|
chooser->addSupportedWidget(ui->arguments);
|
|
|
|
|
chooser->addSupportedWidget(ui->workingDirectory->lineEdit());
|
|
|
|
|
chooser->addSupportedWidget(ui->inputText);
|
2011-03-03 20:50:25 +01:00
|
|
|
|
2018-09-25 13:56:46 +02:00
|
|
|
fillBaseEnvironmentComboBox(ui->baseEnvironment);
|
|
|
|
|
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(ui->description, &QLineEdit::editingFinished,
|
|
|
|
|
this, &ExternalToolConfig::updateCurrentItem);
|
|
|
|
|
connect(ui->executable, &Utils::PathChooser::editingFinished,
|
|
|
|
|
this, &ExternalToolConfig::updateCurrentItem);
|
|
|
|
|
connect(ui->executable, &Utils::PathChooser::browsingFinished,
|
|
|
|
|
this, &ExternalToolConfig::updateCurrentItem);
|
2019-02-09 07:33:37 +01:00
|
|
|
connect(ui->arguments, &QLineEdit::editingFinished,
|
|
|
|
|
this, &ExternalToolConfig::updateCurrentItem);
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(ui->arguments, &QLineEdit::editingFinished,
|
|
|
|
|
this, &ExternalToolConfig::updateEffectiveArguments);
|
|
|
|
|
connect(ui->workingDirectory, &Utils::PathChooser::editingFinished,
|
|
|
|
|
this, &ExternalToolConfig::updateCurrentItem);
|
|
|
|
|
connect(ui->workingDirectory, &Utils::PathChooser::browsingFinished,
|
|
|
|
|
this, &ExternalToolConfig::updateCurrentItem);
|
|
|
|
|
connect(ui->environmentButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &ExternalToolConfig::editEnvironmentChanges);
|
2019-02-09 07:33:37 +01:00
|
|
|
connect(ui->outputBehavior, QOverload<int>::of(&QComboBox::activated),
|
2016-02-02 09:10:54 +02:00
|
|
|
this, &ExternalToolConfig::updateCurrentItem);
|
2019-02-09 07:33:37 +01:00
|
|
|
connect(ui->errorOutputBehavior, QOverload<int>::of(&QComboBox::activated),
|
2016-02-02 09:10:54 +02:00
|
|
|
this, &ExternalToolConfig::updateCurrentItem);
|
|
|
|
|
connect(ui->modifiesDocumentCheckbox, &QAbstractButton::clicked,
|
|
|
|
|
this, &ExternalToolConfig::updateCurrentItem);
|
2019-02-09 07:33:37 +01:00
|
|
|
connect(ui->inputText, &QPlainTextEdit::textChanged,
|
|
|
|
|
this, &ExternalToolConfig::updateCurrentItem);
|
2016-02-02 09:10:54 +02:00
|
|
|
|
2019-02-09 07:33:37 +01:00
|
|
|
connect(ui->revertButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &ExternalToolConfig::revertCurrentItem);
|
|
|
|
|
connect(ui->removeButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &ExternalToolConfig::removeTool);
|
2011-01-24 15:01:48 +01:00
|
|
|
|
2018-07-21 21:11:46 +02:00
|
|
|
auto menu = new QMenu(ui->addButton);
|
2011-02-02 17:04:51 +01:00
|
|
|
ui->addButton->setMenu(menu);
|
2019-02-09 07:33:37 +01:00
|
|
|
auto addTool = new QAction(tr("Add Tool"), this);
|
2011-03-04 09:08:12 +01:00
|
|
|
menu->addAction(addTool);
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(addTool, &QAction::triggered, this, &ExternalToolConfig::addTool);
|
2019-02-09 07:33:37 +01:00
|
|
|
auto addCategory = new QAction(tr("Add Category"), this);
|
2011-02-02 17:04:51 +01:00
|
|
|
menu->addAction(addCategory);
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(addCategory, &QAction::triggered, this, &ExternalToolConfig::addCategory);
|
2011-02-02 17:04:51 +01:00
|
|
|
|
2011-02-08 12:28:35 +01:00
|
|
|
showInfoForItem(QModelIndex());
|
2011-01-06 18:26:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExternalToolConfig::~ExternalToolConfig()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExternalToolConfig::setTools(const QMap<QString, QList<ExternalTool *> > &tools)
|
|
|
|
|
{
|
2011-02-08 12:28:35 +01:00
|
|
|
QMap<QString, QList<ExternalTool *> > toolsCopy;
|
2011-01-21 10:58:06 +01:00
|
|
|
QMapIterator<QString, QList<ExternalTool *> > it(tools);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
QList<ExternalTool *> itemCopy;
|
2019-02-09 07:33:37 +01:00
|
|
|
for (ExternalTool *tool : it.value())
|
2011-01-21 10:58:06 +01:00
|
|
|
itemCopy.append(new ExternalTool(tool));
|
2011-02-08 12:28:35 +01:00
|
|
|
toolsCopy.insert(it.key(), itemCopy);
|
2011-01-06 18:26:09 +01:00
|
|
|
}
|
2012-03-08 08:56:01 +01:00
|
|
|
if (!toolsCopy.contains(QString()))
|
|
|
|
|
toolsCopy.insert(QString(), QList<ExternalTool *>());
|
2011-02-08 12:28:35 +01:00
|
|
|
m_model->setTools(toolsCopy);
|
2011-01-06 18:26:09 +01:00
|
|
|
ui->toolTree->expandAll();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-08 12:28:35 +01:00
|
|
|
void ExternalToolConfig::handleCurrentChanged(const QModelIndex &now, const QModelIndex &previous)
|
2011-01-24 15:01:48 +01:00
|
|
|
{
|
|
|
|
|
updateItem(previous);
|
|
|
|
|
showInfoForItem(now);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-08 12:28:35 +01:00
|
|
|
void ExternalToolConfig::updateButtons(const QModelIndex &index)
|
2011-02-01 15:55:40 +01:00
|
|
|
{
|
2011-02-08 12:28:35 +01:00
|
|
|
ExternalTool *tool = m_model->toolForIndex(index);
|
2011-02-01 15:55:40 +01:00
|
|
|
if (!tool) {
|
|
|
|
|
ui->removeButton->setEnabled(false);
|
|
|
|
|
ui->revertButton->setEnabled(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!tool->preset()) {
|
|
|
|
|
ui->removeButton->setEnabled(true);
|
|
|
|
|
ui->revertButton->setEnabled(false);
|
|
|
|
|
} else {
|
|
|
|
|
ui->removeButton->setEnabled(false);
|
|
|
|
|
ui->revertButton->setEnabled((*tool) != (*(tool->preset())));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExternalToolConfig::updateCurrentItem()
|
|
|
|
|
{
|
2011-02-08 12:28:35 +01:00
|
|
|
QModelIndex index = ui->toolTree->selectionModel()->currentIndex();
|
|
|
|
|
updateItem(index);
|
|
|
|
|
updateButtons(index);
|
2011-02-01 15:55:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-08 12:28:35 +01:00
|
|
|
void ExternalToolConfig::updateItem(const QModelIndex &index)
|
2011-01-24 15:01:48 +01:00
|
|
|
{
|
2011-02-08 12:28:35 +01:00
|
|
|
ExternalTool *tool = m_model->toolForIndex(index);
|
2011-01-24 15:01:48 +01:00
|
|
|
if (!tool)
|
|
|
|
|
return;
|
|
|
|
|
tool->setDescription(ui->description->text());
|
|
|
|
|
QStringList executables = tool->executables();
|
|
|
|
|
if (executables.size() > 0)
|
2011-02-01 15:55:40 +01:00
|
|
|
executables[0] = ui->executable->rawPath();
|
2011-01-24 15:01:48 +01:00
|
|
|
else
|
2011-02-01 15:55:40 +01:00
|
|
|
executables << ui->executable->rawPath();
|
2011-01-24 15:01:48 +01:00
|
|
|
tool->setExecutables(executables);
|
|
|
|
|
tool->setArguments(ui->arguments->text());
|
2011-02-01 15:55:40 +01:00
|
|
|
tool->setWorkingDirectory(ui->workingDirectory->rawPath());
|
2018-09-25 13:56:46 +02:00
|
|
|
tool->setBaseEnvironmentProviderId(Id::fromSetting(ui->baseEnvironment->currentData()));
|
|
|
|
|
tool->setEnvironmentUserChanges(m_environment);
|
2018-09-25 15:51:57 +02:00
|
|
|
tool->setOutputHandling(ExternalTool::OutputHandling(ui->outputBehavior->currentIndex()));
|
|
|
|
|
tool->setErrorHandling(ExternalTool::OutputHandling(ui->errorOutputBehavior->currentIndex()));
|
2011-01-24 15:01:48 +01:00
|
|
|
tool->setModifiesCurrentDocument(ui->modifiesDocumentCheckbox->checkState());
|
|
|
|
|
tool->setInput(ui->inputText->toPlainText());
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-08 12:28:35 +01:00
|
|
|
void ExternalToolConfig::showInfoForItem(const QModelIndex &index)
|
2011-01-06 18:26:09 +01:00
|
|
|
{
|
2011-02-08 12:28:35 +01:00
|
|
|
updateButtons(index);
|
|
|
|
|
ExternalTool *tool = m_model->toolForIndex(index);
|
2011-01-06 18:26:09 +01:00
|
|
|
if (!tool) {
|
2014-07-23 09:53:06 +02:00
|
|
|
ui->description->clear();
|
2011-01-06 18:26:09 +01:00
|
|
|
ui->executable->setPath(QString());
|
2014-07-23 09:53:06 +02:00
|
|
|
ui->arguments->clear();
|
2011-01-06 18:26:09 +01:00
|
|
|
ui->workingDirectory->setPath(QString());
|
2014-07-23 09:53:06 +02:00
|
|
|
ui->inputText->clear();
|
2011-01-06 18:26:09 +01:00
|
|
|
ui->infoWidget->setEnabled(false);
|
2015-01-06 16:41:44 +01:00
|
|
|
m_environment.clear();
|
2011-01-06 18:26:09 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ui->infoWidget->setEnabled(true);
|
|
|
|
|
ui->description->setText(tool->description());
|
2018-09-25 15:51:57 +02:00
|
|
|
ui->executable->setPath(tool->executables().isEmpty() ? QString()
|
|
|
|
|
: tool->executables().constFirst());
|
2011-01-06 18:26:09 +01:00
|
|
|
ui->arguments->setText(tool->arguments());
|
|
|
|
|
ui->workingDirectory->setPath(tool->workingDirectory());
|
2018-09-25 15:51:57 +02:00
|
|
|
ui->outputBehavior->setCurrentIndex(int(tool->outputHandling()));
|
|
|
|
|
ui->errorOutputBehavior->setCurrentIndex(int(tool->errorHandling()));
|
2011-01-24 12:21:42 +01:00
|
|
|
ui->modifiesDocumentCheckbox->setChecked(tool->modifiesCurrentDocument());
|
2018-09-25 13:56:46 +02:00
|
|
|
const int baseEnvironmentIndex = ui->baseEnvironment->findData(
|
|
|
|
|
tool->baseEnvironmentProviderId().toSetting());
|
|
|
|
|
ui->baseEnvironment->setCurrentIndex(std::max(0, baseEnvironmentIndex));
|
|
|
|
|
m_environment = tool->environmentUserChanges();
|
2011-02-08 12:28:35 +01:00
|
|
|
|
2017-09-30 07:12:57 +02:00
|
|
|
{
|
|
|
|
|
QSignalBlocker blocker(ui->inputText);
|
|
|
|
|
ui->inputText->setPlainText(tool->input());
|
|
|
|
|
}
|
2011-02-08 12:28:35 +01:00
|
|
|
|
2011-01-06 18:26:09 +01:00
|
|
|
ui->description->setCursorPosition(0);
|
|
|
|
|
ui->arguments->setCursorPosition(0);
|
2015-01-06 16:41:44 +01:00
|
|
|
updateEnvironmentLabel();
|
2012-12-30 22:02:44 +02:00
|
|
|
updateEffectiveArguments();
|
2011-01-06 18:26:09 +01:00
|
|
|
}
|
2011-01-21 10:58:06 +01:00
|
|
|
|
2011-01-24 15:01:48 +01:00
|
|
|
QMap<QString, QList<ExternalTool *> > ExternalToolConfig::tools() const
|
|
|
|
|
{
|
2011-02-08 12:28:35 +01:00
|
|
|
return m_model->tools();
|
2011-01-24 15:01:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExternalToolConfig::apply()
|
|
|
|
|
{
|
2011-02-08 12:28:35 +01:00
|
|
|
QModelIndex index = ui->toolTree->selectionModel()->currentIndex();
|
|
|
|
|
updateItem(index);
|
|
|
|
|
updateButtons(index);
|
2011-02-01 15:55:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExternalToolConfig::revertCurrentItem()
|
|
|
|
|
{
|
2011-02-08 12:28:35 +01:00
|
|
|
QModelIndex index = ui->toolTree->selectionModel()->currentIndex();
|
|
|
|
|
m_model->revertTool(index);
|
|
|
|
|
showInfoForItem(index);
|
2011-01-24 15:01:48 +01:00
|
|
|
}
|
2011-02-02 12:35:32 +01:00
|
|
|
|
2011-03-04 09:08:12 +01:00
|
|
|
void ExternalToolConfig::addTool()
|
2011-02-02 12:35:32 +01:00
|
|
|
{
|
2011-02-08 12:28:35 +01:00
|
|
|
QModelIndex currentIndex = ui->toolTree->selectionModel()->currentIndex();
|
2011-03-04 09:08:12 +01:00
|
|
|
if (!currentIndex.isValid()) // default to Uncategorized
|
|
|
|
|
currentIndex = m_model->index(0, 0);
|
2011-02-08 12:28:35 +01:00
|
|
|
QModelIndex index = m_model->addTool(currentIndex);
|
|
|
|
|
ui->toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear);
|
|
|
|
|
ui->toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent);
|
|
|
|
|
ui->toolTree->edit(index);
|
2011-02-02 12:35:32 +01:00
|
|
|
}
|
2011-02-02 13:35:48 +01:00
|
|
|
|
|
|
|
|
void ExternalToolConfig::removeTool()
|
|
|
|
|
{
|
2011-02-08 12:28:35 +01:00
|
|
|
QModelIndex currentIndex = ui->toolTree->selectionModel()->currentIndex();
|
|
|
|
|
ui->toolTree->selectionModel()->setCurrentIndex(QModelIndex(), QItemSelectionModel::Clear);
|
|
|
|
|
m_model->removeTool(currentIndex);
|
2011-02-02 13:35:48 +01:00
|
|
|
}
|
2011-02-02 17:04:51 +01:00
|
|
|
|
|
|
|
|
void ExternalToolConfig::addCategory()
|
|
|
|
|
{
|
2011-02-08 12:28:35 +01:00
|
|
|
QModelIndex index = m_model->addCategory();
|
|
|
|
|
ui->toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear);
|
|
|
|
|
ui->toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent);
|
|
|
|
|
ui->toolTree->edit(index);
|
2011-02-02 17:04:51 +01:00
|
|
|
}
|
2012-12-30 22:02:44 +02:00
|
|
|
|
|
|
|
|
void ExternalToolConfig::updateEffectiveArguments()
|
|
|
|
|
{
|
2014-10-21 13:19:38 +02:00
|
|
|
ui->arguments->setToolTip(Utils::globalMacroExpander()->expandProcessArgs(ui->arguments->text()));
|
2012-12-30 22:02:44 +02:00
|
|
|
}
|
2015-01-06 16:41:44 +01:00
|
|
|
|
|
|
|
|
void ExternalToolConfig::editEnvironmentChanges()
|
|
|
|
|
{
|
2016-06-16 14:23:22 +02:00
|
|
|
const QString placeholderText = Utils::HostOsInfo::isWindowsHost()
|
|
|
|
|
? tr("PATH=C:\\dev\\bin;${PATH}")
|
|
|
|
|
: tr("PATH=/opt/bin:${PATH}");
|
2019-05-07 16:51:22 +02:00
|
|
|
const auto newItems = Utils::EnvironmentDialog::getEnvironmentItems(ui->environmentLabel,
|
|
|
|
|
m_environment,
|
|
|
|
|
placeholderText);
|
|
|
|
|
if (newItems) {
|
|
|
|
|
m_environment = *newItems;
|
|
|
|
|
updateEnvironmentLabel();
|
|
|
|
|
}
|
2015-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExternalToolConfig::updateEnvironmentLabel()
|
|
|
|
|
{
|
2019-02-09 07:33:37 +01:00
|
|
|
QString shortSummary = Utils::EnvironmentItem::toStringList(m_environment).join("; ");
|
2015-01-06 16:41:44 +01:00
|
|
|
QFontMetrics fm(ui->environmentLabel->font());
|
|
|
|
|
shortSummary = fm.elidedText(shortSummary, Qt::ElideRight, ui->environmentLabel->width());
|
2015-03-16 10:43:01 +01:00
|
|
|
ui->environmentLabel->setText(shortSummary.isEmpty() ? tr("No changes to apply.") : shortSummary);
|
2015-01-06 16:41:44 +01:00
|
|
|
}
|