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/tdeqt4converter.cpp | |
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/tdeqt4converter.cpp')
-rw-r--r-- | lib/tdeqt4converter.cpp | 68 |
1 files changed, 68 insertions, 0 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 |