Speed up theme engine

r14.0.x
Timothy Pearson 12 years ago
parent 2624ef7e33
commit db0c7b24cf

@ -522,6 +522,74 @@ TQPalette convertQt4ToTQt3Palette(QPalette qt4palette)
return tqt3palette; 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) TQStyle::SFlags convertQt4ToTQt3SFlags(QStyle::State qt4stateflags, TQt3WidgetType wt)
{ {
// Convert sflags // Convert sflags

@ -84,6 +84,7 @@ QBrush convertTQt3ToQt4Brush(TQBrush tqt3brush);
TQBrush convertQt4ToTQt3Brush(QBrush qt4brush); TQBrush convertQt4ToTQt3Brush(QBrush qt4brush);
QPalette convertTQt3ToQt4Palette(TQPalette tqt3palette); QPalette convertTQt3ToQt4Palette(TQPalette tqt3palette);
TQPalette convertQt4ToTQt3Palette(QPalette qt4palette); TQPalette convertQt4ToTQt3Palette(QPalette qt4palette);
QFont convertTQt3ToQt4Font(TQFont qt3font);
TQStyle::SFlags convertQt4ToTQt3SFlags(QStyle::State qt4stateflags, TQt3WidgetType wt); TQStyle::SFlags convertQt4ToTQt3SFlags(QStyle::State qt4stateflags, TQt3WidgetType wt);
#endif // TDEQT4CONVERTER_H #endif // TDEQT4CONVERTER_H

@ -29,6 +29,8 @@
#include "tqpaintdevicemetrics.h" #include "tqpaintdevicemetrics.h"
#undef Qt #undef Qt
#include "tdeqt4converter.h"
/*! /*!
\class TDEQt4PaintDevice tdeqt4painter.h \class TDEQt4PaintDevice tdeqt4painter.h
\brief The TDEQt4PaintDevice class is a paint device that translates \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) { if (c == PdcSetFont) {
TQFont qt3font = *p[0].font; TQFont qt3font = *p[0].font;
qt4font = QFont(QString::fromUtf8(qt3font.family().utf8().data()), qt3font.pointSize(), qt3font.weight(), qt3font.italic()); qt4font = convertTQt3ToQt4Font(qt3font);
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 )
} }
if (c == PdcDrawPixmap) { if (c == PdcDrawPixmap) {
qt4rect = QRect(p[0].rect->x(), p[0].rect->y(), p[0].rect->width(), p[0].rect->height()); qt4rect = QRect(p[0].rect->x(), p[0].rect->y(), p[0].rect->width(), p[0].rect->height());

@ -164,6 +164,9 @@ Qt4TDEStyle::Qt4TDEStyle()
// Set the Qt4 icon set to the TDE icon set // Set the Qt4 icon set to the TDE icon set
QIcon::setThemeName(convertTQt3ToQt4String(KIconTheme::current())); 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 // Set up Qt4 size hints to match the TDE sizes
// FIXME // FIXME
// m_tqt3DialogButtons_ShowIcons, m_tqt3IconSize_MenuItem, and m_tqt3IconSize_Large are still hardcoded // 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; 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; int i;
TQWidget* interfaceWidget = 0; TQWidget* interfaceWidget = 0;
@ -1575,16 +1578,33 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
TQColor bgcolor; TQColor bgcolor;
// FIXME if (forceReload == false) {
// Enabling this breaks sliders and all other dynamically updated widgets // NOTE
#if 0 // 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 // 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 // This is a very simplistic algorithm that should probably be replaced with a full hashtable lookup scheme
if (m_previousQt4InterfaceWidget == w) { if (m_previousQt4InterfaceWidget == w) {
return m_previousTQt3InterfaceWidget; return m_previousTQt3InterfaceWidget;
} }
m_previousQt4InterfaceWidget = w; m_previousQt4InterfaceWidget = w;
#endif }
}
switch (wt) { switch (wt) {
case TQT3WT_TQProgressBar: case TQT3WT_TQProgressBar:

@ -77,7 +77,7 @@ public slots:
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0) const; QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0) const;
private: 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_tqt3parent_widget;
TQWidget* m_tqt3generic_widget; TQWidget* m_tqt3generic_widget;

Loading…
Cancel
Save