Add a platform theme option to affect SH_UnderlineShortcut

The style hint SH_UnderlineShortcut can now be turned on/off via the
platform theme.

No change in functionality so far on any platform, this behaves the
same way it did before the change. The change just adds a possibility
for platforms to redefine the default underlining behavior.

Task-number: QTBUG-76587
Change-Id: Ibda104f1b733371da19825b96e73c22f42faf853
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Mikolaj Boc 2022-10-13 12:34:20 +02:00
parent 8dc3ee03a4
commit 5af0177c9e
5 changed files with 16 additions and 4 deletions

View File

@ -416,6 +416,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickMaximumVelocity); return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickMaximumVelocity);
case FlickDeceleration: case FlickDeceleration:
return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickDeceleration); return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickDeceleration);
case UnderlineShortcut:
return true;
} }
return 0; return 0;

View File

@ -164,7 +164,8 @@ public:
MouseDoubleClickDistance, MouseDoubleClickDistance,
FlickStartDistance, FlickStartDistance,
FlickMaximumVelocity, FlickMaximumVelocity,
FlickDeceleration FlickDeceleration,
UnderlineShortcut,
}; };
virtual QVariant styleHint(StyleHint hint) const; virtual QVariant styleHint(StyleHint hint) const;

View File

@ -525,6 +525,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickMaximumVelocity); return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickMaximumVelocity);
case QPlatformTheme::FlickDeceleration: case QPlatformTheme::FlickDeceleration:
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickDeceleration); return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickDeceleration);
case QPlatformTheme::UnderlineShortcut:
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UnderlineShortcut);
default: default:
return QPlatformTheme::defaultThemeHint(hint); return QPlatformTheme::defaultThemeHint(hint);
} }
@ -637,7 +639,10 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
return QVariant(QString()); return QVariant(QString());
case MouseCursorSize: case MouseCursorSize:
return QVariant(QSize(16, 16)); return QVariant(QSize(16, 16));
case UnderlineShortcut:
return true;
} }
return QVariant(); return QVariant();
} }

View File

@ -95,7 +95,8 @@ public:
FlickDeceleration, FlickDeceleration,
MenuBarFocusOnAltPressRelease, MenuBarFocusOnAltPressRelease,
MouseCursorTheme, MouseCursorTheme,
MouseCursorSize MouseCursorSize,
UnderlineShortcut,
}; };
Q_ENUM(ThemeHint) Q_ENUM(ThemeHint)

View File

@ -5156,9 +5156,12 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
ret = 1; ret = 1;
break; break;
case SH_UnderlineShortcut: case SH_UnderlineShortcut: {
ret = 1; const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme();
ret = theme ? theme->themeHint(QPlatformTheme::UnderlineShortcut).toInt()
: QPlatformTheme::defaultThemeHint(QPlatformTheme::UnderlineShortcut).toInt();
break; break;
}
case SH_SpinBox_ClickAutoRepeatRate: case SH_SpinBox_ClickAutoRepeatRate:
ret = 150; ret = 150;