From c32d71c47fa3ba820924f82ca9eef0610287f4a2 Mon Sep 17 00:00:00 2001 From: WandererFan Date: Thu, 24 Mar 2016 12:48:07 -0400 Subject: [PATCH] Add more preferences --- src/Mod/TechDraw/App/DrawPage.cpp | 13 +- src/Mod/TechDraw/Gui/Command.cpp | 10 +- src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui | 402 +++++++++++++------ src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp | 12 +- src/Mod/TechDraw/Gui/QGIEdge.cpp | 19 +- src/Mod/TechDraw/Gui/QGIEdge.h | 2 + 6 files changed, 318 insertions(+), 140 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawPage.cpp b/src/Mod/TechDraw/App/DrawPage.cpp index ac134b025..00ef18e30 100644 --- a/src/Mod/TechDraw/App/DrawPage.cpp +++ b/src/Mod/TechDraw/App/DrawPage.cpp @@ -32,6 +32,8 @@ #include #include #include +#include + #include #include #include @@ -70,7 +72,16 @@ DrawPage::DrawPage(void) // Projection Properties ProjectionType.setEnums(ProjectionTypeEnums); - ADD_PROPERTY(ProjectionType, ((long)0)); + //ADD_PROPERTY(ProjectionType, ((long)0)); + Base::Reference 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? } diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index 34069b08c..566069b81 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -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")); diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui index b543441a6..39a0221a9 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui @@ -7,7 +7,7 @@ 0 0 601 - 550 + 600 @@ -19,7 +19,7 @@ 20 30 561 - 471 + 551 @@ -142,135 +142,288 @@ - - - - - - - 0 - 0 - - - - Font - - + - 20 - 30 - 301 - 41 + 0 + 160 + 559 + 91 - - - - - Label Font - - - - - - - LabelFont - - - Mod/TechDraw - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - + + + 0 + 0 + + + + Font + + + + + 20 + 30 + 451 + 41 + + + + + + + Label Font + + + + + + + LabelFont + + + Mod/TechDraw + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + - - - - - - Templates - - + - 20 - 30 - 531 - 80 + 0 + 240 + 559 + 121 - - - - - Gui::FileChooser::Directory - - - TemplateDir - - - /Mod/TechDraw - - - - - - - Default Template - - - - - - - Template Directory - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - TemplateFile - - - Mod/TechDraw - - - - + + Templates + + + + + 20 + 20 + 451 + 71 + + + + + + + Template Directory + + + + + + + Default Template + + + + + + + Gui::FileChooser::Directory + + + TemplateDir + + + /Mod/TechDraw + + + + + + + TemplateFile + + + /Mod/TechDraw + + + + + + + + + + 0 + 350 + 551 + 181 + + + + Misc + + + + + 20 + 30 + 531 + 131 + + + + + + + Hidden Line + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ProjectionAngle + + + Mod/TechDraw + + + + First + + + + + Third + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + HiddenLine + + + Mod/TechDraw + + + + Solid + + + + + Dash + + + + + Dot + + + + + DashDot + + + + + DashDotDot + + + + + + + + Projection Angle + + + + + + + Pattern Directory + + + + + + + Default Pattern File + + + + + + + PatternFile + + + /Mod/TechDraw + + + + + + + Gui::FileChooser::Directory + + + PatternDir + + + /Mod/TechDraw + + + + + @@ -298,6 +451,11 @@ Gui::ColorButton
Gui/PrefWidgets.h
+ + Gui::PrefComboBox + QComboBox +
Gui/PrefWidgets.h
+
Gui::PrefLineEdit QLineEdit diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp index 45aead0d8..af678dadc 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp @@ -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(); } /** diff --git a/src/Mod/TechDraw/Gui/QGIEdge.cpp b/src/Mod/TechDraw/Gui/QGIEdge.cpp index 1928ff01a..a96ebc70f 100644 --- a/src/Mod/TechDraw/Gui/QGIEdge.cpp +++ b/src/Mod/TechDraw/Gui/QGIEdge.cpp @@ -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 (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(); } diff --git a/src/Mod/TechDraw/Gui/QGIEdge.h b/src/Mod/TechDraw/Gui/QGIEdge.h index 0c0508eff..db22b224d 100644 --- a/src/Mod/TechDraw/Gui/QGIEdge.h +++ b/src/Mod/TechDraw/Gui/QGIEdge.h @@ -88,6 +88,8 @@ private: QColor m_colPre; QColor m_colSel; QColor m_colHid; + QColor m_defNormal; + Qt::PenStyle m_styleHid; }; } // namespace MDIViewPageGui