Add widget cache and fix checkboxes and pushbuttons

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

@ -666,7 +666,7 @@ TQStyle::SFlags convertQt4ToTQt3SFlags(QStyle::State qt4stateflags, TQt3WidgetTy
// sflags = sflags | TQStyle::;
// }
if (qt4stateflags & QStyle::State_Sunken) {
if ((wt == TQT3WT_TQPopupMenu) || (wt == TQT3WT_TQMenuBar) || (wt == TQT3WT_TQToolButton)) {
if ((wt == TQT3WT_TQPopupMenu) || (wt == TQT3WT_TQMenuBar) || (wt == TQT3WT_TQToolButton) || (wt == TQT3WT_TQRadioButton) || (wt == TQT3WT_TQCheckBox) || (wt == TQT3WT_TQPushButton)) {
sflags = sflags | TQStyle::Style_Down;
}
sflags = sflags | TQStyle::Style_Sunken;

@ -52,6 +52,7 @@ enum TQt3WidgetType {
TQT3WT_TQTabBar,
TQT3WT_TQRadioButton,
TQT3WT_TQCheckBox,
TQT3WT_TQPushButton,
TQT3WT_TQPopupMenu,
TQT3WT_TQComboBox,
TQT3WT_TQSlider,

@ -26,6 +26,7 @@
#include <tqtabbar.h>
#include <tqradiobutton.h>
#include <tqcheckbox.h>
#include <tqpushbutton.h>
#include <tqpopupmenu.h>
#include <tqmenudata.h>
#include <tqcombobox.h>
@ -135,9 +136,6 @@ static QString TDEFileDialogSelectDirectory(QWidget *parent, const QString &capt
Qt4TDEStyle::Qt4TDEStyle()
{
m_previousQt4InterfaceWidget = 0;
m_previousTQt3InterfaceWidget = 0;
enable_debug_warnings = (getenv("DEBUG_TDEQT4_THEME_ENGINE") != NULL);
#ifdef INTEGRATE_WITH_TDE
@ -230,21 +228,7 @@ Qt4TDEStyle::Qt4TDEStyle()
m_tqt3parent_widget = new TQWidget();
m_tqt3generic_widget = new TQWidget(m_tqt3parent_widget);
m_tqt3progressbar_widget = new TQProgressBar(m_tqt3parent_widget);
m_tqt3tabbar_widget = new TQTabBar(m_tqt3parent_widget);
m_tqt3radiobutton_widget = new TQRadioButton(m_tqt3parent_widget);
m_tqt3checkbox_widget = new TQCheckBox(m_tqt3parent_widget);
m_tqt3popupmenu_widget = new TQPopupMenu(m_tqt3parent_widget);
m_tqt3combobox_widget = new TQComboBox(m_tqt3parent_widget);
m_tqt3slider_widget = new TQSlider(m_tqt3parent_widget);
m_tqt3scrollbar_widget = new TQScrollBar(m_tqt3parent_widget);
m_tqt3spinbox_widget = new TQSpinBox(m_tqt3parent_widget);
m_tqt3spinwidget_widget = new TQSpinWidget(m_tqt3parent_widget);
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);
m_tqt3toolbutton_widget = new TQToolButton(m_tqt3parent_widget);
#ifdef INTEGRATE_WITH_TDE
qt_filedialog_open_filename_hook = &TDEFileDialogOpenName;
@ -287,6 +271,7 @@ Qt4TDEStyle::~Qt4TDEStyle()
// Verify I'm not leaking memory like a sieve when this is commented out!!!
// delete m_tqt3parent_widget;
m_internalTQt3WidgetCache->setAutoDelete(false);
delete m_internalTQt3WidgetCache;
delete m_internalTQt3PixmapCache;
@ -356,10 +341,11 @@ bool Qt4TDEStyle::eventFilter(QObject *obj, QEvent *ev)
// repaint = false;
// hoverTab = tab;
if (repaint)
if (repaint) {
tabbar->repaint();
}
}
}
// }
}
@ -1113,7 +1099,8 @@ QSize Qt4TDEStyle::sizeFromContents(ContentsType type, const QStyleOption *opt,
&& (qt4menuactions.at(i)->text() == qt4menuitemoptions->text)
&& (qt4menuactions.at(i)->isChecked() == qt4menuitemoptions->checked)
) {
drawingItem = m_tqt3popupmenu_widget->findItem(m_tqt3popupmenu_widget->idAt(i));
TQPopupMenu* popupMenuWidget = dynamic_cast<TQPopupMenu*>(interfaceWidget);
drawingItem = popupMenuWidget->findItem(popupMenuWidget->idAt(i));
break;
}
}
@ -1559,6 +1546,7 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
const QTabBar* qt4tabbar_widget = 0;
const QRadioButton* qt4radiobutton_widget = 0;
const QCheckBox* qt4checkbox_widget = 0;
const QPushButton* qt4pushbutton_widget = 0;
const QMenu* qt4menu_widget = 0;
const QProgressBar* qt4progressbar_widget = 0;
const QComboBox* qt4combobox_widget = 0;
@ -1578,11 +1566,21 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
TQColor bgcolor;
TQWidget* cacheResult = 0;
const QObject* qt4objectptr = dynamic_cast<const QObject*>(w);
if (qt4objectptr) {
cacheResult = m_internalTQt3WidgetCache->find((long)qt4objectptr);
}
else {
return NULL;
}
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 (cacheResult) {
if (/*(wt == TQT3WT_TQProgressBar)*/
/*||*/ (wt == TQT3WT_TQTabBar)
|| (wt == TQT3WT_TQRadioButton)
@ -1597,20 +1595,53 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
|| (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;
}
return cacheResult;
}
}
}
TQTabBar* m_tqt3tabbar_widget = 0;
TQRadioButton* m_tqt3radiobutton_widget = 0;
TQCheckBox* m_tqt3checkbox_widget = 0;
TQPushButton* m_tqt3pushbutton_widget = 0;
TQProgressBar* m_tqt3progressbar_widget = 0;
TQPopupMenu* m_tqt3popupmenu_widget = 0;
TQComboBox* m_tqt3combobox_widget = 0;
TQSlider* m_tqt3slider_widget = 0;
TQScrollBar* m_tqt3scrollbar_widget = 0;
TQSpinBox* m_tqt3spinbox_widget = 0;
TQSpinWidget* m_tqt3spinwidget_widget = 0;
TQTitleBar* m_tqt3titlebar_widget = 0;
TQMenuBar* m_tqt3menubar_widget = 0;
TQToolBox* m_tqt3toolbox_widget = 0;
TQToolButton* m_tqt3toolbutton_widget = 0;
if (cacheResult) {
// Set pointer
m_tqt3tabbar_widget = dynamic_cast<TQTabBar*>(cacheResult);
m_tqt3radiobutton_widget = dynamic_cast<TQRadioButton*>(cacheResult);
m_tqt3checkbox_widget = dynamic_cast<TQCheckBox*>(cacheResult);
m_tqt3pushbutton_widget = dynamic_cast<TQPushButton*>(cacheResult);
m_tqt3progressbar_widget = dynamic_cast<TQProgressBar*>(cacheResult);
m_tqt3popupmenu_widget = dynamic_cast<TQPopupMenu*>(cacheResult);
m_tqt3combobox_widget = dynamic_cast<TQComboBox*>(cacheResult);
m_tqt3slider_widget = dynamic_cast<TQSlider*>(cacheResult);
m_tqt3scrollbar_widget = dynamic_cast<TQScrollBar*>(cacheResult);
m_tqt3spinbox_widget = dynamic_cast<TQSpinBox*>(cacheResult);
m_tqt3spinwidget_widget = dynamic_cast<TQSpinWidget*>(cacheResult);
m_tqt3titlebar_widget = dynamic_cast<TQTitleBar*>(cacheResult);
m_tqt3menubar_widget = dynamic_cast<TQMenuBar*>(cacheResult);
m_tqt3toolbox_widget = dynamic_cast<TQToolBox*>(cacheResult);
m_tqt3toolbutton_widget = dynamic_cast<TQToolButton*>(cacheResult);
}
switch (wt) {
case TQT3WT_TQProgressBar:
if (!m_tqt3progressbar_widget) m_tqt3progressbar_widget = new TQProgressBar(m_tqt3parent_widget);
interfaceWidget = m_tqt3progressbar_widget;
// Copy over all widget attributes
qt4progressbar_widget = dynamic_cast<const QProgressBar*>(w);
if (qt4progressbar_widget) {
m_tqt3progressbar_widget->setGeometry(0, 0, qt4progressbar_widget->width(), qt4progressbar_widget->height());
m_tqt3progressbar_widget->setEnabled(qt4progressbar_widget->isEnabled());
m_tqt3progressbar_widget->setProgress(qt4progressbar_widget->value()-qt4progressbar_widget->minimum(),qt4progressbar_widget->maximum()-qt4progressbar_widget->minimum());
@ -1621,8 +1652,16 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
}
interfaceWidget = 0;
}
}
else {
if (enable_debug_warnings) {
printf("Unable to draw Qt4 progress bar with no Qt4 object available\n\r"); fflush(stdout);
}
interfaceWidget = 0;
}
break;
case TQT3WT_TQTabBar:
if (!m_tqt3tabbar_widget) m_tqt3tabbar_widget = new TQTabBar(m_tqt3parent_widget);
interfaceWidget = m_tqt3tabbar_widget;
// Copy over all widget attributes
qt4tabbar_widget = dynamic_cast<const QTabBar*>(w);
@ -1677,27 +1716,65 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
}
break;
case TQT3WT_TQRadioButton:
if (!m_tqt3radiobutton_widget) m_tqt3radiobutton_widget = new TQRadioButton(m_tqt3parent_widget);
interfaceWidget = m_tqt3radiobutton_widget;
// Copy over all widget attributes
qt4radiobutton_widget = dynamic_cast<const QRadioButton*>(w);
if (qt4radiobutton_widget) {
m_tqt3radiobutton_widget->setGeometry(0, 0, qt4radiobutton_widget->width(), qt4radiobutton_widget->height());
m_tqt3radiobutton_widget->setEnabled(qt4radiobutton_widget->isEnabled());
m_tqt3radiobutton_widget->setText(convertQt4ToTQt3String(qt4radiobutton_widget->text()));
m_tqt3radiobutton_widget->setDown(qt4radiobutton_widget->isDown());
}
else {
if (enable_debug_warnings) {
printf("Unable to draw Qt4 radio button with no Qt4 object available\n\r"); fflush(stdout);
}
interfaceWidget = 0;
}
break;
case TQT3WT_TQCheckBox:
if (!m_tqt3checkbox_widget) m_tqt3checkbox_widget = new TQCheckBox(m_tqt3parent_widget);
interfaceWidget = m_tqt3checkbox_widget;
// Copy over all widget attributes
qt4checkbox_widget = dynamic_cast<const QCheckBox*>(w);
if (qt4checkbox_widget) {
m_tqt3checkbox_widget->setGeometry(0, 0, qt4checkbox_widget->width(), qt4checkbox_widget->height());
m_tqt3checkbox_widget->setEnabled(qt4checkbox_widget->isEnabled());
m_tqt3checkbox_widget->setText(convertQt4ToTQt3String(qt4checkbox_widget->text()));
m_tqt3checkbox_widget->setDown(qt4checkbox_widget->isDown());
}
else {
if (enable_debug_warnings) {
printf("Unable to draw Qt4 checkbox with no Qt4 object available\n\r"); fflush(stdout);
}
interfaceWidget = 0;
}
break;
case TQT3WT_TQPushButton:
if (!m_tqt3pushbutton_widget) m_tqt3pushbutton_widget = new TQPushButton(m_tqt3parent_widget);
interfaceWidget = m_tqt3pushbutton_widget;
// Copy over all widget attributes
qt4pushbutton_widget = dynamic_cast<const QPushButton*>(w);
if (qt4pushbutton_widget) {
m_tqt3pushbutton_widget->setGeometry(0, 0, qt4pushbutton_widget->width(), qt4pushbutton_widget->height());
m_tqt3pushbutton_widget->setEnabled(qt4pushbutton_widget->isEnabled());
m_tqt3pushbutton_widget->setText(convertQt4ToTQt3String(qt4pushbutton_widget->text()));
m_tqt3pushbutton_widget->setDown(qt4pushbutton_widget->isDown());
}
else {
if (enable_debug_warnings) {
printf("Unable to draw Qt4 pushbutton with no Qt4 object available\n\r"); fflush(stdout);
}
interfaceWidget = 0;
}
break;
case TQT3WT_TQComboBox:
if (!m_tqt3combobox_widget) m_tqt3combobox_widget = new TQComboBox(m_tqt3parent_widget);
interfaceWidget = m_tqt3combobox_widget;
// Copy over all widget attributes
qt4combobox_widget = dynamic_cast<const QComboBox*>(w);
if (qt4combobox_widget) {
m_tqt3combobox_widget->setGeometry(0, 0, qt4combobox_widget->width(), qt4combobox_widget->height());
m_tqt3combobox_widget->setEnabled(qt4combobox_widget->isEnabled());
// Clear out all combobox items
@ -1712,11 +1789,20 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
}
}
m_tqt3combobox_widget->setEditable(qt4combobox_widget->isEditable());
}
else {
if (enable_debug_warnings) {
printf("Unable to draw Qt4 combobox with no Qt4 object available\n\r"); fflush(stdout);
}
interfaceWidget = 0;
}
break;
case TQT3WT_TQPopupMenu:
if (!m_tqt3popupmenu_widget) m_tqt3popupmenu_widget = new TQPopupMenu(m_tqt3parent_widget);
interfaceWidget = m_tqt3popupmenu_widget;
// Copy over all widget attributes
qt4menu_widget = dynamic_cast<const QMenu*>(w);
if (qt4menu_widget) {
m_tqt3popupmenu_widget->setGeometry(0, 0, qt4menu_widget->width(), qt4menu_widget->height());
m_tqt3popupmenu_widget->setEnabled(qt4menu_widget->isEnabled());
// Clear out menu
@ -1754,11 +1840,20 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
// }
}
}
}
else {
if (enable_debug_warnings) {
printf("Unable to draw Qt4 popup menu with no Qt4 object available\n\r"); fflush(stdout);
}
interfaceWidget = 0;
}
break;
case TQT3WT_TQMenuBar:
if (!m_tqt3menubar_widget) m_tqt3menubar_widget = new TQMenuBar(m_tqt3parent_widget);
interfaceWidget = m_tqt3menubar_widget;
// Copy over all widget attributes
qt4menubar_widget = dynamic_cast<const QMenuBar*>(w);
if (qt4menubar_widget) {
m_tqt3menubar_widget->setGeometry(0, 0, qt4menubar_widget->width(), qt4menubar_widget->height());
m_tqt3menubar_widget->setEnabled(qt4menubar_widget->isEnabled());
// Clear out menu
@ -1787,8 +1882,16 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3menubar_widget->setItemVisible(i, currentAction->isVisible());
}
}
}
else {
if (enable_debug_warnings) {
printf("Unable to draw Qt4 menu bar with no Qt4 object available\n\r"); fflush(stdout);
}
interfaceWidget = 0;
}
break;
case TQT3WT_TQSlider:
if (!m_tqt3slider_widget) m_tqt3slider_widget = new TQSlider(m_tqt3parent_widget);
interfaceWidget = m_tqt3slider_widget;
// Copy over all widget attributes
qt4slider_widget = dynamic_cast<const QSlider*>(w);
@ -1814,6 +1917,7 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
}
break;
case TQT3WT_TQScrollBar:
if (!m_tqt3scrollbar_widget) m_tqt3scrollbar_widget = new TQScrollBar(m_tqt3parent_widget);
interfaceWidget = m_tqt3scrollbar_widget;
// Copy over all widget attributes
qt4scrollbar_widget = dynamic_cast<const QScrollBar*>(w);
@ -1837,6 +1941,7 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
break;
#if 0
case TQT3WT_TQSpinBox:
if (!m_tqt3spinbox_widget) m_tqt3spinbox_widget = new TQSpinBox(m_tqt3parent_widget);
interfaceWidget = m_tqt3spinbox_widget;
// Copy over all widget attributes
qt4spinbox_widget = dynamic_cast<const QAbstractSpinBox*>(w);
@ -1857,6 +1962,7 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
break;
#endif
case TQT3WT_TQSpinWidget:
if (!m_tqt3spinwidget_widget) m_tqt3spinwidget_widget = new TQSpinWidget(m_tqt3parent_widget);
interfaceWidget = m_tqt3spinwidget_widget;
// Copy over all widget attributes
qt4spinbox_widget = dynamic_cast<const QAbstractSpinBox*>(w);
@ -1874,6 +1980,7 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
}
break;
case TQT3WT_TQTitleBar:
if (!m_tqt3titlebar_widget) m_tqt3titlebar_widget = new TQTitleBar(m_tqt3window_widget, m_tqt3parent_widget);
interfaceWidget = m_tqt3titlebar_widget;
qt4titlebar_options = static_cast<const QStyleOptionTitleBar*>(qt4styleoptions);
// Construct an internal TQTitleBar widget from the options and widget provided by Qt4
@ -1893,6 +2000,7 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3titlebar_widget->setIcon(convertQt4IconToTQt3Pixmap(qt4titlebar_options->icon, m_tqt3IconSize_Small, m_internalTQt3PixmapCache, false, &bgcolor));
break;
case TQT3WT_TQToolBox:
if (!m_tqt3toolbox_widget) m_tqt3toolbox_widget = new TQToolBox(m_tqt3parent_widget);
interfaceWidget = m_tqt3toolbox_widget;
// Copy over all widget attributes
qt4toolbox_widget = dynamic_cast<const QToolBox*>(w);
@ -1917,6 +2025,7 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
break;
case TQT3WT_TQToolButton:
// FIXME
if (!m_tqt3toolbutton_widget) m_tqt3toolbutton_widget = new TQToolButton(m_tqt3parent_widget);
interfaceWidget = m_tqt3toolbutton_widget;
// Copy over all widget attributes
qt4toolbutton_widget = dynamic_cast<const QToolButton*>(w);
@ -1943,10 +2052,23 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
break;
}
m_previousTQt3InterfaceWidget = interfaceWidget;
if ((qt4objectptr) && (!cacheResult) && (interfaceWidget)) {
connect(qt4objectptr, SIGNAL(destroyed(QObject*)), this, SLOT(handleQt4ObjectDestroyed(QObject*)));
m_internalTQt3WidgetCache->insert((long)qt4objectptr, interfaceWidget);
}
#ifdef DEBUG_SPEW
if (enable_debug_warnings) {
printf("Widget cache: %d items now present in cache\n\r", m_internalTQt3WidgetCache->count());
}
#endif // DEBUG_SPEW
return interfaceWidget;
}
void Qt4TDEStyle::handleQt4ObjectDestroyed(QObject* obj) {
m_internalTQt3WidgetCache->remove((long)obj);
}
QRect Qt4TDEStyle::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *w) const
{
TQStyle::SFlags sflags = 0;
@ -2167,12 +2289,13 @@ void Qt4TDEStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
}
subControlActive = 0;
if (sbopt->activeSubControls & QStyle::SC_SpinBoxUp) {
if ((sbopt->activeSubControls & QStyle::SC_SpinBoxUp) && (sbopt->state & State_Sunken)) {
subControlActive = subControlActive | TQStyle::SC_SpinWidgetUp;
}
if (sbopt->activeSubControls & QStyle::SC_SpinBoxDown) {
if ((sbopt->activeSubControls & QStyle::SC_SpinBoxDown) && (sbopt->state & State_Sunken)) {
subControlActive = subControlActive | TQStyle::SC_SpinWidgetDown;
}
break;
case CC_TitleBar:
tqtCC = TQStyle::CC_TitleBar;
@ -2436,7 +2559,7 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
draw_third_element = true;
tqtCE_element3 = TQStyle::CE_ProgressBarLabel;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQProgressBar);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQProgressBar, w);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQProgressBar, w, NULL, TRUE);
if (interfaceWidget == 0) {
can_override = false;
}
@ -2444,7 +2567,7 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
case QStyle::CE_ProgressBarContents:
tqtCE = TQStyle::CE_ProgressBarContents;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQProgressBar);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQProgressBar, w);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQProgressBar, w, NULL, TRUE);
if (interfaceWidget == 0) {
can_override = false;
}
@ -2455,7 +2578,7 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
draw_second_element = true;
tqtCE_element2 = TQStyle::CE_TabBarLabel;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQTabBar);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQTabBar, w);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQTabBar, w, NULL, TRUE);
if (interfaceWidget == 0) {
can_override = false;
}
@ -2466,7 +2589,8 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
// I have to guess based on the Qt4 position of the tab in the tab bar, which may or may not work 100% in all cases
drawingTab = 0;
estimated_tab_index = dynamic_cast<const QTabBar*>(w)->tabAt(QPoint(opt->rect.x(), opt->rect.y()));
drawingTab = m_tqt3tabbar_widget->tabAt(estimated_tab_index);
TQTabBar* tabBarWidget = dynamic_cast<TQTabBar*>(interfaceWidget);
drawingTab = tabBarWidget->tabAt(estimated_tab_index);
if (drawingTab) {
tqt3opt = TQStyleOption(drawingTab);
@ -2485,7 +2609,7 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
tqt3elementrect = TQRect(tqt3elementrect.x()-tqt3tabwidth, tqt3elementrect.y(), tqt3elementrect.width()+(tqt3tabwidth*1), tqt3elementrect.height());
}
if (drawingTab) {
if (drawingTab->identifier() == (TQApplication::reverseLayout() ? (m_tqt3tabbar_widget->count()-1) : 0)) {
if (drawingTab->identifier() == (TQApplication::reverseLayout() ? (tabBarWidget->count()-1) : 0)) {
// This is the first tab in the tab bar
// We will end up clipping on the left edge if the rectangle is not adjusted
tqt3elementrect = TQRect(tqt3elementrect.x()+tqt3tabwidth, tqt3elementrect.y(), tqt3elementrect.width()-(tqt3tabwidth*1), tqt3elementrect.height());
@ -2502,7 +2626,7 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
tqtCE_element2 = TQStyle::CE_RadioButtonLabel;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQRadioButton);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQRadioButton, w);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQRadioButton, w, NULL, TRUE);
if (interfaceWidget == 0) {
can_override = false;
}
@ -2514,6 +2638,7 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
// [FIXME 001]
// Figure out why this is needed! Without it the text shows up lower than the indicator does...
// Potential subRect() mismatch between Qt4 and TQt3? See TQt3 qcommonstyle.cpp lines 1307 and 1315
// Strange that this hack is not needed for the CheckBox and PushButton cases...
tqt3element2rect.setHeight(tqt3elementrect.height());
}
break;
@ -2526,25 +2651,36 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
tqtCE_element2 = TQStyle::CE_CheckBoxLabel;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQCheckBox);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQCheckBox, w);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQCheckBox, w, NULL, TRUE);
if (interfaceWidget == 0) {
can_override = false;
}
else {
tqt3elementrect = tqApp->style().visualRect( tqApp->style().subRect(TQStyle::SR_CheckBoxIndicator, interfaceWidget), interfaceWidget);
tqt3element2rect = tqApp->style().visualRect( tqApp->style().subRect(TQStyle::SR_CheckBoxContents, interfaceWidget), interfaceWidget);
// HACK
// Lock text area height to indicator height
// [FIXME 001]
// Figure out why this is needed! Without it the text shows up lower than the indicator does...
// Potential subRect() mismatch between Qt4 and TQt3? See TQt3 qcommonstyle.cpp lines 1307 and 1315
tqt3element2rect.setHeight(tqt3elementrect.height());
}
break;
case CE_PushButton:
// Unlike Qt3, QStyle::CE_PushButton draws the button, the label, and the focus rectangle
// FIXME
// Handle the focus rectangle
tqtCE = TQStyle::CE_PushButton;
draw_second_element = true;
tqtCE_element2 = TQStyle::CE_PushButtonLabel;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQPushButton);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQPushButton, w, NULL, TRUE);
if (interfaceWidget == 0) {
can_override = false;
}
else {
tqt3element2rect = tqApp->style().visualRect( tqApp->style().subRect(TQStyle::SR_PushButtonContents, interfaceWidget), interfaceWidget);
}
break;
case CE_MenuItem:
tqtCE = TQStyle::CE_PopupMenuItem;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQPopupMenu);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQPopupMenu, w);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQPopupMenu, w, NULL, TRUE);
if (interfaceWidget == 0) {
can_override = false;
}
@ -2558,7 +2694,8 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
qt4menuactions = dynamic_cast<const QMenu*>(w)->actions();
for (i=0; i<qt4menuactions.size();++i) {
if (qt4menuactions.at(i) == drawingAction) {
drawingItem = m_tqt3popupmenu_widget->findItem(m_tqt3popupmenu_widget->idAt(i));
TQPopupMenu* popupMenuWidget = dynamic_cast<TQPopupMenu*>(interfaceWidget);
drawingItem = popupMenuWidget->findItem(popupMenuWidget->idAt(i));
}
}
@ -2572,7 +2709,7 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
case QStyle::CE_MenuBarItem:
tqtCE = TQStyle::CE_MenuBarItem;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQMenuBar);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQMenuBar, w);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQMenuBar, w, NULL, TRUE);
if (interfaceWidget == 0) {
can_override = false;
}
@ -2584,9 +2721,10 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
drawingItem = 0;
drawingAction = dynamic_cast<const QMenuBar*>(w)->actionAt(QPoint(opt->rect.x(), opt->rect.y()));
qt4menuactions = dynamic_cast<const QMenuBar*>(w)->actions();
TQMenuBar* menuBarWidget = dynamic_cast<TQMenuBar*>(interfaceWidget);
for (i=0; i<qt4menuactions.size();++i) {
if (qt4menuactions.at(i) == drawingAction) {
drawingItem = m_tqt3menubar_widget->findItem(m_tqt3menubar_widget->idAt(i));
drawingItem = menuBarWidget->findItem(menuBarWidget->idAt(i));
}
}
@ -2610,7 +2748,7 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
// See below for Qt4 drawing calls
tqtCE = TQStyle::CE_ToolBoxTab;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQToolBox);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQToolBox, w);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQToolBox, w, NULL, TRUE);
if (interfaceWidget == 0) {
can_override = false;
}
@ -2618,7 +2756,7 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
case QStyle::CE_MenuBarEmptyArea:
tqtCE = TQStyle::CE_MenuBarEmptyArea;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQMenuBar);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQMenuBar, w);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQMenuBar, w, NULL, TRUE);
if (interfaceWidget == 0) {
can_override = false;
}

@ -76,26 +76,29 @@ public:
public slots:
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0) const;
private slots:
void handleQt4ObjectDestroyed(QObject*);
private:
TQWidget* initializeInterfaceWidget(TQt3WidgetType wt, const QWidget * widget, const QStyleOption* qt4styleoptions = 0, bool forceReload = false) const;
TQWidget* m_tqt3parent_widget;
TQWidget* m_tqt3generic_widget;
TQTabBar* m_tqt3tabbar_widget;
TQRadioButton* m_tqt3radiobutton_widget;
TQCheckBox* m_tqt3checkbox_widget;
TQProgressBar* m_tqt3progressbar_widget;
TQPopupMenu* m_tqt3popupmenu_widget;
TQComboBox* m_tqt3combobox_widget;
TQSlider* m_tqt3slider_widget;
TQScrollBar* m_tqt3scrollbar_widget;
TQSpinBox* m_tqt3spinbox_widget;
TQSpinWidget* m_tqt3spinwidget_widget;
// mutable TQTabBar* m_tqt3tabbar_widget;
// mutable TQRadioButton* m_tqt3radiobutton_widget;
// mutable TQCheckBox* m_tqt3checkbox_widget;
// mutable TQProgressBar* m_tqt3progressbar_widget;
// mutable TQPopupMenu* m_tqt3popupmenu_widget;
// mutable TQComboBox* m_tqt3combobox_widget;
// mutable TQSlider* m_tqt3slider_widget;
// mutable TQScrollBar* m_tqt3scrollbar_widget;
// mutable TQSpinBox* m_tqt3spinbox_widget;
// mutable TQSpinWidget* m_tqt3spinwidget_widget;
TQWidget* m_tqt3window_widget;
TQTitleBar* m_tqt3titlebar_widget;
TQMenuBar* m_tqt3menubar_widget;
TQToolBox* m_tqt3toolbox_widget;
TQToolButton* m_tqt3toolbutton_widget;
// mutable TQTitleBar* m_tqt3titlebar_widget;
// mutable TQMenuBar* m_tqt3menubar_widget;
// mutable TQToolBox* m_tqt3toolbox_widget;
// mutable TQToolButton* m_tqt3toolbutton_widget;
int m_tqt3IconSize_NoGroup;
int m_tqt3IconSize_Desktop;

Loading…
Cancel
Save