OSDN Git Service

build fix for the case when QT_NO_STYLE_WINDOWS is defined
authorIvailo Monev <xakepa10@gmail.com>
Sat, 26 Feb 2022 20:24:40 +0000 (22:24 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 26 Feb 2022 20:24:40 +0000 (22:24 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
tests/auto/qboxlayout/tst_qboxlayout.cpp
tests/auto/qformlayout/tst_qformlayout.cpp
tests/auto/qstyle/tst_qstyle.cpp

index c950bce..a424372 100644 (file)
@@ -55,6 +55,7 @@ private slots:
     void taskQTBUG_27420_takeAtShouldUnparentLayout();
 };
 
+#ifndef QT_NO_STYLE_WINDOWS
 class CustomLayoutStyle : public QWindowsStyle
 {
     Q_OBJECT
@@ -93,7 +94,7 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti
     }
     return QWindowsStyle::pixelMetric(metric, option, widget);
 }
-
+#endif // QT_NO_STYLE_WINDOWS
 
 tst_QBoxLayout::tst_QBoxLayout()
 {
@@ -223,7 +224,7 @@ void tst_QBoxLayout::setGeometry()
 
 void tst_QBoxLayout::setStyleShouldChangeSpacing()
 {
-
+#ifndef QT_NO_STYLE_WINDOWS
     QWidget *window = new QWidget;
     QHBoxLayout *hbox = new QHBoxLayout(window);
     QPushButton *pb1 = new QPushButton(tr("The spacing between this"));
@@ -251,11 +252,15 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing()
     delete window;
     delete style1;
     delete style2;
+    delete style;
+#else // QT_NO_STYLE_WINDOWS
+    QSKIP("Katie compiled without windows style support (QT_NO_STYLE_WINDOWS)", SkipAll);
+#endif // QT_NO_STYLE_WINDOWS
 }
 
 void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
 {
-    QLabel *label = new QLabel("Qt uses standard C++, but makes extensive use of the C pre-processor to enrich the language. Qt can also be used in several other programming languages via language bindings. It runs on all major platforms, and has extensive internationalization support. Non-GUI features include SQL database access, XML parsing, thread management, network support and a unified cross-platform API for file handling.");
+    QLabel *label = new QLabel("Katie uses standard C++, but makes extensive use of the C pre-processor to enrich the language. Qt can also be used in several other programming languages via language bindings. It runs on all major platforms, and has extensive internationalization support. Non-GUI features include SQL database access, XML parsing, thread management, network support and a unified cross-platform API for file handling.");
     label->setWordWrap(true);
     label->setFixedWidth(200);
 
index 0fb13a5..c186a6e 100644 (file)
 #include <qwidget.h>
 #include <qwindowsstyle.h>
 #include <qsizepolicy.h>
-#include <QtGui>
-#include <QtGui/QWindowsStyle>
 #include <QStyleFactory>
 #include <QSharedPointer>
 #include <qformlayout.h>
+#include <QLineEdit>
+#include <QLabel>
+#include <QBitArray>
+#include <QPushButton>
 
 //TESTED_CLASS=
 //TESTED_FILES=
@@ -250,6 +252,7 @@ void tst_QFormLayout::wrapping()
     delete w;
 }
 
+#ifndef QT_NO_STYLE_WINDOWS
 class CustomLayoutStyle : public QWindowsStyle
 {
     Q_OBJECT
@@ -281,9 +284,11 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti
     }
     return QWindowsStyle::pixelMetric(metric, option, widget);
 }
+#endif // QT_NO_STYLE_WINDOWS
 
 void tst_QFormLayout::spacing()
 {
+#ifndef QT_NO_STYLE_WINDOWS
     //TODO: confirm spacing behavior
     QWidget *w = new QWidget;
     CustomLayoutStyle *style = new CustomLayoutStyle;
@@ -320,6 +325,9 @@ void tst_QFormLayout::spacing()
 
     delete w;
     delete style;
+#else // QT_NO_STYLE_WINDOWS
+    QSKIP("Katie compiled without windows style support (QT_NO_STYLE_WINDOWS)", SkipAll);
+#endif // QT_NO_STYLE_WINDOWS
 }
 
 void tst_QFormLayout::contentsRect()
@@ -382,6 +390,7 @@ public:
 
 void tst_QFormLayout::setFormStyle()
 {
+#ifndef QT_NO_STYLE_WINDOWS
     QWidget widget;
     QFormLayout layout;
     widget.setLayout(&layout);
@@ -410,6 +419,9 @@ void tst_QFormLayout::setFormStyle()
     QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
     QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::AllNonFixedFieldsGrow);
     QVERIFY(layout.rowWrapPolicy() == QFormLayout::WrapLongRows);
+#else // QT_NO_STYLE_WINDOWS
+    QSKIP("Katie compiled without windows style support (QT_NO_STYLE_WINDOWS)", SkipAll);
+#endif // QT_NO_STYLE_WINDOWS
 }
 
 void tst_QFormLayout::setFieldGrowthPolicy()
index 3b108f6..9509d0a 100644 (file)
@@ -159,7 +159,7 @@ class CustomProxy : public QProxyStyle
 
 void tst_QStyle::testProxyStyle()
 {
-#ifndef QT_NO_STYLE_PROXY
+#if !defined(QT_NO_STYLE_PROXY) && !defined(QT_NO_STYLE_WINDOWS)
     QProxyStyle *proxyStyle = new QProxyStyle();
     QVERIFY(proxyStyle->baseStyle());
     QStyle *style = new QWindowsStyle;
@@ -184,7 +184,7 @@ void tst_QStyle::testProxyStyle()
     QVERIFY(!customStyle.parent());
     QVERIFY(edit.style()->pixelMetric(QStyle::PM_ButtonIconSize) == 13);
 #else // QT_NO_STYLE_PROXY
-    QSKIP("Katie compiled without style proxy support (QT_NO_STYLE_PROXY)", SkipAll);
+    QSKIP("Katie compiled without style proxy or windows style support (QT_NO_STYLE_PROXY or QT_NO_STYLE_WINDOWS)", SkipAll);
 #endif // QT_NO_STYLE_PROXY
 }
 
@@ -309,6 +309,7 @@ void tst_QStyle::testCleanlooksStyle()
 
 void tst_QStyle::testWindowsStyle()
 {
+#ifndef QT_NO_STYLE_WINDOWS
     QWindowsStyle wstyle;
     testAllFunctions(&wstyle);
     lineUpLayoutTest(&wstyle);
@@ -319,6 +320,9 @@ void tst_QStyle::testWindowsStyle()
     QPixmap surface(QSize(200, 200));
     QPainter painter(&surface);
     wstyle.drawControl(QStyle::CE_ProgressBar, &pb, &painter, 0);
+#else // QT_NO_STYLE_WINDOWS
+    QSKIP("Katie compiled without windows style support (QT_NO_STYLE_WINDOWS)", SkipAll);
+#endif // QT_NO_STYLE_WINDOWS
 }
 
 void writeImage(const QString &fileName, QImage image)
@@ -360,7 +364,7 @@ void MyWidget::paintEvent( QPaintEvent* )
     style()->drawItemPixmap(&p, rect(), Qt::AlignCenter, big);
 }
 
-
+#ifndef QT_NO_STYLE_WINDOWS
 class Qt42Style : public QWindowsStyle
 {
     Q_OBJECT
@@ -399,10 +403,11 @@ int Qt42Style::pixelMetric(PixelMetric metric, const QStyleOption * option /*= 0
     }
     return QWindowsStyle::pixelMetric(metric, option, widget);
 }
-
+#endif // QT_NO_STYLE_WINDOWS
 
 void tst_QStyle::pixelMetric()
 {
+#ifndef QT_NO_STYLE_WINDOWS
     Qt42Style *style = new Qt42Style();
     QCOMPARE(style->pixelMetric(QStyle::PM_DefaultTopLevelMargin), 10);
     QCOMPARE(style->pixelMetric(QStyle::PM_DefaultChildMargin), 5);
@@ -423,6 +428,9 @@ void tst_QStyle::pixelMetric()
     QCOMPARE(style->pixelMetric(QStyle::PM_DefaultLayoutSpacing), -1);
 
     delete style;
+#else // QT_NO_STYLE_WINDOWS
+    QSKIP("Katie compiled without windows style support (QT_NO_STYLE_WINDOWS)", SkipAll);
+#endif // QT_NO_STYLE_WINDOWS
 }
 
 void tst_QStyle::lineUpLayoutTest(QStyle *style)