From 186c78eae9e99f5f4be9ad6c5c2dfbb8035451de Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Sun, 16 Jan 2022 12:16:59 +0800 Subject: [PATCH] Add: Option to toggle DPI scaling --- deploy/template/deploy.yaml | 4 ++++ requirements-in.txt | 2 +- requirements.txt | 2 +- webapp/packages/main/src/config.ts | 1 + webapp/packages/main/src/index.ts | 9 ++++++--- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/deploy/template/deploy.yaml b/deploy/template/deploy.yaml index 50aeed04f..1f22b7ab3 100644 --- a/deploy/template/deploy.yaml +++ b/deploy/template/deploy.yaml @@ -99,6 +99,10 @@ Deploy: # 'default' for light theme # 'dark' for dark theme Theme: default + # Follow system DPI scaling + # [In most cases] true + # [In few cases] false to make Alas smaller, if you have a low resolution but high DPI scaling. + DpiScaling: true # --key. Password of web ui # Useful when expose Alas to the public network Password: null diff --git a/requirements-in.txt b/requirements-in.txt index 7b3e8cb2d..14cbca7e4 100644 --- a/requirements-in.txt +++ b/requirements-in.txt @@ -20,4 +20,4 @@ aiofiles wrapt==1.13.1 prettytable==2.2.1 pypresence==4.2.1 -alas-webapp==0.3.6 \ No newline at end of file +alas-webapp==0.3.7 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 27c2ac7e3..26a2f426d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ # adbutils==0.11.0 # via uiautomator2 aiofiles==0.7.0 # via -r requirements-in.txt -alas-webapp==0.3.6 # via -r requirements-in.txt +alas-webapp==0.3.7 # via -r requirements-in.txt anyio==1.3.1 # via -r requirements-in.txt apkutils2==1.0.0 # via adbutils asgiref==3.4.1 # via uvicorn diff --git a/webapp/packages/main/src/config.ts b/webapp/packages/main/src/config.ts index e66e2a165..b295c5eae 100644 --- a/webapp/packages/main/src/config.ts +++ b/webapp/packages/main/src/config.ts @@ -14,3 +14,4 @@ export const pythonPath = (path.isAbsolute(PythonExecutable) ? PythonExecutable export const webuiUrl = `http://127.0.0.1:${WebuiPort}`; export const webuiPath = 'gui.py'; export const webuiArgs = ['--port', WebuiPort, '--electron']; +export const dpiScaling = Boolean(config.Deploy.Webui.DpiScaling) || (config.Deploy.Webui.DpiScaling === undefined) ; diff --git a/webapp/packages/main/src/index.ts b/webapp/packages/main/src/index.ts index 013e14d7f..e034861a5 100644 --- a/webapp/packages/main/src/index.ts +++ b/webapp/packages/main/src/index.ts @@ -1,7 +1,7 @@ import {app, Menu, Tray, BrowserWindow, ipcMain, globalShortcut} from 'electron'; import {URL} from 'url'; import {PyShell} from '/@/pyshell'; -import {webuiArgs, webuiPath} from '/@/config'; +import {webuiArgs, webuiPath, dpiScaling} from '/@/config'; const path = require('path'); @@ -143,8 +143,11 @@ const createWindow = async () => { // No DPI scaling -// app.commandLine.appendSwitch('high-dpi-support', '1'); -// app.commandLine.appendSwitch('force-device-scale-factor', '1'); +if (!dpiScaling) { + app.commandLine.appendSwitch('high-dpi-support', '1'); + app.commandLine.appendSwitch('force-device-scale-factor', '1'); +} + function loadURL() { /**