feat: Add desktop scaling and fix linux postinst (#1800)

* fix: resolve Linux window close handler to prevent app hang

- Add delete-event callback that properly quits the application when window is closed

* feat: Add desktop scaling and fix linux postinst

- Implement desktop interface scaling in main.dart using FittedBox.
- Add desktop scaling setting UI.
- Add desktopScale to storage preference.
- Fix typos and logic in Linux postinst script.
- Update piliplus.desktop with StartupWMClass.

* update

Signed-off-by: dom <githubaccount56556@proton.me>

---------

Signed-off-by: Shao Guohao <shao.gh.98@gmail.com>
Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
s
2026-01-10 10:03:51 +08:00
committed by GitHub
parent 069cf555ea
commit 28b69a06fa
9 changed files with 195 additions and 15 deletions

View File

@@ -292,15 +292,43 @@ class MyApp extends StatelessWidget {
getPages: Routes.getPages,
defaultTransition: Pref.pageTransition,
builder: FlutterSmartDialog.init(
toastBuilder: (String msg) => CustomToast(msg: msg),
toastBuilder: (msg) => CustomToast(msg: msg),
loadingBuilder: (msg) => LoadingWidget(msg: msg),
builder: (context, child) {
child = MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaler: TextScaler.linear(Pref.defaultTextScale),
),
child: child!,
);
final uiScale = Pref.uiScale;
final mediaQuery = MediaQuery.of(context);
final textScaler = TextScaler.linear(Pref.defaultTextScale);
if (uiScale != 1.0) {
// Apply full UI scaling for desktop
final actualSize = mediaQuery.size;
final scaledSize = actualSize / uiScale;
child = MediaQuery(
data: mediaQuery.copyWith(
// Tell child the logical size it should layout to
size: scaledSize,
padding: mediaQuery.padding / uiScale,
viewPadding: mediaQuery.viewPadding / uiScale,
viewInsets: mediaQuery.viewInsets / uiScale,
textScaler: textScaler,
),
// Use OverflowBox to let child layout to scaledSize,
// then FittedBox scales it to fit actualSize
child: FittedBox(
fit: BoxFit.fill,
alignment: Alignment.topLeft,
child: SizedBox(
width: scaledSize.width,
height: scaledSize.height,
child: child,
),
),
);
} else {
child = MediaQuery(
data: mediaQuery.copyWith(textScaler: textScaler),
child: child!,
);
}
if (PlatformUtils.isDesktop) {
return Focus(
canRequestFocus: false,