diff options
-rw-r--r-- | plugin/simplestyle.cpp | 104 | ||||
-rw-r--r-- | plugin/simplestyle.h | 6 | ||||
-rw-r--r-- | plugin/simplestyleplugin.cpp | 12 | ||||
-rw-r--r-- | plugin/simplestyleplugin.h | 4 |
4 files changed, 75 insertions, 51 deletions
diff --git a/plugin/simplestyle.cpp b/plugin/simplestyle.cpp index 496b070..4345810 100644 --- a/plugin/simplestyle.cpp +++ b/plugin/simplestyle.cpp @@ -694,7 +694,7 @@ static QString TDEFileDialogSelectDirectory(QWidget *parent, const QString &capt #define NO_QT3_EQUIVALENT can_override = false; #define DO_NOT_DRAW can_override = true; do_not_draw = true; -SimpleStyle::SimpleStyle() +Qt4TDEStyle::Qt4TDEStyle() { m_previousQt4InterfaceWidget = 0; m_previousTQt3InterfaceWidget = 0; @@ -709,9 +709,9 @@ SimpleStyle::SimpleStyle() // Supply it with fake data to keep KApplication happy argv = (char**) malloc(sizeof(char*)); argv[0] = (char*) malloc(sizeof(char) * 19); - strncpy(argv[0], "SimpleStyle", 19); + strncpy(argv[0], "Qt4TDEStyle", 19); - m_aboutData = new KAboutData("SimpleStyle", I18N_NOOP(convertQt4ToTQt3String(qApp->applicationName())), "v0.1", + m_aboutData = new KAboutData("Qt4TDEStyle", 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"); @@ -805,7 +805,7 @@ SimpleStyle::SimpleStyle() #endif // INTEGRATE_WITH_TDE } -SimpleStyle::~SimpleStyle() +Qt4TDEStyle::~Qt4TDEStyle() { // delete tqApp; @@ -835,14 +835,14 @@ SimpleStyle::~SimpleStyle() delete m_aboutData; } -void SimpleStyle::polish(QPalette &palette) +void Qt4TDEStyle::polish(QPalette &palette) { // FIXME // Figure out some way to polish the Qt4 widgets with the Qt3 polish method // This probably involves modifying Qt3 to specify a painter... } -void SimpleStyle::polish(QWidget *widget) +void Qt4TDEStyle::polish(QWidget *widget) { // HACK // Many TQt3 styles need to be notified when their widgets are moused over @@ -853,18 +853,18 @@ void SimpleStyle::polish(QWidget *widget) widget->installEventFilter(this); } -void SimpleStyle::unpolish(QWidget *widget) +void Qt4TDEStyle::unpolish(QWidget *widget) { // HACK - // See SimpleStyle::polish + // See Qt4TDEStyle::polish widget->setMouseTracking(false); widget->removeEventFilter(this); } -bool SimpleStyle::eventFilter(QObject *obj, QEvent *ev) +bool Qt4TDEStyle::eventFilter(QObject *obj, QEvent *ev) { // HACK - // See SimpleStyle::polish + // See Qt4TDEStyle::polish if (!obj->isWidgetType() ) { return false; } @@ -907,7 +907,7 @@ bool SimpleStyle::eventFilter(QObject *obj, QEvent *ev) return false; } -QIcon SimpleStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption* opt, const QWidget* w) const +QIcon Qt4TDEStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption* opt, const QWidget* w) const { QIcon reticon; TQString iconLookupName; @@ -1147,7 +1147,7 @@ QIcon SimpleStyle::standardIconImplementation(StandardPixmap standardIcon, const return reticon; } -int SimpleStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *w, QStyleHintReturn* returnData) const +int Qt4TDEStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *w, QStyleHintReturn* returnData) const { int retval = 0; TQWidget* interfaceWidget = 0; @@ -1583,7 +1583,7 @@ int SimpleStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidge return retval; } -QSize SimpleStyle::sizeFromContents(ContentsType type, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const +QSize Qt4TDEStyle::sizeFromContents(ContentsType type, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const { int i; @@ -1659,7 +1659,7 @@ QSize SimpleStyle::sizeFromContents(ContentsType type, const QStyleOption *opt, return retval; } -int SimpleStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *w ) const +int Qt4TDEStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *w ) const { int retval = 0; TQWidget* interfaceWidget = 0; @@ -1907,14 +1907,14 @@ int SimpleStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const // retval = 0; // retswitch = 2; // break; -// case QStyle::PM_MenuHMargin: -// retval = 0; -// retswitch = 2; -// break; -// case QStyle::PM_MenuVMargin: -// retval = 0; -// retswitch = 2; -// break; + case QStyle::PM_MenuHMargin: + tqt3pixelmetric = TQStyle::PM_PopupMenuFrameHorizontalExtra; + retswitch = 1; + break; + case QStyle::PM_MenuVMargin: + tqt3pixelmetric = TQStyle::PM_PopupMenuFrameVerticalExtra; + retswitch = 1; + break; // case QStyle::PM_MenuScrollerHeight: // tqt3pixelmetric = TQStyle::PM_MenuScrollerHeight; // retswitch = 1; @@ -2053,7 +2053,7 @@ int SimpleStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const return retval; } -TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidget* w, const QStyleOption* qt4styleoptions) const +TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidget* w, const QStyleOption* qt4styleoptions) const { int i; TQWidget* interfaceWidget = 0; @@ -2114,8 +2114,8 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge m_tqt3tabbar_widget->setGeometry(0, 0, qt4tabbar_widget->width(), qt4tabbar_widget->height()); m_tqt3tabbar_widget->setEnabled(qt4tabbar_widget->isEnabled()); // Clear out tabbar - for (i=0;i<m_tqt3tabbar_widget->count();i++) { - m_tqt3tabbar_widget->removeTab(m_tqt3tabbar_widget->tabAt(i)); + while (m_tqt3tabbar_widget->count() > 0) { + m_tqt3tabbar_widget->removeTab(m_tqt3tabbar_widget->tabAt(0)); } // Copy over all tabs for (i=0;i<qt4tabbar_widget->count();i++) { @@ -2219,9 +2219,14 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge m_tqt3popupmenu_widget->setItemEnabled(i, currentAction->isEnabled()); m_tqt3popupmenu_widget->setItemChecked(i, currentAction->isChecked()); m_tqt3popupmenu_widget->setItemVisible(i, currentAction->isVisible()); - if (currentAction->isCheckable()) { - m_tqt3popupmenu_widget->setCheckable(true); - } + + // FIXME + // It seems that all menus under TQt3 are checkable + // VERIFY THIS + m_tqt3popupmenu_widget->setCheckable(true); +// if (currentAction->isCheckable()) { +// m_tqt3popupmenu_widget->setCheckable(true); +// } } } break; @@ -2329,13 +2334,13 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge // Copy over all widget attributes qt4spinbox_widget = dynamic_cast<const QSpinBox*>(w); if (qt4spinbox_widget) { - m_tqt3spinbox_widget->setGeometry(0, 0, qt4spinbox_widget->width(), qt4spinbox_widget->height()); - m_tqt3spinbox_widget->setEnabled(qt4spinbox_widget->isEnabled()); + m_tqt3spinwidget_widget->setGeometry(0, 0, qt4spinbox_widget->width(), qt4spinbox_widget->height()); + m_tqt3spinwidget_widget->setEnabled(qt4spinbox_widget->isEnabled()); // FIXME -// m_tqt3spinbox_widget->setMinValue(qt4spinbox_widget->minimum()); -// m_tqt3spinbox_widget->setMaxValue(qt4spinbox_widget->maximum()); -// m_tqt3spinbox_widget->setLineStep(qt4spinbox_widget->singleStep()); -// m_tqt3spinbox_widget->setValue(qt4spinbox_widget->value()); +// m_tqt3spinwidget_widget->setMinValue(qt4spinbox_widget->minimum()); +// m_tqt3spinwidget_widget->setMaxValue(qt4spinbox_widget->maximum()); +// m_tqt3spinwidget_widget->setLineStep(qt4spinbox_widget->singleStep()); +// m_tqt3spinwidget_widget->setValue(qt4spinbox_widget->value()); } else { if (enable_debug_warnings) { @@ -2392,7 +2397,7 @@ TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge return interfaceWidget; } -QRect SimpleStyle::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *w) const +QRect Qt4TDEStyle::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *w) const { TQStyle::SFlags sflags = 0; @@ -2435,7 +2440,7 @@ QRect SimpleStyle::subElementRect(SubElement element, const QStyleOption *opt, c return retRect; } -void SimpleStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w) const +void Qt4TDEStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w) const { TQStyle::SFlags sflags = 0; @@ -2467,6 +2472,7 @@ void SimpleStyle::drawComplexControl(ComplexControl control, const QStyleOptionC } const QStyleOptionTitleBar* tbopt; + const QStyleOptionSpinBox* sbopt; bool drawCloseButton; bool drawMaxButton; bool drawMinButton; @@ -2499,10 +2505,23 @@ void SimpleStyle::drawComplexControl(ComplexControl control, const QStyleOptionC break; case CC_SpinBox: tqtCC = TQStyle::CC_SpinWidget; - interfaceWidget = initializeInterfaceWidget(TQT3WT_TQSpinWidget, w); + interfaceWidget = initializeInterfaceWidget(TQT3WT_TQSpinWidget, w, opt); if (interfaceWidget == 0) { can_override = false; } + + // Draw the correct subcontrol(s) + sbopt = static_cast<const QStyleOptionSpinBox*>(opt); + subControl = 0; + if ((sbopt->subControls & QStyle::SC_SpinBoxUp) || (sbopt->subControls & QStyle::SC_SpinBoxDown)) { + subControl = subControl | TQStyle::SC_SpinWidgetButtonField; + } + if (sbopt->subControls & QStyle::SC_SpinBoxEditField) { + subControl = subControl | TQStyle::SC_SpinWidgetFrame; + } + if (sbopt->subControls & QStyle::SC_SpinBoxFrame) { + subControl = subControl | TQStyle::SC_SpinWidgetFrame; + } break; case CC_TitleBar: tqtCC = TQStyle::CC_TitleBar; @@ -2678,7 +2697,7 @@ void SimpleStyle::drawComplexControl(ComplexControl control, const QStyleOptionC } } -void SimpleStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w) const +void Qt4TDEStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w) const { int i; TQStyle::SFlags sflags = 0; @@ -2785,11 +2804,16 @@ void SimpleStyle::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() == 0) { + if (drawingTab->identifier() == (TQApplication::reverseLayout() ? (m_tqt3tabbar_widget->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()); } + 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; @@ -2987,7 +3011,7 @@ void SimpleStyle::drawControl(ControlElement element, const QStyleOption *opt, Q } } -void SimpleStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const +void Qt4TDEStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const { // Construct a Qt3 paint device translator on the Qt4 painter TDEQt4PaintDevice qt4pd(p); diff --git a/plugin/simplestyle.h b/plugin/simplestyle.h index 65cf25e..c4ab90e 100644 --- a/plugin/simplestyle.h +++ b/plugin/simplestyle.h @@ -59,13 +59,13 @@ enum TQt3WidgetType { TQT3WT_TQToolBox }; -class SimpleStyle : public QWindowsStyle +class Qt4TDEStyle : public QWindowsStyle { Q_OBJECT public: - SimpleStyle(); - ~SimpleStyle(); + Qt4TDEStyle(); + ~Qt4TDEStyle(); void polish(QPalette &palette); void polish(QWidget *widget); diff --git a/plugin/simplestyleplugin.cpp b/plugin/simplestyleplugin.cpp index a474217..9c8b29e 100644 --- a/plugin/simplestyleplugin.cpp +++ b/plugin/simplestyleplugin.cpp @@ -44,21 +44,21 @@ #include "simplestyle.h" //! [0] -QStringList SimpleStylePlugin::keys() const +QStringList Qt4TDEStylePlugin::keys() const { - return QStringList() << "SimpleStyle"; + return QStringList() << "Qt4TDEStyle"; } //! [0] //! [1] -QStyle *SimpleStylePlugin::create(const QString &key) +QStyle *Qt4TDEStylePlugin::create(const QString &key) { - if (key.toLower() == "simplestyle") - return new SimpleStyle; + if (key.toLower() == "qt4tdestyle") + return new Qt4TDEStyle; return 0; } //! [1] QT_BEGIN_NAMESPACE -Q_EXPORT_PLUGIN2(simplestyleplugin, SimpleStylePlugin) +Q_EXPORT_PLUGIN2(simplestyleplugin, Qt4TDEStylePlugin) QT_END_NAMESPACE diff --git a/plugin/simplestyleplugin.h b/plugin/simplestyleplugin.h index e7616dd..81b4cc5 100644 --- a/plugin/simplestyleplugin.h +++ b/plugin/simplestyleplugin.h @@ -49,12 +49,12 @@ class QStyle; QT_END_NAMESPACE //! [0] -class SimpleStylePlugin : public QStylePlugin +class Qt4TDEStylePlugin : public QStylePlugin { Q_OBJECT public: - SimpleStylePlugin() {}; + Qt4TDEStylePlugin() {}; QStringList keys() const; QStyle *create(const QString &key); |