Add Pref Font Widget

This commit is contained in:
WandererFan
2018-02-27 14:28:36 -05:00
parent 606653787f
commit 314dcaa3cd
5 changed files with 200 additions and 0 deletions

View File

@@ -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"

View File

@@ -27,6 +27,8 @@
#include <QCheckBox>
#include <QComboBox>
#include <QRadioButton>
#include <QFontComboBox>
#include <QFont>
#include <Base/Parameter.h>
#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