Add more preferences

This commit is contained in:
WandererFan 2016-03-24 12:48:07 -04:00 committed by wmayer
parent 20de9af2c2
commit c32d71c47f
6 changed files with 318 additions and 140 deletions

View File

@ -32,6 +32,8 @@
#include <Base/Exception.h>
#include <Base/Console.h>
#include <Base/FileInfo.h>
#include <Base/Parameter.h>
#include <App/Application.h>
#include <App/Document.h>
#include <boost/regex.hpp>
@ -70,7 +72,16 @@ DrawPage::DrawPage(void)
// Projection Properties
ProjectionType.setEnums(ProjectionTypeEnums);
ADD_PROPERTY(ProjectionType, ((long)0));
//ADD_PROPERTY(ProjectionType, ((long)0));
Base::Reference<ParameterGrp> hGrp =
App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw");
int projType = hGrp->GetInt("ProjectionAngle", 0x01); //in prefs, 1 -> FirstAngle 2 -> ThirdAngle
if (projType == 2) {
ADD_PROPERTY(ProjectionType, ((long)1));
} else {
ADD_PROPERTY(ProjectionType, ((long)0));
}
ADD_PROPERTY_TYPE(Scale ,(1.0), group, App::Prop_None, "Scale factor for this Page");
//TODO: Page should create itself with default Template instead of Cmd figuring it out?
}

View File

@ -104,16 +104,11 @@ void CmdTechDrawNewPageDef::activated(int iMsg)
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw");
std::string defaultDir = App::Application::getResourceDir() + "Mod/Drawing/Templates";
QString templateDir = QString::fromStdString(hGrp->GetASCII("TemplateDir", defaultDir.c_str()));
if (templateDir.isEmpty()) { //preference key can be present, but have null value
templateDir = QString::fromStdString(defaultDir);
}
std::string defaultFileName = "A4_Landscape.svg";
std::string defaultFileName = defaultDir + "A4_Landscape.svg";
QString templateFileName = QString::fromStdString(hGrp->GetASCII("TemplateFile",defaultFileName.c_str()));
if (templateFileName.isEmpty()) {
templateFileName = QString::fromStdString(defaultFileName);
}
templateFileName = templateDir + QString::fromUtf8("/") + templateFileName;
std::string PageName = getUniqueObjectName("Page");
std::string TemplateName = getUniqueObjectName("Template");
@ -141,8 +136,7 @@ void CmdTechDrawNewPageDef::activated(int iMsg)
else {
Base::Console().Log("INFO - Template: %s for Page: %s NOT Found\n", PageName.c_str(),TemplateName.c_str());
}
}
else {
} else {
QMessageBox::critical(Gui::getMainWindow(),
QLatin1String("No template"),
QLatin1String("No default template found"));

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>601</width>
<height>550</height>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
@ -19,7 +19,7 @@
<x>20</x>
<y>30</y>
<width>561</width>
<height>471</height>
<height>551</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -142,135 +142,288 @@
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_Font">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Font</string>
</property>
<widget class="QWidget" name="gridLayoutWidget_2">
<widget class="QGroupBox" name="gb_Font">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>301</width>
<height>41</height>
<x>0</x>
<y>160</y>
<width>559</width>
<height>91</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="lbl_LabelFont">
<property name="text">
<string>Label Font</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Gui::PrefLineEdit" name="le_LabelFont">
<property name="prefEntry" stdset="0">
<cstring>LabelFont</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Font</string>
</property>
<widget class="QWidget" name="gridLayoutWidget_2">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>451</width>
<height>41</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="lbl_LabelFont">
<property name="text">
<string>Label Font</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Gui::PrefLineEdit" name="le_LabelFont">
<property name="prefEntry" stdset="0">
<cstring>LabelFont</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_Templates">
<property name="title">
<string>Templates</string>
</property>
<widget class="QWidget" name="gridLayoutWidget_3">
<widget class="QGroupBox" name="gb_Templates">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>531</width>
<height>80</height>
<x>0</x>
<y>240</y>
<width>559</width>
<height>121</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="2">
<widget class="Gui::PrefFileChooser" name="pfc_DefDir">
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
<property name="prefEntry" stdset="0">
<cstring>TemplateDir</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Default Template</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Template Directory</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="Gui::PrefLineEdit" name="le_DefTemplate">
<property name="prefEntry" stdset="0">
<cstring>TemplateFile</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw</cstring>
</property>
</widget>
</item>
</layout>
<property name="title">
<string>Templates</string>
</property>
<widget class="QWidget" name="gridLayoutWidget_3">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>451</width>
<height>71</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Template Directory</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Default Template</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="Gui::PrefFileChooser" name="pfc_DefDir">
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
<property name="prefEntry" stdset="0">
<cstring>TemplateDir</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw</cstring>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="Gui::PrefFileChooser" name="pfc_DefTemp">
<property name="prefEntry" stdset="0">
<cstring>TemplateFile</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="gbMisc">
<property name="geometry">
<rect>
<x>0</x>
<y>350</y>
<width>551</width>
<height>181</height>
</rect>
</property>
<property name="title">
<string>Misc</string>
</property>
<widget class="QWidget" name="gridLayoutWidget_4">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>531</width>
<height>131</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0">
<widget class="QLabel" name="lbl_HidLine">
<property name="text">
<string>Hidden Line</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="Gui::PrefComboBox" name="cb_Angle">
<property name="prefEntry" stdset="0">
<cstring>ProjectionAngle</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw</cstring>
</property>
<item>
<property name="text">
<string>First</string>
</property>
</item>
<item>
<property name="text">
<string>Third</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="Gui::PrefComboBox" name="cb_HidLine">
<property name="prefEntry" stdset="0">
<cstring>HiddenLine</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw</cstring>
</property>
<item>
<property name="text">
<string>Solid</string>
</property>
</item>
<item>
<property name="text">
<string>Dash</string>
</property>
</item>
<item>
<property name="text">
<string>Dot</string>
</property>
</item>
<item>
<property name="text">
<string>DashDot</string>
</property>
</item>
<item>
<property name="text">
<string>DashDotDot</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Angle">
<property name="text">
<string>Projection Angle</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_HatchDir">
<property name="text">
<string>Pattern Directory</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_Hatch">
<property name="text">
<string>Default Pattern File</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="Gui::PrefFileChooser" name="pfc_HatchFile">
<property name="prefEntry" stdset="0">
<cstring>PatternFile</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw</cstring>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="Gui::PrefFileChooser" name="pfc_HatchDir">
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
<property name="prefEntry" stdset="0">
<cstring>PatternDir</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
@ -298,6 +451,11 @@
<extends>Gui::ColorButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefComboBox</class>
<extends>QComboBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefLineEdit</class>
<extends>QLineEdit</extends>

View File

@ -48,8 +48,12 @@ void DlgPrefsTechDrawImp::saveSettings()
pcb_PreSelect->onSave();
pcb_Hidden->onSave();
le_LabelFont->onSave();
le_DefTemplate->onSave();
pfc_DefTemp->onSave();
pfc_DefDir->onSave();
cb_HidLine->onSave();
cb_Angle->onSave();
pfc_HatchFile->onSave();
pfc_HatchDir->onSave();
}
void DlgPrefsTechDrawImp::loadSettings()
@ -59,8 +63,12 @@ void DlgPrefsTechDrawImp::loadSettings()
pcb_PreSelect->onRestore();
pcb_Hidden->onRestore();
le_LabelFont->onRestore();
le_DefTemplate->onRestore();
pfc_DefTemp->onRestore();
pfc_DefDir->onRestore();
cb_HidLine->onRestore();
cb_Angle->onRestore();
pfc_HatchFile->onRestore();
pfc_HatchDir->onRestore();
}
/**

View File

@ -62,6 +62,7 @@ QGIEdge::QGIEdge(int index) :
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("NormalColor", 0x00000000));
m_colNormal = fcColor.asQColor();
m_defNormal = m_colNormal;
fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", 0x0000FF00));
m_colSel = fcColor.asQColor();
fcColor.setPackedValue(hGrp->GetUnsigned("PreSelectColor", 0x00080800));
@ -69,6 +70,9 @@ QGIEdge::QGIEdge(int index) :
fcColor.setPackedValue(hGrp->GetUnsigned("HiddenColor", 0x08080800));
m_colHid = fcColor.asQColor();
hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw");
m_styleHid = static_cast<Qt::PenStyle> (hGrp->GetInt("HiddenLine",2));
m_pen.setStyle(Qt::SolidLine);
m_pen.setCapStyle(Qt::RoundCap);
@ -137,11 +141,7 @@ void QGIEdge::setHighlighted(bool b)
}
void QGIEdge::setPrettyNormal() {
if (isHiddenEdge) {
m_colCurrent = m_colHid;
} else {
m_colCurrent = m_colNormal;
}
m_colCurrent = m_colNormal;
update();
}
@ -160,10 +160,15 @@ void QGIEdge::setStrokeWidth(float width) {
update();
}
//TODO: obs? we never change an existing edge's visibility.
void QGIEdge::setHiddenEdge(bool b) {
isHiddenEdge = b;
if (b) m_colCurrent = m_colHid;
if (b) {
m_pen.setStyle(m_styleHid);
m_colNormal = m_colHid;
} else {
m_pen.setStyle(Qt::SolidLine);
m_colNormal = m_defNormal;
}
update();
}

View File

@ -88,6 +88,8 @@ private:
QColor m_colPre;
QColor m_colSel;
QColor m_colHid;
QColor m_defNormal;
Qt::PenStyle m_styleHid;
};
} // namespace MDIViewPageGui