A bunch of changes
This commit is contained in:
@@ -68,7 +68,8 @@ from constants import (
|
||||
)
|
||||
import constants
|
||||
from settings import SettingsDialog
|
||||
from imagescanner import CacheCleaner, ImageScanner, ThumbnailCache, ThumbnailGenerator
|
||||
from imagescanner import (CacheCleaner, ImageScanner, ThumbnailCache,
|
||||
ThumbnailGenerator, ThreadPoolManager)
|
||||
from imageviewer import ImageViewer
|
||||
from propertiesdialog import PropertiesDialog
|
||||
from widgets import (
|
||||
@@ -903,13 +904,14 @@ class MainWindow(QMainWindow):
|
||||
scanners and individual image viewer windows.
|
||||
"""
|
||||
|
||||
def __init__(self, cache, args):
|
||||
def __init__(self, cache, args, thread_pool_manager):
|
||||
"""
|
||||
Initializes the MainWindow.
|
||||
|
||||
Args:
|
||||
cache (ThumbnailCache): The shared thumbnail cache instance.
|
||||
args (list): Command-line arguments passed to the application.
|
||||
thread_pool_manager (ThreadPoolManager): The shared thread pool manager.
|
||||
"""
|
||||
super().__init__()
|
||||
self.cache = cache
|
||||
@@ -917,6 +919,7 @@ class MainWindow(QMainWindow):
|
||||
self.set_app_icon()
|
||||
|
||||
self.viewer_shortcuts = {}
|
||||
self.thread_pool_manager = thread_pool_manager
|
||||
self.full_history = []
|
||||
self.history = []
|
||||
self.current_thumb_size = THUMBNAILS_DEFAULT_SIZE
|
||||
@@ -1320,12 +1323,14 @@ class MainWindow(QMainWindow):
|
||||
def _on_scroll_interaction(self, value):
|
||||
"""Pauses scanning during scroll to keep UI fluid."""
|
||||
if self.scanner and self.scanner.isRunning():
|
||||
self.thread_pool_manager.set_user_active(True)
|
||||
self.scanner.set_paused(True)
|
||||
self.resume_scan_timer.start()
|
||||
|
||||
def _resume_scanning(self):
|
||||
"""Resumes scanning after interaction pause."""
|
||||
if self.scanner:
|
||||
self.thread_pool_manager.set_user_active(False)
|
||||
# Prioritize currently visible images
|
||||
visible_paths = self.get_visible_image_paths()
|
||||
self.scanner.prioritize(visible_paths)
|
||||
@@ -1676,6 +1681,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
# Trigger a repaint to apply other color changes like filename color
|
||||
self._apply_global_stylesheet()
|
||||
self.thread_pool_manager.update_default_thread_count()
|
||||
self.thumbnail_view.updateGeometries()
|
||||
self.thumbnail_view.viewport().update()
|
||||
|
||||
@@ -2352,6 +2358,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.is_cleaning = False
|
||||
self.scanner = ImageScanner(self.cache, paths, is_file_list=self._scan_all,
|
||||
thread_pool_manager=self.thread_pool_manager,
|
||||
viewers=self.viewers)
|
||||
if self._is_loading_all:
|
||||
self.scanner.set_auto_load(True)
|
||||
@@ -3516,7 +3523,8 @@ class MainWindow(QMainWindow):
|
||||
if not paths:
|
||||
return
|
||||
|
||||
self.thumbnail_generator = ThumbnailGenerator(self.cache, paths, size)
|
||||
self.thumbnail_generator = ThumbnailGenerator(
|
||||
self.cache, paths, size, self.thread_pool_manager)
|
||||
self.thumbnail_generator.generation_complete.connect(
|
||||
self.on_high_res_generation_finished)
|
||||
self.thumbnail_generator.progress.connect(
|
||||
@@ -3983,7 +3991,8 @@ class MainWindow(QMainWindow):
|
||||
|
||||
# Create a ThumbnailGenerator to regenerate the thumbnail
|
||||
size = self._get_tier_for_size(self.current_thumb_size)
|
||||
self.thumbnail_generator = ThumbnailGenerator(self.cache, [path], size)
|
||||
self.thumbnail_generator = ThumbnailGenerator(
|
||||
self.cache, [path], size, self.thread_pool_manager)
|
||||
self.thumbnail_generator.generation_complete.connect(
|
||||
self.on_high_res_generation_finished)
|
||||
self.thumbnail_generator.progress.connect(
|
||||
@@ -4362,6 +4371,7 @@ def main():
|
||||
# Increase QPixmapCache limit (default is usually small, ~10MB) to ~100MB
|
||||
QPixmapCache.setCacheLimit(102400)
|
||||
|
||||
thread_pool_manager = ThreadPoolManager()
|
||||
cache = ThumbnailCache()
|
||||
|
||||
args = [a for a in sys.argv[1:] if a != "--x11"]
|
||||
@@ -4370,7 +4380,7 @@ def main():
|
||||
if path.startswith("file:/"):
|
||||
path = path[6:]
|
||||
|
||||
win = MainWindow(cache, args)
|
||||
win = MainWindow(cache, args, thread_pool_manager)
|
||||
shortcut_controller = AppShortcutController(win)
|
||||
win.shortcut_controller = shortcut_controller
|
||||
app.installEventFilter(shortcut_controller)
|
||||
|
||||
Reference in New Issue
Block a user