+ fixes #0001049: Sketcher preferences in preferences editor
This commit is contained in:
parent
f0b54d3ee5
commit
06239e9a57
|
@ -37,6 +37,7 @@
|
|||
/// Here the FreeCAD includes sorted by Base,App,Gui......
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/ViewProj.h>
|
||||
#include <App/Application.h>
|
||||
|
||||
#include "ViewProvider2DObject.h"
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
@ -143,9 +144,11 @@ SoSeparator* ViewProvider2DObject::createGrid(void)
|
|||
mycolor->rgb.setValue(0.7f, 0.7f ,0.7f);
|
||||
parent->addChild(mycolor);
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
|
||||
int pattern = hGrp->GetInt("GridLinePattern", 0x0f0f);
|
||||
SoDrawStyle* DefaultStyle = new SoDrawStyle;
|
||||
DefaultStyle->lineWidth = 1;
|
||||
DefaultStyle->linePattern = 0x0f0f;
|
||||
DefaultStyle->linePattern = pattern;
|
||||
|
||||
SoMaterial* LightStyle = new SoMaterial;
|
||||
LightStyle->transparency = 0.7f;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
|
@ -73,10 +74,15 @@ void finishDistanceConstraint(Gui::Command* cmd, Sketcher::SketchObject* sketch)
|
|||
vp->draw(); // Redraw
|
||||
}
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General");
|
||||
bool show = hGrp->GetBool("ShowDialogOnDistanceConstraint", true);
|
||||
|
||||
// Ask for the value of the distance immediately
|
||||
EditDatumDialog *editDatumDialog = new EditDatumDialog(sketch, ConStr.size() - 1);
|
||||
editDatumDialog->exec(false);
|
||||
delete editDatumDialog;
|
||||
if (show) {
|
||||
EditDatumDialog *editDatumDialog = new EditDatumDialog(sketch, ConStr.size() - 1);
|
||||
editDatumDialog->exec(false);
|
||||
delete editDatumDialog;
|
||||
}
|
||||
|
||||
//updateActive();
|
||||
cmd->getSelection().clearSelection();
|
||||
|
|
|
@ -24,11 +24,13 @@
|
|||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QPixmap>
|
||||
#endif
|
||||
|
||||
#include "SketcherSettings.h"
|
||||
#include "ui_SketcherSettings.h"
|
||||
#include "TaskSketcherGeneral.h"
|
||||
#include <App/Application.h>
|
||||
#include <Gui/PrefWidgets.h>
|
||||
|
||||
using namespace SketcherGui;
|
||||
|
@ -39,8 +41,13 @@ SketcherSettings::SketcherSettings(QWidget* parent)
|
|||
: PreferencePage(parent), ui(new Ui_SketcherSettings)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
form = new SketcherGeneralWidget(ui->groupBox);
|
||||
ui->gridLayout->addWidget(form, 1, 0, 1, 1);
|
||||
QGroupBox* groupBox = new QGroupBox(this);
|
||||
QGridLayout* gridLayout = new QGridLayout(groupBox);
|
||||
gridLayout->setSpacing(0);
|
||||
gridLayout->setMargin(0);
|
||||
form = new SketcherGeneralWidget(groupBox);
|
||||
gridLayout->addWidget(form, 0, 0, 1, 1);
|
||||
ui->gridLayout_3->addWidget(groupBox, 2, 0, 1, 1);
|
||||
|
||||
// Don't need them at the moment
|
||||
ui->label_16->hide();
|
||||
|
@ -49,6 +56,30 @@ SketcherSettings::SketcherSettings(QWidget* parent)
|
|||
ui->DefaultSketcherVertexWidth->hide();
|
||||
ui->label_13->hide();
|
||||
ui->DefaultSketcherLineWidth->hide();
|
||||
|
||||
QList < QPair<Qt::PenStyle, int> > styles;
|
||||
styles << qMakePair(Qt::SolidLine, 0xffff)
|
||||
<< qMakePair(Qt::DashLine, 0x0f0f)
|
||||
<< qMakePair(Qt::DotLine, 0xaaaa);
|
||||
// << qMakePair(Qt::DashDotLine, 0x????)
|
||||
// << qMakePair(Qt::DashDotDotLine, 0x????);
|
||||
ui->comboBox->setIconSize (QSize(80, 12));
|
||||
for (QList < QPair<Qt::PenStyle, int> >::iterator it = styles.begin(); it != styles.end(); ++it) {
|
||||
QPixmap px(ui->comboBox->iconSize());
|
||||
px.fill(Qt::transparent);
|
||||
QBrush brush(Qt::black);
|
||||
QPen pen(it->first);
|
||||
pen.setBrush(brush);
|
||||
pen.setWidth(2);
|
||||
|
||||
QPainter painter(&px);
|
||||
painter.setPen(pen);
|
||||
double mid = ui->comboBox->iconSize().height() / 2.0;
|
||||
painter.drawLine(0, mid, ui->comboBox->iconSize().width(), mid);
|
||||
painter.end();
|
||||
|
||||
ui->comboBox->addItem(QIcon(px), QString(), QVariant(it->second));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,7 +113,13 @@ void SketcherSettings::saveSettings()
|
|||
|
||||
// Sketch editing
|
||||
ui->EditSketcherFontSize->onSave();
|
||||
ui->dialogOnDistanceConstraint->onSave();
|
||||
form->saveSettings();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
|
||||
QVariant data = ui->comboBox->itemData(ui->comboBox->currentIndex());
|
||||
int pattern = data.toInt();
|
||||
hGrp->SetInt("GridLinePattern", pattern);
|
||||
}
|
||||
|
||||
void SketcherSettings::loadSettings()
|
||||
|
@ -107,7 +144,14 @@ void SketcherSettings::loadSettings()
|
|||
|
||||
// Sketch editing
|
||||
ui->EditSketcherFontSize->onRestore();
|
||||
ui->dialogOnDistanceConstraint->onRestore();
|
||||
form->loadSettings();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
|
||||
int pattern = hGrp->GetInt("GridLinePattern", 0x0f0f);
|
||||
int index = ui->comboBox->findData(QVariant(pattern));
|
||||
if (index <0) index = 1;
|
||||
ui->comboBox->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>359</width>
|
||||
<height>544</height>
|
||||
<height>586</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -456,19 +456,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>74</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -517,18 +504,39 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Grid line pattern</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="dialogOnDistanceConstraint">
|
||||
<property name="text">
|
||||
<string>Ask for value after creating a distance constraint</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</spacer>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ShowDialogOnDistanceConstraint</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -564,6 +572,11 @@
|
|||
<extends>Gui::ColorButton</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>CursorTextColor</tabstop>
|
||||
|
|
Loading…
Reference in New Issue
Block a user