Skip to content

Commit f851387

Browse files
committed
✨ feat: feat: desktop integration with template system + viewer enhancements
Template System: - WebAppTemplate dataclass (13 fields: mime_types, url_schemes, features, etc.) - TemplateRegistry with search, match_url, category grouping - 45 pre-built templates across 5 modules: office365 (8), google (10), communication (7), media (8), productivity (12) - Template Gallery UI (Adw.Window, FlowBox grid, search, category sections) - Gallery integrated into webapp_dialog.py headerbar ("Templates" button) - Template selection auto-fills: URL, name, icon, category, app mode Desktop Integration: - .desktop generation: MimeType, Comment, GenericName, Keywords, X-BigWebApp-Template - URL scheme handlers → x-scheme-handler/* MIME type auto-conversion - %f positional arg in Exec line when MIME types present - File handler: FileAwarePage(QWebEnginePage) with chooseFiles() intercept - Download handler: QFileDialog.getSaveFileName via xdg-desktop-portal - Notifications: setNotificationPresenter → notify-send bridge - Permissions: auto-grant notifications, camera, microphone - MPRIS media keys: optional D-Bus service + JS Media Session bridge - command_executor: extra_env param for template metadata env vars - webapp_model: template fields + apply_template() method Viewer Fixes: - fix Wayland/KWin resize bug: lock window size during navigation (setFixedSize on loadStarted, unlock on loadFinished) - _on_new_window: use request.openIn(page) instead of setUrl() - _enforce_screen_limits: setMaximumSize to screen bounds - _load_geometry: clamp saved dimensions to 90% of screen - _toggle_fullscreen: lift/restore max-size limits properly
1 parent 9ae3643 commit f851387

14 files changed

Lines changed: 1456 additions & 11 deletions

File tree

biglinux-webapps/usr/bin/big-webapps

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,36 +168,71 @@ if [ "$command" = "create" ]; then
168168
exit 1
169169
fi
170170

171+
# optional metadata via env vars (backward compatible)
172+
: "${WEBAPP_MIME_TYPES:=}"
173+
: "${WEBAPP_COMMENT:=}"
174+
: "${WEBAPP_GENERIC_NAME:=}"
175+
: "${WEBAPP_KEYWORDS:=}"
176+
: "${WEBAPP_TEMPLATE_ID:=}"
177+
: "${WEBAPP_URL_SCHEMES:=}"
178+
179+
# merge url_schemes into mime_types as x-scheme-handler/*
180+
if [[ -n "$WEBAPP_URL_SCHEMES" ]]; then
181+
IFS=';' read -ra schemes <<< "$WEBAPP_URL_SCHEMES"
182+
for scheme in "${schemes[@]}"; do
183+
[[ -z "$scheme" ]] && continue
184+
WEBAPP_MIME_TYPES+="x-scheme-handler/$scheme;"
185+
done
186+
fi
187+
188+
# build optional .desktop fields
189+
extra_fields=""
190+
[[ -n "$WEBAPP_MIME_TYPES" ]] && extra_fields+="MimeType=$WEBAPP_MIME_TYPES
191+
"
192+
[[ -n "$WEBAPP_COMMENT" ]] && extra_fields+="Comment=$WEBAPP_COMMENT
193+
"
194+
[[ -n "$WEBAPP_GENERIC_NAME" ]] && extra_fields+="GenericName=$WEBAPP_GENERIC_NAME
195+
"
196+
[[ -n "$WEBAPP_KEYWORDS" ]] && extra_fields+="Keywords=$WEBAPP_KEYWORDS
197+
"
198+
[[ -n "$WEBAPP_TEMPLATE_ID" ]] && extra_fields+="X-BigWebApp-Template=$WEBAPP_TEMPLATE_ID
199+
"
200+
171201
if [[ "$browser" == "__viewer__" ]]; then
172202
# App mode — Qt6 viewer without browser chrome
173203
app_id=$(sed 's|https://||;s|http://||;s|/|_|g;s|[^a-zA-Z0-9_-]||g' <<< "$url")
204+
# support file args (%f) when mime types registered
205+
exec_line="big-webapps-viewer --url=\"$url\" --name=\"$name\" --icon=\"${icon}\" --app-id=\"$app_id\""
206+
[[ -n "$WEBAPP_MIME_TYPES" ]] && exec_line+=" %f"
174207
read -d $'' ShowText <<EOF
175208
#!/usr/bin/env xdg-open
176209
[Desktop Entry]
177210
Version=1.0
178211
Terminal=false
179212
Type=Application
180213
Name=$name
181-
Exec=big-webapps-viewer --url="$url" --name="$name" --icon="${icon}" --app-id="$app_id"
214+
Exec=$exec_line
182215
Icon=$icon
183216
StartupWMClass=br.com.biglinux.webapp.$app_id
184217
Categories=$category
185-
StartupNotify=false
218+
${extra_fields}StartupNotify=false
186219
EOF
187220
else
188221
# Browser mode — standard webapp
222+
exec_line="big-webapps-exec filename=\"$filename\" $browser --class=\"$class\" --profile-directory=$profile --app=\"$url\""
223+
[[ -n "$WEBAPP_MIME_TYPES" ]] && exec_line+=" %f"
189224
read -d $'' ShowText <<EOF
190225
#!/usr/bin/env xdg-open
191226
[Desktop Entry]
192227
Version=1.0
193228
Terminal=false
194229
Type=Application
195230
Name=$name
196-
Exec=big-webapps-exec filename="$filename" $browser --class="$class" --profile-directory=$profile --app="$url"
231+
Exec=$exec_line
197232
Icon=$icon
198233
StartupWMClass=$class
199234
Categories=$category
200-
StartupNotify=false
235+
${extra_fields}StartupNotify=false
201236
EOF
202237
fi
203238

0 commit comments

Comments
 (0)