Skip to content

Commit

Permalink
Docker fixes, CoverManager optimizations and settings fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePromidius committed Feb 27, 2024
1 parent 94353ee commit 59b8ce1
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 28 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ENV GUIAUTOSTART=true

WORKDIR /tmp
COPY requirements.txt /tmp/
COPY requirements.txt /app/

# Copy App
COPY --chown=$UID:$GID [ "/MangaManager", "/app" ]
Expand All @@ -22,6 +23,7 @@ RUN apt-get update && \
xubuntu-default-settings \
xubuntu-icon-theme \
unrar\
# git\
# Python \
idle-python3.11 \
python3-tk \
Expand Down
71 changes: 49 additions & 22 deletions MangaManager/src/MetadataManager/CoverManager/CoverManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
from idlelib.tooltip import Hovertip
from tkinter import Frame, CENTER, Button, NW
from tkinter.filedialog import askopenfile
from tkinter.ttk import Treeview
from tkinter.ttk import Treeview, Checkbutton

import numpy as np
from PIL import Image, ImageTk

from src.Common import ResourceLoader
from src.Common.LoadedComicInfo.LoadedComicInfo import CoverActions, LoadedComicInfo

from src.MetadataManager.GUI.MessageBox import MessageBoxWidgetFactory as mb
from src.MetadataManager.GUI.scrolledframe import ScrolledFrame
from src.MetadataManager.GUI.widgets import ButtonWidget
Expand Down Expand Up @@ -137,6 +138,8 @@ def __init__(self, master, super_: GUIApp = None, **kwargs):
"""
Initializes the toplevel window but hides the window.
"""
self.last_width = None
self.last_height = None
if self.name is None: # Check if the "name" attribute has been set
raise ValueError(
f"Error initializing the {self.__class__.__name__} Extension. The 'name' attribute must be set in the ExtensionApp class.")
Expand All @@ -160,7 +163,7 @@ def __init__(self, master, super_: GUIApp = None, **kwargs):
# so that it will be called whenever the window is resized
self.bind("<Configure>", self.redraw)

def redraw(self, event):
def redraw(self, event,frames=None):
"""
Redraws the widgets in the scrolled widget based on the current size of the window.
Expand All @@ -174,19 +177,34 @@ def redraw(self, event):
"""
width = self.winfo_width()
height = self.winfo_height()
if not event:
return
if not (width != event.width or height != event.height):
if self.last_width is None and self.last_height is None:
self.last_width = width
self.last_height = height
elif self.last_width == width and self.last_height == height:
return
else:
self.last_width = width
self.last_height = height
if event:

width = self.winfo_width() - 300
if isinstance(event.widget,ComicFrame):
return

width = self.winfo_width()- 120
if width == self.prev_width:
return
childrens = self.scrolled_widget.winfo_children()
for child in childrens:
child.grid_forget()
if not self.scrolled_widget.winfo_children():
return
if frames is None:
childrens = self.scrolled_widget.winfo_children()
for child in childrens:
child.grid_forget()
if not self.scrolled_widget.winfo_children():
return
widgets_to_redraw = list(
reversed(copy.copy(self.scrolled_widget.winfo_children()))) # self.scrolled_widget.grid_slaves()
else:
childrens = frames
widgets_to_redraw = frames# self.scrolled_widget.grid_slaves()
width = width - self.side_panel_control.winfo_width()

num_widgets = width // 414
try:
Expand All @@ -195,14 +213,16 @@ def redraw(self, event):
except ZeroDivisionError:
pass
# redraw the widgets
widgets_to_redraw = list(
reversed(copy.copy(self.scrolled_widget.winfo_children()))) # self.scrolled_widget.grid_slaves()

i = 0
j = 0
while widgets_to_redraw:
if j >= num_widgets:
if i%12 == 0:
self.update()
i += 1
j = 0

widgets_to_redraw.pop().grid(row=i, column=j)
j += 1

Expand All @@ -219,19 +239,19 @@ def serve_gui(self):
self.attributes('-zoomed', True)
elif platform.system() == "Windows":
self.state('zoomed')
side_panel_control = Frame(self)
side_panel_control.pack(side="right", expand=False, fill="y")
self.side_panel_control = Frame(self)
self.side_panel_control.pack(side="right", expand=False, fill="y")
ctr_btn = Frame(self)
ctr_btn.pack()
#
#
tree = self.tree = Treeview(side_panel_control, columns=("Filename", "type"), show="headings", height=8)
tree = self.tree = Treeview(self.side_panel_control, columns=("Filename", "type"), show="headings", height=8)
tree.column("#1")
tree.heading("#1", text="Filename")
tree.column("#2", anchor=CENTER, width=80)
tree.heading("#2", text="Type")
tree.pack(expand=True, fill="y", pady=(80, 0), padx=30, side="top")
action_buttons = Frame(side_panel_control)
action_buttons = Frame(self.side_panel_control)
action_buttons.pack(ipadx=20, ipady=20, pady=(0, 80), fill="x", padx=30)

ButtonWidget(master=action_buttons, text="Delete Selected",
Expand Down Expand Up @@ -275,8 +295,8 @@ def serve_gui(self):
self.scan_covers = tkinter.BooleanVar(value=True)
self.scan_backcovers = tkinter.BooleanVar(value=False)

tkinter.Checkbutton(frame, text="Covers", variable=self.scan_covers).pack()
tkinter.Checkbutton(frame, text="Back Covers", variable=self.scan_backcovers).pack()
Checkbutton(frame, text="Covers", variable=self.scan_covers).pack()
Checkbutton(frame, text="Back Covers", variable=self.scan_backcovers).pack()

content_frame = Frame(self)
content_frame.pack(fill="both", side="left", expand=True)
Expand All @@ -290,8 +310,10 @@ def serve_gui(self):
self.prev_width = 0
self.last_folder = ""
self.selected_frames: list[tuple[ComicFrame, str]] = []

self.shadow_frame_size = None
frames = []
for i, cinfo in enumerate(self._super.loaded_cinfo_list):

# create a ComicFrame for each LoadedComicInfo object
comic_frame = ComicFrame(self.scrolled_widget, cinfo)

Expand All @@ -300,8 +322,13 @@ def serve_gui(self):
comic_frame.backcover_canvas.bind("<Button-1>",
lambda event, frame_=comic_frame: self.select_frame(event, frame_,
"back"))
comic_frame.grid()
self.redraw(None)
# comic_frame.grid()
if self.shadow_frame_size is None:
comic_frame.grid()
self.shadow_frame_size = comic_frame.winfo_width()
comic_frame.grid_forget()
frames.append(comic_frame)
self.redraw(None,frames=frames)
def process(self):

frames_with_actions = [frame for frame in self.scrolled_widget.winfo_children() if frame.loaded_cinfo.cover_action or frame.loaded_cinfo.backcover_action]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def template_validation(key_list):
validate=lambda key, value: '[' + ", ".join(template_validation(
re.findall(r'\{(\w+)\}', value))) + "] are not valid tags" if len(
template_validation(re.findall(r'\{(\w+)\}', value))) != 0 else ""),
"clean_ui_on_drag_drop": SettingControl("remove_old_selection_on_drag_drop","Clean previous selection\non drag and drop", SettingControlType.Bool, True, "After you drag and drop, previous selected files will be discarded"),
"togle_dark_mode": SettingControl("darkmode_enabled","Enable darkmode", SettingControlType.Bool,value=False)
"remove_old_selection_on_drag_drop": SettingControl("remove_old_selection_on_drag_drop","Clean previous selection\non drag and drop", SettingControlType.Bool, True, "After you drag and drop, previous selected files will be discarded"),
"darkmode_enabled": SettingControl("darkmode_enabled","Enable darkmode", SettingControlType.Bool,value=False)
},
SettingHeading.WebpConverter: {
"default_base_path": SettingControl("default_base_path", "Default base path", SettingControlType.Text, "",
Expand Down
2 changes: 1 addition & 1 deletion MangaManager/src/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.4:nightly:d7dcd87e"
__version__ = "1.0.4:nightly:9b38295c"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Version=1.0
Type=Application
Exec=python /app/main.py
Exec=python3.11 /app/main.py
Icon=
StartupNotify=true
Terminal=False
Expand Down
2 changes: 1 addition & 1 deletion docker-root/config/Desktop/manga-manager-link.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Version=1.0
Type=Application
Name=Manga Manager
Comment=
Exec=python /app/main.py
Exec=python3.11 /app/main.py
Icon=
Path=/app
Terminal=false
Expand Down
2 changes: 1 addition & 1 deletion docker-root/defaults/startwm.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
/startpulse.sh &
/usr/bin/startxfce4 > /dev/null 2>&1
python /app/main.py
python3.11 /app/main.py

0 comments on commit 59b8ce1

Please sign in to comment.