From 27aa41cbba6c0bd76148fde63863cfbba0ec2456 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 17 Nov 2012 00:52:26 +0100 Subject: Made QMacStyle internal We will take this opportynity to remove various QStyle specializations from the public API in Qt5. This gives us much more freedom, for example changing the inheritance hierarchy, pluginizing etc. without worrying about BC. => Use QStyleFactory and/or QProxyStyle instead of creating an instance or inheriting QMacStyle directly. Change-Id: I44a2f5ee3fe08ecc837b593a2a2737eb90e8c267 Reviewed-by: Gabriel de Dietrich --- tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp | 3 --- .../qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 5 +---- tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp | 6 +----- tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp | 8 +++----- tests/auto/widgets/styles/qstyle/tst_qstyle.cpp | 9 +++------ tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 5 +---- tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp | 3 +-- tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp | 7 ++----- 8 files changed, 12 insertions(+), 34 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index cd52977d61..ae71d33c50 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -50,9 +50,6 @@ #include #include #include -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) -#include -#endif #define CONVENIENCE_FUNC_SYMS(func) \ { \ diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 61ac6bb693..04976f4a8c 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -45,9 +45,6 @@ #include #include #include // qSmartMin functions... -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) -#include -#endif #include "../../../qtest-config.h" @@ -2721,7 +2718,7 @@ void tst_QGraphicsProxyWidget::childPos() #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) // The Mac style wants the popup to show up at QPoint(4 - 11, 1). // See QMacStyle::subControlRect SC_ComboBoxListBoxPopup. - if (qobject_cast(QApplication::style())) + if (QApplication::style()->inherits("QMacStyle")) expectedXPosition = qreal(4 - 11); #endif QCOMPARE(proxyChild->pos().x(), expectedXPosition); diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp index e4c76cd237..7e68db0e8c 100644 --- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp +++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp @@ -57,10 +57,6 @@ #include #include -#ifdef Q_OS_MAC -# include -#endif - class tst_QLayout : public QObject { Q_OBJECT @@ -276,7 +272,7 @@ public: void tst_QLayout::layoutItemRect() { #ifdef Q_OS_MAC - if (qobject_cast(QApplication::style())) { + if (QApplication::style()->inherits("QMacStyle")) { QWidget *window = new QWidget; QRadioButton *radio = new QRadioButton(window); QWidgetItem item(radio); diff --git a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp index c0b857d540..bd14a76bbb 100644 --- a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp +++ b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp @@ -43,8 +43,6 @@ #include #include -#include - const int N = 1; enum Size { Normal, Small, Mini }; @@ -322,13 +320,13 @@ void tst_QMacStyle::setSize(QWidget *widget, Size size) { switch (size) { case Normal: - QMacStyle::setWidgetSizePolicy(widget, QMacStyle::SizeDefault); + widget->setAttribute(Qt::WA_MacNormalSize, true); break; case Small: - QMacStyle::setWidgetSizePolicy(widget, QMacStyle::SizeSmall); + widget->setAttribute(Qt::WA_MacSmallSize, true); break; case Mini: - QMacStyle::setWidgetSizePolicy(widget, QMacStyle::SizeMini); + widget->setAttribute(Qt::WA_MacMiniSize, true); } } diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index f5358b4e15..7cbd30ebb3 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -71,10 +71,6 @@ #include #include -#ifdef Q_OS_MAC -#include -#endif - #ifdef Q_OS_WINCE_WM #include @@ -527,8 +523,9 @@ qDebug("TEST PAINTING"); #ifdef Q_OS_MAC void tst_QStyle::testMacStyle() { - QMacStyle mstyle; - QVERIFY(testAllFunctions(&mstyle)); + QStyle *mstyle = QStyleFactory::create("Macintosh"); + QVERIFY(testAllFunctions(mstyle)); + delete mstyle; } #endif diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index af14ad13d3..4f390fa2c8 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -60,9 +60,6 @@ #include #include #include -#ifdef Q_OS_MAC -#include -#endif #include #include @@ -450,7 +447,7 @@ void tst_QComboBox::setEditable() void tst_QComboBox::setPalette() { #ifdef Q_OS_MAC - if (qobject_cast(testWidget->style())) { + if (testWidget->style()->inherits("QMacStyle")) { QSKIP("This test doesn't make sense for pixmap-based styles"); } #endif diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 51a49f467d..5aa7b19917 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -60,7 +60,6 @@ #ifndef QT_NO_OPENGL #include #endif -#include #include static const Qt::WindowFlags DefaultWindowFlags @@ -195,7 +194,7 @@ static bool verifyArrangement(QMdiArea *mdiArea, Arrangement arrangement, const int titleBarHeight = firstSubWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options); #ifdef Q_OS_MAC // ### Remove this after the mac style has been fixed - if (qobject_cast(firstSubWindow->style())) + if (firstSubWindow->style()->inherits("QMacStyle")) titleBarHeight -= 4; #endif const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar")); diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index caf030e3b6..4b2124e8d4 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -59,9 +59,6 @@ #include #include #include -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) -#include -#endif #include "../../../qtest-config.h" @@ -598,7 +595,7 @@ void tst_QMdiSubWindow::showShaded() QPoint mousePosition(window->width() - qMax(offset, 2), window->height() - qMax(offset, 2)); QWidget *mouseReceiver = 0; #ifdef Q_OS_MAC - if (qobject_cast(window->style())) + if (window->style()->inherits("QMacStyle")) mouseReceiver = qFindChild(window); else #endif @@ -1704,7 +1701,7 @@ void tst_QMdiSubWindow::fixedMinMaxSize() int minimizedHeight = subWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options); #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) // ### Remove this after mac style has been fixed - if (qobject_cast(subWindow->style())) + if (subWindow->style()->inherits("QMacStyle")) minimizedHeight -= 4; #endif if (!subWindow->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, subWindow)) -- cgit v1.2.3