[TechDraw] Simplify retrievement of user preferences

This commit is contained in:
Benjamin Bræstrup Sayoc
2023-04-07 15:49:12 +02:00
committed by WandererFan
parent 010e2ca377
commit 3b2e44a274
3 changed files with 63 additions and 301 deletions

View File

@@ -101,19 +101,13 @@ QColor PreferencesGui::sectionLineQColor()
App::Color PreferencesGui::centerColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Decorations");
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CenterColor", 0x000000FF));
App::Color fcColor = App::Color((uint32_t) Preferences::getPreferenceGroup("Decorations")->GetUnsigned("CenterColor", 0x000000FF));
return fcColor;
}
QColor PreferencesGui::centerQColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Decorations");
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CenterColor", 0x000000FF));
App::Color fcColor = App::Color((uint32_t) Preferences::getPreferenceGroup("Decorations")->GetUnsigned("CenterColor", 0x000000FF));
return fcColor.asValue<QColor>();
}
@@ -124,96 +118,67 @@ QColor PreferencesGui::vertexQColor()
App::Color PreferencesGui::dimColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Dimensions");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
fcColor.setPackedValue(Preferences::getPreferenceGroup("Dimensions")->GetUnsigned("Color", 0x000000FF)); //#000000 black
return fcColor;
}
QColor PreferencesGui::dimQColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Dimensions");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
fcColor.setPackedValue(Preferences::getPreferenceGroup("Dimensions")->GetUnsigned("Color", 0x000000FF)); //#000000 black
return fcColor.asValue<QColor>();
}
App::Color PreferencesGui::leaderColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/LeaderLine");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
fcColor.setPackedValue(Preferences::getPreferenceGroup("LeaderLine")->GetUnsigned("Color", 0x000000FF)); //#000000 black
return fcColor;
}
QColor PreferencesGui::leaderQColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/LeaderLine");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
fcColor.setPackedValue(Preferences::getPreferenceGroup("LeaderLine")->GetUnsigned("Color", 0x000000FF)); //#000000 black
return fcColor.asValue<QColor>();
}
int PreferencesGui::dimArrowStyle()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Dimensions");
int style = hGrp->GetInt("ArrowStyle", 0);
int style = Preferences::getPreferenceGroup("Dimensions")->GetInt("ArrowStyle", 0);
return style;
}
double PreferencesGui::dimArrowSize()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Dimensions");
double size = hGrp->GetFloat("ArrowSize", Preferences::dimFontSizeMM());
double size = Preferences::getPreferenceGroup("Dimensions")->GetFloat("ArrowSize", Preferences::dimFontSizeMM());
return size;
}
double PreferencesGui::edgeFuzz()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/General");
double result = hGrp->GetFloat("EdgeFuzz", 10.0);
double result = Preferences::getPreferenceGroup("General")->GetFloat("EdgeFuzz", 10.0);
return result;
}
Qt::PenStyle PreferencesGui::sectionLineStyle()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Decorations");
Qt::PenStyle sectStyle = static_cast<Qt::PenStyle> (hGrp->GetInt("SectionLine", 2));
Qt::PenStyle sectStyle = static_cast<Qt::PenStyle> (Preferences::getPreferenceGroup("Decorations")->GetInt("SectionLine", 2));
return sectStyle;
}
bool PreferencesGui::sectionLineMarks()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Decorations");
return hGrp->GetBool("SectionLineMarks", true);
return Preferences::getPreferenceGroup("Decorations")->GetBool("SectionLineMarks", true);
}
QString PreferencesGui::weldingDirectory()
{
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Symbols/Welding/AWS/";
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files");
std::string symbolDir = hGrp->GetASCII("WeldingDir", defaultDir.c_str());
std::string symbolDir = Preferences::getPreferenceGroup("Files")->GetASCII("WeldingDir", defaultDir.c_str());
if (symbolDir.empty()) {
symbolDir = defaultDir;
}
@@ -228,49 +193,34 @@ QString PreferencesGui::weldingDirectory()
App::Color PreferencesGui::gridColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("gridColor", 0x000000FF)); //#000000 black
fcColor.setPackedValue(Preferences::getPreferenceGroup("Colors")->GetUnsigned("gridColor", 0x000000FF)); //#000000 black
return fcColor;
}
QColor PreferencesGui::gridQColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("gridColor", 0x000000FF)); //#000000 black
fcColor.setPackedValue(Preferences::getPreferenceGroup("Colors")->GetUnsigned("gridColor", 0x000000FF)); //#000000 black
return fcColor.asValue<QColor>();
}
double PreferencesGui::gridSpacing()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/General");
double spacing = hGrp->GetFloat("gridSpacing", 10.0);
double spacing = Preferences::getPreferenceGroup("General")->GetFloat("gridSpacing", 10.0);
return spacing;
}
bool PreferencesGui::showGrid()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/General");
bool show = hGrp->GetBool("showGrid", false);
bool show = Preferences::getPreferenceGroup("General")->GetBool("showGrid", false);
return show;
}
App::Color PreferencesGui::pageColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Colors");
App::Color result;
result.setPackedValue(hGrp->GetUnsigned("PageColor", 0xFFFFFFFF)); //#FFFFFFFF white
result.setPackedValue(Preferences::getPreferenceGroup("Colors")->GetUnsigned("PageColor", 0xFFFFFFFF)); //#FFFFFFFF white
return result;
}