Update GUI 2.2.0: Settings tab

This commit is contained in:
2026-04-30 06:24:09 +08:00
parent edd15df3fc
commit 1426a618f4
5 changed files with 614 additions and 103 deletions
+23 -10
View File
@@ -16,6 +16,7 @@ class DroneMap:
self.map_view = QWebEngineView()
self.map_loaded = False
self.pending_map_updates = {}
self.font_scale = 1.0
# 創建橋接對象
self.bridge = MapBridge()
@@ -36,6 +37,7 @@ class DroneMap:
<script src="https://unpkg.com/leaflet-rotatedmarker/leaflet.rotatedMarker.js"></script>
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
<style>
:root { --ui-font-scale: 1; }
html, body, #map { height: 100%; margin: 0; }
#map {
user-select: none;
@@ -70,7 +72,7 @@ class DroneMap:
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 13px;
font-size: calc(13px * var(--ui-font-scale));
font-weight: bold;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
@@ -90,7 +92,7 @@ class DroneMap:
}
.mission-info-row {
margin-bottom: 8px;
font-size: 12px;
font-size: calc(12px * var(--ui-font-scale));
color: #333;
}
.mission-info-label {
@@ -109,7 +111,7 @@ class DroneMap:
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 13px;
font-size: calc(13px * var(--ui-font-scale));
font-weight: bold;
margin-top: 8px;
}
@@ -136,7 +138,7 @@ class DroneMap:
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 13px;
font-size: calc(13px * var(--ui-font-scale));
font-weight: bold;
transition: background-color 0.2s;
}
@@ -154,7 +156,7 @@ class DroneMap:
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 13px;
font-size: calc(13px * var(--ui-font-scale));
font-weight: bold;
transition: background-color 0.2s;
}
@@ -172,7 +174,7 @@ class DroneMap:
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 13px;
font-size: calc(13px * var(--ui-font-scale));
font-weight: bold;
transition: background-color 0.2s;
}
@@ -327,7 +329,7 @@ class DroneMap:
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 12px;
font-size: calc(12px * var(--ui-font-scale));
text-shadow: 1px 1px 2px rgba(255,255,255,0.8), -1px -1px 2px rgba(255,255,255,0.8);
">${sysid}</div>`,
iconSize: [16, 16],
@@ -569,7 +571,7 @@ class DroneMap:
'align-items: center;' +
'justify-content: center;' +
'font-weight: bold;' +
'font-size: 11px;' +
'font-size: calc(11px * var(--ui-font-scale));' +
'border: 2px solid white;' +
'box-shadow: 0 2px 5px rgba(0,0,0,0.3);' +
'">' + idx + '</div>',
@@ -622,6 +624,10 @@ class DroneMap:
}
}
// ================================================================================
function setFontScale(scale) {
document.documentElement.style.setProperty('--ui-font-scale', scale);
}
// 開始任務
function startMission() {
@@ -807,7 +813,7 @@ class DroneMap:
'width: 22px; height: 22px;' +
'border-radius: 50%;' +
'display: flex; align-items: center; justify-content: center;' +
'font-weight: bold; font-size: 10px;' +
'font-weight: bold; font-size: calc(10px * var(--ui-font-scale));' +
'border: 2px solid white;' +
'box-shadow: 0 2px 5px rgba(0,0,0,0.3);' +
'">' + groupId + '</div>',
@@ -827,7 +833,7 @@ class DroneMap:
'width: 22px; height: 22px;' +
'border-radius: 50%;' +
'display: flex; align-items: center; justify-content: center;' +
'font-weight: bold; font-size: 14px;' +
'font-weight: bold; font-size: calc(14px * var(--ui-font-scale));' +
'border: 2px solid white;' +
'box-shadow: 0 2px 5px rgba(0,0,0,0.3);' +
'">★</div>',
@@ -878,6 +884,7 @@ class DroneMap:
"""地圖加載完成回調"""
if ok:
self.map_loaded = True
self.set_font_scale(self.font_scale)
else:
_log("ERROR", "地圖載入失敗")
@@ -909,6 +916,12 @@ class DroneMap:
"""聚焦到指定無人機"""
if self.map_loaded:
self.map_view.page().runJavaScript(f"focusOn('{drone_id}');")
def set_font_scale(self, scale):
"""設定地圖 HTML 控制項的字體倍率。"""
self.font_scale = scale
if self.map_loaded:
self.map_view.page().runJavaScript(f"setFontScale({scale:.3f});")
# ================================================================================
# 任務規劃視覺化方法