Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
0bcc8094
Commit
0bcc8094
authored
Feb 02, 2011
by
con
Browse files
Use the add button for adding categories.
parent
9a52e1dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
View file @
0bcc8094
...
...
@@ -41,6 +41,7 @@
#include
<QtCore/QTextStream>
#include
<QtCore/QFile>
#include
<QtGui/QMessageBox>
#include
<QtGui/QMenu>
using
namespace
Core
;
using
namespace
Core
::
Internal
;
...
...
@@ -73,6 +74,12 @@ ExternalToolConfig::ExternalToolConfig(QWidget *parent) :
connect
(
ui
->
addButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addTool
()));
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
);
updateButtons
(
ui
->
toolTree
->
currentItem
());
}
...
...
@@ -143,7 +150,6 @@ void ExternalToolConfig::handleCurrentItemChanged(QTreeWidgetItem *now, QTreeWid
void
ExternalToolConfig
::
updateButtons
(
QTreeWidgetItem
*
item
)
{
ExternalTool
*
tool
=
0
;
ui
->
addButton
->
setEnabled
(
item
!=
0
);
if
(
item
)
tool
=
item
->
data
(
0
,
Qt
::
UserRole
).
value
<
ExternalTool
*>
();
if
(
!
tool
)
{
...
...
@@ -313,7 +319,10 @@ void ExternalToolConfig::addTool()
{
// find category to use
QTreeWidgetItem
*
currentItem
=
ui
->
toolTree
->
currentItem
();
QTC_ASSERT
(
currentItem
,
return
);
if
(
!
currentItem
)
{
addCategory
();
return
;
}
QString
category
;
QTreeWidgetItem
*
parent
;
if
(
currentItem
->
parent
())
{
...
...
@@ -361,3 +370,24 @@ void ExternalToolConfig::removeTool()
delete
currentItem
;
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
);
}
src/plugins/coreplugin/dialogs/externaltoolconfig.h
View file @
0bcc8094
...
...
@@ -70,6 +70,7 @@ private slots:
void
updateCurrentItem
();
void
addTool
();
void
removeTool
();
void
addCategory
();
private:
Ui
::
ExternalToolConfig
*
ui
;
...
...
src/plugins/coreplugin/dialogs/externaltoolconfig.ui
View file @
0bcc8094
...
...
@@ -42,6 +42,9 @@ p, li { white-space: pre-wrap; }
<property
name=
"text"
>
<string>
+
</string>
</property>
<property
name=
"popupMode"
>
<enum>
QToolButton::MenuButtonPopup
</enum>
</property>
</widget>
</item>
<item>
...
...
@@ -122,11 +125,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item
row=
"1"
column=
"1"
>
<widget
class=
"Utils::PathChooser"
name=
"executable"
>
<property
name=
"expectedKind"
>
<enum>
Utils::PathChooser::Command
</enum>
</property>
</widget>
<widget
class=
"Utils::PathChooser"
name=
"executable"
native=
"true"
/>
</item>
<item
row=
"2"
column=
"0"
>
<widget
class=
"QLabel"
name=
"argumentsLabel"
>
...
...
@@ -146,11 +145,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item
row=
"3"
column=
"1"
>
<widget
class=
"Utils::PathChooser"
name=
"workingDirectory"
>
<property
name=
"expectedKind"
>
<enum>
Utils::PathChooser::Command
</enum>
</property>
</widget>
<widget
class=
"Utils::PathChooser"
name=
"workingDirectory"
native=
"true"
/>
</item>
<item
row=
"4"
column=
"0"
>
<widget
class=
"QLabel"
name=
"outputLabel"
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment