[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/kdm/kfrontend/themer
From: Oswald Buddenhagen <ossi () kde ! org>
Date: 2006-10-01 0:19:22
Message-ID: 1159661962.194182.20541.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 590818 by ossi:
have a font struct that knows whether it was explicitly set
M +8 -5 kdmlabel.cpp
M +1 -1 kdmlabel.h
M +27 -24 parse.cpp
M +13 -3 parse.h
--- trunk/KDE/kdebase/workspace/kdm/kfrontend/themer/kdmlabel.cpp #590817:590818
@@ -88,6 +88,9 @@
}
}
+ if (!label.normal.font.present)
+ parseFont( "Sans 14", label.normal.font );
+
// Check if this is a timer label
label.isTimer = label.text.indexOf( "%c" ) >= 0;
if (label.isTimer) {
@@ -145,7 +148,7 @@
else if (state == Sprelight && label.prelight.present)
l = &label.prelight;
// get the hint from font metrics
- return QFontMetrics( l->font ).size( Qt::AlignLeft | Qt::TextSingleLine, cText );
+ return QFontMetrics( l->font.font ).size( Qt::AlignLeft | Qt::TextSingleLine, cText );
}
void
@@ -158,21 +161,21 @@
else if (state == Sprelight && label.prelight.present)
l = &label.prelight;
// draw the label
- p->setFont( l->font );
+ p->setFont( l->font.font );
p->setPen( l->color );
if (cAccelOff != -1) {
QRect tarea( area );
- QFontMetrics fm( l->font );
+ QFontMetrics fm( l->font.font );
QString left = cText.left( cAccelOff );
p->drawText( area, Qt::AlignLeft | Qt::SingleLine, left );
tarea.rLeft() += fm.width( left );
- QFont f( l->font );
+ QFont f( l->font.font );
f.setUnderline( true );
p->setFont( f );
QString acc( cText[cAccelOff + 1] );
p->drawText( tarea, Qt::AlignLeft | Qt::SingleLine, acc );
tarea.rLeft() += fm.width( acc );
- p->setFont( l->font );
+ p->setFont( l->font.font );
p->drawText( tarea, Qt::AlignLeft | Qt::SingleLine, cText.mid( cAccelOff + 2 ) );
} else
p->drawText( area, Qt::AlignLeft | Qt::TextSingleLine, cText );
--- trunk/KDE/kdebase/workspace/kdm/kfrontend/themer/kdmlabel.h #590817:590818
@@ -59,7 +59,7 @@
bool isTimer;
struct LabelClass {
QColor color;
- QFont font;
+ FontType font;
bool present;
} normal, active, prelight;
} label;
--- trunk/KDE/kdebase/workspace/kdm/kfrontend/themer/parse.cpp #590817:590818
@@ -23,7 +23,6 @@
#include <QString>
#include <QStringList>
-#include <QFont>
#include <QColor>
void
@@ -73,60 +72,64 @@
}
void
-parseFont( const QString &is, QFont &font )
+parseFont( const QString &is, FontType &ft )
{
+ if (is.isNull())
+ return;
QString rs( is.simplified() );
+ if (!(ft.present = !rs.isEmpty()))
+ return;
QString s( getword( rs ) );
bool ok;
if (s.endsWith( "px" )) {
int ps = s.left( s.length() - 2 ).toInt( &ok );
if (ok) {
- font.setPixelSize( ps );
+ ft.font.setPixelSize( ps );
s = getword( rs );
}
} else {
double ps = s.toDouble( &ok );
if (ok) {
- font.setPointSizeF( ps );
+ ft.font.setPointSizeF( ps );
s = getword( rs );
}
}
forever {
QString ss( s.toLower() );
if (ss == "oblique")
- font.setStyle( QFont::StyleOblique );
+ ft.font.setStyle( QFont::StyleOblique );
else if (ss == "italic")
- font.setStyle( QFont::StyleItalic );
+ ft.font.setStyle( QFont::StyleItalic );
else if (ss == "ultra-light")
- font.setWeight( 13 );
+ ft.font.setWeight( 13 );
else if (ss == "light")
- font.setWeight( QFont::Light );
+ ft.font.setWeight( QFont::Light );
else if (ss == "medium")
- font.setWeight( 50 );
+ ft.font.setWeight( 50 );
else if (ss == "semi-bold")
- font.setWeight( QFont::DemiBold );
+ ft.font.setWeight( QFont::DemiBold );
else if (ss == "bold")
- font.setWeight( QFont::Bold );
+ ft.font.setWeight( QFont::Bold );
else if (ss == "ultra-bold")
- font.setWeight( QFont::Black );
+ ft.font.setWeight( QFont::Black );
else if (ss == "heavy")
- font.setWeight( 99 );
+ ft.font.setWeight( 99 );
else if (ss == "ultra-condensed")
- font.setStretch( QFont::UltraCondensed );
+ ft.font.setStretch( QFont::UltraCondensed );
else if (ss == "extra-condensed")
- font.setStretch( QFont::ExtraCondensed );
+ ft.font.setStretch( QFont::ExtraCondensed );
else if (ss == "condensed")
- font.setStretch( QFont::Condensed );
+ ft.font.setStretch( QFont::Condensed );
else if (ss == "semi-condensed")
- font.setStretch( QFont::SemiCondensed );
+ ft.font.setStretch( QFont::SemiCondensed );
else if (ss == "semi-expanded")
- font.setStretch( QFont::SemiExpanded );
+ ft.font.setStretch( QFont::SemiExpanded );
else if (ss == "expanded")
- font.setStretch( QFont::Expanded );
+ ft.font.setStretch( QFont::Expanded );
else if (ss == "extra-expanded")
- font.setStretch( QFont::ExtraExpanded );
+ ft.font.setStretch( QFont::ExtraExpanded );
else if (ss == "ultra-expanded")
- font.setStretch( QFont::UltraExpanded );
+ ft.font.setStretch( QFont::UltraExpanded );
else if (ss == "normal" || // no-op
ss == "small-caps" || // this and following ignored
ss == "not-rotated" || ss == "south" || ss == "upside-down" ||
@@ -145,11 +148,11 @@
QStringList ffs = rs.split( QRegExp( " ?, ?" ), QString::SkipEmptyParts );
if (!ffs.isEmpty()) {
foreach (QString ff, ffs) {
- font.setFamily( ff );
- if (font.exactMatch())
+ ft.font.setFamily( ff );
+ if (ft.font.exactMatch())
return;
}
- font.setFamily( ffs.first() );
+ ft.font.setFamily( ffs.first() );
}
}
--- trunk/KDE/kdebase/workspace/kdm/kfrontend/themer/parse.h #590817:590818
@@ -22,8 +22,9 @@
#ifndef PARSE_H
#define PARSE_H
+#include <QFont>
+
class QString;
-class QFont;
class QColor;
enum DataType { DTnone, DTpixel, DTnpixel, DTpercent, DTbox, DTscale };
@@ -32,8 +33,17 @@
DataType type;
};
+struct FontType {
+ QFont font;
+ bool present;
+
+ FontType() : present( false )
+ {
+ }
+};
+
void parseSize( const QString &, DataPoint & );
-void parseFont( const QString &, QFont & );
-void parseColor( const QString &col, const QString &a, QColor & );
+void parseFont( const QString &, FontType & );
+void parseColor( const QString &color, const QString &alpha, QColor & );
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic