Add initial support for CE_RadioButton and CE_CheckBox

Fix tab bar drawing glitches
r14.0.x
Timothy Pearson 13 years ago
parent 751d247ce2
commit c145c60fdb

@ -24,6 +24,7 @@
#include <tqprogressbar.h>
#include <tqtabbar.h>
#include <tqradiobutton.h>
#include <tqcheckbox.h>
#include <tqpopupmenu.h>
#include <tqmenudata.h>
#include <tqcombobox.h>
@ -225,8 +226,8 @@ inline TQPixmap convertQt4ToTQt3Pixmap(QIcon qt4icon, int iconsize, TQPixmapCach
inline QIcon convertTQt3ToQt4Pixmap(TQPixmap tqt3pixmap)
{
QPixmap qtPM = QPixmap::fromX11Pixmap(tqt3pixmap.handle(), QPixmap::ExplicitlyShared);
return QIcon(qtPM);
QPixmap qt4pm = QPixmap::fromX11Pixmap(tqt3pixmap.handle(), QPixmap::ImplicitlyShared);
return QIcon(qt4pm);
}
inline TQIconSet convertQt4ToTQt3IconSet(QIcon qt4icon, int smallsize, int largesize, TQPixmapCache* pmCache = 0)
@ -792,6 +793,7 @@ Qt4TDEStyle::Qt4TDEStyle()
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);
@ -822,6 +824,7 @@ Qt4TDEStyle::~Qt4TDEStyle()
// delete m_tqt3progressbar_widget;
// delete m_tqt3tabbar_widget;
// delete m_tqt3radiobutton_widget;
// delete m_tqt3checkbox_widget;
// delete m_tqt3popupmenu_widget;
// delete m_tqt3combobox_widget;
// delete m_tqt3slider_widget;
@ -927,12 +930,33 @@ QIcon Qt4TDEStyle::standardIconImplementation(StandardPixmap standardIcon, const
TQStyle::StylePixmap tqt3stylepixmap = TQStyle::SP_CustomBase;
switch (standardIcon) {
// case QStyle::SP_TitleBarMenuButton;
// case QStyle::SP_TitleBarMinButton:
// case QStyle::SP_TitleBarMaxButton:
// case QStyle::SP_TitleBarCloseButton:
// case QStyle::SP_TitleBarNormalButton:
// case QStyle::SP_TitleBarShadeButton:
// case QStyle::SP_TitleBarUnshadeButton:
// tqt3stylepixmap = TQStyle::SP_TitleBarMenuButton;
// retswitch = 1;
// break;
case QStyle::SP_TitleBarMinButton:
tqt3stylepixmap = TQStyle::SP_TitleBarMinButton;
retswitch = 1;
break;
case QStyle::SP_TitleBarMaxButton:
tqt3stylepixmap = TQStyle::SP_TitleBarMaxButton;
retswitch = 1;
break;
case QStyle::SP_TitleBarCloseButton:
tqt3stylepixmap = TQStyle::SP_TitleBarCloseButton;
retswitch = 1;
break;
case QStyle::SP_TitleBarNormalButton:
tqt3stylepixmap = TQStyle::SP_TitleBarNormalButton;
retswitch = 1;
break;
case QStyle::SP_TitleBarShadeButton:
tqt3stylepixmap = TQStyle::SP_TitleBarShadeButton;
retswitch = 1;
break;
case QStyle::SP_TitleBarUnshadeButton:
tqt3stylepixmap = TQStyle::SP_TitleBarUnshadeButton;
retswitch = 1;
break;
// case QStyle::SP_TitleBarContextHelpButton:
// case QStyle::SP_DockWidgetCloseButton:
case QStyle::SP_MessageBoxInformation:
@ -1138,7 +1162,16 @@ QIcon Qt4TDEStyle::standardIconImplementation(StandardPixmap standardIcon, const
}
if (retswitch == 1) {
reticon = convertTQt3ToQt4Pixmap(tqApp->style().stylePixmap(tqt3stylepixmap, interfaceWidget));
TQPixmap tqt3pixmap = tqApp->style().stylePixmap(tqt3stylepixmap, interfaceWidget);
// FIXME
// This spews tons of "X Error: BadDrawable (invalid Pixmap or Window parameter) 9" errors and fails to work
// if (tqt3pixmap.isNull() == false) {
// reticon = convertTQt3ToQt4Pixmap(tqt3pixmap);
// }
// else {
// Tell Qt4 to get the information
reticon = BASE_QT4_STYLE_CLASS::standardIconImplementation(standardIcon, opt, w);
// }
}
else {
if (retswitch == 2) {
@ -1146,7 +1179,7 @@ QIcon Qt4TDEStyle::standardIconImplementation(StandardPixmap standardIcon, const
}
else if (retswitch == 3) {
// convert string to icon
reticon = convertTQt3ToQt4Pixmap(DesktopIcon(iconLookupName));
reticon = QIcon(convertTQt3ToQt4String(KGlobal::iconLoader()->iconPath(iconLookupName, KIcon::Desktop, true)));
}
else {
// Tell Qt4 to get the information
@ -2049,6 +2082,13 @@ int Qt4TDEStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const
if (tqt3pixelmetric == TQStyle::PM_TabBarTabVSpace) {
retval = retval - 1;
}
// HACK
// Qt4 does not normally allow enough space for the rightmost tab to be
// completely drawn when PM_TabBarTabOverlap is greater than zero
// This is related to the fact that PM_TabBarTabOverlap is not implemented in Qt4
if (tqt3pixelmetric == TQStyle::PM_TabBarTabHSpace) {
retval = retval + tqApp->style().pixelMetric(TQStyle::PM_TabBarTabOverlap, interfaceWidget);
}
}
else {
if (retswitch == 2) {
@ -2071,6 +2111,7 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
// Qt4 interface widget pointers
const QTabBar* qt4tabbar_widget = 0;
const QRadioButton* qt4radiobutton_widget = 0;
const QCheckBox* qt4checkbox_widget = 0;
const QMenu* qt4menu_widget = 0;
const QProgressBar* qt4progressbar_widget = 0;
const QComboBox* qt4combobox_widget = 0;
@ -2180,6 +2221,15 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3radiobutton_widget->setText(convertQt4ToTQt3String(qt4radiobutton_widget->text()));
m_tqt3radiobutton_widget->setDown(qt4radiobutton_widget->isDown());
break;
case TQT3WT_TQCheckBox:
interfaceWidget = m_tqt3checkbox_widget;
// Copy over all widget attributes
qt4checkbox_widget = dynamic_cast<const QCheckBox*>(w);
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());
break;
case TQT3WT_TQComboBox:
interfaceWidget = m_tqt3combobox_widget;
// Copy over all widget attributes
@ -2877,27 +2927,57 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
// 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());
}
if (drawingTab->identifier() == (TQApplication::reverseLayout() ? 0 : (m_tqt3tabbar_widget->count()-1))) {
// This is the last tab in the tab bar
// We will end up clipping on the right edge if the rectangle is not adjusted
tqt3elementrect = TQRect(tqt3elementrect.x(), tqt3elementrect.y(), tqt3elementrect.width()-(tqt3tabwidth*2), tqt3elementrect.height());
}
}
}
break;
#if 0
case CE_RadioButton:
// Unlike Qt3, QStyle::CE_RadioButton draws the button, the label, and the focus rectangle
// FIXME
// Handle the focus rectangle
tqtCE = TQStyle::CE_RadioButton;
draw_second_element = true;
tqtCE_element2 = TQStyle::CE_RadioButtonLabel;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQRadioButton);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQRadioButton, w);
if (interfaceWidget == 0) {
can_override = false;
}
else {
tqt3elementrect = tqApp->style().visualRect( tqApp->style().subRect(TQStyle::SR_RadioButtonIndicator, interfaceWidget), interfaceWidget);
tqt3element2rect = tqApp->style().visualRect( tqApp->style().subRect(TQStyle::SR_RadioButtonContents, 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_CheckBox:
// Unlike Qt3, QStyle::CE_CheckBox draws the button, the label, and the focus rectangle
// FIXME
// Handle the focus rectangle
tqtCE = TQStyle::CE_CheckBox;
draw_second_element = true;
tqtCE_element2 = TQStyle::CE_CheckBoxLabel;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQCheckBox);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQCheckBox, w);
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;
#endif
case CE_MenuItem:
tqtCE = TQStyle::CE_PopupMenuItem;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQPopupMenu);
@ -2974,9 +3054,15 @@ void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
break;
case QStyle::CE_MenuBarEmptyArea:
tqtCE = TQStyle::CE_MenuBarEmptyArea;
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQMenuBar);
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQMenuBar, w);
if (interfaceWidget == 0) {
can_override = false;
}
break;
case QStyle::CE_MenuEmptyArea:
tqtCE = TQStyle::CE_MenuBarEmptyArea;
// Ignore request as Qt3 has no equivalent
can_override = false;
break;
case QStyle::CE_ItemViewItem:
// Ignore request as Qt3 has no equivalent
@ -3095,6 +3181,9 @@ void Qt4TDEStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP
TQStyle::PrimitiveElement tqtPE;
TQStyleOption tqt3opt(TQStyleOption::Default);
// Convert the style flags
TQStyle::SFlags sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_NONE);
// NOTE: Qt3 seems to combine PE_FrameMenu and PE_PanelMenu into PE_PanelPopup
switch (pe) {
@ -3264,9 +3353,6 @@ void Qt4TDEStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP
can_override = false;
}
// Convert the style flags
TQStyle::SFlags sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_NONE);
// Determine the correct color group
TQPalette tqt3palette = convertQt4ToTQt3Palette(opt->palette);
TQColorGroup tqt3colorgroup;

@ -29,6 +29,7 @@ QT_END_NAMESPACE
class TQWidget;
class TQTabBar;
class TQRadioButton;
class TQCheckBox;
class TQProgressBar;
class TQPopupMenu;
class TQComboBox;
@ -49,6 +50,7 @@ enum TQt3WidgetType {
TQT3WT_TQProgressBar,
TQT3WT_TQTabBar,
TQT3WT_TQRadioButton,
TQT3WT_TQCheckBox,
TQT3WT_TQPopupMenu,
TQT3WT_TQComboBox,
TQT3WT_TQSlider,
@ -83,6 +85,7 @@ public:
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;
public slots:
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0) const;
private:
@ -92,6 +95,7 @@ private:
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;

Loading…
Cancel
Save