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);
case FlickDeceleration:
return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickDeceleration);
case UnderlineShortcut:
return true;
}
return 0;

View File

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

View File

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

View File

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

View File

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