macOS: rename 'macintosh' style to 'macos'

Change the name/key of the style to 'macos'. Besides the
name 'macintosh' being archaic, we also need this
change to avoid creating 'macintosh' style folders
in QtQuickControls, now that we plan to use QPlatformTheme
also there to resolve the style.

[ChangeLog][Widgets][QStyle] The 'macintosh' style
has been renamed to 'macos'.

Change-Id: I14b8a8b4dbd369e7a7d16b94e4ad27e501e7e8d0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Richard Moe Gustavsen 2020-08-19 14:44:17 +02:00
parent 9efe2a8603
commit ed813c19fa
12 changed files with 20 additions and 14 deletions

View File

@ -631,7 +631,7 @@
currently available GUI styles using currently available GUI styles using
QStyleFactory. QStyleFactory::keys() returns a list of valid keys, QStyleFactory. QStyleFactory::keys() returns a list of valid keys,
typically including "windows" and "fusion". Depending on the platform, typically including "windows" and "fusion". Depending on the platform,
"windowsvista" and "macintosh" may be available. "windowsvista" and "macos" may be available.
We create one action for each key, and adds the action to the We create one action for each key, and adds the action to the
action group. Also, for each action, we call QAction::setData() action group. Also, for each action, we call QAction::setData()
@ -666,7 +666,7 @@
For each action, we first extract the style name using For each action, we first extract the style name using
QAction::data(). Since this is only a QStyleFactory key (e.g., QAction::data(). Since this is only a QStyleFactory key (e.g.,
"macintosh"), we cannot compare it directly to the current "macos"), we cannot compare it directly to the current
style's class name. We need to create a QStyle object using the style's class name. We need to create a QStyle object using the
static QStyleFactory::create() function and compare the class static QStyleFactory::create() function and compare the class
name of the created QStyle object with that of the current style. name of the created QStyle object with that of the current style.

View File

@ -501,7 +501,7 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
{ {
switch (hint) { switch (hint) {
case QPlatformTheme::StyleNames: case QPlatformTheme::StyleNames:
return QStringList(QStringLiteral("macintosh")); return QStringList(QStringLiteral("macos"));
case QPlatformTheme::DialogButtonBoxLayout: case QPlatformTheme::DialogButtonBoxLayout:
return QVariant(QPlatformDialogHelper::MacLayout); return QVariant(QPlatformDialogHelper::MacLayout);
case KeyboardScheme: case KeyboardScheme:

View File

@ -1,3 +1,3 @@
{ {
"Keys": [ "macintosh" ] "Keys": [ "macos" ]
} }

View File

@ -53,7 +53,7 @@ public:
QStyle *QMacStylePlugin::create(const QString &key) QStyle *QMacStylePlugin::create(const QString &key)
{ {
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
if (key.compare(QLatin1String("macintosh"), Qt::CaseInsensitive) == 0) if (key.compare(QLatin1String("macos"), Qt::CaseInsensitive) == 0)
return new QMacStyle(); return new QMacStyle();
return 0; return 0;

View File

@ -2572,7 +2572,7 @@ QPalette QMacStyle::standardPalette() const
{ {
auto platformTheme = QGuiApplicationPrivate::platformTheme(); auto platformTheme = QGuiApplicationPrivate::platformTheme();
auto styleNames = platformTheme->themeHint(QPlatformTheme::StyleNames); auto styleNames = platformTheme->themeHint(QPlatformTheme::StyleNames);
if (styleNames.toStringList().contains("macintosh")) if (styleNames.toStringList().contains("macos"))
return QPalette(); // Inherit everything from theme return QPalette(); // Inherit everything from theme
else else
return QStyle::standardPalette(); return QStyle::standardPalette();

View File

@ -48,7 +48,7 @@
\li The Windows Vista style ("windowsvista") is provided by \li The Windows Vista style ("windowsvista") is provided by
QWindowsVistaStyle. QWindowsVistaStyle.
\row \row
\li The \macos style ("macintosh") is provided by QMacStyle. \li The \macos style ("macos") is provided by QMacStyle.
\li \image macos-style.png \macos Style \li \image macos-style.png \macos Style
\row \row
\li \image fusion-style.png Fusion Style \li \image fusion-style.png Fusion Style

View File

@ -1066,7 +1066,7 @@ void QApplication::setStyle(QStyle *style)
Requests a QStyle object for \a style from the QStyleFactory. Requests a QStyle object for \a style from the QStyleFactory.
The string must be one of the QStyleFactory::keys(), typically one of The string must be one of the QStyleFactory::keys(), typically one of
"windows", "windowsvista", "fusion", or "macintosh". Style "windows", "windowsvista", "fusion", or "macos". Style
names are case insensitive. names are case insensitive.
Returns \nullptr if an unknown \a style is passed, otherwise the QStyle object Returns \nullptr if an unknown \a style is passed, otherwise the QStyle object

View File

@ -69,7 +69,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
The valid keys can be retrieved using the keys() The valid keys can be retrieved using the keys()
function. Typically they include "windows" and "fusion". function. Typically they include "windows" and "fusion".
Depending on the platform, "windowsvista" Depending on the platform, "windowsvista"
and "macintosh" may be available. and "macos" may be available.
Note that keys are case insensitive. Note that keys are case insensitive.
\sa QStyle \sa QStyle
@ -99,6 +99,12 @@ QStyle *QStyleFactory::create(const QString& key)
if (style == QLatin1String("fusion")) if (style == QLatin1String("fusion"))
ret = new QFusionStyle; ret = new QFusionStyle;
else else
#endif
#if defined(Q_OS_MACOS) && QT_DEPRECATED_SINCE(6, 0)
if (style == QLatin1String("macintosh")) {
qWarning() << "The style key 'macintosh' is deprecated. Please use 'macos' instead.";
style = QStringLiteral("macos");
} else
#endif #endif
{ } // Keep these here - they make the #ifdefery above work { } // Keep these here - they make the #ifdefery above work
if (!ret) if (!ret)

View File

@ -2892,7 +2892,7 @@ void tst_QGraphicsView::scrollBarRanges()
QFETCH(ExpectedValueDescription, vmax); QFETCH(ExpectedValueDescription, vmax);
QFETCH(bool, useStyledPanel); QFETCH(bool, useStyledPanel);
if (useStyledPanel && style == "macintosh" && platformName == QStringLiteral("cocoa")) if (useStyledPanel && style == "macos" && platformName == QStringLiteral("cocoa"))
QSKIP("Insignificant on OSX"); QSKIP("Insignificant on OSX");
QScopedPointer<QStyle> stylePtr; QScopedPointer<QStyle> stylePtr;

View File

@ -270,7 +270,7 @@ bool tst_QStyle::testAllFunctions(QStyle *style)
bool tst_QStyle::testScrollBarSubControls(const QStyle *style) bool tst_QStyle::testScrollBarSubControls(const QStyle *style)
{ {
const bool isMacStyle = style->objectName().compare(QLatin1String("macintosh"), const bool isMacStyle = style->objectName().compare(QLatin1String("macos"),
Qt::CaseInsensitive) == 0; Qt::CaseInsensitive) == 0;
QScrollBar scrollBar; QScrollBar scrollBar;
setFrameless(&scrollBar); setFrameless(&scrollBar);
@ -328,7 +328,7 @@ void tst_QStyle::testWindowsVistaStyle()
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
void tst_QStyle::testMacStyle() void tst_QStyle::testMacStyle()
{ {
QStyle *mstyle = QStyleFactory::create("Macintosh"); QStyle *mstyle = QStyleFactory::create("macos");
QVERIFY(testAllFunctions(mstyle)); QVERIFY(testAllFunctions(mstyle));
delete mstyle; delete mstyle;
} }

View File

@ -79,7 +79,7 @@ void tst_QFocusFrame::focusFrameInsideScrollview()
// is why special considerations are taken inside the focus frame to // is why special considerations are taken inside the focus frame to
// prevent the frame to scroll away from the widget it tracks. // prevent the frame to scroll away from the widget it tracks.
if (qApp->style()->objectName() != QLatin1String("macintosh")) if (qApp->style()->objectName() != QLatin1String("macos"))
QSKIP("This test is only valid when using a style that has a focus frame"); QSKIP("This test is only valid when using a style that has a focus frame");
QWidget window; QWidget window;

View File

@ -516,7 +516,7 @@ void tst_QPushButton::sizeHint_data()
QTest::newRow("windows") << QString::fromLatin1("windows"); QTest::newRow("windows") << QString::fromLatin1("windows");
#endif #endif
#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC)
QTest::newRow("macintosh") << QString::fromLatin1("macintosh"); QTest::newRow("macos") << QString::fromLatin1("macos");
#endif #endif
#if !defined(QT_NO_STYLE_FUSION) #if !defined(QT_NO_STYLE_FUSION)
QTest::newRow("fusion") << QString::fromLatin1("fusion"); QTest::newRow("fusion") << QString::fromLatin1("fusion");