forked from qt-creator/qt-creator
Use the add button for adding categories.
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
#include <QtCore/QTextStream>
|
#include <QtCore/QTextStream>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
@@ -73,6 +74,12 @@ ExternalToolConfig::ExternalToolConfig(QWidget *parent) :
|
|||||||
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addTool()));
|
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addTool()));
|
||||||
connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(removeTool()));
|
connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(removeTool()));
|
||||||
|
|
||||||
|
QMenu *menu = new QMenu(ui->addButton);
|
||||||
|
ui->addButton->setMenu(menu);
|
||||||
|
QAction *addCategory = new QAction(tr("Add Category"), this);
|
||||||
|
menu->addAction(addCategory);
|
||||||
|
connect(addCategory, SIGNAL(triggered()), this, SLOT(addCategory()));
|
||||||
|
|
||||||
showInfoForItem(0);
|
showInfoForItem(0);
|
||||||
updateButtons(ui->toolTree->currentItem());
|
updateButtons(ui->toolTree->currentItem());
|
||||||
}
|
}
|
||||||
@@ -143,7 +150,6 @@ void ExternalToolConfig::handleCurrentItemChanged(QTreeWidgetItem *now, QTreeWid
|
|||||||
void ExternalToolConfig::updateButtons(QTreeWidgetItem *item)
|
void ExternalToolConfig::updateButtons(QTreeWidgetItem *item)
|
||||||
{
|
{
|
||||||
ExternalTool *tool = 0;
|
ExternalTool *tool = 0;
|
||||||
ui->addButton->setEnabled(item != 0);
|
|
||||||
if (item)
|
if (item)
|
||||||
tool = item->data(0, Qt::UserRole).value<ExternalTool *>();
|
tool = item->data(0, Qt::UserRole).value<ExternalTool *>();
|
||||||
if (!tool) {
|
if (!tool) {
|
||||||
@@ -313,7 +319,10 @@ void ExternalToolConfig::addTool()
|
|||||||
{
|
{
|
||||||
// find category to use
|
// find category to use
|
||||||
QTreeWidgetItem *currentItem = ui->toolTree->currentItem();
|
QTreeWidgetItem *currentItem = ui->toolTree->currentItem();
|
||||||
QTC_ASSERT(currentItem, return);
|
if (!currentItem) {
|
||||||
|
addCategory();
|
||||||
|
return;
|
||||||
|
}
|
||||||
QString category;
|
QString category;
|
||||||
QTreeWidgetItem *parent;
|
QTreeWidgetItem *parent;
|
||||||
if (currentItem->parent()) {
|
if (currentItem->parent()) {
|
||||||
@@ -361,3 +370,24 @@ void ExternalToolConfig::removeTool()
|
|||||||
delete currentItem;
|
delete currentItem;
|
||||||
delete tool;
|
delete tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExternalToolConfig::addCategory()
|
||||||
|
{
|
||||||
|
const QString &categoryBase = tr("New category");
|
||||||
|
QString category = categoryBase;
|
||||||
|
int count = 0;
|
||||||
|
while (m_tools.contains(category)) {
|
||||||
|
++count;
|
||||||
|
category = categoryBase + QString::number(count);
|
||||||
|
}
|
||||||
|
bool blocked = ui->toolTree->blockSignals(true); // block itemChanged
|
||||||
|
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList() << category);
|
||||||
|
item->setFlags(TOOL_ITEM_FLAGS);
|
||||||
|
item->setData(0, Qt::UserRole, category); // save name for the renaming stuff
|
||||||
|
m_tools.insert(category, QList<ExternalTool *>());
|
||||||
|
int newIndex = m_tools.keys().indexOf(category);
|
||||||
|
ui->toolTree->insertTopLevelItem(newIndex, item);
|
||||||
|
ui->toolTree->blockSignals(blocked); // unblock itemChanged
|
||||||
|
ui->toolTree->setCurrentItem(item);
|
||||||
|
ui->toolTree->editItem(item);
|
||||||
|
}
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ private slots:
|
|||||||
void updateCurrentItem();
|
void updateCurrentItem();
|
||||||
void addTool();
|
void addTool();
|
||||||
void removeTool();
|
void removeTool();
|
||||||
|
void addCategory();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ExternalToolConfig *ui;
|
Ui::ExternalToolConfig *ui;
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>+</string>
|
<string>+</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="popupMode">
|
||||||
|
<enum>QToolButton::MenuButtonPopup</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -122,11 +125,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="Utils::PathChooser" name="executable">
|
<widget class="Utils::PathChooser" name="executable" native="true"/>
|
||||||
<property name="expectedKind">
|
|
||||||
<enum>Utils::PathChooser::Command</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="argumentsLabel">
|
<widget class="QLabel" name="argumentsLabel">
|
||||||
@@ -146,11 +145,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="Utils::PathChooser" name="workingDirectory">
|
<widget class="Utils::PathChooser" name="workingDirectory" native="true"/>
|
||||||
<property name="expectedKind">
|
|
||||||
<enum>Utils::PathChooser::Command</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="outputLabel">
|
<widget class="QLabel" name="outputLabel">
|
||||||
|
|||||||
Reference in New Issue
Block a user