summaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/simplestyle.cpp388
-rw-r--r--plugin/simplestyle.h9
2 files changed, 286 insertions, 111 deletions
diff --git a/plugin/simplestyle.cpp b/plugin/simplestyle.cpp
index 7adacbb..496b070 100644
--- a/plugin/simplestyle.cpp
+++ b/plugin/simplestyle.cpp
@@ -32,7 +32,9 @@
#include <tqspinbox.h>
#include <tqiconset.h>
#include <tqmenubar.h>
+#include <tqtoolbox.h>
#include <qtitlebar_p.h>
+#include <tqpixmapcache.h>
#undef Qt
// HACK to gain access to QSpinBox QLineEdit object
@@ -60,9 +62,15 @@
#include <kfiledialog.h>
#endif
-#define DEBUG_WARNINGS 1
// #define DEBUG_SPEW 1
+//#define BASE_QT4_STYLE_CLASS QCommonStyle
+#define BASE_QT4_STYLE_CLASS QWindowsStyle
+
+// Run your application like this:
+// DEBUG_TDEQT4_THEME_ENGINE=true <appname>
+// to debug the theme engine
+bool enable_debug_warnings = false;
#ifdef INTEGRATE_WITH_TDE
// BEGIN
@@ -158,7 +166,69 @@ inline QStringList convertTQt3ToQt4StringList(TQStringList tqt3stringlist)
return qt4stringlist;
}
-inline TQIconSet convertQt4ToTQt3IconSet(QIcon qt4icon, int smallsize, int largesize)
+inline QSize convertTQt3ToQt4Size(TQSize tqt3size)
+{
+ return QSize(tqt3size.width(), tqt3size.height());
+}
+
+inline TQSize convertQt4ToTQt3Size(QSize qt4size)
+{
+ return TQSize(qt4size.width(), qt4size.height());
+}
+
+inline TQString generateTQt3CacheKey(QIcon qt4icon, int iconsize, bool transparent, TQColor* bgcolor)
+{
+ if (bgcolor) {
+ return TQString("%1 %2 %3 %4 %5 %6").arg(qt4icon.cacheKey()).arg(iconsize).arg(transparent).arg(bgcolor->red()).arg(bgcolor->green()).arg(bgcolor->blue());
+ }
+ else {
+ return TQString("%1 %2 %3 0 0 0").arg(qt4icon.cacheKey()).arg(iconsize).arg(transparent);
+ }
+}
+
+inline TQPixmap convertQt4ToTQt3Pixmap(QIcon qt4icon, int iconsize, TQPixmapCache* pmCache = 0, bool copyTransparency = true, TQColor* bgcolor = 0)
+{
+ TQString cacheKey;
+ if (pmCache) {
+ // See if the pixmap for this icon and size is already in the TQt3 cache
+ cacheKey = generateTQt3CacheKey(qt4icon, iconsize, copyTransparency, bgcolor);
+ TQPixmap tqtCachedPM;
+ if (pmCache->find(cacheKey, tqtCachedPM) == true) {
+ return tqtCachedPM;
+ }
+ }
+
+ QSize qt4size = QSize(iconsize, iconsize);
+
+ QPixmap qt4iconpm = qt4icon.pixmap(qt4size);
+ TQPixmap tqtPM(qt4iconpm.width(), qt4iconpm.height(), (copyTransparency)?qt4iconpm.depth():((qt4iconpm.depth()>24)?24:qt4iconpm.depth()));
+ QPixmap qtPM = QPixmap::fromX11Pixmap(tqtPM.handle(), QPixmap::ExplicitlyShared);
+
+ if (copyTransparency) {
+ qtPM.fill(Qt::transparent);
+ }
+ else {
+ tqtPM.fill(*bgcolor);
+ }
+ QPainter qt4painter(&qtPM);
+ qt4painter.drawPixmap(0, 0, qt4iconpm);
+ qt4painter.end();
+
+ if (pmCache) {
+ // Insert this pixmap into the cache
+ pmCache->insert(cacheKey, tqtPM);
+ }
+
+ return tqtPM;
+}
+
+inline QIcon convertTQt3ToQt4Pixmap(TQPixmap tqt3pixmap)
+{
+ QPixmap qtPM = QPixmap::fromX11Pixmap(tqt3pixmap.handle(), QPixmap::ExplicitlyShared);
+ return QIcon(qtPM);
+}
+
+inline TQIconSet convertQt4ToTQt3IconSet(QIcon qt4icon, int smallsize, int largesize, TQPixmapCache* pmCache = 0)
{
int i=0;
int j=0;
@@ -208,16 +278,7 @@ inline TQIconSet convertQt4ToTQt3IconSet(QIcon qt4icon, int smallsize, int large
tqt3iconsized = largeIconSize;
}
- QPixmap qt4iconpm = qt4icon.pixmap(QSize(tqt3iconsized.width(), tqt3iconsized.height()), qt4iconmode, qt4iconstate);
- TQPixmap tqtPM(qt4iconpm.width(), qt4iconpm.height(), qt4iconpm.depth());
- QPixmap qtPM = QPixmap::fromX11Pixmap(tqtPM.handle(), QPixmap::ExplicitlyShared);
-
- qtPM.fill(Qt::transparent);
- QPainter qt4painter(&qtPM);
- qt4painter.drawPixmap(0, 0, qt4iconpm);
- qt4painter.end();
-
- tqt3iconset.setPixmap(tqtPM, tqt3iconsize, tqt3iconmode, tqt3iconstate);
+ tqt3iconset.setPixmap(convertQt4ToTQt3Pixmap(qt4icon, tqt3iconsized.width(), pmCache), tqt3iconsize, tqt3iconmode, tqt3iconstate);
}
}
}
@@ -225,33 +286,6 @@ inline TQIconSet convertQt4ToTQt3IconSet(QIcon qt4icon, int smallsize, int large
return tqt3iconset;
}
-inline TQPixmap convertQt4ToTQt3Pixmap(QIcon qt4icon, int iconsize, bool copyTransparency = true, TQColor* bgcolor = 0)
-{
- QSize qt4size = QSize(iconsize, iconsize);
-
- QPixmap qt4iconpm = qt4icon.pixmap(qt4size);
- TQPixmap tqtPM(qt4iconpm.width(), qt4iconpm.height(), (copyTransparency)?qt4iconpm.depth():((qt4iconpm.depth()>24)?24:qt4iconpm.depth()));
- QPixmap qtPM = QPixmap::fromX11Pixmap(tqtPM.handle(), QPixmap::ExplicitlyShared);
-
- if (copyTransparency) {
- qtPM.fill(Qt::transparent);
- }
- else {
- tqtPM.fill(*bgcolor);
- }
- QPainter qt4painter(&qtPM);
- qt4painter.drawPixmap(0, 0, qt4iconpm);
- qt4painter.end();
-
- return tqtPM;
-}
-
-inline QIcon convertTQt3ToQt4Pixmap(TQPixmap tqt3pixmap)
-{
- QPixmap qtPM = QPixmap::fromX11Pixmap(tqt3pixmap.handle(), QPixmap::ExplicitlyShared);
- return QIcon(qtPM);
-}
-
inline QRect convertTQt3ToQt4Rect(TQRect tqt3rect)
{
return QRect(tqt3rect.x(), tqt3rect.y(), tqt3rect.width(), tqt3rect.height());
@@ -665,6 +699,8 @@ SimpleStyle::SimpleStyle()
m_previousQt4InterfaceWidget = 0;
m_previousTQt3InterfaceWidget = 0;
+ enable_debug_warnings = (getenv("DEBUG_TDEQT4_THEME_ENGINE") != NULL);
+
#ifdef INTEGRATE_WITH_TDE
if (!tqApp) {
// Initialize KApplication required data structures
@@ -675,7 +711,7 @@ SimpleStyle::SimpleStyle()
argv[0] = (char*) malloc(sizeof(char) * 19);
strncpy(argv[0], "SimpleStyle", 19);
- m_aboutData = new KAboutData("SimpleStyle", I18N_NOOP("SimpleStyle"), "v0.1",
+ m_aboutData = new KAboutData("SimpleStyle", I18N_NOOP(convertQt4ToTQt3String(qApp->applicationName())), "v0.1",
"TDE Qt4 theme engine", KAboutData::License_GPL,
"(c) 2012, Timothy Pearson",
"message goes here", 0 /* TODO: Website */, "kb9vqf@pearsoncomputing.net");
@@ -739,6 +775,10 @@ SimpleStyle::SimpleStyle()
// Set the Qt4 palette to the TQt3 palette
qApp->setPalette(convertTQt3ToQt4Palette(tqApp->palette()));
+ // Initialize the pixmap cache
+ m_internalTQt3PixmapCache = new TQPixmapCache();
+ m_internalTQt3PixmapCache->setCacheLimit(4096);
+
// Create interface widgets
m_tqt3parent_widget = new TQWidget();
@@ -755,6 +795,7 @@ SimpleStyle::SimpleStyle()
m_tqt3window_widget = new TQWidget(m_tqt3parent_widget);
m_tqt3titlebar_widget = new TQTitleBar(m_tqt3window_widget, m_tqt3parent_widget);
m_tqt3menubar_widget = new TQMenuBar(m_tqt3parent_widget);
+ m_tqt3toolbox_widget = new TQToolBox(m_tqt3parent_widget);
#ifdef INTEGRATE_WITH_TDE
qt_filedialog_open_filename_hook = &TDEFileDialogOpenName;
@@ -783,11 +824,14 @@ SimpleStyle::~SimpleStyle()
// delete m_tqt3window_widget;
// delete m_tqt3titlebar_widget;
// delete m_tqt3menubar_widget;
+// delete m_tqt3toolbox_widget;
// FIXME
// Verify I'm not leaking memory like a sieve when this is commented out!!!
// delete m_tqt3parent_widget;
+ delete m_internalTQt3PixmapCache;
+
delete m_aboutData;
}
@@ -1078,9 +1122,9 @@ QIcon SimpleStyle::standardIconImplementation(StandardPixmap standardIcon, const
// case QStyle::SP_MediaVolumeMuted:
#endif // INTEGRATE_WITH_TDE
default:
-#ifdef DEBUG_WARNINGS
- printf("No pixmap for Qt4 standard pixmap request %d\n\r", standardIcon); fflush(stdout);
-#endif
+ if (enable_debug_warnings) {
+ printf("No pixmap for Qt4 standard pixmap request %d\n\r", standardIcon); fflush(stdout);
+ }
}
if (retswitch == 1) {
@@ -1096,7 +1140,7 @@ QIcon SimpleStyle::standardIconImplementation(StandardPixmap standardIcon, const
}
else {
// Tell Qt4 to get the information
- reticon = QCommonStyle::standardIconImplementation(standardIcon, opt, w);
+ reticon = BASE_QT4_STYLE_CLASS::standardIconImplementation(standardIcon, opt, w);
}
}
@@ -1517,9 +1561,9 @@ int SimpleStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidge
// retswitch=1;
// break;
default:
-#ifdef DEBUG_WARNINGS
- printf("No hints for Qt4 hint request %d\n\r", hint); fflush(stdout);
-#endif
+ if (enable_debug_warnings) {
+ printf("No hints for Qt4 hint request %d\n\r", hint); fflush(stdout);
+ }
retval = 0;
}
@@ -1532,7 +1576,83 @@ int SimpleStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidge
}
else {
// Tell Qt4 to get the information
- retval = QCommonStyle::styleHint(hint, opt, w);
+ retval = BASE_QT4_STYLE_CLASS::styleHint(hint, opt, w);
+ }
+ }
+
+ return retval;
+}
+
+QSize SimpleStyle::sizeFromContents(ContentsType type, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const
+{
+ int i;
+
+ QSize retval;
+ TQWidget* interfaceWidget = 0;
+ TQStyleOption tqt3opt(TQStyleOption::Default);
+
+ TQMenuItem* drawingItem = 0;
+ QAction* drawingAction = 0;
+ QList<QAction*> qt4menuactions;
+ int tqt3tabwidth = 0;
+ int tqt3iconwidth = 0;
+ const QStyleOptionMenuItem* qt4menuitemoptions;
+
+ char retswitch = 0;
+ TQStyle::ContentsType tqt3contentstype = TQStyle::CT_CustomBase;
+
+ switch (type) {
+ case QStyle::CT_MenuItem:
+ tqt3contentstype = TQStyle::CT_PopupMenuItem;
+ interfaceWidget = initializeInterfaceWidget(TQT3WT_TQPopupMenu, w);
+ if (interfaceWidget == 0) {
+ retswitch = 0;
+ }
+ else {
+ // Convert the QStyleOption to the proper TQStyleOption
+ // In other words, figure out which TQt3 menu item is currently being drawn
+ // Qt4 makes this impossible in sizeFromContents()
+ // The best we can do is to find a menu item that is somewhat close and use that
+ drawingItem = 0;
+ qt4menuactions = dynamic_cast<const QMenu*>(w)->actions();
+ qt4menuitemoptions = static_cast<const QStyleOptionMenuItem*>(opt);
+
+ for (i=0; i<qt4menuactions.size();++i) {
+ if (((qt4menuactions.at(i)->isSeparator() == 1) == (qt4menuitemoptions->menuItemType == QStyleOptionMenuItem::Separator))
+ && (qt4menuactions.at(i)->icon().cacheKey() == qt4menuitemoptions->icon.cacheKey())
+ && (qt4menuactions.at(i)->text() == qt4menuitemoptions->text)
+ && (qt4menuactions.at(i)->isChecked() == qt4menuitemoptions->checked)
+ ) {
+ drawingItem = m_tqt3popupmenu_widget->findItem(m_tqt3popupmenu_widget->idAt(i));
+ break;
+ }
+ }
+
+ if (drawingItem) {
+ tqt3tabwidth = static_cast<const QStyleOptionMenuItem*>(opt)->tabWidth;
+ tqt3iconwidth = static_cast<const QStyleOptionMenuItem*>(opt)->maxIconWidth;
+ tqt3opt = TQStyleOption(drawingItem, tqt3iconwidth, tqt3tabwidth);
+
+ retswitch = 1;
+ }
+ }
+ break;
+ default:
+ if (enable_debug_warnings) {
+ printf("No size for Qt4 contents %d\n\r", type); fflush(stdout);
+ }
+ }
+
+ if (retswitch == 1) {
+ retval = convertTQt3ToQt4Size(tqApp->style().sizeFromContents(tqt3contentstype, interfaceWidget, convertQt4ToTQt3Size(contentsSize), tqt3opt));
+ }
+ else {
+ if (retswitch == 2) {
+ // retval was already set
+ }
+ else {
+ // Tell Qt4 to get the information
+ retval = BASE_QT4_STYLE_CLASS::sizeFromContents(type, opt, contentsSize, w);
}
}
@@ -1633,18 +1753,22 @@ int SimpleStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const
break;
case QStyle::PM_SliderThickness:
tqt3pixelmetric = TQStyle::PM_SliderThickness;
+ interfaceWidget = initializeInterfaceWidget(TQT3WT_TQSlider, w);
retswitch = 1;
break;
case QStyle::PM_SliderControlThickness:
tqt3pixelmetric = TQStyle::PM_SliderControlThickness;
+ interfaceWidget = initializeInterfaceWidget(TQT3WT_TQSlider, w);
retswitch = 1;
break;
case QStyle::PM_SliderLength:
tqt3pixelmetric = TQStyle::PM_SliderLength;
+ interfaceWidget = initializeInterfaceWidget(TQT3WT_TQSlider, w);
retswitch = 1;
break;
case QStyle::PM_SliderTickmarkOffset:
tqt3pixelmetric = TQStyle::PM_SliderTickmarkOffset;
+ interfaceWidget = initializeInterfaceWidget(TQT3WT_TQSlider, w);
retswitch = 1;
break;
case QStyle::PM_SliderSpaceAvailable:
@@ -1900,9 +2024,9 @@ int SimpleStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const
// retswitch = 1;
// break;
default:
-#ifdef DEBUG_WARNINGS
- printf("No metrics for Qt4 element %d\n\r", metric); fflush(stdout);
-#endif
+ if (enable_debug_warnings) {
+ printf("No metrics for Qt4 element %d\n\r", metric); fflush(stdout);
+ }
retval = 0;
}
@@ -1922,7 +2046,7 @@ int SimpleStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const
}
else {
// Tell Qt4 to get the information
- retval = QCommonStyle::pixelMetric(metric, opt, w);
+ retval = BASE_QT4_STYLE_CLASS::pixelMetric(metric, opt, w);
}
}
@@ -1944,6 +2068,7 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
const QScrollBar* qt4scrollbar_widget = 0;
const QSpinBox* qt4spinbox_widget = 0;
const QMenuBar* qt4menubar_widget = 0;
+ const QToolBox* qt4toolbox_widget = 0;
const QStyleOptionTitleBar* qt4titlebar_options = 0;
@@ -1954,12 +2079,16 @@ TQWidget* SimpleStyle::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;
}
m_previousQt4InterfaceWidget = w;
+#endif
switch (wt) {
case TQT3WT_TQProgressBar:
@@ -1971,10 +2100,10 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3progressbar_widget->setProgress(qt4progressbar_widget->value()-qt4progressbar_widget->minimum(),qt4progressbar_widget->maximum()-qt4progressbar_widget->minimum());
if (qt4progressbar_widget->orientation() != Qt::Horizontal) {
// Qt3 cannot draw vertical progress bars
-#ifdef DEBUG_WARNINGS
- printf("No rules to draw vertical Qt4 progress bar\n\r"); fflush(stdout);
+ if (enable_debug_warnings) {
+ printf("No rules to draw vertical Qt4 progress bar\n\r"); fflush(stdout);
+ }
interfaceWidget = 0;
-#endif
}
break;
case TQT3WT_TQTabBar:
@@ -1996,7 +2125,7 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
newTab->setIdentifier(i);
}
else {
- TQTab* newTab = new TQTab(convertQt4ToTQt3IconSet(qt4tabbar_widget->tabIcon(i), m_tqt3IconSize_Small, m_tqt3IconSize_Large), convertQt4ToTQt3String(qt4tabbar_widget->tabText(i)));
+ TQTab* newTab = new TQTab(convertQt4ToTQt3IconSet(qt4tabbar_widget->tabIcon(i), m_tqt3IconSize_Small, m_tqt3IconSize_Large, m_internalTQt3PixmapCache), convertQt4ToTQt3String(qt4tabbar_widget->tabText(i)));
m_tqt3tabbar_widget->insertTab(newTab, i);
newTab->setIdentifier(i);
}
@@ -2017,18 +2146,18 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
break;
default:
// Qt3 cannot draw other tab shapes
-#ifdef DEBUG_WARNINGS
- printf("No rules to draw Qt4 tab shape %d\n\r", qt4tabbar_widget->shape()); fflush(stdout);
+ if (enable_debug_warnings) {
+ printf("No rules to draw Qt4 tab shape %d\n\r", qt4tabbar_widget->shape()); fflush(stdout);
+ }
interfaceWidget = 0;
-#endif
}
m_tqt3tabbar_widget->setShape(tqt3tbshape);
}
else {
-#ifdef DEBUG_WARNINGS
- printf("Unable to draw Qt4 tabbar with no Qt4 object available\n\r"); fflush(stdout);
+ if (enable_debug_warnings) {
+ printf("Unable to draw Qt4 tabbar with no Qt4 object available\n\r"); fflush(stdout);
+ }
interfaceWidget = 0;
-#endif
}
break;
case TQT3WT_TQRadioButton:
@@ -2054,7 +2183,7 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3combobox_widget->insertItem(convertQt4ToTQt3String(qt4combobox_widget->itemText(i)), i);
}
else {
- m_tqt3combobox_widget->insertItem(convertQt4ToTQt3Pixmap(qt4combobox_widget->itemIcon(i), m_tqt3IconSize_Small), convertQt4ToTQt3String(qt4combobox_widget->itemText(i)), i);
+ m_tqt3combobox_widget->insertItem(convertQt4ToTQt3Pixmap(qt4combobox_widget->itemIcon(i), m_tqt3IconSize_Small, m_internalTQt3PixmapCache), convertQt4ToTQt3String(qt4combobox_widget->itemText(i)), i);
}
}
m_tqt3combobox_widget->setEditable(qt4combobox_widget->isEditable());
@@ -2082,7 +2211,7 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3popupmenu_widget->insertItem(convertQt4ToTQt3String(currentAction->text()), i, i);
}
else {
- m_tqt3popupmenu_widget->insertItem(convertQt4ToTQt3IconSet(currentAction->icon(), m_tqt3IconSize_Small, m_tqt3IconSize_Large), convertQt4ToTQt3String(currentAction->text()), i, i);
+ m_tqt3popupmenu_widget->insertItem(convertQt4ToTQt3IconSet(currentAction->icon(), m_tqt3IconSize_Small, m_tqt3IconSize_Large, m_internalTQt3PixmapCache), convertQt4ToTQt3String(currentAction->text()), i, i);
}
// FIXME
// Handle pixmaps, etc.
@@ -2118,7 +2247,7 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3menubar_widget->insertItem(convertQt4ToTQt3String(currentAction->text()), i, i);
}
else {
- m_tqt3menubar_widget->insertItem(convertQt4ToTQt3IconSet(currentAction->icon(), m_tqt3IconSize_Small, m_tqt3IconSize_Large), convertQt4ToTQt3String(currentAction->text()), i, i);
+ m_tqt3menubar_widget->insertItem(convertQt4ToTQt3IconSet(currentAction->icon(), m_tqt3IconSize_Small, m_tqt3IconSize_Large, m_internalTQt3PixmapCache), convertQt4ToTQt3String(currentAction->text()), i, i);
}
// FIXME
// Handle pixmaps, etc.
@@ -2148,10 +2277,10 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3slider_widget->setValue(qt4slider_widget->value());
}
else {
-#ifdef DEBUG_WARNINGS
- printf("Unable to draw Qt4 slider with no Qt4 object available\n\r"); fflush(stdout);
+ if (enable_debug_warnings) {
+ printf("Unable to draw Qt4 slider with no Qt4 object available\n\r"); fflush(stdout);
+ }
interfaceWidget = 0;
-#endif
}
break;
case TQT3WT_TQScrollBar:
@@ -2170,10 +2299,10 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3scrollbar_widget->setValue(qt4scrollbar_widget->value());
}
else {
-#ifdef DEBUG_WARNINGS
- printf("Unable to draw Qt4 scrollbar with no Qt4 object available\n\r"); fflush(stdout);
+ if (enable_debug_warnings) {
+ printf("Unable to draw Qt4 scrollbar with no Qt4 object available\n\r"); fflush(stdout);
+ }
interfaceWidget = 0;
-#endif
}
break;
case TQT3WT_TQSpinBox:
@@ -2189,10 +2318,10 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3spinbox_widget->setValue(qt4spinbox_widget->value());
}
else {
-#ifdef DEBUG_WARNINGS
- printf("Unable to draw Qt4 spinbox with no Qt4 object available\n\r"); fflush(stdout);
+ if (enable_debug_warnings) {
+ printf("Unable to draw Qt4 spinbox with no Qt4 object available\n\r"); fflush(stdout);
+ }
interfaceWidget = 0;
-#endif
}
break;
case TQT3WT_TQSpinWidget:
@@ -2209,10 +2338,10 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
// m_tqt3spinbox_widget->setValue(qt4spinbox_widget->value());
}
else {
-#ifdef DEBUG_WARNINGS
- printf("Unable to draw Qt4 spinbox with no Qt4 object available\n\r"); fflush(stdout);
+ if (enable_debug_warnings) {
+ printf("Unable to draw Qt4 spinbox with no Qt4 object available\n\r"); fflush(stdout);
+ }
interfaceWidget = 0;
-#endif
}
break;
case TQT3WT_TQTitleBar:
@@ -2232,7 +2361,31 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
else {
bgcolor = convertQt4ToTQt3Palette(qt4styleoptions->palette).inactive().highlight();
}
- m_tqt3titlebar_widget->setIcon(convertQt4ToTQt3Pixmap(qt4titlebar_options->icon, m_tqt3IconSize_Small, false, &bgcolor));
+ m_tqt3titlebar_widget->setIcon(convertQt4ToTQt3Pixmap(qt4titlebar_options->icon, m_tqt3IconSize_Small, m_internalTQt3PixmapCache, false, &bgcolor));
+ break;
+ case TQT3WT_TQToolBox:
+ interfaceWidget = m_tqt3toolbox_widget;
+ // Copy over all widget attributes
+ qt4toolbox_widget = dynamic_cast<const QToolBox*>(w);
+ if (qt4toolbox_widget) {
+ m_tqt3toolbox_widget->setGeometry(0, 0, qt4toolbox_widget->width(), qt4toolbox_widget->height());
+ m_tqt3toolbox_widget->setEnabled(qt4toolbox_widget->isEnabled());
+ // Remove all tabs
+ for (i=0;i<m_tqt3toolbox_widget->count();i++) {
+ m_tqt3toolbox_widget->removeItem(m_tqt3toolbox_widget->item(i));
+ }
+ // Copy all tabs
+ for (i=0;i<qt4toolbox_widget->count();i++) {
+ m_tqt3toolbox_widget->insertItem(i, m_tqt3generic_widget, convertQt4ToTQt3String(qt4toolbox_widget->itemText(i)));
+ }
+ }
+ else {
+ if (enable_debug_warnings) {
+ printf("Unable to draw Qt4 toolbox with no Qt4 object available\n\r"); fflush(stdout);
+ }
+ interfaceWidget = 0;
+ }
+ break;
}
m_previousTQt3InterfaceWidget = interfaceWidget;
@@ -2258,9 +2411,9 @@ QRect SimpleStyle::subElementRect(SubElement element, const QStyleOption *opt, c
}
break;
default:
-#ifdef DEBUG_WARNINGS
- printf("No rules to obtain Qt4 subelement rect %d\n\r", element); fflush(stdout);
-#endif
+ if (enable_debug_warnings) {
+ printf("No rules to obtain Qt4 subelement rect %d\n\r", element); fflush(stdout);
+ }
can_override = false;
}
@@ -2268,15 +2421,15 @@ QRect SimpleStyle::subElementRect(SubElement element, const QStyleOption *opt, c
// Instruct TQt3 to obtain the subelement rect information
retRect = convertTQt3ToQt4Rect(tqApp->style().subRect(tqtSR, interfaceWidget));
-#ifdef DEBUG_WARNINGS
+ if (enable_debug_warnings) {
#ifdef DEBUG_SPEW
- printf("Used Qt3 subelement rect %d to handle Qt4 subelement rect %d\n\r", tqtSR, control); fflush(stdout);
-#endif
+ printf("Used Qt3 subelement rect %d to handle Qt4 subelement rect %d\n\r", tqtSR, control); fflush(stdout);
#endif
+ }
}
else {
// Tell Qt4 to obtain the subelement rect information
- retRect = QCommonStyle::subElementRect(element, opt, w);
+ retRect = BASE_QT4_STYLE_CLASS::subElementRect(element, opt, w);
}
return retRect;
@@ -2449,9 +2602,9 @@ void SimpleStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
NO_QT3_EQUIVALENT
break;
default:
-#ifdef DEBUG_WARNINGS
- printf("No rules to draw Qt4 complex control %d\n\r", control); fflush(stdout);
-#endif
+ if (enable_debug_warnings) {
+ printf("No rules to draw Qt4 complex control %d\n\r", control); fflush(stdout);
+ }
can_override = false;
}
@@ -2500,11 +2653,11 @@ void SimpleStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
tqtPainter.setClipRect(tqt3rect.x(),tqt3rect.y(),sbleRect.x()+sbleRect.width(),tqt3rect.height());
p->fillRect(sbleRect,convertTQt3ToQt4Color(tqt3colorgroup.base()));
}
-#ifdef DEBUG_WARNINGS
else {
- printf("Unable to draw Qt4 spinbox with no Qt4 object available\n\r"); fflush(stdout);
+ if (enable_debug_warnings) {
+ printf("Unable to draw Qt4 spinbox with no Qt4 object available\n\r"); fflush(stdout);
+ }
}
-#endif
// Now draw the outside frame again, but clipped to the editor widget side of the spinwidget this time
// This fixes drawing glitches inside of the editor widget while leaving the spinbutton area untouched
@@ -2513,15 +2666,15 @@ void SimpleStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
tqtPainter.end();
-#ifdef DEBUG_WARNINGS
+ if (enable_debug_warnings) {
#ifdef DEBUG_SPEW
- printf("Used Qt3 complex control %d to draw Qt4 complex control %d\n\r", tqtCE, control); fflush(stdout);
-#endif
+ printf("Used Qt3 complex control %d to draw Qt4 complex control %d\n\r", tqtCE, control); fflush(stdout);
#endif
+ }
}
else {
// Tell Qt4 to draw it
- QCommonStyle::drawComplexControl(control, opt, p, w);
+ BASE_QT4_STYLE_CLASS::drawComplexControl(control, opt, p, w);
}
}
@@ -2717,6 +2870,16 @@ void SimpleStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
// It is drawn as such below
DO_NOT_DRAW
break;
+ case QStyle::CE_ToolBoxTab:
+ // Unlike TQt3, QStyle::CE_ToolBoxTab draws the tab, the label, and the focus rectangle
+ // See below for Qt4 drawing calls
+ tqtCE = TQStyle::CE_ToolBoxTab;
+ sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQToolBox);
+ interfaceWidget = initializeInterfaceWidget(TQT3WT_TQToolBox, w);
+ if (interfaceWidget == 0) {
+ can_override = false;
+ }
+ break;
case QStyle::CE_MenuBarEmptyArea:
tqtCE = TQStyle::CE_MenuBarEmptyArea;
break;
@@ -2764,9 +2927,9 @@ void SimpleStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
can_override = false;
break;
default:
-#ifdef DEBUG_WARNINGS
- printf("No rules to draw Qt4 control %d\n\r", element); fflush(stdout);
-#endif
+ if (enable_debug_warnings) {
+ printf("No rules to draw Qt4 control %d\n\r", element); fflush(stdout);
+ }
can_override = false;
}
@@ -2805,16 +2968,21 @@ void SimpleStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
tqtPainter.end();
-#ifdef DEBUG_WARNINGS
+ if (tqtCE == TQStyle::CE_ToolBoxTab) {
+ // Instruct Qt4 to draw the label
+ BASE_QT4_STYLE_CLASS::drawControl(QStyle::CE_ToolBoxTabLabel, opt, p, w);
+ }
+
+ if (enable_debug_warnings) {
#ifdef DEBUG_SPEW
- printf("Used Qt3 control %d to draw Qt4 control %d\n\r", tqtCE, element); fflush(stdout);
-#endif
+ printf("Used Qt3 control %d to draw Qt4 control %d\n\r", tqtCE, element); fflush(stdout);
#endif
+ }
}
else {
if (do_not_draw == false) {
// Tell Qt4 to draw it
- QCommonStyle::drawControl(element, opt, p, w);
+ BASE_QT4_STYLE_CLASS::drawControl(element, opt, p, w);
}
}
}
@@ -2998,9 +3166,9 @@ void SimpleStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP
tqtPE = TQStyle::PE_Separator;
break;
default:
-#ifdef DEBUG_WARNINGS
- printf("No rules to draw Qt4 element %d\n\r", pe); fflush(stdout);
-#endif
+ if (enable_debug_warnings) {
+ printf("No rules to draw Qt4 element %d\n\r", pe); fflush(stdout);
+ }
can_override = false;
}
@@ -3032,7 +3200,7 @@ void SimpleStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP
if (tqtPE == TQStyle::PE_PanelLineEdit) {
if (draw_transparent_background == false) {
// Tell Qt4 to draw the background
- QCommonStyle::drawPrimitive(pe, opt, p, w);
+ BASE_QT4_STYLE_CLASS::drawPrimitive(pe, opt, p, w);
}
else {
p->fillRect(opt->rect, Qt::transparent);
@@ -3048,16 +3216,16 @@ void SimpleStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP
tqtPainter.end();
-#ifdef DEBUG_WARNINGS
+ if (enable_debug_warnings) {
#ifdef DEBUG_SPEW
- printf("Used Qt3 element %d to draw Qt4 element %d\n\r", tqtPE, pe); fflush(stdout);
-#endif
+ printf("Used Qt3 element %d to draw Qt4 element %d\n\r", tqtPE, pe); fflush(stdout);
#endif
+ }
}
else {
if (do_not_draw == false) {
// Tell Qt4 to draw it
- QCommonStyle::drawPrimitive(pe, opt, p, w);
+ BASE_QT4_STYLE_CLASS::drawPrimitive(pe, opt, p, w);
}
}
}
diff --git a/plugin/simplestyle.h b/plugin/simplestyle.h
index b2fe548..65cf25e 100644
--- a/plugin/simplestyle.h
+++ b/plugin/simplestyle.h
@@ -38,8 +38,10 @@ class TQSpinBox;
class TQSpinWidget;
class TQTitleBar;
class TQMenuBar;
+class TQToolBox;
class KAboutData;
+class TQPixmapCache;
enum TQt3WidgetType {
TQT3WT_NONE,
@@ -53,7 +55,8 @@ enum TQt3WidgetType {
TQT3WT_TQSpinBox,
TQT3WT_TQSpinWidget,
TQT3WT_TQTitleBar,
- TQT3WT_TQMenuBar
+ TQT3WT_TQMenuBar,
+ TQT3WT_TQToolBox
};
class SimpleStyle : public QWindowsStyle
@@ -76,6 +79,7 @@ public:
int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0) const;
int styleHint(StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0) const;
+ QSize sizeFromContents(ContentsType type, const QStyleOption * option, const QSize & contentsSize, const QWidget * widget = 0) const;
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0) const;
@@ -96,6 +100,7 @@ private:
TQWidget* m_tqt3window_widget;
TQTitleBar* m_tqt3titlebar_widget;
TQMenuBar* m_tqt3menubar_widget;
+ TQToolBox* m_tqt3toolbox_widget;
int m_tqt3IconSize_NoGroup;
int m_tqt3IconSize_Desktop;
@@ -117,6 +122,8 @@ private:
mutable TQWidget* m_previousTQt3InterfaceWidget;
KAboutData* m_aboutData;
+
+ TQPixmapCache* m_internalTQt3PixmapCache;
};
#endif