summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-09-13 16:04:01 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-09-13 16:04:01 -0500
commitdb0c7b24cfa766aa88a8c0d7dfdae16f346033a0 (patch)
treee0eb289e5e98256398813a1fde5d99a4086c0af3
parent2624ef7e332e99316a26b16cf8c3f0043017edf1 (diff)
downloadqt4-tqt-theme-engine-db0c7b24cfa766aa88a8c0d7dfdae16f346033a0.tar.gz
qt4-tqt-theme-engine-db0c7b24cfa766aa88a8c0d7dfdae16f346033a0.zip
Speed up theme engine
-rw-r--r--lib/tdeqt4converter.cpp68
-rw-r--r--lib/tdeqt4converter.h1
-rw-r--r--lib/tdeqt4painter.cpp63
-rw-r--r--plugin/simplestyle.cpp40
-rw-r--r--plugin/simplestyle.h2
5 files changed, 103 insertions, 71 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());
diff --git a/plugin/simplestyle.cpp b/plugin/simplestyle.cpp
index 4d4b9e7..18cf536 100644
--- a/plugin/simplestyle.cpp
+++ b/plugin/simplestyle.cpp
@@ -164,6 +164,9 @@ Qt4TDEStyle::Qt4TDEStyle()
// Set the Qt4 icon set to the TDE icon set
QIcon::setThemeName(convertTQt3ToQt4String(KIconTheme::current()));
+ // Set the Qt4 default font
+ QApplication::setFont(convertTQt3ToQt4Font(TQApplication::font()));
+
// Set up Qt4 size hints to match the TDE sizes
// FIXME
// m_tqt3DialogButtons_ShowIcons, m_tqt3IconSize_MenuItem, and m_tqt3IconSize_Large are still hardcoded
@@ -1547,7 +1550,7 @@ int Qt4TDEStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const
return retval;
}
-TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidget* w, const QStyleOption* qt4styleoptions) const
+TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidget* w, const QStyleOption* qt4styleoptions, bool forceReload) const
{
int i;
TQWidget* interfaceWidget = 0;
@@ -1575,16 +1578,33 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
TQColor bgcolor;
- // FIXME
- // Enabling this breaks sliders and all other dynamically updated widgets
-#if 0
- // If the interface widget was already initialized for this widget then do nothing
- // This is a very simplistic algorithm that should probably be replaced with a full hashtable lookup scheme
- if (m_previousQt4InterfaceWidget == w) {
- return m_previousTQt3InterfaceWidget;
+ if (forceReload == false) {
+ // NOTE
+ // Enabling this for every widget breaks sliders and all other dynamically updated widgets
+ // Disabling it for every widget makes the style engine run too slowly to be of much use
+ // Much of the slowdown appears to be from Qt4TDEStyle::pixelMetric calling this method
+ if (/*(wt == TQT3WT_TQProgressBar)*/
+ /*||*/ (wt == TQT3WT_TQTabBar)
+ || (wt == TQT3WT_TQRadioButton)
+ || (wt == TQT3WT_TQCheckBox)
+ || (wt == TQT3WT_TQPopupMenu)
+ || (wt == TQT3WT_TQComboBox)
+ //|| (wt == TQT3WT_TQSlider)
+ //|| (wt == TQT3WT_TQScrollBar)
+ //|| (wt == TQT3WT_TQSpinBox)
+ //|| (wt == TQT3WT_TQSpinWidget)
+ || (wt == TQT3WT_TQTitleBar)
+ || (wt == TQT3WT_TQMenuBar)
+ || (wt == TQT3WT_TQToolBox)
+ || (wt == TQT3WT_TQToolButton)) {
+ // If the interface widget was already initialized for this widget then do nothing
+ // This is a very simplistic algorithm that should probably be replaced with a full hashtable lookup scheme
+ if (m_previousQt4InterfaceWidget == w) {
+ return m_previousTQt3InterfaceWidget;
+ }
+ m_previousQt4InterfaceWidget = w;
+ }
}
- m_previousQt4InterfaceWidget = w;
-#endif
switch (wt) {
case TQT3WT_TQProgressBar:
diff --git a/plugin/simplestyle.h b/plugin/simplestyle.h
index d7988e3..28f5726 100644
--- a/plugin/simplestyle.h
+++ b/plugin/simplestyle.h
@@ -77,7 +77,7 @@ public slots:
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0) const;
private:
- TQWidget* initializeInterfaceWidget(TQt3WidgetType wt, const QWidget * widget, const QStyleOption* qt4styleoptions = 0) const;
+ TQWidget* initializeInterfaceWidget(TQt3WidgetType wt, const QWidget * widget, const QStyleOption* qt4styleoptions = 0, bool forceReload = false) const;
TQWidget* m_tqt3parent_widget;
TQWidget* m_tqt3generic_widget;