diff --git a/main.py b/main.py index b0dad1b..e586737 100644 --- a/main.py +++ b/main.py @@ -954,19 +954,7 @@ class SettingsDialog(QtWidgets.QDialog): subcontrol-origin: padding; subcontrol-position: center right; }} - QComboBox::down-arrow {{ - image: none; - width: 0px; - height: 0px; - border-left: 5px solid transparent; - border-right: 5px solid transparent; - border-top: 6px solid {colors['foreground']}; - margin: 0px; - padding: 0px; - }} - QComboBox::down-arrow:hover {{ - border-top-color: {colors['accent']}; - }} + /* Removed custom down-arrow to use native system arrow (fix for missing/rectangle glyphs) */ QComboBox QAbstractItemView {{ background-color: {colors['input_bg']}; border: 1px solid {colors['border']}; @@ -1180,19 +1168,7 @@ class SettingsDialog(QtWidgets.QDialog): subcontrol-origin: padding; subcontrol-position: center right; }} - QComboBox::down-arrow {{ - image: none; - width: 0px; - height: 0px; - border-left: 5px solid transparent; - border-right: 5px solid transparent; - border-top: 6px solid {colors['foreground']}; - margin: 0px; - padding: 0px; - }} - QComboBox::down-arrow:hover {{ - border-top-color: {colors['accent']}; - }} + /* Removed custom down-arrow to use native system arrow (fix for missing/rectangle glyphs) */ QComboBox QAbstractItemView {{ background-color: {colors['input_bg']}; border: 1px solid {colors['border']}; @@ -2286,13 +2262,15 @@ class MainWindow(QtWidgets.QMainWindow): config_path = os.path.join(CONFIG_DIR, 'window_config.json') - # Get current geometry + # Use frameGeometry to capture actual on-screen top-left (accounts for title bar) + frame_geo = self.frameGeometry() geometry_data = { - 'x': self.x(), - 'y': self.y(), - 'width': self.width(), - 'height': self.height(), - 'maximized': self.isMaximized() + 'x': frame_geo.x(), + 'y': frame_geo.y(), + 'width': self.width(), # client width + 'height': self.height(), # client height + 'maximized': self.isMaximized(), + 'qt_geometry': bytes(self.saveGeometry()).hex() # serialized QByteArray } # Validate geometry data before saving - only prevent extremely invalid values @@ -2362,11 +2340,30 @@ class MainWindow(QtWidgets.QMainWindow): screen_width = screen.width() screen_height = screen.height() - # Use the exact saved position and dimensions - no adjustments - x = geometry_data['x'] - y = geometry_data['y'] - width = geometry_data['width'] - height = geometry_data['height'] + # First try Qt native restore if available + if 'qt_geometry' in geometry_data: + try: + geo_bytes = bytes.fromhex(geometry_data['qt_geometry']) + if self.restoreGeometry(QtCore.QByteArray(geo_bytes)): + logger.debug("Restored geometry via Qt restoreGeometry") + # Ensure move matches saved frame position (some WM shift). Adjust if off by <=10px + saved_x, saved_y = geometry_data['x'], geometry_data['y'] + current_frame = self.frameGeometry() + dx = saved_x - current_frame.x() + dy = saved_y - current_frame.y() + if abs(dx) > 2 or abs(dy) > 2: + self.move(saved_x, saved_y) + # Continue to restore other settings then return + else: + logger.debug("Qt restoreGeometry failed, falling back to manual restore") + except Exception as e: + logger.debug(f"Qt geometry restore error, fallback manual: {e}") + + # Manual fallback if needed (or to overwrite size only) + x = geometry_data.get('x', self.x()) + y = geometry_data.get('y', self.y()) + width = geometry_data.get('width', max(640, self.width())) + height = geometry_data.get('height', max(720, self.height())) # Only ensure the saved dimensions meet actual minimum requirements # but preserve the exact position @@ -2386,8 +2383,9 @@ class MainWindow(QtWidgets.QMainWindow): if y > screen_height - 10: # Too far down (only if less than 10px visible) y = screen_height - 10 - # Apply geometry immediately - self.setGeometry(x, y, width, height) + # Apply position and size separately to reduce WM adjustments + self.move(x, y) + self.resize(width, height) # Log the exact values being applied for debugging logger.debug(f"Applying geometry: x={x}, y={y}, width={width}, height={height}") @@ -2395,14 +2393,14 @@ class MainWindow(QtWidgets.QMainWindow): logger.debug(f"Screen dimensions: {screen_width}x{screen_height}") # Apply geometry again with a small delay to override any system adjustments - QtCore.QTimer.singleShot(50, lambda: self.setGeometry(x, y, width, height)) + QtCore.QTimer.singleShot(50, lambda: (self.move(x, y), self.resize(width, height))) # Restore maximized state if applicable if geometry_data.get('maximized', False): self.showMaximized() else: # Ensure we're not maximized and apply the geometry one more time - QtCore.QTimer.singleShot(100, lambda: self.setGeometry(x, y, width, height)) + QtCore.QTimer.singleShot(100, lambda: (self.move(x, y), self.resize(width, height))) # Restore update interval if saved saved_interval = config.get('update_interval') @@ -3002,14 +3000,7 @@ class MainWindow(QtWidgets.QMainWindow): subcontrol-origin: padding; subcontrol-position: center right; }} - QComboBox::down-arrow {{ - /* Use native arrow; prior triangle via borders rendered as rectangles on some systems */ - width: 12px; - height: 12px; - }} - QComboBox::down-arrow:hover {{ - /* Keep default hover */ - }} + /* Removed custom down-arrow to use native system arrow (fix for missing/rectangle glyphs) */ QComboBox QAbstractItemView {{ background-color: {colors['input_bg']}; border: 1px solid {colors['border']}; @@ -3124,19 +3115,7 @@ class MainWindow(QtWidgets.QMainWindow): subcontrol-origin: padding; subcontrol-position: center right; }} - QComboBox::down-arrow {{ - image: none; - width: 0px; - height: 0px; - border-left: 5px solid transparent; - border-right: 5px solid transparent; - border-top: 6px solid {colors['foreground']}; - margin: 0px; - padding: 0px; - }} - QComboBox::down-arrow:hover {{ - border-top-color: {colors['accent']}; - }} + /* Removed custom down-arrow to use native system arrow (fix for missing/rectangle glyphs) */ QComboBox QAbstractItemView {{ background-color: {colors['input_bg']}; border: 1px solid {colors['border']};