summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-03-22 20:07:14 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-03-22 20:07:14 -0500
commit751d247ce2b6140556b2db87dff31303d35ca902 (patch)
treea0e20c3e6ec90cdcaeaba84a5fee8833408e9986
parentbd425eca72d136ba29cfdd2822019b36913a3889 (diff)
downloadqt4-tqt-theme-engine-751d247ce2b6140556b2db87dff31303d35ca902.tar.gz
qt4-tqt-theme-engine-751d247ce2b6140556b2db87dff31303d35ca902.zip
Add toolbar button drawing routines
-rw-r--r--plugin/simplestyle.cpp82
-rw-r--r--plugin/simplestyle.h5
2 files changed, 79 insertions, 8 deletions
diff --git a/plugin/simplestyle.cpp b/plugin/simplestyle.cpp
index 4345810..de4c5b8 100644
--- a/plugin/simplestyle.cpp
+++ b/plugin/simplestyle.cpp
@@ -33,6 +33,7 @@
#include <tqiconset.h>
#include <tqmenubar.h>
#include <tqtoolbox.h>
+#include <tqtoolbutton.h>
#include <qtitlebar_p.h>
#include <tqpixmapcache.h>
#undef Qt
@@ -606,6 +607,9 @@ inline TQStyle::SFlags convertQt4ToTQt3SFlags(QStyle::State qt4stateflags, TQt3W
// }
if (qt4stateflags & QStyle::State_MouseOver) {
sflags = sflags | TQStyle::Style_MouseOver;
+ if ((wt == TQT3WT_TQToolButton) && (qt4stateflags & QStyle::State_Enabled)) {
+ sflags = sflags | TQStyle::Style_Raised;
+ }
}
if (qt4stateflags & QStyle::State_NoChange) {
sflags = sflags | TQStyle::Style_NoChange;
@@ -617,7 +621,9 @@ inline TQStyle::SFlags convertQt4ToTQt3SFlags(QStyle::State qt4stateflags, TQt3W
sflags = sflags | TQStyle::Style_On;
}
if (qt4stateflags & QStyle::State_Raised) {
- sflags = sflags | TQStyle::Style_Raised;
+ if (wt != TQT3WT_TQToolButton) {
+ sflags = sflags | TQStyle::Style_Raised;
+ }
}
// if (qt4stateflags & QStyle::State_ReadOnly) {
// sflags = sflags | TQStyle::;
@@ -638,7 +644,7 @@ inline TQStyle::SFlags convertQt4ToTQt3SFlags(QStyle::State qt4stateflags, TQt3W
// sflags = sflags | TQStyle::;
// }
if (qt4stateflags & QStyle::State_Sunken) {
- if ((wt == TQT3WT_TQPopupMenu) || (wt == TQT3WT_TQMenuBar)) {
+ if ((wt == TQT3WT_TQPopupMenu) || (wt == TQT3WT_TQMenuBar) || (wt == TQT3WT_TQToolButton)) {
sflags = sflags | TQStyle::Style_Down;
}
sflags = sflags | TQStyle::Style_Sunken;
@@ -796,6 +802,7 @@ Qt4TDEStyle::Qt4TDEStyle()
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;
@@ -825,6 +832,7 @@ Qt4TDEStyle::~Qt4TDEStyle()
// delete m_tqt3titlebar_widget;
// delete m_tqt3menubar_widget;
// delete m_tqt3toolbox_widget;
+// delete m_tqt3toolbutton_widget;
// FIXME
// Verify I'm not leaking memory like a sieve when this is commented out!!!
@@ -832,7 +840,9 @@ Qt4TDEStyle::~Qt4TDEStyle()
delete m_internalTQt3PixmapCache;
- delete m_aboutData;
+ // FIXME
+ // Do I need to delete this?
+// delete m_aboutData;
}
void Qt4TDEStyle::polish(QPalette &palette)
@@ -2069,6 +2079,7 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
const QSpinBox* qt4spinbox_widget = 0;
const QMenuBar* qt4menubar_widget = 0;
const QToolBox* qt4toolbox_widget = 0;
+ const QToolButton* qt4toolbutton_widget = 0;
const QStyleOptionTitleBar* qt4titlebar_options = 0;
@@ -2391,6 +2402,32 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
interfaceWidget = 0;
}
break;
+ case TQT3WT_TQToolButton:
+ // FIXME
+ interfaceWidget = m_tqt3toolbutton_widget;
+ // Copy over all widget attributes
+ qt4toolbutton_widget = dynamic_cast<const QToolButton*>(w);
+ if (qt4toolbutton_widget) {
+ m_tqt3toolbutton_widget->setGeometry(0, 0, qt4toolbutton_widget->width(), qt4toolbutton_widget->height());
+ m_tqt3toolbutton_widget->setEnabled(qt4toolbutton_widget->isEnabled());
+ m_tqt3toolbutton_widget->setIconSet(convertQt4ToTQt3IconSet(qt4toolbutton_widget->icon(), m_tqt3IconSize_Small, m_tqt3IconSize_Large, m_internalTQt3PixmapCache));
+// m_tqt3toolbutton_widget->setUsesBigPixmap(qt4toolbutton_widget->);
+ m_tqt3toolbutton_widget->setUsesTextLabel(((qt4toolbutton_widget->toolButtonStyle() != Qt::ToolButtonIconOnly) && (qt4toolbutton_widget->toolButtonStyle() != Qt::ToolButtonFollowStyle)));
+ m_tqt3toolbutton_widget->setTextLabel(convertQt4ToTQt3String(qt4toolbutton_widget->text()));
+ m_tqt3toolbutton_widget->setToggleButton(qt4toolbutton_widget->isCheckable());
+ m_tqt3toolbutton_widget->setOn(qt4toolbutton_widget->isChecked());
+ if (qt4toolbutton_widget->toolButtonStyle() == Qt::ToolButtonTextBesideIcon) {
+ m_tqt3toolbutton_widget->setTextPosition(TQToolButton::BesideIcon);
+ }
+ m_tqt3toolbutton_widget->setAutoRaise(qt4toolbutton_widget->autoRaise());
+ }
+ else {
+ if (enable_debug_warnings) {
+ printf("Unable to draw Qt4 toolbutton with no Qt4 object available\n\r"); fflush(stdout);
+ }
+ interfaceWidget = 0;
+ }
+ break;
}
m_previousTQt3InterfaceWidget = interfaceWidget;
@@ -2445,6 +2482,7 @@ void Qt4TDEStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
TQStyle::SFlags sflags = 0;
bool can_override = true;
+ bool do_not_draw = false;
TQStyle::ComplexControl tqtCC;
TQStyle::SCFlags subControl = TQStyle::SC_All;
@@ -2617,6 +2655,26 @@ void Qt4TDEStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
}
}
break;
+ case CC_ToolButton:
+ // Qt4 expects this to also draw CE_ToolButtonLabel
+ // See below for drawControl() call
+ tqtCC = TQStyle::CC_ToolButton;
+ sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQToolButton);
+ interfaceWidget = initializeInterfaceWidget(TQT3WT_TQToolButton, w);
+ if (interfaceWidget == 0) {
+ can_override = false;
+ }
+
+ // Draw the correct subcontrol(s)
+ sbopt = static_cast<const QStyleOptionSpinBox*>(opt);
+ subControl = 0;
+ if (sbopt->subControls & QStyle::SC_ToolButton) {
+ subControl = subControl | TQStyle::SC_ToolButton;
+ }
+ if (sbopt->subControls & QStyle::SC_ToolButtonMenu) {
+ subControl = subControl | TQStyle::SC_ToolButtonMenu;
+ }
+ break;
case CC_GroupBox:
NO_QT3_EQUIVALENT
break;
@@ -2660,8 +2718,10 @@ void Qt4TDEStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
tqApp->style().drawPrimitive(TQStyle::PE_PanelLineEdit, &tqtPainter, tqt3rect, tqt3colorgroup, sflags, tqt3opt);
}
- // Instruct TQt3 to draw the complex control
- tqApp->style().drawComplexControl(tqtCC, &tqtPainter, interfaceWidget, tqt3rect, tqt3colorgroup, sflags, subControl, subControlActive, tqt3opt);
+ if (do_not_draw == false) {
+ // Instruct TQt3 to draw the complex control
+ tqApp->style().drawComplexControl(tqtCC, &tqtPainter, interfaceWidget, tqt3rect, tqt3colorgroup, sflags, subControl, subControlActive, tqt3opt);
+ }
if (tqtCC == TQStyle::CC_SpinWidget) {
// Paint the spinbox's editor widget over the outside frame (outside the spinbutton area)
@@ -2683,8 +2743,14 @@ void Qt4TDEStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
tqApp->style().drawPrimitive(TQStyle::PE_PanelLineEdit, &tqtPainter, tqt3rect, tqt3colorgroup, sflags, tqt3opt);
}
+
tqtPainter.end();
+ // Qt4 still needs to draw the button contents over the TQt3 frame and panel
+ if (tqtCC == TQStyle::CC_ToolButton) {
+ drawControl(QStyle::CE_ToolButtonLabel, opt, p, w);
+ }
+
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);
@@ -2692,8 +2758,10 @@ void Qt4TDEStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
}
}
else {
- // Tell Qt4 to draw it
- BASE_QT4_STYLE_CLASS::drawComplexControl(control, opt, p, w);
+ if (do_not_draw == false) {
+ // Tell Qt4 to draw it
+ BASE_QT4_STYLE_CLASS::drawComplexControl(control, opt, p, w);
+ }
}
}
diff --git a/plugin/simplestyle.h b/plugin/simplestyle.h
index c4ab90e..a40df86 100644
--- a/plugin/simplestyle.h
+++ b/plugin/simplestyle.h
@@ -39,6 +39,7 @@ class TQSpinWidget;
class TQTitleBar;
class TQMenuBar;
class TQToolBox;
+class TQToolButton;
class KAboutData;
class TQPixmapCache;
@@ -56,7 +57,8 @@ enum TQt3WidgetType {
TQT3WT_TQSpinWidget,
TQT3WT_TQTitleBar,
TQT3WT_TQMenuBar,
- TQT3WT_TQToolBox
+ TQT3WT_TQToolBox,
+ TQT3WT_TQToolButton
};
class Qt4TDEStyle : public QWindowsStyle
@@ -101,6 +103,7 @@ private:
TQTitleBar* m_tqt3titlebar_widget;
TQMenuBar* m_tqt3menubar_widget;
TQToolBox* m_tqt3toolbox_widget;
+ TQToolButton* m_tqt3toolbutton_widget;
int m_tqt3IconSize_NoGroup;
int m_tqt3IconSize_Desktop;