Add Pref Font Widget
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user