Added system language detection

This commit is contained in:
Ignacio Serantes
2026-03-26 20:09:46 +01:00
parent a7ce2ceb75
commit 096cee6ca3
5 changed files with 50 additions and 32 deletions

View File

@@ -14,7 +14,7 @@ Classes:
MainWindow: The main application window containing the thumbnail grid and docks.
"""
__appname__ = "BagheeraView"
__version__ = "0.9.14"
__version__ = "0.9.15"
__author__ = "Ignacio Serantes"
__email__ = "kde@aynoa.net"
__license__ = "LGPL"
@@ -53,7 +53,7 @@ from PySide6.QtDBus import QDBusConnection, QDBusMessage, QDBus
from pathlib import Path
from constants import (
APP_CONFIG, CONFIG_PATH, CURRENT_LANGUAGE, DEFAULT_GLOBAL_SHORTCUTS,
APP_CONFIG, CONFIG_PATH, DEFAULT_GLOBAL_SHORTCUTS, DEFAULT_LANGUAGE,
DEFAULT_VIEWER_SHORTCUTS, GLOBAL_ACTIONS, HISTORY_PATH, ICON_THEME,
ICON_THEME_FALLBACK, IMAGE_MIME_TYPES, LAYOUTS_DIR, FAVORITES_PATH, PROG_AUTHOR,
PROG_NAME, PROG_VERSION, RATING_XATTR_NAME, SCANNER_GENERATE_SIZES,
@@ -1236,6 +1236,12 @@ class MainWindow(QMainWindow):
self.favorites_tab.favorites_changed.connect(
self.shortcut_controller.refresh_favorite_shortcuts)
# Initialize FileSystemWatcher
self.fs_watcher = FileSystemWatcher()
self.fs_watcher.file_created.connect(self.on_fs_file_created)
self.fs_watcher.file_deleted.connect(self.on_fs_file_deleted)
self.fs_watcher.file_modified.connect(self.on_fs_file_modified)
self.main_dock.setWidget(self.tags_tabs)
self.addDockWidget(Qt.RightDockWidgetArea, self.main_dock)
@@ -1687,7 +1693,7 @@ class MainWindow(QMainWindow):
for code, name in SUPPORTED_LANGUAGES.items():
action = QAction(name, self, checkable=True)
action.setData(code)
if code == CURRENT_LANGUAGE:
if code == APP_CONFIG.get("language", DEFAULT_LANGUAGE):
action.setChecked(True)
language_menu.addAction(action)
lang_group.addAction(action)
@@ -4429,7 +4435,7 @@ class MainWindow(QMainWindow):
for code, name in SUPPORTED_LANGUAGES.items():
action = QAction(name, self, checkable=True)
action.setData(code)
if code == CURRENT_LANGUAGE:
if code == APP_CONFIG.get("language", DEFAULT_LANGUAGE):
action.setChecked(True)
language_menu.addAction(action)
lang_group.addAction(action)
@@ -4438,7 +4444,7 @@ class MainWindow(QMainWindow):
"""Handles language change, saves config, and prompts for restart."""
new_lang = action.data()
# Only save and show message if the language actually changed
if new_lang != APP_CONFIG.get("language", CURRENT_LANGUAGE):
if new_lang != APP_CONFIG.get("language", DEFAULT_LANGUAGE):
APP_CONFIG["language"] = new_lang
constants.save_app_config()
@@ -4457,7 +4463,7 @@ def main():
app = QApplication(sys.argv)
# Increase QPixmapCache limit (default is usually small, ~10MB) to ~100MB
QPixmapCache.setCacheLimit(102400)
QPixmapCache.setCacheLimit(104857600) # Old value: 102400
thread_pool_manager = ThreadPoolManager()
cache = ThumbnailCache()