diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-09-13 16:04:01 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-09-13 16:04:01 -0500 |
commit | db0c7b24cfa766aa88a8c0d7dfdae16f346033a0 (patch) | |
tree | e0eb289e5e98256398813a1fde5d99a4086c0af3 /lib | |
parent | 2624ef7e332e99316a26b16cf8c3f0043017edf1 (diff) | |
download | qt4-tqt-theme-engine-db0c7b24cfa766aa88a8c0d7dfdae16f346033a0.tar.gz qt4-tqt-theme-engine-db0c7b24cfa766aa88a8c0d7dfdae16f346033a0.zip |
Speed up theme engine
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tdeqt4converter.cpp | 68 | ||||
-rw-r--r-- | lib/tdeqt4converter.h | 1 | ||||
-rw-r--r-- | lib/tdeqt4painter.cpp | 63 |
3 files changed, 72 insertions, 60 deletions
diff --git a/lib/tdeqt4converter.cpp b/lib/tdeqt4converter.cpp index e81c2d0..e65dca2 100644 --- a/lib/tdeqt4converter.cpp +++ b/lib/tdeqt4converter.cpp @@ -522,6 +522,74 @@ TQPalette convertQt4ToTQt3Palette(QPalette qt4palette) return tqt3palette; } +QFont convertTQt3ToQt4Font(TQFont qt3font) +{ + QFont qt4font; + + qt4font = QFont(QString::fromUtf8(qt3font.family().utf8().data()), qt3font.pointSize(), qt3font.weight(), qt3font.italic()); + + qt4font.setBold(qt3font.bold()); +// qt4font.setCapitalization ( Capitalization caps ) + qt4font.setFamily(QString::fromUtf8(qt3font.family().utf8().data())); + qt4font.setFixedPitch(qt3font.fixedPitch()); + qt4font.setItalic(qt3font.italic()); +// qt4font.setKerning ( bool enable ) +// qt4font.setLetterSpacing ( SpacingType type, qreal spacing ) + qt4font.setOverline(qt3font.overline()); + int pixelSize = qt3font.pixelSize(); + if (pixelSize < 0) { + float pointSizeFloat = qt3font.pointSizeFloat(); + if (pointSizeFloat < 0) { + qt4font.setPointSize(qt3font.pointSize()); + } + else { + qt4font.setPointSizeF(pointSizeFloat); + } + } + else { + qt4font.setPixelSize(pixelSize); + } +// qt4font.setRawMode ( bool enable ) +// qt4font.setRawName(QString::fromUtf8(qt3font.rawName().utf8().data())); + qt4font.setStretch(qt3font.stretch()); + qt4font.setStrikeOut(qt3font.strikeOut()); +// qt4font.setStyle ( Style style ) + + TQFont::StyleHint qt3fontstylehint = qt3font.styleHint(); + QFont::StyleHint qt4fontstylehint = QFont::AnyStyle; + if (qt3fontstylehint == TQFont::Helvetica) qt4fontstylehint = QFont::Helvetica; + else if (qt3fontstylehint == TQFont::SansSerif) qt4fontstylehint = QFont::SansSerif; + else if (qt3fontstylehint == TQFont::Times) qt4fontstylehint = QFont::Times; + else if (qt3fontstylehint == TQFont::Serif) qt4fontstylehint = QFont::Serif; + else if (qt3fontstylehint == TQFont::Courier) qt4fontstylehint = QFont::Courier; + else if (qt3fontstylehint == TQFont::TypeWriter) qt4fontstylehint = QFont::TypeWriter; + else if (qt3fontstylehint == TQFont::OldEnglish) qt4fontstylehint = QFont::OldEnglish; + else if (qt3fontstylehint == TQFont::Decorative) qt4fontstylehint = QFont::Decorative; + else if (qt3fontstylehint == TQFont::System) qt4fontstylehint = QFont::System; + else if (qt3fontstylehint == TQFont::AnyStyle) qt4fontstylehint = QFont::AnyStyle; + + TQFont::StyleStrategy qt3fontstrategy = qt3font.styleStrategy(); + QFont::StyleStrategy qt4fontstrategy = (QFont::StyleStrategy)0; + if (qt3fontstrategy & TQFont::PreferDefault) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferDefault); + if (qt3fontstrategy & TQFont::PreferBitmap) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferBitmap); + if (qt3fontstrategy & TQFont::PreferDevice) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferDevice); + if (qt3fontstrategy & TQFont::PreferOutline) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferOutline); + if (qt3fontstrategy & TQFont::ForceOutline) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::ForceOutline); + if (qt3fontstrategy & TQFont::PreferMatch) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferMatch); + if (qt3fontstrategy & TQFont::PreferQuality) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferQuality); + if (qt3fontstrategy & TQFont::PreferAntialias) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferAntialias); + if (qt3fontstrategy & TQFont::NoAntialias) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::NoAntialias); + if (qt3fontstrategy & TQFont::OpenGLCompatible) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::OpenGLCompatible); + + qt4font.setStyleHint (qt4fontstylehint, qt4fontstrategy); +// qt4font.setStyleStrategy ( StyleStrategy s ) + qt4font.setUnderline(qt3font.underline()); + qt4font.setWeight(qt3font.weight()); +// qt4font.setWordSpacing ( qreal spacing ) + + return qt4font; +} + TQStyle::SFlags convertQt4ToTQt3SFlags(QStyle::State qt4stateflags, TQt3WidgetType wt) { // Convert sflags diff --git a/lib/tdeqt4converter.h b/lib/tdeqt4converter.h index 74ec770..bea9035 100644 --- a/lib/tdeqt4converter.h +++ b/lib/tdeqt4converter.h @@ -84,6 +84,7 @@ QBrush convertTQt3ToQt4Brush(TQBrush tqt3brush); TQBrush convertQt4ToTQt3Brush(QBrush qt4brush); QPalette convertTQt3ToQt4Palette(TQPalette tqt3palette); TQPalette convertQt4ToTQt3Palette(QPalette qt4palette); +QFont convertTQt3ToQt4Font(TQFont qt3font); TQStyle::SFlags convertQt4ToTQt3SFlags(QStyle::State qt4stateflags, TQt3WidgetType wt); #endif // TDEQT4CONVERTER_H
\ No newline at end of file diff --git a/lib/tdeqt4painter.cpp b/lib/tdeqt4painter.cpp index b8ddb28..6bc09d1 100644 --- a/lib/tdeqt4painter.cpp +++ b/lib/tdeqt4painter.cpp @@ -29,6 +29,8 @@ #include "tqpaintdevicemetrics.h" #undef Qt +#include "tdeqt4converter.h" + /*! \class TDEQt4PaintDevice tdeqt4painter.h \brief The TDEQt4PaintDevice class is a paint device that translates @@ -452,66 +454,7 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) } if (c == PdcSetFont) { TQFont qt3font = *p[0].font; - qt4font = QFont(QString::fromUtf8(qt3font.family().utf8().data()), qt3font.pointSize(), qt3font.weight(), qt3font.italic()); - - qt4font.setBold(qt3font.bold()); -// qt4font.setCapitalization ( Capitalization caps ) - qt4font.setFamily(QString::fromUtf8(qt3font.family().utf8().data())); - qt4font.setFixedPitch(qt3font.fixedPitch()); - qt4font.setItalic(qt3font.italic()); -// qt4font.setKerning ( bool enable ) -// qt4font.setLetterSpacing ( SpacingType type, qreal spacing ) - qt4font.setOverline(qt3font.overline()); - int pixelSize = qt3font.pixelSize(); - if (pixelSize < 0) { - float pointSizeFloat = qt3font.pointSizeFloat(); - if (pointSizeFloat < 0) { - qt4font.setPointSize(qt3font.pointSize()); - } - else { - qt4font.setPointSizeF(pointSizeFloat); - } - } - else { - qt4font.setPixelSize(pixelSize); - } -// qt4font.setRawMode ( bool enable ) -// qt4font.setRawName(QString::fromUtf8(qt3font.rawName().utf8().data())); - qt4font.setStretch(qt3font.stretch()); - qt4font.setStrikeOut(qt3font.strikeOut()); -// qt4font.setStyle ( Style style ) - - TQFont::StyleHint qt3fontstylehint = qt3font.styleHint(); - QFont::StyleHint qt4fontstylehint = QFont::AnyStyle; - if (qt3fontstylehint == TQFont::Helvetica) qt4fontstylehint = QFont::Helvetica; - else if (qt3fontstylehint == TQFont::SansSerif) qt4fontstylehint = QFont::SansSerif; - else if (qt3fontstylehint == TQFont::Times) qt4fontstylehint = QFont::Times; - else if (qt3fontstylehint == TQFont::Serif) qt4fontstylehint = QFont::Serif; - else if (qt3fontstylehint == TQFont::Courier) qt4fontstylehint = QFont::Courier; - else if (qt3fontstylehint == TQFont::TypeWriter) qt4fontstylehint = QFont::TypeWriter; - else if (qt3fontstylehint == TQFont::OldEnglish) qt4fontstylehint = QFont::OldEnglish; - else if (qt3fontstylehint == TQFont::Decorative) qt4fontstylehint = QFont::Decorative; - else if (qt3fontstylehint == TQFont::System) qt4fontstylehint = QFont::System; - else if (qt3fontstylehint == TQFont::AnyStyle) qt4fontstylehint = QFont::AnyStyle; - - TQFont::StyleStrategy qt3fontstrategy = qt3font.styleStrategy(); - QFont::StyleStrategy qt4fontstrategy = (QFont::StyleStrategy)0; - if (qt3fontstrategy & TQFont::PreferDefault) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferDefault); - if (qt3fontstrategy & TQFont::PreferBitmap) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferBitmap); - if (qt3fontstrategy & TQFont::PreferDevice) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferDevice); - if (qt3fontstrategy & TQFont::PreferOutline) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferOutline); - if (qt3fontstrategy & TQFont::ForceOutline) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::ForceOutline); - if (qt3fontstrategy & TQFont::PreferMatch) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferMatch); - if (qt3fontstrategy & TQFont::PreferQuality) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferQuality); - if (qt3fontstrategy & TQFont::PreferAntialias) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::PreferAntialias); - if (qt3fontstrategy & TQFont::NoAntialias) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::NoAntialias); - if (qt3fontstrategy & TQFont::OpenGLCompatible) qt4fontstrategy = (QFont::StyleStrategy)(qt4fontstrategy | QFont::OpenGLCompatible); - - qt4font.setStyleHint (qt4fontstylehint, qt4fontstrategy); -// qt4font.setStyleStrategy ( StyleStrategy s ) - qt4font.setUnderline(qt3font.underline()); - qt4font.setWeight(qt3font.weight()); -// qt4font.setWordSpacing ( qreal spacing ) + qt4font = convertTQt3ToQt4Font(qt3font); } if (c == PdcDrawPixmap) { qt4rect = QRect(p[0].rect->x(), p[0].rect->y(), p[0].rect->width(), p[0].rect->height()); |