OSDN Git Service

move private QMotifStyle members to QMotifStylePrivate
authorIvailo Monev <xakepa10@gmail.com>
Mon, 14 Dec 2020 06:51:35 +0000 (06:51 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Mon, 14 Dec 2020 06:51:35 +0000 (06:51 +0000)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
13 files changed:
src/gui/styles/qcleanlooksstyle.cpp
src/gui/styles/qcleanlooksstyle.h
src/gui/styles/qcommonstyle.cpp
src/gui/styles/qcommonstyle.h
src/gui/styles/qmotifstyle.cpp
src/gui/styles/qmotifstyle.h
src/gui/styles/qmotifstyle_p.h
src/gui/styles/qplastiquestyle.cpp
src/gui/styles/qplastiquestyle.h
src/gui/styles/qproxystyle.cpp
src/gui/styles/qproxystyle.h
src/gui/styles/qwindowsstyle.cpp
src/gui/styles/qwindowsstyle.h

index ca78ee0..b0fccd0 100644 (file)
@@ -587,13 +587,6 @@ QCleanlooksStyle::QCleanlooksStyle(QCleanlooksStylePrivate &dd) : QWindowsStyle(
 }
 
 /*!
-    Destroys the QCleanlooksStyle object.
-*/
-QCleanlooksStyle::~QCleanlooksStyle()
-{
-}
-
-/*!
     \fn void QCleanlooksStyle::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette,
                                     bool enabled, const QString& text, QPalette::ColorRole textRole) const
 
index d98fb2d..090af58 100644 (file)
@@ -51,7 +51,6 @@ class Q_GUI_EXPORT QCleanlooksStyle : public QWindowsStyle
 
 public:
     QCleanlooksStyle();
-    ~QCleanlooksStyle();
 
     QPalette standardPalette () const;
     void drawPrimitive(PrimitiveElement elem,
@@ -89,7 +88,6 @@ public:
 
 protected:
     QCleanlooksStyle(QCleanlooksStylePrivate &dd);
-
 };
 
 #endif // QT_NO_STYLE_CLEANLOOKS
index 4c2efca..2f22715 100644 (file)
@@ -110,13 +110,6 @@ QCommonStyle::QCommonStyle(QCommonStylePrivate &dd)
 { }
 
 /*!
-    Destroys the style.
-*/
-QCommonStyle::~QCommonStyle()
-{ }
-
-
-/*!
     \reimp
 */
 void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
index 8ddd9c3..038de5f 100644 (file)
@@ -48,7 +48,6 @@ class Q_GUI_EXPORT QCommonStyle: public QStyle
     
 public:
     QCommonStyle();
-    ~QCommonStyle();
 
     void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
                        const QWidget *w = Q_NULLPTR) const;
index e918e89..f4302a5 100644 (file)
@@ -111,9 +111,7 @@ static const int motifCheckMarkSpace    = 16;
   text color.
 */
 QMotifStyle::QMotifStyle(bool useHighlightCols)
-    : QCommonStyle(*new QMotifStylePrivate),
-    focus(0),
-    highlightCols(useHighlightCols)
+    : QCommonStyle(*new QMotifStylePrivate(useHighlightCols))
 {
     setObjectName(QLatin1String("Motif"));
 }
@@ -122,25 +120,12 @@ QMotifStyle::QMotifStyle(bool useHighlightCols)
 /*!
     \internal
 */
-QMotifStyle::QMotifStyle(QMotifStylePrivate &dd, bool useHighlightCols)
-    : QCommonStyle(dd),
-    focus(0),
-    highlightCols(useHighlightCols)
+QMotifStyle::QMotifStyle(QMotifStylePrivate &dd)
+    : QCommonStyle(dd)
 {
     setObjectName(QLatin1String("Motif"));
 }
 
-
-/*!
-  \overload
-
-  Destroys the style.
-*/
-QMotifStyle::~QMotifStyle()
-{
-    delete focus;
-}
-
 /*!
     \internal
     Animate indeterminate progress bars only when visible
@@ -197,14 +182,21 @@ void QMotifStyle::timerEvent(QTimerEvent *event)
     QCommonStyle::timerEvent(event);
 }
 
-
-QMotifStylePrivate::QMotifStylePrivate()
+QMotifStylePrivate::QMotifStylePrivate(bool useHighlightCols)
+    : QCommonStylePrivate(),
+    focus(Q_NULLPTR),
+    highlightCols(useHighlightCols),
 #ifndef QT_NO_PROGRESSBAR
-    animationFps(25), animateTimer(0), animateStep(0)
+    animationFps(25), animateTimer(0), animateStep(0)
 #endif
 {
 }
 
+QMotifStylePrivate::~QMotifStylePrivate()
+{
+    delete focus;
+}
+
 /*!
   If \a arg is false, the style will polish the application's color
   palette to emulate the Motif way of highlighting, which is a
@@ -218,7 +210,8 @@ QMotifStylePrivate::QMotifStylePrivate()
 */
 void QMotifStyle::setUseHighlightColors(bool arg)
 {
-    highlightCols = arg;
+    Q_D(QMotifStyle);
+    d->highlightCols = arg;
 }
 
 /*!
@@ -229,13 +222,15 @@ void QMotifStyle::setUseHighlightColors(bool arg)
 */
 bool QMotifStyle::useHighlightColors() const
 {
-    return highlightCols;
+    Q_D(const QMotifStyle);
+    return d->highlightCols;
 }
 
 /*! \reimp */
 
 void QMotifStyle::polish(QPalette& pal)
 {
+    Q_D(const QMotifStyle);
     if (pal.brush(QPalette::Active, QPalette::Light) == pal.brush(QPalette::Active, QPalette::Base)) {
         QColor nlight = pal.color(QPalette::Active, QPalette::Light).darker(108);
         pal.setColor(QPalette::Active, QPalette::Light, nlight) ;
@@ -243,7 +238,7 @@ void QMotifStyle::polish(QPalette& pal)
         pal.setColor(QPalette::Inactive, QPalette::Light, nlight) ;
     }
 
-    if (highlightCols)
+    if (d->highlightCols)
         return;
 
     // force the ugly motif way of highlighting *sigh*
@@ -334,6 +329,7 @@ static void rot(QPolygon& a, int n)
 void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
                                 const QWidget *w) const
 {
+    Q_D(const QMotifStyle);
     switch(pe) {
 
     case PE_FrameTabWidget:
@@ -342,7 +338,7 @@ void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP
         break;
     case PE_FrameFocusRect:
         if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
-            if ((fropt->state & State_HasFocus) && focus && focus->isVisible()
+            if ((fropt->state & State_HasFocus) && d->focus && d->focus->isVisible()
                     && !(fropt->state & QStyle::State_Item))
                 break;
             QCommonStyle::drawPrimitive(pe, opt, p, w);
@@ -788,6 +784,7 @@ void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP
 void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
                               const QWidget *widget) const
 {
+    Q_D(const QMotifStyle);
     switch(element) {
     case CE_Splitter: {
         QStyleOption handleOpt = *opt;
@@ -843,7 +840,7 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
             subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
                                          : SE_CheckBoxContents, btn, widget);
             proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget);
-            if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+            if ((btn->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) {
                 QStyleOptionFocusRect fropt;
                 fropt.QStyleOption::operator=(*btn);
                 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
@@ -858,7 +855,7 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q
             QStyleOptionButton subopt = *btn;
             subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
             proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget);
-            if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+            if ((btn->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) {
                 QStyleOptionFocusRect fropt;
                 fropt.QStyleOption::operator=(*btn);
                 fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget);
@@ -1368,6 +1365,7 @@ static void get_combo_parameters(const QRect &r,
 void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
                                      const QWidget *widget) const
 {
+    Q_D(const QMotifStyle);
     switch (cc) {
     case CC_ToolButton:
         if (const QStyleOptionToolButton *toolbutton
@@ -1399,7 +1397,7 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple
                 }
             }
 
-            if ((toolbutton->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+            if ((toolbutton->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) {
                 QStyleOptionFocusRect fr;
                 fr.QStyleOption::operator=(*toolbutton);
                 fr.rect = toolbutton->rect.adjusted(3, 3, -3, -3);
@@ -1506,7 +1504,7 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple
             if ((opt->subControls & SC_SliderGroove) && groove.isValid()) {
                 qDrawShadePanel(p, groove, opt->palette, true, proxy()->pixelMetric(PM_DefaultFrameWidth),
                                 &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window));
-                if ((opt->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+                if ((opt->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) {
                     QStyleOption focusOpt = *opt;
                     focusOpt.rect = subElementRect(SE_SliderFocusRect, opt, widget);
                     proxy()->drawPrimitive(PE_FrameFocusRect, &focusOpt, p, widget);
@@ -1580,12 +1578,12 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple
                 p->drawLine(ar.x()+1, sy+sh-1, ar.x()+awh-1, sy+sh-1);
                 p->drawLine(ar.x()+awh-1, sy+1, ar.x()+awh-1, sy+sh-1);
 
-                if ((cb->state & State_HasFocus) && (!focus || !focus->isVisible())) {
-                    QStyleOptionFocusRect focus;
-                    focus.QStyleOption::operator=(*opt);
-                    focus.rect = subElementRect(SE_ComboBoxFocusRect, opt, widget);
-                    focus.backgroundColor = opt->palette.button().color();
-                    proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
+                if ((cb->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) {
+                    QStyleOptionFocusRect focusRect;
+                    focusRect.QStyleOption::operator=(*opt);
+                    focusRect.rect = subElementRect(SE_ComboBoxFocusRect, opt, widget);
+                    focusRect.backgroundColor = opt->palette.button().color();
+                    proxy()->drawPrimitive(PE_FrameFocusRect, &focusRect, p, widget);
                 }
             }
 
@@ -2269,6 +2267,7 @@ QMotifStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *o
 /*! \reimp */
 bool QMotifStyle::event(QEvent *e)
 {
+    Q_D(QMotifStyle);
     if(e->type() == QEvent::FocusIn) {
         if (QWidget *focusWidget = QApplication::focusWidget()) {
 #ifndef QT_NO_GRAPHICSVIEW
@@ -2281,16 +2280,15 @@ bool QMotifStyle::event(QEvent *e)
                 }
             }
 #endif
-            if(!focus)
-                focus = new QFocusFrame(focusWidget);
-            focus->setWidget(focusWidget);
+            if (!d->focus)
+                d->focus = new QFocusFrame(focusWidget);
+            d->focus->setWidget(focusWidget);
         } else {
-            if(focus)
-                focus->setWidget(0);
+            if (d->focus)
+                d->focus->setWidget(0);
         }
-    } else if(e->type() == QEvent::FocusOut) {
-        if(focus)
-            focus->setWidget(0);
+    } else if (e->type() == QEvent::FocusOut && d->focus) {
+        d->focus->setWidget(0);
     }
     return QCommonStyle::event(e);
 }
index d667b20..e1c72bc 100644 (file)
@@ -35,7 +35,6 @@
 #define QMOTIFSTYLE_H
 
 #include <QtGui/qcommonstyle.h>
-#include <QtCore/qpointer.h>
 
 QT_BEGIN_HEADER
 
@@ -52,8 +51,7 @@ class Q_GUI_EXPORT QMotifStyle : public QCommonStyle
 {
     Q_OBJECT
 public:
-    explicit QMotifStyle(bool useHighlightCols=false);
-    virtual ~QMotifStyle();
+    explicit QMotifStyle(bool useHighlightCols = false);
 
     void setUseHighlightColors(bool);
     bool useHighlightColors() const;
@@ -94,16 +92,13 @@ public:
     QPalette standardPalette() const;
 
 protected:
-    QPointer<QFocusFrame> focus;
-    QMotifStyle(QMotifStylePrivate &dd, bool useHighlightCols = false);
+    QMotifStyle(QMotifStylePrivate &dd);
     void timerEvent(QTimerEvent *event);
     bool eventFilter(QObject *o, QEvent *e);
 
 private:
     Q_DECLARE_PRIVATE(QMotifStyle)
     Q_DISABLE_COPY(QMotifStyle)
-
-    bool highlightCols;
 };
 
 #endif // QT_NO_STYLE_MOTIF
index fcbe82c..8df2eb2 100644 (file)
@@ -57,9 +57,13 @@ class QMotifStylePrivate : public QCommonStylePrivate
 {
     Q_DECLARE_PUBLIC(QMotifStyle)
 public:
-    QMotifStylePrivate();
+    explicit QMotifStylePrivate(bool useHighlightCols = false);
+    ~QMotifStylePrivate();
 
 public:
+    QPointer<QFocusFrame> focus;
+    bool highlightCols;
+
 #ifndef QT_NO_PROGRESSBAR
     QList<QProgressBar *> bars;
     int animationFps;
index a43c85a..c300f01 100644 (file)
@@ -1015,13 +1015,6 @@ QPlastiqueStyle::QPlastiqueStyle()
     setObjectName(QLatin1String("Plastique"));
 }
 
-/*!
-    Destructs the QPlastiqueStyle object.
-*/
-QPlastiqueStyle::~QPlastiqueStyle()
-{
-}
-
 /*
     Used by spin- and combo box.
     Draws a rounded frame around rect but omits the right hand edge
index f442537..ab03a1c 100644 (file)
@@ -50,7 +50,6 @@ class Q_GUI_EXPORT QPlastiqueStyle : public QWindowsStyle
     Q_DECLARE_PRIVATE(QPlastiqueStyle)
 public:
     QPlastiqueStyle();
-    ~QPlastiqueStyle();
 
     void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
                        QPainter *painter, const QWidget *widget = Q_NULLPTR) const;
index e7c82ca..8a54c67 100644 (file)
@@ -117,13 +117,6 @@ QProxyStyle::QProxyStyle(QStyle *style) :
 }
 
 /*!
-    Destroys the QProxyStyle object.
-*/
-QProxyStyle::~QProxyStyle()
-{
-}
-
-/*!
     Returns the proxy base style object. If no base style
     is set on the proxy style, QProxyStyle will create
     an instance of the application style instead.
index cbc5656..c674734 100644 (file)
@@ -50,7 +50,6 @@ class Q_GUI_EXPORT QProxyStyle : public QCommonStyle
 
 public:
     QProxyStyle(QStyle *baseStyle = Q_NULLPTR);
-    ~QProxyStyle();
 
     QStyle *baseStyle() const;
     void setBaseStyle(QStyle *style);
index e4f8919..ec5fc4b 100644 (file)
@@ -212,12 +212,6 @@ QWindowsStyle::QWindowsStyle(QWindowsStylePrivate &dd) : QCommonStyle(dd)
     setObjectName(QLatin1String("Windows"));
 }
 
-
-/*! Destroys the QWindowsStyle object. */
-QWindowsStyle::~QWindowsStyle()
-{
-}
-
 /*! \reimp */
 void QWindowsStyle::polish(QApplication *app)
 {
index b74c996..6a51678 100644 (file)
@@ -50,7 +50,6 @@ class Q_GUI_EXPORT QWindowsStyle : public QCommonStyle
     Q_OBJECT
 public:
     QWindowsStyle();
-    ~QWindowsStyle();
 
     void polish(QApplication*);
     void unpolish(QApplication*);