IQ.Pilot Release Commit @ 27f668a
This commit is contained in:
@@ -70,7 +70,7 @@ from iqpilot.system.ui.iqwidgets.widgets.list_view import (
|
||||
Spacer,
|
||||
)
|
||||
from iqpilot.system.ui.iqwidgets.widgets.list_view import IQListItem
|
||||
from iqpilot.system.ui.iqwidgets.widgets.list_view import IQListItem, IQMultipleButtonAction, IQToggleAction, IQLineSeparator
|
||||
from iqpilot.system.ui.iqwidgets.widgets.list_view import IQListItem, IQMultipleButtonAction, IQToggleAction, IQLineSeparator, toggle_item_iq
|
||||
from iqpilot.system.ui.iqwidgets.widgets.list_view import button_item, toggle_item
|
||||
from iqpilot.system.ui.iqwidgets.widgets.list_view import NoticeModal
|
||||
from iqpilot.system.ui.iqwidgets.widgets.list_view import PickerDialog, PickerItem, PickerGroup
|
||||
@@ -1655,6 +1655,14 @@ class ModelsLayout(Widget):
|
||||
)
|
||||
self.big_model_item.action_item.set_value(self._big_model_value())
|
||||
|
||||
self.small_on_mac_item = toggle_item_iq(
|
||||
lambda: tr("Active Model on eMac"),
|
||||
tr("Run the selected small model on the Mac instead of a big model."),
|
||||
initial_state=ui_state.params.get_bool("IQEmacSmallModel"),
|
||||
callback=self._on_small_on_mac_toggled,
|
||||
param="IQEmacSmallModel",
|
||||
)
|
||||
|
||||
self.supercombo_label = progress_item(tr("Combined Model"))
|
||||
self.vision_label = progress_item(tr("Vision Weights"))
|
||||
self.policy_label = progress_item(tr("Policy Weights"))
|
||||
@@ -1671,7 +1679,7 @@ class ModelsLayout(Widget):
|
||||
self.redownload_item = button_item(lambda: tr("Redownload Current Model"), lambda: tr("REDOWNLOAD"), "", self._redownload_model)
|
||||
self.cancel_download_item = button_item(tr("Stop Download"), tr("Cancel"), "", self._cancel_model_request)
|
||||
|
||||
self.items = [self.current_model_item, self.big_model_item, self.cancel_download_item, self.supercombo_label, self.vision_label,
|
||||
self.items = [self.current_model_item, self.big_model_item, self.small_on_mac_item, self.cancel_download_item, self.supercombo_label, self.vision_label,
|
||||
self.policy_label, self.redownload_item, self.refresh_item, self.clear_cache_item]
|
||||
|
||||
def _is_downloading(self):
|
||||
@@ -1921,10 +1929,18 @@ class ModelsLayout(Widget):
|
||||
get_folders_fn=self._get_folders, on_exit=self._on_model_selected)
|
||||
gui_app.set_modal_overlay(self.model_dialog, callback=self._on_model_selected)
|
||||
|
||||
def _on_small_on_mac_toggled(self, state: bool) -> None:
|
||||
p = ui_state.params
|
||||
p.put_bool("IQEmacSmallModel", bool(state))
|
||||
p.put_bool("IQEmacEnabled", True if state else bool(p.get("IQEmacModel")))
|
||||
self.big_model_item.action_item.set_value(self._big_model_value())
|
||||
|
||||
@staticmethod
|
||||
def _big_model_value() -> str:
|
||||
if not ui_state.params.get_bool("IQEmacEnabled"):
|
||||
return tr("Off")
|
||||
if ui_state.params.get_bool("IQEmacSmallModel"):
|
||||
return tr("Active model (eMac)")
|
||||
key = ui_state.params.get("IQEmacModel")
|
||||
key = key.decode() if isinstance(key, bytes) else (key or "")
|
||||
return _big_model_label(key) if key in [n for n, _ in _big_model_options()] else tr("Off")
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos/
|
||||
"""
|
||||
|
||||
import math
|
||||
import time
|
||||
|
||||
import pyray as rl
|
||||
@@ -17,6 +18,9 @@ from iqpilot.system.ui.widgets import Widget
|
||||
|
||||
_POLL_S = 1.0
|
||||
_FONT_SIZE = 70
|
||||
_ICON_H = 76
|
||||
_ICONS = {"MAC": ("mac", 62 / 46), "GPU": ("egpu", 1.0)}
|
||||
_GREY = rl.Color(165, 165, 170, 235)
|
||||
|
||||
|
||||
class EmacStatusRenderer(Widget):
|
||||
@@ -27,6 +31,21 @@ class EmacStatusRenderer(Widget):
|
||||
self._last_poll = 0.0
|
||||
self._label = ""
|
||||
self._state = SourceState.HIDDEN
|
||||
self._icons: dict[str, dict[str, rl.Texture]] = {}
|
||||
|
||||
def _icon_set(self, label: str) -> dict[str, rl.Texture] | None:
|
||||
spec = _ICONS.get(label)
|
||||
if spec is None:
|
||||
return None
|
||||
if label not in self._icons:
|
||||
base, aspect = spec
|
||||
w = int(_ICON_H * aspect)
|
||||
self._icons[label] = {
|
||||
"base": gui_app.texture(f"icons_mici/{base}.png", w, _ICON_H),
|
||||
"green": gui_app.texture(f"icons_mici/{base}_green.png", w, _ICON_H),
|
||||
"orange": gui_app.texture(f"icons_mici/{base}_orange.png", int(w * 1.26), _ICON_H),
|
||||
}
|
||||
return self._icons[label]
|
||||
|
||||
def update(self):
|
||||
now = time.monotonic()
|
||||
@@ -38,7 +57,25 @@ class EmacStatusRenderer(Widget):
|
||||
def _render(self, rect: rl.Rectangle):
|
||||
if self._state == SourceState.HIDDEN:
|
||||
return
|
||||
size = measure_text_cached(self._font, self._label, _FONT_SIZE)
|
||||
x = rect.x + UI_BORDER_SIZE + BTN_SIZE // 2 - size.x / 2
|
||||
y = rect.y + rect.height / 2 - size.y / 2
|
||||
draw_source_label(self._font, self._label, self._state, rl.Vector2(x, y), _FONT_SIZE)
|
||||
icons = self._icon_set(self._label)
|
||||
if icons is None:
|
||||
size = measure_text_cached(self._font, self._label, _FONT_SIZE)
|
||||
x = rect.x + UI_BORDER_SIZE + BTN_SIZE // 2 - size.x / 2
|
||||
y = rect.y + rect.height / 2 - size.y / 2
|
||||
draw_source_label(self._font, self._label, self._state, rl.Vector2(x, y), _FONT_SIZE)
|
||||
return
|
||||
if self._state == SourceState.ACTIVE:
|
||||
tex, tint = icons["green"], rl.Color(255, 255, 255, 255)
|
||||
elif self._state == SourceState.FAILED:
|
||||
tex, tint = icons["orange"], rl.Color(255, 255, 255, 255)
|
||||
elif self._state == SourceState.CROSSED:
|
||||
tex, tint = icons["base"], rl.Color(255, 255, 255, 165)
|
||||
else:
|
||||
pulse = 0.35 + 0.65 * (0.5 - 0.5 * math.cos(rl.get_time() * 6.0))
|
||||
tex, tint = icons["base"], rl.Color(_GREY.r, _GREY.g, _GREY.b, int(_GREY.a * pulse))
|
||||
x = int(rect.x + UI_BORDER_SIZE + BTN_SIZE // 2 - tex.width / 2)
|
||||
y = int(rect.y + rect.height / 2 - tex.height / 2)
|
||||
rl.draw_texture(tex, x, y, tint)
|
||||
if self._state == SourceState.CROSSED:
|
||||
cy = y + tex.height // 2
|
||||
rl.draw_line_ex(rl.Vector2(x - 4, cy), rl.Vector2(x + tex.width + 4, cy), 4, rl.Color(255, 255, 255, 165))
|
||||
|
||||
Reference in New Issue
Block a user