Use ActionSelector in Loft panel and expose to Python by UiLoader
This commit is contained in:
@@ -68,10 +68,14 @@ LoftWidget::LoftWidget(QWidget* parent)
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
|
||||
d->ui.setupUi(this);
|
||||
connect(d->ui.treeWidgetWire, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
|
||||
d->ui.selector->setAvailableLabel(tr("Vertex/Wire"));
|
||||
d->ui.selector->setSelectedLabel(tr("Loft"));
|
||||
|
||||
connect(d->ui.selector->availableTreeWidget(), SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
|
||||
this, SLOT(onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
|
||||
connect(d->ui.treeWidgetLoft, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
|
||||
connect(d->ui.selector->selectedTreeWidget(), SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
|
||||
this, SLOT(onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
|
||||
|
||||
findShapes();
|
||||
}
|
||||
|
||||
@@ -105,7 +109,7 @@ void LoftWidget::findShapes()
|
||||
child->setData(0, Qt::UserRole, name);
|
||||
Gui::ViewProvider* vp = activeGui->getViewProvider(*it);
|
||||
if (vp) child->setIcon(0, vp->getIcon());
|
||||
d->ui.treeWidgetWire->addTopLevelItem(child);
|
||||
d->ui.selector->availableTreeWidget()->addTopLevelItem(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,13 +129,13 @@ bool LoftWidget::accept()
|
||||
|
||||
QTextStream str(&list);
|
||||
|
||||
int count = d->ui.treeWidgetLoft->topLevelItemCount();
|
||||
int count = d->ui.selector->selectedTreeWidget()->topLevelItemCount();
|
||||
if (count < 2) {
|
||||
QMessageBox::critical(this, tr("Too few elements"), tr("At least two vertices, edges or wires are required."));
|
||||
return false;
|
||||
}
|
||||
for (int i=0; i<count; i++) {
|
||||
QTreeWidgetItem* child = d->ui.treeWidgetLoft->topLevelItem(i);
|
||||
QTreeWidgetItem* child = d->ui.selector->selectedTreeWidget()->topLevelItem(i);
|
||||
QString name = child->data(0, Qt::UserRole).toString();
|
||||
str << "App.getDocument('" << d->document.c_str() << "')." << name << ", ";
|
||||
}
|
||||
@@ -177,61 +181,13 @@ void LoftWidget::onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem*
|
||||
}
|
||||
}
|
||||
|
||||
void LoftWidget::on_addButton_clicked()
|
||||
{
|
||||
QTreeWidgetItem* item = d->ui.treeWidgetWire->currentItem();
|
||||
if (item) {
|
||||
int index = d->ui.treeWidgetWire->indexOfTopLevelItem(item);
|
||||
item = d->ui.treeWidgetWire->takeTopLevelItem(index);
|
||||
d->ui.treeWidgetWire->setCurrentItem(0);
|
||||
d->ui.treeWidgetLoft->addTopLevelItem(item);
|
||||
d->ui.treeWidgetLoft->setCurrentItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void LoftWidget::on_removeButton_clicked()
|
||||
{
|
||||
QTreeWidgetItem* item = d->ui.treeWidgetLoft->currentItem();
|
||||
if (item) {
|
||||
int index = d->ui.treeWidgetLoft->indexOfTopLevelItem(item);
|
||||
item = d->ui.treeWidgetLoft->takeTopLevelItem(index);
|
||||
d->ui.treeWidgetLoft->setCurrentItem(0);
|
||||
d->ui.treeWidgetWire->addTopLevelItem(item);
|
||||
d->ui.treeWidgetWire->setCurrentItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void LoftWidget::on_upButton_clicked()
|
||||
{
|
||||
QTreeWidgetItem* item = d->ui.treeWidgetLoft->currentItem();
|
||||
if (item && d->ui.treeWidgetLoft->isItemSelected(item)) {
|
||||
int index = d->ui.treeWidgetLoft->indexOfTopLevelItem(item);
|
||||
if (index > 0) {
|
||||
d->ui.treeWidgetLoft->takeTopLevelItem(index);
|
||||
d->ui.treeWidgetLoft->insertTopLevelItem(index-1, item);
|
||||
d->ui.treeWidgetLoft->setCurrentItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoftWidget::on_downButton_clicked()
|
||||
{
|
||||
QTreeWidgetItem* item = d->ui.treeWidgetLoft->currentItem();
|
||||
if (item && d->ui.treeWidgetLoft->isItemSelected(item)) {
|
||||
int index = d->ui.treeWidgetLoft->indexOfTopLevelItem(item);
|
||||
if (index < d->ui.treeWidgetLoft->topLevelItemCount()-1) {
|
||||
d->ui.treeWidgetLoft->takeTopLevelItem(index);
|
||||
d->ui.treeWidgetLoft->insertTopLevelItem(index+1, item);
|
||||
d->ui.treeWidgetLoft->setCurrentItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoftWidget::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
d->ui.retranslateUi(this);
|
||||
d->ui.selector->setAvailableLabel(tr("Vertex/Wire"));
|
||||
d->ui.selector->setSelectedLabel(tr("Loft"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +43,6 @@ public:
|
||||
bool reject();
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_addButton_clicked();
|
||||
void on_removeButton_clicked();
|
||||
void on_upButton_clicked();
|
||||
void on_downButton_clicked();
|
||||
void onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*);
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>324</width>
|
||||
<width>336</width>
|
||||
<height>326</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -14,172 +14,8 @@
|
||||
<string>Loft</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QTreeWidget" name="treeWidgetWire">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Vertex/Wire</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<spacer name="spacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>33</width>
|
||||
<height>58</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="addButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Move right</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string><b>Move the selected item one level down.</b><p>This will also change the level of the parent item.</p></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/button_right.xpm</normaloff>:/icons/button_right.xpm</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Move left</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string><b>Move the selected item one level up.</b><p>This will also change the level of the parent item.</p></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/button_left.xpm</normaloff>:/icons/button_left.xpm</iconset>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="upButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Move up</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string><b>Move the selected item up.</b><p>The item will be moved within the hierarchy level.</p></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/button_up.xpm</normaloff>:/icons/button_up.xpm</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="downButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Move down</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string><b>Move the selected item down.</b><p>The item will be moved within the hierarchy level.</p></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/button_down.xpm</normaloff>:/icons/button_down.xpm</iconset>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>33</width>
|
||||
<height>57</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QTreeWidget" name="treeWidgetLoft">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Loft</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="Gui::ActionSelector" name="selector"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkSolid">
|
||||
@@ -188,15 +24,35 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkRuledSurface">
|
||||
<property name="text">
|
||||
<string>Ruled surface</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::ActionSelector</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../Gui/Icons/resource.qrc"/>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user