refactor: remove dead code, fix home screen config bug
This commit is contained in:
+7
-18
@@ -10,7 +10,7 @@ from PyQt5.QtGui import QFont, QColor, QPalette, QCursor
|
||||
from PyQt5.QtWidgets import (
|
||||
QApplication, QWidget, QHBoxLayout, QVBoxLayout,
|
||||
QPushButton, QLabel, QScrollArea, QDialog, QLineEdit,
|
||||
QMessageBox, QFrame, QMenu, QAction,
|
||||
QMessageBox, QFrame,
|
||||
QTreeWidget, QTreeWidgetItem, QAbstractItemView
|
||||
)
|
||||
|
||||
@@ -18,7 +18,6 @@ HOME_URL = "file:///home/jgitta/kiosk-home/index.html"
|
||||
BOOKMARKS_FILE = "/home/jgitta/kiosk-browser/bookmarks.json"
|
||||
CDP_PORT = 9222
|
||||
TOOLBAR_H = 72 # single row — was 142 (82 + 60)
|
||||
TOP_H = TOOLBAR_H
|
||||
# Screen size is detected dynamically in main() after QApplication starts
|
||||
SCREEN_W = 1920 # overwritten at runtime
|
||||
SCREEN_H = 1080 # overwritten at runtime
|
||||
@@ -39,16 +38,6 @@ PURPLE = "#5a5a8a"
|
||||
PURPLE_HOVER = "#7a7aaa"
|
||||
FONT_SIZE = 18
|
||||
|
||||
MENU_STYLE = """
|
||||
QMenu {
|
||||
background: #1e3a5c; color: white;
|
||||
border: 2px solid #3a6da4; border-radius: 8px; padding: 4px;
|
||||
}
|
||||
QMenu::item { padding: 14px 36px 14px 16px; border-radius: 6px; font-size: 17px; }
|
||||
QMenu::item:selected { background: #3a6da4; color: white; }
|
||||
QMenu::separator { height: 1px; background: #3a6da4; margin: 4px 8px; }
|
||||
"""
|
||||
|
||||
# ── Helpers ───────────────────────────────────────────────────────
|
||||
def mk_btn(label, color, hover, min_w=120, min_h=52, fs=FONT_SIZE):
|
||||
b = QPushButton(label)
|
||||
@@ -603,7 +592,7 @@ class KioskOverlay(QWidget):
|
||||
Qt.Tool
|
||||
)
|
||||
self.setAttribute(Qt.WA_ShowWithoutActivating)
|
||||
self.setGeometry(0, 0, SCREEN_W, TOP_H)
|
||||
self.setGeometry(0, 0, SCREEN_W, TOOLBAR_H)
|
||||
self.setStyleSheet("background:transparent;")
|
||||
QApplication.instance().installEventFilter(self)
|
||||
|
||||
@@ -629,8 +618,8 @@ class KioskOverlay(QWidget):
|
||||
if w < 400 or h < 200:
|
||||
return
|
||||
SCREEN_W, SCREEN_H = w, h
|
||||
self.setGeometry(0, 0, SCREEN_W, TOP_H)
|
||||
self.resize(SCREEN_W, TOP_H)
|
||||
self.setGeometry(0, 0, SCREEN_W, TOOLBAR_H)
|
||||
self.resize(SCREEN_W, TOOLBAR_H)
|
||||
if self.bm_panel.isVisible():
|
||||
pw = self.bm_panel.width()
|
||||
self.bm_panel.move(SCREEN_W - pw - 4, TOOLBAR_H)
|
||||
@@ -638,7 +627,7 @@ class KioskOverlay(QWidget):
|
||||
QTimer.singleShot(500, self._resize_chrome)
|
||||
|
||||
def _resize_chrome(self):
|
||||
self.cdp.resize_window(0, TOP_H, SCREEN_W, SCREEN_H - TOP_H)
|
||||
self.cdp.resize_window(0, TOOLBAR_H, SCREEN_W, SCREEN_H - TOOLBAR_H)
|
||||
|
||||
def changeEvent(self, event):
|
||||
"""Un-minimise the toolbar the instant it gets iconified."""
|
||||
@@ -787,7 +776,7 @@ def launch_chrome():
|
||||
except Exception as e:
|
||||
print(f"Cookie clear warning: {e}")
|
||||
|
||||
chrome_h = SCREEN_H - TOP_H
|
||||
chrome_h = SCREEN_H - TOOLBAR_H
|
||||
cmd = [
|
||||
"chromium",
|
||||
"--no-first-run",
|
||||
@@ -803,7 +792,7 @@ def launch_chrome():
|
||||
"--user-data-dir=/home/jgitta/chromium-kiosk",
|
||||
f"--remote-debugging-port={CDP_PORT}",
|
||||
"--remote-allow-origins=*",
|
||||
f"--window-position=0,{TOP_H}",
|
||||
f"--window-position=0,{TOOLBAR_H}",
|
||||
f"--window-size={SCREEN_W},{chrome_h}",
|
||||
f"--app={HOME_URL}",
|
||||
]
|
||||
|
||||
@@ -23,7 +23,7 @@ inject_config() {
|
||||
|
||||
if [ -f "$config" ]; then
|
||||
local config_json=$(cat "$config" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | tr '\n' ' ')
|
||||
sed "s|const config = {.*};|const config = $config_json;|" "$src" > "$dst"
|
||||
sed "s|const config = {};|const config = $config_json;|" "$src" > "$dst"
|
||||
echo " Injected config.json into home screen"
|
||||
else
|
||||
cp "$src" "$dst"
|
||||
@@ -67,7 +67,7 @@ if [ -n "$KIOSK" ]; then
|
||||
git pull
|
||||
# Inject config at deploy time
|
||||
config_json=\$(cat config.json | sed 's/\\\\/\\\\\\\\/g' | sed 's/\"/\\\\\"/g' | tr '\n' ' ')
|
||||
sed \"s|const config = {.*};|const config = \$config_json;|\" home-screen-index.html > /home/jgitta/kiosk-home/index.html
|
||||
sed \"s|const config = {};|const config = \$config_json;|\" home-screen-index.html > /home/jgitta/kiosk-home/index.html
|
||||
/usr/local/bin/kiosk-restart
|
||||
"
|
||||
echo " Production updated."
|
||||
|
||||
@@ -98,6 +98,8 @@
|
||||
<div class="grid" id="buttonGrid"></div>
|
||||
|
||||
<script>
|
||||
const config = {};
|
||||
|
||||
const buttons = [
|
||||
{ id: 'email', label: 'Email', icon: '✉️', class: 'btn-gmail' },
|
||||
{ id: 'internet', label: 'Internet', icon: '🌐', class: 'btn-browse' },
|
||||
@@ -109,10 +111,10 @@
|
||||
];
|
||||
|
||||
function loadButtons() {
|
||||
const config = {};
|
||||
const grid = document.getElementById('buttonGrid');
|
||||
const urls = config.urls || {};
|
||||
buttons.forEach(btn => {
|
||||
const url = config.urls[btn.id];
|
||||
const url = urls[btn.id] || '#';
|
||||
const link = document.createElement('a');
|
||||
link.className = `btn ${btn.class}`;
|
||||
link.href = url;
|
||||
|
||||
Reference in New Issue
Block a user