fix default Hatch file/dir

This commit is contained in:
WandererFan 2016-04-26 12:55:03 -04:00 committed by wmayer
parent 37df199f24
commit 9a85375705
4 changed files with 48 additions and 76 deletions

View File

@ -29,6 +29,9 @@
#include <iomanip>
# include <QFile>
# include <QFileInfo>
#include <App/Application.h>
#include <Base/Console.h>
#include <Base/Exception.h>
@ -58,18 +61,16 @@ DrawHatch::DrawHatch(void)
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw");
std::string defaultDir = App::Application::getResourceDir() + "Mod/Drawing/patterns";
QString patternDir = QString::fromStdString(hGrp->GetASCII("PatternDir", defaultDir.c_str()));
if (patternDir.isEmpty()) { //PatternDir key probably has null value
patternDir = QString::fromStdString(defaultDir);
}
std::string defaultFileName = "simple.svg";
std::string defaultDir = App::Application::getResourceDir() + "Mod/Drawing/patterns/";
std::string defaultFileName = defaultDir + "simple.svg";
QString patternFileName = QString::fromStdString(hGrp->GetASCII("PatternFile",defaultFileName.c_str()));
if (patternFileName.isEmpty()) {
patternFileName = QString::fromStdString(defaultFileName);
}
patternFileName = patternDir + QString::fromUtf8("/") + patternFileName;
HatchPattern.setValue(patternFileName.toUtf8().constData());
QFileInfo tfi(patternFileName);
if (tfi.isReadable()) {
HatchPattern.setValue(patternFileName.toUtf8().constData());
}
}
DrawHatch::~DrawHatch()

View File

@ -155,7 +155,8 @@ void CmdTechDrawNewHatch::activated(int iMsg)
//should this be: doCommand(Doc,"App..Feat..Edges = [(App...%s,%s),(App..%s,%s),...]",objs[0]->getNameInDocument(),subs[0],...);
//seems very unwieldy
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
//Note: Hatch is not added to the Page Views. DVP::getHatches gathers them via PartView property when needed. Can't remember why!
//doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
commitCommand();
//Horrible hack to force Tree update ??still required??

View File

@ -286,7 +286,7 @@
<x>20</x>
<y>30</y>
<width>531</width>
<height>131</height>
<height>103</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
@ -297,20 +297,7 @@
</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">
<item row="0" column="1">
<widget class="Gui::PrefComboBox" name="cb_Angle">
<property name="prefEntry" stdset="0">
<cstring>ProjectionAngle</cstring>
@ -330,20 +317,7 @@
</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">
<item row="1" column="1">
<widget class="Gui::PrefComboBox" name="cb_HidLine">
<property name="prefEntry" stdset="0">
<cstring>HiddenLine</cstring>
@ -385,42 +359,38 @@
</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>
</layout>
</widget>
<widget class="QWidget" name="gridLayoutWidget_5">
<property name="geometry">
<rect>
<x>20</x>
<y>130</y>
<width>531</width>
<height>54</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="1">
<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="0" column="0">
<widget class="QLabel" name="lbl_Hatch">
<property name="text">
<string>Default Pattern File</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>

View File

@ -53,7 +53,7 @@ void DlgPrefsTechDrawImp::saveSettings()
cb_HidLine->onSave();
cb_Angle->onSave();
pfc_HatchFile->onSave();
pfc_HatchDir->onSave();
//pfc_HatchDir->onSave();
}
void DlgPrefsTechDrawImp::loadSettings()
@ -68,7 +68,7 @@ void DlgPrefsTechDrawImp::loadSettings()
cb_HidLine->onRestore();
cb_Angle->onRestore();
pfc_HatchFile->onRestore();
pfc_HatchDir->onRestore();
//pfc_HatchDir->onRestore();
}
/**