Skip to content

Commit

Permalink
v1.4.12.46
Browse files Browse the repository at this point in the history
  • Loading branch information
sebdelsol committed Apr 1, 2024
1 parent 3e5d371 commit d287947
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 43 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ You'll find them in the app folder[^3]:
[^3]:The app is installed by default in `%LocalAppData%\Programs\Sfvip All x64`, `%LocalAppData%\Programs\Sfvip All x86` or the installation directory you've specified during the installation.

# Build
[![version](https://custom-icon-badges.demolab.com/badge/Build%201.4.12.45-informational?logo=github)](/build_config.py#L27)
[![version](https://custom-icon-badges.demolab.com/badge/Build%201.4.12.46-informational?logo=github)](/build_config.py#L27)
[![Sloc](https://custom-icon-badges.demolab.com/badge/Sloc%208.5k-informational?logo=file-code)](https://api.codetabs.com/v1/loc/?github=sebdelsol/sfvip-all)
[![Ruff](https://custom-icon-badges.demolab.com/badge/Ruff-informational?logo=ruff-color)](https://docs.astral.sh/ruff/)
[![Python](https://custom-icon-badges.demolab.com/badge/Python%203.11.8-linen?logo=python-color)](https://www.python.org/downloads/release/python-3118/)
[![mitmproxy](https://custom-icon-badges.demolab.com/badge/Mitmproxy%2010.2.4-linen?logo=mitmproxy-black)](https://mitmproxy.org/)
[![Nsis](https://custom-icon-badges.demolab.com/badge/Nsis%203.09-linen?logo=nsis-color)](https://nsis.sourceforge.io/Download)
[![Nsis](https://custom-icon-badges.demolab.com/badge/Nsis%203.10-linen?logo=nsis-color)](https://nsis.sourceforge.io/Download)
[![Nuitka](https://custom-icon-badges.demolab.com/badge/Nuitka%202.1.4-linen?logo=nuitka)](https://nuitka.net/)
[![PyInstaller](https://custom-icon-badges.demolab.com/badge/PyInstaller%206.5.0-linen?logo=pyinstaller-windowed)](https://pyinstaller.org/en/stable/)

* [***NSIS***](https://nsis.sourceforge.io/Download) will be automatically installed if missing.
* [***NSIS***](https://nsis.sourceforge.io/Download) will be automatically installed if missing when [upgrading dependencies](#upgrade-dependencies).
* Check the [***build config***](build_config.py).

### Create the environments
Expand Down
5 changes: 5 additions & 0 deletions build/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.4.12.46
* Bump _NSIS_ to 3.10.
* Fix position & size of M3U account EPG.
* Hit 'e' or 'E' for showing the M3U account EPG.

## 1.4.12.45
* Bump _Nuitka_ to 2.1.4.
* Fix MAC account update info.
Expand Down
2 changes: 1 addition & 1 deletion build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Build:
main: ClassVar = "sfvip_all.py"
company: ClassVar = "sebdelsol"
name: ClassVar = "Sfvip All"
version: ClassVar = "1.4.12.45"
version: ClassVar = "1.4.12.46"
dir: ClassVar = "build"
enable_console: ClassVar = False
logs_dir: ClassVar = "../logs"
Expand Down
2 changes: 1 addition & 1 deletion resources/README_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ You'll find them in the app folder[^3]:
[![Nuitka](https://custom-icon-badges.demolab.com/badge/Nuitka%20{nuitka_version}-linen?logo=nuitka)](https://nuitka.net/)
[![PyInstaller](https://custom-icon-badges.demolab.com/badge/PyInstaller%20{pyinstaller_version}-linen?logo=pyinstaller-windowed)](https://pyinstaller.org/en/stable/)

* [***NSIS***](https://nsis.sourceforge.io/Download) will be automatically installed if missing.
* [***NSIS***](https://nsis.sourceforge.io/Download) will be automatically installed if missing when [upgrading dependencies](#upgrade-dependencies).
* Check the [***build config***](build_config.py).

### Create the environments
Expand Down
2 changes: 1 addition & 1 deletion src/mitm/proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _minimum_addons(user_addon: SfVipAddOn) -> Sequence[Any]:
return (
core.Core(),
proxyserver.Proxyserver(),
user_addon,
user_addon, # user addon @ its right place
next_layer.NextLayer(),
tlsconfig.TlsConfig(),
)
Expand Down
2 changes: 1 addition & 1 deletion src/sfvip/epg.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class EpgUpdater:
# pylint: disable=too-many-instance-attributes
def __init__(self, config: AppConfig, epg_updates: EPGUpdates, ui: UI) -> None:
self.hover_epg = HoverEPG(ui)
self.keyboard_watcher = KeyboardWatcher("e", self.hover_epg.on_key_pressed)
self.keyboard_watcher = KeyboardWatcher("eE", self.hover_epg.on_key_pressed)
self.show_epg_job = JobRunner[ShowEpg](self.hover_epg.show_epg, "Show epg job", check_new=False)
self.show_channel_job = JobRunner[ShowChannel](
self.hover_epg.show_channel, "Show channel job", check_new=False
Expand Down
74 changes: 57 additions & 17 deletions src/sfvip/ui/hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@
from ...mitm.epg.programme import EPGprogrammeM3U
from ...winapi import win
from .fx import Fade
from .sticky import Offset, StickyWindow, sticky_windows
from .sticky import Offset, Rect, StickyWindow, sticky_windows
from .style import Style
from .widgets import Border, Button, GetWidgetT, HorizontalProgressBar, RoundedBox, RoundedBoxScroll

# TODO check max width & height


class _HoverWindow(StickyWindow):
show_when_no_border = True
click_through = True
max_height = None

offset: Offset
bg = "black"
alpha = 0.9
Expand All @@ -43,7 +39,6 @@ def __init__(self, get_widget: GetWidgetT, get_scrolling_widget: Optional[GetWid
box_color=self.box_color,
get_widget=get_widget,
get_scrolling_widget=get_scrolling_widget,
max_height=self.max_height,
)
else:
self.box = RoundedBox(
Expand All @@ -52,24 +47,34 @@ def __init__(self, get_widget: GetWidgetT, get_scrolling_widget: Optional[GetWid
radius=self.radius,
box_color=self.box_color,
get_widget=get_widget,
max_height=self.max_height,
)
self.box.pack()
self._fade = Fade(self)
self._size = None, None

def update_and_show(self) -> None:
self.box.update_widget()
sticky_windows.update_position(self)
if rect := sticky_windows.get_rect():
self.change_position(rect, forced=True)
if self.wait_before_fade is not None:
self._fade.fade_in_and_out(
self.fade_duration,
self.auto_fade_out_duration,
self.wait_before_fade,
max_alpha=self.alpha,
self.fade_duration, self.auto_fade_out_duration, self.wait_before_fade, max_alpha=self.alpha
)
else:
self._fade.fade(self.fade_duration, out=False, max_alpha=self.alpha)

def change_position(self, rect: Rect, forced: bool = False) -> None:
if forced or self.is_shown():
x, y = self.offset.regular
size = max(10, rect.w - (x + self.radius) * 2), max(10, rect.h - (y + self.radius) * 2)
if forced or size != self._size:
self.set_width(size[0])
self.box.update_widget(size[1])
self._size = size
super().change_position(rect)

def set_width(self, width: Optional[float]) -> None:
pass

def hide(self) -> None:
self._fade.fade(self.fade_duration, out=True)

Expand All @@ -94,12 +99,16 @@ def show(self, message: str) -> None:
self.label.config(**self.stl(message).to_tk)
self.update_and_show()

def set_width(self, width: Optional[float]) -> None:
if width and self.label:
self.label.config(wraplength=width)


class ProgrammeNow(tk.Frame):
stl_title = Style().font("Calibri").font_size(12).bold
stl_schedule = Style().font("Calibri").font_size(14).bold
stl_descr = Style().font("Calibri").font_size(14).wrap(100)
progress_bar = dict(bg="#606060", fg="#1c8cbc", height=10, length=400)
stl_descr = Style().font("Calibri").font_size(14)
progress_bar = dict(bg="#606060", fg="#1c8cbc", height=10)

def __init__(self, master: tk.BaseWidget, bg: str, **kwargs: Any) -> None:
super().__init__(master, bg=bg, **kwargs)
Expand All @@ -115,7 +124,7 @@ def __init__(self, master: tk.BaseWidget, bg: str, **kwargs: Any) -> None:
self.label_descr.pack(anchor=tk.W)

def set(self, name: Optional[str], prg: EPGprogrammeM3U, now: float) -> None:
if prg.start_timestamp <= now: # check it's now
if prg.start_timestamp <= now and prg.duration: # check it's now and lasts something
name = f"{name} - " if name else ""
self.label_title.config(**self.stl_title(f"{name}{prg.title}").to_tk)
self.label_schedule.config(**self.stl_schedule(f"{prg.start}").to_tk)
Expand All @@ -126,6 +135,14 @@ def set(self, name: Optional[str], prg: EPGprogrammeM3U, now: float) -> None:
else:
self.label_descr.pack_forget()

def set_width(self, width: Optional[float]) -> None:
if width:
padx = sum(self.progressbar.pack_info()["padx"], 0) # type: ignore
schedule_width = self.label_schedule.winfo_reqwidth() + padx
self.progressbar.config(length=max(10, width - schedule_width))
self.label_title.config(wraplength=width)
self.label_descr.config(wraplength=width)


class HoverChannelEpg(_HoverWindow):
offset = Offset(regular=(22, 0), center=(0, 0.75))
Expand All @@ -143,6 +160,10 @@ def show(self, epg: ShowEpg, now: float) -> None:
self.programme.set(epg.name, epg.programmes[0], now)
self.update_and_show()

def set_width(self, width: Optional[float]) -> None:
if self.programme:
self.programme.set_width(width)


class Programme(tk.Frame):
border_color = "#303030"
Expand All @@ -155,6 +176,7 @@ def __init__(self, master: tk.BaseWidget, bg: str, **kwargs: Any) -> None:
self.label_title.pack(anchor=tk.W)
self.label_schedule.pack(anchor=tk.W)
self.label_descr.pack(anchor=tk.W)
self.is_packed = False

def set(self, prg: EPGprogrammeM3U) -> None:
self.label_title.config(**ProgrammeNow.stl_title(prg.title).to_tk)
Expand All @@ -165,11 +187,23 @@ def set(self, prg: EPGprogrammeM3U) -> None:
else:
self.label_descr.pack_forget()

def set_width(self, width: Optional[float]) -> None:
if width:
self.label_title.config(wraplength=width)
self.label_descr.config(wraplength=width)

def pack(self, **kw: Any) -> None:
super().pack(**kw)
self.is_packed = True

def pack_forget(self) -> None:
super().pack_forget()
self.is_packed = False


class HoverChannelProgrammes(_HoverWindow):
wait_before_fade = None
click_through = False
max_height = 600
offset = HoverMessage.offset
stl_channel = Style().font("Calibri").font_size(15).bold
stl_button = Style().font("Calibri").font_size(10)
Expand Down Expand Up @@ -212,3 +246,9 @@ def show(self, epg: ShowEpg) -> None:
else:
shown_prg.pack_forget()
self.update_and_show()

def set_width(self, width: Optional[float]) -> None:
if width and self.programmes:
for shown_prg in self.programmes:
if shown_prg.is_packed:
shown_prg.set_width(width)
6 changes: 2 additions & 4 deletions src/sfvip/ui/sticky.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def change_position_all(self, rect: Rect, border: bool) -> None:
for sticky in self._instances:
if border or sticky.show_when_no_border:
sticky.change_position(rect)
if self._instances:
self._instances[0].update_idletasks()

def bring_to_front_all(self, is_topmost: bool, is_foreground: bool, border: bool) -> None:
for sticky in self._instances:
Expand Down Expand Up @@ -123,10 +125,6 @@ def on_state_changed(self, state: WinState) -> None:
self._current_rect = state.rect
self.change_position_all(Maximized.fix(state.rect), not state.no_border)

def update_position(self, window: StickyWindow) -> None:
if rect := self._current_rect:
window.change_position(rect)

def has_focus(self) -> bool:
return win.is_foreground(self._followed_pid) if self._followed_pid else False

Expand Down
21 changes: 6 additions & 15 deletions src/sfvip/ui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,20 +396,12 @@ class RoundedBox(tk.Canvas):
_rounded_box_tag = "canvas"
minimum_steps = 10 # lower values give pixelated corners

# pylint: disable=too-many-arguments
def __init__(
self,
master: tk.BaseWidget,
radius: int,
box_color: str,
get_widget: GetWidgetT,
max_height: Optional[int] = None,
**kwargs: Any,
self, master: tk.BaseWidget, radius: int, box_color: str, get_widget: GetWidgetT, **kwargs: Any
) -> None:
super().__init__(master, bd=0, highlightthickness=0, **kwargs)
self.radius = radius
self.box_color = box_color
self.max_height = max_height
self.widget = get_widget(self)
self.cos_sin_r = tuple(self.get_cos_sin())
self.create_window(radius, radius, window=self.widget, anchor=tk.NW)
Expand All @@ -435,10 +427,10 @@ def create_rounded_box(self, x0: int, y0: int, x1: int, y1: int, color: str = "b
self.delete(self._rounded_box_tag)
self.create_polygon(points, fill=color, tags=self._rounded_box_tag)

def update_widget(self) -> None:
def update_widget(self, max_height: Optional[float]) -> None:
self.widget.update_idletasks()
w, h = self.widget.winfo_reqwidth(), self.widget.winfo_reqheight()
box_h = min(h, self.max_height) if self.max_height else h
box_h = round(min(h, max_height) if max_height else h)
w_box, h_box = w + 2 * self.radius, box_h + 2 * self.radius
self.create_rounded_box(0, 0, w_box, h_box, color=self.box_color)
self.config(width=w_box, height=h_box)
Expand All @@ -454,23 +446,22 @@ def __init__(
box_color: str,
get_widget: GetWidgetT,
get_scrolling_widget: GetWidgetT,
max_height: Optional[int] = None,
**kwargs: Any,
) -> None:
super().__init__(master, radius, box_color, get_widget, max_height, **kwargs)
super().__init__(master, radius, box_color, get_widget, **kwargs)
self.scroll = tk.Canvas(self, bg=self.box_color, bd=0, highlightthickness=0)
self.scrolling_widget = get_scrolling_widget(self.scroll)
self.scroll.create_window(0, 0, window=self.scrolling_widget, anchor=tk.NW)
self.scroll_id = self.create_window(0, 0, window=self.scroll, anchor=tk.NW)
self.bind_all("<MouseWheel>", self._on_mousewheel, add="+")

def update_widget(self) -> None:
def update_widget(self, max_height: Optional[float]) -> None:
self.widget.update_idletasks()
w, h = self.widget.winfo_reqwidth(), self.widget.winfo_reqheight()

self.scrolling_widget.update_idletasks()
ws, hs = self.scrolling_widget.winfo_reqwidth(), self.scrolling_widget.winfo_reqheight()
box_h = min(hs, self.max_height) if self.max_height else hs
box_h = round(min(hs, max_height) if max_height else hs)
w_box, h_box = max(w, ws) + 2 * self.radius, h + box_h + 2 * self.radius

self.scroll.config(scrollregion=(0, 0, w_box, hs), width=w_box, height=box_h)
Expand Down

0 comments on commit d287947

Please sign in to comment.