30 :
QObject(parent), pReference(parent), pTarget(parent), pInhibitFontChangeRecursion(false),
31 pHasAppliedFont(false), pThorough(false)
33 klfDbg(
"constructor. Parent="<<parent) ;
34 parent->installEventFilter(
this);
38 :
QObject(target), pReference(ref), pTarget(target), pInhibitFontChangeRecursion(false),
39 pHasAppliedFont(false), pThorough(false)
41 klfDbg(
"constructor. Ref="<<ref<<
", tgt="<<target) ;
42 ref->installEventFilter(
this);
44 target->installEventFilter(
this);
64 klfDbg(
"eventFilter("<<
object<<
",ev.type="<<event->
type()<<
"), ref="<<ref<<
", tgt="<<target) ;
73 if (event->
type() == QEvent::FontChange) {
74 klfDbg(
"event filter, font change event! object="<<
object<<
", event/type="<<event->
type()
75 <<
", refWidget="<<ref<<
", targetWidget="<<target) ;
76 if (pInhibitFontChangeRecursion) {
77 klfDbg(
"inhibited `font change' event recursion.");
78 pInhibitFontChangeRecursion =
false;
82 calculateAndApplyNewFont();
86 if (
object == target) {
87 if (event->
type() == QEvent::Show) {
89 calculateAndApplyNewFont();
97 static void set_property_children(
QObject *
object,
const char *
inherits,
const char *propName,
101 QObjectList
children =
object->children();
102 Q_FOREACH(
QObject *obj, children) {
104 QString dontchangepropname =
QString(
"klfDontChange_") + propName;
108 set_property_children(obj,
inherits, propName, value);
115 void KLFRelativeFontBase::calculateAndApplyNewFont()
120 klfDbg(
"Applying font "<<f<<
" calculated from base font "<<ref->font()) ;
123 pInhibitFontChangeRecursion =
true;
127 set_property_children(target,
"QWidget",
"font",
QVariant(f));
129 pHasAppliedFont =
true;
148 void KLFRelativeFont::rfinit()
166 pRelPointSize = relps;
170 pForceFamily = family;
188 if (pForceWeight >= 0)
190 if (pForceStyle >= 0)
191 f.
setStyle((QFont::Style)pForceStyle);
192 if (pRelPointSize != 0)
void setPointSize(int pointSize)
virtual ~KLFRelativeFontBase()
void setForceStyle(int style)
const QObjectList & children() const
bool eventFilter(QObject *object, QEvent *event)
#define klfDbg(streamableItems)
print debug stream items
#define KLF_DEBUG_BLOCK(msg)
Utility to debug the execution of a block.
void setWeight(int weight)
virtual ~KLFRelativeFont()
virtual QFont calculateRelativeFont(const QFont &baseFont)=0
QWidget * referenceWidget()
virtual bool event(QEvent *e)
virtual QFont calculateRelativeFont(const QFont &baseFont)
void setStyle(Style style)
QVariant property(const char *name) const
bool inherits(const char *className) const
const char * constData() const
void setForceWeight(int weight)
KLFRelativeFont(QWidget *parent)
QByteArray toLatin1() const
void setForceFamily(const QString &family)
void setThorough(bool thorough)
void setFamily(const QString &family)
void setRelPointSize(int relps)
bool setProperty(const char *name, const QVariant &value)
KLFRelativeFontBase(QWidget *parent)