|
10 | 10 | QMenu, QInputDialog, QDialog, QApplication, QTableWidget, |
11 | 11 | QTableWidgetItem, QHeaderView, QDialogButtonBox, QLabel as QDialogLabel |
12 | 12 | ) |
13 | | -from PySide6.QtGui import QPixmap, QImage, QTransform, QAction, QPainter |
| 13 | +from PySide6.QtGui import QPixmap, QImage, QTransform, QAction, QPainter, QColor |
14 | 14 | from PySide6.QtCore import Qt, QTimer, QSize, QSettings, QThread, Signal |
15 | 15 |
|
16 | 16 | from .widgets import ClickableLabel, MinimalProgressBar, ButtonOverlay |
@@ -649,7 +649,10 @@ def _update_zoom_display(self): |
649 | 649 | if self.pan_offset_x != 0 or self.pan_offset_y != 0: |
650 | 650 | # Create a canvas the size of the label |
651 | 651 | canvas = QPixmap(self.image_label.size()) |
652 | | - canvas.fill(Qt.black) # Use black background instead of transparent |
| 652 | + |
| 653 | + # Get the appropriate background color based on current mode |
| 654 | + bg_color = self._get_current_background_color() |
| 655 | + canvas.fill(bg_color) |
653 | 656 |
|
654 | 657 | # Paint the scaled image with offset |
655 | 658 | painter = QPainter(canvas) |
@@ -754,6 +757,30 @@ def cycle_background_mode(self): |
754 | 757 |
|
755 | 758 | self.change_bg_mode(next_mode) |
756 | 759 |
|
| 760 | + def _get_current_background_color(self): |
| 761 | + """Get the current background color as QColor based on the active mode.""" |
| 762 | + mode = self.settings.value("bg_mode", "Black") |
| 763 | + |
| 764 | + if mode == "Gray": |
| 765 | + return QColor(0x44, 0x44, 0x44) # #444444 |
| 766 | + elif mode == "Adaptive Color": |
| 767 | + # Try to extract the current background color from the parent widget |
| 768 | + parent = self.image_label.parentWidget() |
| 769 | + if parent: |
| 770 | + style = parent.styleSheet() |
| 771 | + # Look for rgb() or background-color in the stylesheet |
| 772 | + import re |
| 773 | + rgb_match = re.search(r'rgb\((\d+),\s*(\d+),\s*(\d+)\)', style) |
| 774 | + if rgb_match: |
| 775 | + r, g, b = map(int, rgb_match.groups()) |
| 776 | + return QColor(r, g, b) |
| 777 | + |
| 778 | + # Fallback to dark gray if we can't extract the adaptive color |
| 779 | + return QColor(40, 40, 40) |
| 780 | + else: |
| 781 | + # Default to black |
| 782 | + return QColor(0, 0, 0) |
| 783 | + |
757 | 784 | def show_keyboard_shortcuts(self): |
758 | 785 | """Show the keyboard shortcuts help dialog.""" |
759 | 786 | dialog = KeyboardShortcutsDialog(self) |
|
0 commit comments