diff --git a/src/Gui/PrefWidgets.cpp b/src/Gui/PrefWidgets.cpp index c5750981a4..77d7408d6f 100644 --- a/src/Gui/PrefWidgets.cpp +++ b/src/Gui/PrefWidgets.cpp @@ -640,4 +640,45 @@ void PrefQuantitySpinBox::setHistorySize(int i) d->historySize = i; } +// -------------------------------------------------------------------- + +PrefFontBox::PrefFontBox ( QWidget * parent ) + : QFontComboBox(parent), PrefWidget() +{ +} + +PrefFontBox::~PrefFontBox() +{ +} + +void PrefFontBox::restorePreferences() +{ + if ( getWindowParameter().isNull() ) + { + Console().Warning("Cannot restore!\n"); + return; + } + + QFont currFont = currentFont(); //QFont from selector widget + QString currName = currFont.family(); + + std::string prefName = getWindowParameter()->GetASCII(entryName(), currName.toUtf8()); //font name from cfg file + + currFont.setFamily(QString::fromStdString(prefName)); + setCurrentFont(currFont); //set selector widget to name from cfg file +} + +void PrefFontBox::savePreferences() +{ + if (getWindowParameter().isNull()) + { + Console().Warning("Cannot save!\n"); + return; + } + + QFont currFont = currentFont(); + QString currName = currFont.family(); + getWindowParameter()->SetASCII( entryName() , currName.toUtf8() ); +} + #include "moc_PrefWidgets.cpp" diff --git a/src/Gui/PrefWidgets.h b/src/Gui/PrefWidgets.h index 1a9870334e..643ef265ba 100644 --- a/src/Gui/PrefWidgets.h +++ b/src/Gui/PrefWidgets.h @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include "Widgets.h" #include "Window.h" @@ -322,6 +324,26 @@ private: Q_DECLARE_PRIVATE(PrefQuantitySpinBox) }; +/** The PrefFontBox class. + * \author wandererfan + */ +class GuiExport PrefFontBox : public QFontComboBox, public PrefWidget +{ + Q_OBJECT + + Q_PROPERTY( QByteArray prefEntry READ entryName WRITE setEntryName ) + Q_PROPERTY( QByteArray prefPath READ paramGrpPath WRITE setParamGrpPath ) + +public: + PrefFontBox ( QWidget * parent = 0 ); + virtual ~PrefFontBox(); + +protected: + // restore from/save to parameters + void restorePreferences(); + void savePreferences(); +}; + } // namespace Gui #endif // GUI_PREFWIDGETS_H diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui index 05e5384605..b38b000983 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui @@ -159,29 +159,6 @@ - - - - Template Dot Size - - - - - - - EditableText Dot Size in mm - - - 3.000000000000000 - - - TemplateDotSize - - - /Mod/TechDraw/General - - - @@ -603,7 +580,23 @@ - + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + @@ -623,22 +616,6 @@ - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - @@ -646,19 +623,6 @@ - - - - osifont - - - LabelFont - - - Mod/TechDraw/Labels - - - @@ -666,6 +630,73 @@ + + + + Font for View Labels + + + + osifont + + + + LabelFont + + + /Mod/TechDraw/Labels + + + + + + + Template Dot Size + + + + + + + EditableText Dot Size in mm + + + 3.000000000000000 + + + TemplateDotSize + + + /Mod/TechDraw/General + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -740,6 +771,11 @@ QDoubleSpinBox
Gui/PrefWidgets.h
+ + Gui::PrefFontBox + QFontComboBox +
Gui/PrefWidgets.h
+
diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp index d5e57fa7d2..1c53fc7237 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp @@ -58,7 +58,7 @@ void DlgPrefsTechDrawImp::saveSettings() pcb_Background->onSave(); pcb_Hatch->onSave(); - le_LabelFont->onSave(); + pfb_LabelFont->onSave(); dsb_LabelSize->onSave(); pfc_DefTemp->onSave(); @@ -85,7 +85,7 @@ void DlgPrefsTechDrawImp::loadSettings() pcb_Background->onRestore(); pcb_Hatch->onRestore(); - le_LabelFont->onRestore(); + pfb_LabelFont->onRestore(); dsb_LabelSize->onRestore(); pfc_DefTemp->onRestore(); diff --git a/src/Tools/plugins/widget/customwidgets.cpp b/src/Tools/plugins/widget/customwidgets.cpp index 51f70a6dfa..b1840c3793 100644 --- a/src/Tools/plugins/widget/customwidgets.cpp +++ b/src/Tools/plugins/widget/customwidgets.cpp @@ -1224,3 +1224,35 @@ void PrefSlider::setParamGrpPath ( const QByteArray& name ) { m_sPrefGrp = name; } + +// -------------------------------------------------------------------- + +PrefFontBox::PrefFontBox ( QWidget * parent ) + : QFontComboBox(parent) +{ +} + +PrefFontBox::~PrefFontBox() +{ +} + +QByteArray PrefFontBox::entryName () const +{ + return m_sPrefName; +} + +QByteArray PrefFontBox::paramGrpPath () const +{ + return m_sPrefGrp; +} + +void PrefFontBox::setEntryName ( const QByteArray& name ) +{ + m_sPrefName = name; +} + +void PrefFontBox::setParamGrpPath ( const QByteArray& name ) +{ + m_sPrefGrp = name; +} + diff --git a/src/Tools/plugins/widget/customwidgets.h b/src/Tools/plugins/widget/customwidgets.h index cdb697aab2..361418eb87 100644 --- a/src/Tools/plugins/widget/customwidgets.h +++ b/src/Tools/plugins/widget/customwidgets.h @@ -38,6 +38,7 @@ #include #include #include +#include namespace Base { class Quantity{}; @@ -581,6 +582,28 @@ private: QByteArray m_sPrefGrp; }; +// ------------------------------------------------------------------------------ + +class PrefFontBox : public QFontComboBox +{ + Q_OBJECT + + Q_PROPERTY( QByteArray prefEntry READ entryName WRITE setEntryName ) + Q_PROPERTY( QByteArray prefPath READ paramGrpPath WRITE setParamGrpPath ) + +public: + PrefFontBox ( QWidget * parent = 0 ); + virtual ~PrefFontBox(); + + QByteArray entryName () const; + QByteArray paramGrpPath () const; + void setEntryName ( const QByteArray& name ); + void setParamGrpPath ( const QByteArray& name ); + +private: + QByteArray m_sPrefName; + QByteArray m_sPrefGrp; +}; } // namespace Gui #endif // GUI_CUSTOMWIDGETS_H diff --git a/src/Tools/plugins/widget/plugin.cpp b/src/Tools/plugins/widget/plugin.cpp index 9ac5134681..450493fa6c 100644 --- a/src/Tools/plugins/widget/plugin.cpp +++ b/src/Tools/plugins/widget/plugin.cpp @@ -1372,6 +1372,87 @@ public: } }; + +/* XPM */ +static const char *fontbox_pixmap[]={ +"22 22 6 1", +"a c #000000", +"# c #000080", +"b c #008080", +"c c #808080", +"d c #c0c0c0", +". c #ffffff", +"...#aaaaaaaaaaaaaa#...", +".baccccccccccccccccab.", +".acccddddddddddddddca.", +"#ccd.................a", +"acc..................a", +"acd..................a", +"acd..................a", +"acd. ................a", +"acd..................a", +"acd..................a", +"acd..................a", +"acd..................a", +"acd..................a", +"acd..................a", +"acd..................a", +"acd..................a", +"acd..................a", +"acd..................a", +"#cd..................#", +".ac................da.", +".badd............dda#.", +"...#aaaaaaaaaaaaaa#..."}; + +class PrefFontBoxPlugin : public QDesignerCustomWidgetInterface +{ + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + PrefFontBoxPlugin() + { + } + QWidget *createWidget(QWidget *parent) + { + return new Gui::PrefFontBox(parent); + } + QString group() const + { + return QLatin1String("Preference Widgets"); + } + QIcon icon() const + { + return QIcon( QPixmap( fontbox_pixmap ) ); + } + QString includeFile() const + { + return QLatin1String("Gui/PrefWidgets.h"); + } + QString toolTip() const + { + return QLatin1String("Font Box"); + } + QString whatsThis() const + { + return QLatin1String("Font box widget (spin button)."); + } + bool isContainer() const + { + return false; + } + QString domXml() const + { + return "\n" + " \n" + " \n" + ""; + } + QString name() const + { + return QLatin1String("Gui::PrefFontBox"); + } +}; + /* XPM */ /* static char *listbox_pixmap[]={ @@ -1432,6 +1513,7 @@ QList CustomWidgetPlugin::customWidgets () con cw.append(new PrefComboBoxPlugin); cw.append(new PrefLineEditPlugin); cw.append(new PrefDoubleSpinBoxPlugin); + cw.append(new PrefFontBoxPlugin); return cw; }