feat: add reset app scale hotkey (#5386)

Co-authored-by: Mathias Mogensen <mathiasrieckm@gmail.com>
This commit is contained in:
Sander Hoeve 2024-05-30 02:30:40 +02:00 committed by GitHub
parent 0bfe071caf
commit 859eaf903b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -141,6 +141,16 @@ class _HomeHotKeysState extends State<HomeHotKeys> {
keyDownHandler: (_) => _scaleWithStep(-0.1),
),
// Reset app scaling
HotKeyItem(
hotKey: HotKey(
KeyCode.digit0,
modifiers: [Platform.isMacOS ? KeyModifier.meta : KeyModifier.control],
scope: HotKeyScope.inapp,
),
keyDownHandler: (_) => _scaleToSize(1),
),
// Open settings dialog
openSettingsHotKey(context, widget.userProfile),
];
@ -182,7 +192,11 @@ class _HomeHotKeysState extends State<HomeHotKeys> {
Log.info('scale the app from $currentScaleFactor to $textScale');
ScaledWidgetsFlutterBinding.instance.scaleFactor = (_) => textScale;
await windowSizeManager.setScaleFactor(textScale);
await _scaleToSize(textScale);
}
Future<void> _scaleToSize(double size) async {
ScaledWidgetsFlutterBinding.instance.scaleFactor = (_) => size;
await windowSizeManager.setScaleFactor(size);
}
}