-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSaveState_gui.py
More file actions
3965 lines (3500 loc) · 192 KB
/
SaveState_gui.py
File metadata and controls
3965 lines (3500 loc) · 192 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SaveState_gui.py
# -*- coding: utf-8 -*-
#import sys
import os
import logging
import platform
import math
import configparser
import re # Per espressioni regolari
import core_logic # Added import
# --- PySide6 Imports (misuriamo i moduli principali) ---
# Importa il modulo base prima, poi gli elementi specifici
from PySide6.QtWidgets import (
QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
QPushButton, QLabel, QStatusBar, QFrame, QSizePolicy,
QProgressBar, QGroupBox, QLineEdit,
QStyle, QDockWidget, QPlainTextEdit, QTableWidget, QGraphicsOpacityEffect,
QDialog, QFileDialog, QMenu, QSpinBox, QComboBox, QCheckBox, QFormLayout,
QSizeGrip, QMessageBox, QGridLayout, QSystemTrayIcon, QInputDialog
)
from PySide6.QtGui import QKeyEvent # Added for keyPressEvent
from PySide6.QtCore import (
Slot, Qt, QSize,
QEvent, Signal,
QTimer, QPropertyAnimation, QEasingCurve, QAbstractAnimation
)
# Try to import pynput for global mouse monitoring
try:
from pynput import mouse
PYNPUT_AVAILABLE = True
logging.info("pynput.mouse imported successfully. Global mouse drag detection enabled.")
except ImportError:
PYNPUT_AVAILABLE = False
mouse = None # Define mouse as None if import fails, to prevent NameError if referenced before conditional check
logging.warning("pynput.mouse could not be imported. Global mouse drag detection will be disabled. "
"Install pynput for this feature (e.g., 'pip install pynput').")
from PySide6.QtGui import (
QIcon, QColor, QDragEnterEvent, QDropEvent, QDragLeaveEvent, QDragMoveEvent,
QPalette, QAction, QCursor, QPixmap, QPainter, QFont,
)
# Import condizionale per PyWin32 (solo su Windows)
if platform.system() == "Windows":
try:
import win32gui
import win32con
import win32api
HAS_PYWIN32 = True
logging.debug("PyWin32 importato con successo")
except ImportError:
HAS_PYWIN32 = False
logging.warning("PyWin32 non disponibile. Il rilevamento del drag globale sarà limitato.")
else:
HAS_PYWIN32 = False
from gui_utils import QtLogHandler
from utils import resource_path
from gui_components.profile_list_manager import ProfileListManager
from gui_components.theme_manager import ThemeManager
from gui_components.profile_creation_manager import ProfileCreationManager
from gui_components.drag_drop_handler import DragDropHandler
from cloud_utils.cloud_panel import CloudSavePanel
import cloud_settings_manager
import core_logic # Mantenuto per load_profiles
from gui_handlers import MainWindowHandlers
from controller_manager import ControllerManager
from gui_components.controller_panel import (
ControllerPanel,
CTRL_BUTTONS, CTRL_ACTIONS, CTRL_DEFAULT_MAPPINGS, CTRL_BADGE_COLOR,
)
# --- COSTANTI GLOBALI PER IDENTIFICARE L'ISTANZA ---
# Import from config.py for early access in main.py before heavy imports
from config import SHARED_MEM_KEY, LOCAL_SERVER_NAME
# --- FINE COSTANTI ---
# ---------------------------------------------------------------------------
# Controller dialog badger — adds controller badge icons to dialog buttons
# ---------------------------------------------------------------------------
from PySide6.QtCore import QObject as _QObject, QEvent as _QEvent
from PySide6.QtWidgets import QDialogButtonBox as _QDialogButtonBox
class _ControllerDialogBadger(_QObject):
"""Application-level event filter.
Watches for any QDialog being shown and adds controller badge icons to its
buttons, using the current button mapping from the main window.
Recognised dialog patterns (by attribute inspection, no class imports):
• QMessageBox — Yes/OK → A, No/Cancel → B
• RestoreDialog — ok_button → A, Cancel → B
• ManageBackupsDialog — delete_button → A, close_button → B,
delete_all_button → X
• Any dialog with button_box (QDialogButtonBox) — OK → A, Cancel → B
"""
def __init__(self, main_window):
super().__init__()
self._mw = main_window
def eventFilter(self, watched, event):
if event.type() == _QEvent.Type.Show and isinstance(watched, QDialog):
QTimer.singleShot(0, lambda d=watched: self.update_dialog(d))
return False
def update_all_open_dialogs(self):
"""Update badges on all open dialogs according to the current input mode."""
from PySide6.QtWidgets import QApplication
for w in QApplication.topLevelWidgets():
if isinstance(w, QDialog) and w.isVisible():
self.update_dialog(w)
def update_dialog(self, dialog):
"""Show or hide badges on a dialog depending on the active controller mode."""
if not dialog.isVisible():
return
mw = self._mw
in_cloud_ctrl = getattr(mw, '_cloud_mode_active', False) and getattr(mw.cloud_panel, '_ctrl_mode_active', False) if hasattr(mw, 'cloud_panel') else False
is_ctrl_active = getattr(mw, '_ctrl_focus_section', None) is not None or in_cloud_ctrl
self._badge(dialog, apply=is_ctrl_active)
# ------------------------------------------------------------------
def _badge(self, dialog, apply=True):
if not dialog.isVisible():
return
mw = self._mw
make = mw._make_ctrl_badge_icon
sz = QSize(16, 16)
# Resolve action → physical button name from current mapping
saved = mw.current_settings.get("controller_button_mappings", {})
mapping = {**CTRL_DEFAULT_MAPPINGS, **saved}
action_to_btn: dict[str, str] = {}
for btn_name, action in mapping.items():
if action and action not in action_to_btn:
action_to_btn[action] = btn_name
def _icon(action_key, fallback_btn, fallback_color):
btn_name = action_to_btn.get(action_key, fallback_btn)
color = CTRL_BADGE_COLOR.get(btn_name, fallback_color)
return make(btn_name, color, 16), sz
def _set(widget, action_key, fallback_btn, fallback_color):
if widget and widget.isVisible():
if apply:
ico, sz_ = _icon(action_key, fallback_btn, fallback_color)
widget.setIcon(ico)
widget.setIconSize(sz_)
else:
widget.setIcon(QIcon())
# ── QMessageBox ────────────────────────────────────────────────
if isinstance(dialog, QMessageBox):
# ── Exit-confirmation dialog (tagged by _ctrl_show_exit_dialog) ──
if hasattr(dialog, '_ctrl_exit_confirm_btn') and hasattr(dialog, '_ctrl_exit_cancel_btn'):
_set(dialog._ctrl_exit_confirm_btn, "backup", "A", "#1E8449")
_set(dialog._ctrl_exit_cancel_btn, "back", "B", "#922B21")
return
for sb in (QMessageBox.StandardButton.Yes, QMessageBox.StandardButton.Ok,
QMessageBox.StandardButton.Open, QMessageBox.StandardButton.Save):
btn = dialog.button(sb)
if btn:
_set(btn, "backup", "A", "#1E8449")
break
for sb in (QMessageBox.StandardButton.No, QMessageBox.StandardButton.Cancel,
QMessageBox.StandardButton.Close, QMessageBox.StandardButton.Discard,
QMessageBox.StandardButton.Abort):
btn = dialog.button(sb)
if btn:
_set(btn, "back", "B", "#922B21")
break
return
# ── ManageBackupsDialog (delete_button, delete_all_button, close_button)
if (hasattr(dialog, 'delete_button') and
hasattr(dialog, 'delete_all_button') and
hasattr(dialog, 'close_button')):
_set(dialog.delete_button, "backup", "A", "#1E8449")
_set(dialog.close_button, "back", "B", "#922B21")
_set(dialog.delete_all_button, "restore", "X", "#1A5276")
return
# ── SteamDialog (configure_button, refresh_button, close_button)
if (hasattr(dialog, 'configure_button') and
hasattr(dialog, 'refresh_button') and
hasattr(dialog, 'close_button')):
_set(dialog.configure_button, "backup", "A", "#1E8449")
_set(dialog.close_button, "back", "B", "#922B21")
_set(dialog.refresh_button, "restore", "X", "#1A5276")
return
# ── QInputDialog (Select Steam Profile, etc.: OK / Cancel)
if isinstance(dialog, QInputDialog):
for bb in dialog.findChildren(_QDialogButtonBox):
ok_btn = bb.button(_QDialogButtonBox.StandardButton.Ok)
cancel_btn = bb.button(_QDialogButtonBox.StandardButton.Cancel)
_set(ok_btn, "backup", "A", "#1E8449")
_set(cancel_btn, "back", "B", "#922B21")
return
return
# ── RestoreDialog (ok_button + button_box with Cancel) ────────
if hasattr(dialog, 'ok_button') and hasattr(dialog, 'button_box'):
_set(dialog.ok_button, "backup", "A", "#1E8449")
bb = dialog.button_box
if isinstance(bb, _QDialogButtonBox):
cancel = bb.button(_QDialogButtonBox.StandardButton.Cancel)
_set(cancel, "back", "B", "#922B21")
return
# ── Generic dialog with QDialogButtonBox (New Profile, Edit…) ─
if hasattr(dialog, 'button_box') and isinstance(dialog.button_box, _QDialogButtonBox):
bb = dialog.button_box
ok_btn = bb.button(_QDialogButtonBox.StandardButton.Ok)
cancel_btn = bb.button(_QDialogButtonBox.StandardButton.Cancel)
_set(ok_btn, "backup", "A", "#1E8449")
_set(cancel_btn, "back", "B", "#922B21")
# --- Finestra Principale ---
# Approccio semplificato: mostrare l'overlay quando la finestra è attiva
class MainWindow(QMainWindow):
# Segnali per la gestione dell'overlay dal thread principale della GUI
request_show_overlay = Signal()
request_hide_overlay = Signal()
# --- Initialization ---
# Initializes the main window, sets up UI elements, managers, and connects signals.
def __init__(self, initial_settings, console_log_handler, qt_log_handler, settings_manager_instance):
super().__init__()
self.console_log_handler = console_log_handler # Salva riferimento al gestore console
self.qt_log_handler = qt_log_handler
self.settings_manager = settings_manager_instance # Assign settings_manager instance
self.core_logic = core_logic # Assign core_logic module to an instance attribute
# Use a custom, frameless title bar so we can reclaim vertical space
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
self._drag_pos = None # Used by the custom title bar drag logic
self._window_pos = None # Store window position for dragging
self._is_linux = platform.system() == "Linux" # Check if running on Linux
# Inizializza il cancellation manager per i thread di ricerca
from cancellation_utils import CancellationManager
self.cancellation_manager = CancellationManager()
# Inizializza le liste per il tracciamento dei thread
self._detection_threads = []
self.active_threads = {}
self.processing_cancelled = False
# Variabili per il rilevamento del drag globale
self.is_drag_operation_active = False
self.mouse_pressed = False # True se il tasto sinistro è attualmente premuto
self.mouse_press_time = 0 # Timestamp (ms) di quando il tasto è stato premuto
self.min_press_duration = 250 # Durata minima (ms) della pressione per attivare il drag (1/4 di secondo)
self.press_position = None # Posizione (x, y) di quando il tasto è stato premuto
self.min_drag_distance = 10 # Distanza minima (pixel) di movimento per attivare il drag
self.mouse_listener = None # Initialize to None
self.overlay_active = False # Flag to track if overlay is already active
# Initial state of the listener will be set by update_global_drag_listener_state
# called after settings are fully initialized and accessible.
if PYNPUT_AVAILABLE and mouse is not None:
try:
# Configura il listener del mouse per il rilevamento globale del drag
self.mouse_listener = mouse.Listener(
on_click=self.on_mouse_click,
on_move=self.on_mouse_move # Aggiungiamo il gestore per il movimento
)
self.mouse_listener.daemon = True # Il thread si chiuderà quando l'applicazione termina
# self.mouse_listener.start()
logging.info("Global mouse listener for drag detection initialized successfully.")
except Exception as e:
logging.error(f"Failed to start pynput mouse listener: {e}. Global drag detection will be disabled.", exc_info=True)
self.mouse_listener = None # Ensure it's None if an error occurs during start
else:
logging.info("pynput is not available or mouse module is None. Global mouse drag detection is disabled.")
# Translator removed - application is now English-only
self.setGeometry(650, 250, 720, 600)
self.setMinimumSize(720, 600) # Set minimum size to current size
self.setAcceptDrops(True)
self.current_settings = initial_settings
self.profiles = core_logic.load_profiles()
self.installed_steam_games_dict = core_logic.find_installed_steam_games()
# Log the result for debugging
if self.installed_steam_games_dict:
logging.info(f"Initialized installed_steam_games_dict with {len(self.installed_steam_games_dict)} games.")
# Example: Log first 3 games found for quick verification
# for i, (app_id, details) in enumerate(self.installed_steam_games_dict.items()):
# if i < 3:
# logging.debug(f" Found Steam game: {details.get('name', 'N/A')} (AppID: {app_id})")
# else:
# break
else:
logging.warning("installed_steam_games_dict is empty or None after initialization from core_logic.find_installed_steam_games().")
# Connect signals for overlay management
self.request_show_overlay.connect(self._show_overlay)
self.request_hide_overlay.connect(self._hide_overlay)
# Initialize and set the global drag listener state based on settings
self.update_global_drag_listener_state()
# --- Overlay Widget for Drag and Drop ---
self.overlay_widget = QWidget(self) # Parent to MainWindow directly
self.overlay_widget.setObjectName("BusyOverlay")
self.overlay_widget.setStyleSheet("QWidget#BusyOverlay { background-color: rgba(0, 0, 0, 200); }") # Semi-transparent background, darker
self.overlay_widget.hide() # Start hidden
self.overlay_widget.setMouseTracking(False) # Don't let the overlay intercept mouse events for itself
self.loading_label = QLabel("Drop Here", self.overlay_widget)
# font = self.loading_label.font()
# font.setPointSize(24)
# font.setBold(True)
# self.loading_label.setFont(font) # Stylesheet handles this now
self.loading_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.loading_label.setStyleSheet("QLabel { color: white; background-color: transparent; font-size: 24pt; font-weight: bold; }")
self.loading_label.hide()
# Fade-in animation for the overlay (using QGraphicsOpacityEffect for QWidget)
self.overlay_opacity_effect = QGraphicsOpacityEffect(self.overlay_widget)
self.overlay_widget.setGraphicsEffect(self.overlay_opacity_effect)
self.fade_in_animation = QPropertyAnimation(self.overlay_opacity_effect, b"opacity")
self.fade_in_animation.setDuration(400) # ms - Increased duration for better visibility
self.fade_in_animation.setStartValue(0.0)
self.fade_in_animation.setEndValue(1.0)
self.fade_in_animation.setEasingCurve(QEasingCurve.InOutQuad)
# Fade-out animation for the overlay
self.fade_out_animation = QPropertyAnimation(self.overlay_opacity_effect, b"opacity")
self.fade_out_animation.setDuration(400) # ms - Increased duration for better visibility
self.fade_out_animation.setStartValue(1.0)
self.fade_out_animation.setEndValue(0.0)
self.fade_out_animation.setEasingCurve(QEasingCurve.InOutQuad)
# Connect finished signals to hide widgets after animation
self.fade_out_animation.finished.connect(self.overlay_widget.hide) # Hides the widget itself
self.fade_out_animation.finished.connect(self._on_overlay_faded_out) # Manages overlay_active flag and hides label
# Overlay lock flag (keeps overlay visible when True, e.g., during Multi-Profile dialog)
self._overlay_locked = False
self.developer_mode_enabled = False # Stato iniziale delle opzioni sviluppatore
self.log_button_press_timer = None # Timer per il long press
self.log_icon_normal = None # Icona normale del log
self.log_icon_dev = None # Icona modalità sviluppatore
# Ottieni lo stile per le icone standard
style = QApplication.instance().style()
icon_size = QSize(16, 16) # Dimensione comune icone
# --- Widget ---
self.profile_table_widget = QTableWidget()
self.settings_button = QPushButton()
self.controller_button = QPushButton()
# Small circular indicator shown in the title bar when an update is
# available / being downloaded / ready to install. Wiring is done
# later in __init__ once the UpdateManager is constructed.
from gui_components.update_indicator import UpdateIndicator
self.update_indicator = UpdateIndicator()
self.status_label = QLabel()
self.status_label.setWordWrap(True)
self.new_profile_button = QPushButton()
self.steam_button = QPushButton()
self.delete_profile_button = QPushButton() # Crea pulsante Elimina Profilo
self.backup_button = QPushButton() # Crea pulsante Backup
self.restore_button = QPushButton() # Crea pulsante Ripristina
self.manage_backups_button = QPushButton() # Crea pulsante Gestisci Backup
self.open_backup_dir_button = QPushButton() # Crea pulsante Apri Cartella
# New visible Cloud entry
self.cloud_button = QPushButton("Cloud Sync")
# Cloud icon
cloud_icon_path = resource_path("icons/cloud-sync.png")
if os.path.exists(cloud_icon_path):
cloud_icon = QIcon(cloud_icon_path)
self.cloud_button.setIcon(cloud_icon)
else:
logging.warning(f"File icona Cloud non trovato: {cloud_icon_path}")
# Search bar for profiles (initially hidden)
self.search_bar = QLineEdit(self)
self.search_bar.setPlaceholderText("Type to search profiles...")
self.search_bar.hide()
self.search_bar.textChanged.connect(self._on_main_search_text_changed)
# Nuovo pulsante per il Log
self.toggle_log_button = QPushButton()
self.toggle_log_button.setObjectName("LogToggleButton")
self.toggle_log_button.setFlat(True)
self.toggle_log_button.setFixedSize(QSize(24, 24))
self.toggle_log_button.setObjectName("LogToggleButton")
# Carica entrambe le icone per il pulsante log
icon_normal_path = resource_path("icons/terminal.png")
icon_dev_path = resource_path("icons/terminalDev.png") # Nuova icona
if os.path.exists(icon_normal_path):
self.log_icon_normal = QIcon(icon_normal_path)
else:
logging.warning(f"File icona log NORMALE non trovato: {icon_normal_path}")
self.log_icon_normal = None # O gestisci il fallback
if os.path.exists(icon_dev_path):
self.log_icon_dev = QIcon(icon_dev_path)
else:
logging.warning(f"File icona log DEVELOPER non trovato: {icon_dev_path}")
self.log_icon_dev = self.log_icon_normal # Usa icona normale come fallback se manca quella dev
self.log_button_press_timer = QTimer(self)
self.log_button_press_timer.setSingleShot(True) # Scatta una sola volta
self.log_button_press_timer.setInterval(1500) # Durata pressione lunga in ms (1.5 secondi)
logging.debug(f"Timer object created in __init__: {self.log_button_press_timer}")
# Imposta l'icona iniziale (normale)
if self.log_icon_normal:
self.toggle_log_button.setIcon(self.log_icon_normal)
else:
self.toggle_log_button.setText("L") # Fallback testo se manca anche l'icona normale
button_size = QSize(24, 24)
self.toggle_log_button.setFixedSize(button_size)
#self.toggle_log_button.setToolTip(self.tr("Mostra/Nascondi Log (Tieni premuto per Opzioni Sviluppatore)"))
icon_path = resource_path("icons/settings.png") # Percorso relativo dell'icona
if os.path.exists(icon_path): # Controlla se il file esiste
self.settings_icon_normal = QIcon(icon_path) # Save normal icon
self.settings_button.setIcon(self.settings_icon_normal)
self.settings_button.setIconSize(QSize(20, 20)) # Icona più grande
else:
logging.warning(f"File icona impostazioni non trovato: {icon_path}")
self.settings_icon_normal = None
# Cloud settings icon
cloud_settings_icon_path = resource_path("icons/cloud option.png")
if os.path.exists(cloud_settings_icon_path):
self.settings_icon_cloud = QIcon(cloud_settings_icon_path)
else:
logging.warning(f"File icona cloud settings non trovato: {cloud_settings_icon_path}")
self.settings_icon_cloud = self.settings_icon_normal # Fallback to normal icon
self.theme_button = QPushButton()
# Style settings/theme/controller as square, icon-only buttons for the title bar
self.settings_button.setFlat(True)
self.settings_button.setFixedSize(QSize(28, 28))
self.theme_button.setFlat(True)
self.theme_button.setFixedSize(QSize(28, 28))
controller_icon_path = resource_path("icons/controller.png")
if os.path.exists(controller_icon_path):
self.controller_button.setIcon(QIcon(controller_icon_path))
self.controller_button.setIconSize(QSize(20, 20))
else:
self.controller_button.setText("🎮")
self.controller_button.setFlat(True)
self.controller_button.setFixedSize(QSize(28, 28))
self.controller_button.setToolTip("Controller Settings")
#self.status_label = QLabel(self.tr("Pronto."))
self.status_label.setObjectName("StatusLabel")
self.progress_bar = QProgressBar()
self.progress_bar.setVisible(False)
self.progress_bar.setMaximum(0)
self.progress_bar.setMinimum(0)
new_icon = style.standardIcon(QStyle.StandardPixmap.SP_FileDialogNewFolder) # Icona Nuova Cartella?
self.new_profile_button.setIcon(new_icon)
steam_icon_path = resource_path("icons/steam.png")
if os.path.exists(steam_icon_path): # Controlla se il file esiste
steam_icon = QIcon(steam_icon_path)
self.steam_button.setIcon(steam_icon)
self.steam_button.setIconSize(QSize(16, 16)) # Imposta la stessa dimensione delle altre icone
else:
logging.warning(f"File icona Steam non trovato: {steam_icon_path}")
delete_prof_icon = style.standardIcon(QStyle.StandardPixmap.SP_TrashIcon) # Icona Cestino
self.delete_profile_button.setIcon(delete_prof_icon)
self.backup_button = QPushButton("Backup")
self.backup_button.setObjectName("BackupButton")
backup_icon_path = resource_path("icons/backup.png")
if os.path.exists(backup_icon_path):
backup_icon = QIcon(backup_icon_path)
self.backup_button.setIcon(backup_icon)
else:
logging.warning(f"File icona Backup non trovato: {backup_icon_path}")
backup_icon = style.standardIcon(QStyle.StandardPixmap.SP_DialogSaveButton) # Icona Salva (Floppy)
self.backup_button.setIcon(backup_icon)
# --- Backup Mode Toggle Integration ---
self.backup_mode = "single" # Default mode
# Toggle Button (Small +) - Will be parented to actions_group later for independent enable/disable
self.backup_mode_toggle = QPushButton("+")
self.backup_mode_toggle.setFixedSize(22, 18)
self.backup_mode_toggle.setCursor(Qt.CursorShape.PointingHandCursor)
self.backup_mode_toggle.setToolTip("Switch to 'Backup All' mode - Click to toggle")
# Style for the toggle - clearer
self.backup_mode_toggle.setStyleSheet("""
QPushButton {
border: none;
background-color: transparent;
color: rgba(255, 255, 255, 0.5);
font-family: 'Segoe UI', Arial, sans-serif;
font-weight: bold;
font-size: 18px;
padding: 0px;
margin: 0px;
/* Override global QPushButton min-width from theme */
min-width: 0px;
max-width: 22px;
min-height: 0px;
max-height: 18px;
}
QPushButton:hover {
color: #3498DB;
background-color: rgba(0,0,0,0.2);
border-radius: 4px;
}
QPushButton:disabled {
color: rgba(255, 255, 255, 0.2);
}
""")
# Start hidden - visibility will be controlled by update_action_button_states
# based on profile count (only show when 3+ profiles exist)
self.backup_mode_toggle.setVisible(False)
# Install event filter to handle manual positioning
self.backup_button.installEventFilter(self)
# Style is now provided by the global theme QSS (DARK_THEME_QSS / LIGHT_THEME_QSS)
# via the #BackupButton / #RestoreButton / #ManageButton object names so the
# action buttons follow the active theme automatically.
self.restore_button = QPushButton("Restore")
self.restore_button.setObjectName("RestoreButton")
restore_icon_path = resource_path("icons/restore.png")
if os.path.exists(restore_icon_path):
restore_icon = QIcon(restore_icon_path)
self.restore_button.setIcon(restore_icon)
else:
logging.warning(f"File icona Restore non trovato: {restore_icon_path}")
# Fallback to standard icon if custom icon is not found
restore_icon = style.standardIcon(QStyle.StandardPixmap.SP_ArrowDown)
self.restore_button.setIcon(restore_icon)
self.manage_backups_button = QPushButton("Manage Backups")
self.manage_backups_button.setObjectName("ManageButton")
manage_icon = style.standardIcon(QStyle.StandardPixmap.SP_FileDialogDetailedView) # Icona Vista Dettagliata?
self.manage_backups_button.setIcon(manage_icon)
self.open_backup_dir_button = QPushButton("Open Backup Folder")
open_folder_icon = style.standardIcon(QStyle.StandardPixmap.SP_DirOpenIcon) # Icona Apri Cartella
self.open_backup_dir_button.setIcon(open_folder_icon)
# Imposta dimensione icone (opzionale, regola i px se necessario)
icon_size = QSize(16, 16) # Larghezza, Altezza in pixel
icon_size_action = QSize(16, 16) # Icone più grandi per pulsanti Backup/Restore
self.new_profile_button.setIconSize(icon_size)
self.delete_profile_button.setIconSize(icon_size)
self.backup_button.setIconSize(icon_size_action)
self.restore_button.setIconSize(icon_size_action)
self.manage_backups_button.setIconSize(icon_size)
self.open_backup_dir_button.setIconSize(icon_size)
self.cloud_button.setIconSize(icon_size)
# self.settings_button.setIconSize(icon_size)
# self.steam_button.setIconSize(icon_size)
#self.update_profile_table()
# --- Layout ---
main_layout = QVBoxLayout()
# Make the title bar reach the window edges, while preserving content margins via a container
main_layout.setContentsMargins(0, 0, 0, 0)
main_layout.setSpacing(0) # no gap below the title bar
# Custom Title Bar (frameless)
self.title_bar = QWidget()
self.title_bar.setObjectName("CustomTitleBar")
# Compact title bar height and internal padding
self.title_bar.setMinimumHeight(36)
title_layout = QHBoxLayout()
title_layout.setContentsMargins(12, 4, 12, 4)
title_layout.setSpacing(6)
self.title_label = QLabel("SaveState - 2.6.0")
self.title_label.setObjectName("TitleLabel")
title_layout.addWidget(self.title_label)
# Update indicator sits immediately to the right of the version text,
# is invisible by default and only appears when there is something
# actionable (update available / downloading / restart pending).
title_layout.addWidget(self.update_indicator)
title_layout.addStretch(1)
# Right-side icon buttons: Controller, then Theme, then spacer, then Settings
self.controller_button.setObjectName("ControllerButton")
self.settings_button.setObjectName("SettingsButton")
self.theme_button.setObjectName("ThemeButton")
title_layout.addWidget(self.controller_button)
title_layout.addWidget(self.theme_button)
# Distanziatore
title_layout.addSpacing(16)
title_layout.addWidget(self.settings_button)
# Window control buttons (minimize, close) - no maximize/fullscreen
self.minimize_button = QPushButton()
self.minimize_button.setObjectName("MinimizeButton")
self.minimize_button.setIcon(style.standardIcon(QStyle.StandardPixmap.SP_TitleBarMinButton))
self.minimize_button.setFixedSize(QSize(28, 28))
self.minimize_button.setFlat(True)
self.minimize_button.setIconSize(QSize(14, 14))
self.minimize_button.clicked.connect(self.showMinimized)
self.close_button = QPushButton()
self.close_button.setObjectName("CloseButton")
self.close_button.setIcon(style.standardIcon(QStyle.StandardPixmap.SP_TitleBarCloseButton))
self.close_button.setFixedSize(QSize(28, 28))
self.close_button.setFlat(True)
self.close_button.setIconSize(QSize(14, 14))
self.close_button.clicked.connect(self.close)
title_layout.addWidget(self.minimize_button)
title_layout.addWidget(self.close_button)
self.title_bar.setLayout(title_layout)
# Allow dragging the window from the title bar
self.title_bar.installEventFilter(self)
# Title bar styling (darker than main UI, icon-only square buttons)
self.title_bar.setStyleSheet(
"""
QWidget#CustomTitleBar { background-color: #0d0d0d; border-bottom: 1px solid #333333; }
QLabel#TitleLabel { color: #f2f2f2; font-size: 14pt; font-weight: 700; }
QPushButton#SettingsButton, QPushButton#ThemeButton, QPushButton#ControllerButton, QPushButton#MinimizeButton, QPushButton#CloseButton {
border: none; background: transparent; min-width: 28px; max-width: 28px; min-height: 28px; max-height: 28px; padding: 0px; border-radius: 4px;
}
QPushButton#SettingsButton:hover, QPushButton#ThemeButton:hover, QPushButton#ControllerButton:hover, QPushButton#MinimizeButton:hover {
background-color: rgba(255, 255, 255, 0.15);
}
QPushButton#ControllerButton[active="true"] {
background-color: rgba(255, 255, 255, 0.2);
}
QPushButton#CloseButton:hover { background-color: #b00020; }
"""
)
main_layout.addWidget(self.title_bar)
# Content container restores the usual margins around the app content
content_container = QWidget()
content_layout = QVBoxLayout()
content_layout.setContentsMargins(12, 8, 12, 4)
content_layout.setSpacing(4)
content_container.setLayout(content_layout)
# Create Profiles group - button positioned in title area via absolute positioning
profile_group = QGroupBox("Profiles")
profile_group.setObjectName("ProfilesGroup")
self.profile_group = profile_group
profile_layout = QVBoxLayout()
profile_layout.setContentsMargins(6, 6, 6, 6)
profile_layout.setSpacing(4)
profile_layout.addWidget(self.profile_table_widget)
profile_group.setLayout(profile_layout)
content_layout.addWidget(profile_group, stretch=1)
# Inline Profile Editor (hidden by default)
self.profile_editor_group = QGroupBox("Edit Profile")
editor_layout = QVBoxLayout()
# --- Icon picker row (custom profile icon) ---
# Hidden when "show_profile_icons" is disabled in Settings.
self.edit_icon_row = QWidget()
icon_row_layout = QHBoxLayout(self.edit_icon_row)
icon_row_layout.setContentsMargins(0, 0, 0, 0)
icon_row_layout.setSpacing(8)
icon_row_layout.addWidget(QLabel("Icon:"))
self.edit_icon_preview = QLabel()
self.edit_icon_preview.setFixedSize(48, 48)
self.edit_icon_preview.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.edit_icon_preview.setStyleSheet(
"QLabel { border: 1px solid #555; border-radius: 4px; background-color: rgba(0, 0, 0, 30); }"
)
icon_row_layout.addWidget(self.edit_icon_preview)
self.edit_icon_change_button = QPushButton("Change Icon...")
self.edit_icon_change_button.setToolTip(
"Pick a custom image (PNG, JPG, ICO, BMP, WEBP, SVG) or steal "
"the icon from a program / shortcut (.exe, .dll, .lnk, "
".desktop, .AppImage)"
)
self.edit_icon_reset_button = QPushButton("Reset")
self.edit_icon_reset_button.setToolTip(
"Remove the custom icon and use the automatically detected one"
)
icon_row_layout.addWidget(self.edit_icon_change_button)
icon_row_layout.addWidget(self.edit_icon_reset_button)
icon_row_layout.addStretch(1)
editor_layout.addWidget(self.edit_icon_row)
# Name field
name_row = QHBoxLayout()
name_row.addWidget(QLabel("Name:"))
self.edit_name_edit = QLineEdit()
name_row.addWidget(self.edit_name_edit)
editor_layout.addLayout(name_row)
# Path field with browse
path_row = QHBoxLayout()
path_row.addWidget(QLabel("Save Path:"))
self.edit_path_edit = QLineEdit()
self.edit_browse_button = QPushButton()
self.edit_browse_button.setIcon(style.standardIcon(QStyle.StandardPixmap.SP_DirIcon))
path_row.addWidget(self.edit_path_edit)
path_row.addWidget(self.edit_browse_button)
editor_layout.addLayout(path_row)
# Overrides toggle and group
self.overrides_enable_checkbox = QCheckBox("Use profile-specific settings")
editor_layout.addWidget(self.overrides_enable_checkbox)
self.overrides_group = QGroupBox("Overrides")
overrides_form = QFormLayout()
# Max backups
self.override_max_backups_spin = QSpinBox()
self.override_max_backups_spin.setRange(1, 999)
overrides_form.addRow("Max backups:", self.override_max_backups_spin)
# Compression mode
self.override_compression_combo = QComboBox()
self.override_compression_combo.addItems(["standard", "maximum", "stored"])
overrides_form.addRow("Compression:", self.override_compression_combo)
# Max source size MB (match Settings dialog options)
self.override_size_options = [
("50 MB", 50), ("100 MB", 100), ("250 MB", 250), ("500 MB", 500),
("1 GB (1024 MB)", 1024), ("2 GB (2048 MB)", 2048),
("5 GB (5120 MB)", 5120), ("No Limit", -1)
]
self.override_max_size_combo = QComboBox()
for display_text, _ in self.override_size_options:
self.override_max_size_combo.addItem(display_text)
overrides_form.addRow("Max source size (MB):", self.override_max_size_combo)
# Check free space
self.override_check_space_checkbox = QCheckBox("Check free disk space before backup")
overrides_form.addRow(self.override_check_space_checkbox)
self.overrides_group.setLayout(overrides_form)
editor_layout.addWidget(self.overrides_group)
# Save/Cancel buttons
buttons_row = QHBoxLayout()
self.edit_save_button = QPushButton("Save")
self.edit_cancel_button = QPushButton("Cancel")
buttons_row.addStretch(1)
buttons_row.addWidget(self.edit_save_button)
buttons_row.addWidget(self.edit_cancel_button)
editor_layout.addLayout(buttons_row)
self.profile_editor_group.setLayout(editor_layout)
self.profile_editor_group.setVisible(False)
content_layout.addWidget(self.profile_editor_group, stretch=1)
# --- Inline Settings Panel (hidden by default) ---
self.settings_panel_group = QGroupBox("Application Settings")
settings_main_layout = QVBoxLayout()
settings_main_layout.setContentsMargins(8, 4, 8, 8) # Reduce top margin
settings_main_layout.setSpacing(8)
# Create grid layout for 2-column layout
settings_grid = QGridLayout()
settings_grid.setContentsMargins(4, 4, 4, 4) # Reduce margins
settings_grid.setHorizontalSpacing(16)
settings_grid.setVerticalSpacing(12)
# ROW 0, COL 0-1: Backup Base Path (full width)
backup_path_group = QGroupBox("Backup Base Path")
backup_path_layout = QHBoxLayout()
backup_path_layout.setContentsMargins(8, 8, 8, 8)
backup_path_layout.setSpacing(6)
self.settings_path_edit = QLineEdit()
self.settings_browse_button = QPushButton("Browse...")
self.settings_browse_button.setIcon(style.standardIcon(QStyle.StandardPixmap.SP_DirOpenIcon))
backup_path_layout.addWidget(self.settings_path_edit)
backup_path_layout.addWidget(self.settings_browse_button)
backup_path_group.setLayout(backup_path_layout)
settings_grid.addWidget(backup_path_group, 0, 0, 1, 2) # span 2 columns
# ROW 1, COL 0: Portable Mode
portable_group = QGroupBox("Portable Mode")
portable_layout = QVBoxLayout()
portable_layout.setContentsMargins(8, 8, 8, 8)
portable_layout.setSpacing(6)
self.settings_portable_checkbox = QCheckBox("Use only JSONs in backup folder (.savestate)")
portable_layout.addWidget(self.settings_portable_checkbox)
portable_group.setLayout(portable_layout)
settings_grid.addWidget(portable_group, 1, 0)
# ROW 1, COL 1: Maximum Source Size
max_size_group = QGroupBox("Maximum Source Size for Backup")
max_size_layout = QVBoxLayout()
max_size_layout.setContentsMargins(8, 8, 8, 8)
max_size_layout.setSpacing(6)
self.settings_max_size_combo = QComboBox()
self.settings_size_options = [
("50 MB", 50), ("100 MB", 100), ("250 MB", 250), ("500 MB", 500),
("1 GB (1024 MB)", 1024), ("2 GB (2048 MB)", 2048),
("5 GB (5120 MB)", 5120), ("No Limit", -1)
]
for display_text, _ in self.settings_size_options:
self.settings_max_size_combo.addItem(display_text)
max_size_layout.addWidget(self.settings_max_size_combo)
max_size_group.setLayout(max_size_layout)
settings_grid.addWidget(max_size_group, 1, 1)
# ROW 2, COL 0: Max Number of Backups
max_backups_group = QGroupBox("Maximum Number of Backups per Profile")
max_backups_layout = QHBoxLayout()
max_backups_layout.setContentsMargins(8, 8, 8, 8)
max_backups_layout.setSpacing(6)
self.settings_max_backups_spin = QSpinBox()
self.settings_max_backups_spin.setRange(1, 99)
self.settings_max_backups_spin.setMaximumWidth(80) # Limit width
max_backups_layout.addWidget(self.settings_max_backups_spin)
max_backups_layout.addWidget(QLabel("backups per profile (.zip)"))
max_backups_layout.addStretch(1) # Push everything to the left
max_backups_group.setLayout(max_backups_layout)
settings_grid.addWidget(max_backups_group, 2, 0)
# ROW 2, COL 1: Backup Compression
compression_group = QGroupBox("Backup Compression (.zip)")
compression_layout = QVBoxLayout()
compression_layout.setContentsMargins(8, 8, 8, 8)
compression_layout.setSpacing(6)
self.settings_compression_combo = QComboBox()
self.settings_compression_options = {
"standard": "Standard (Recommended)",
"maximum": "Maximum (Slower)",
"stored": "None (Faster)"
}
for key, text in self.settings_compression_options.items():
self.settings_compression_combo.addItem(text, key)
compression_layout.addWidget(self.settings_compression_combo)
compression_group.setLayout(compression_layout)
settings_grid.addWidget(compression_group, 2, 1)
# ROW 3, COL 0: Space check / update
space_check_group = QGroupBox("Space check/update")
space_check_layout = QVBoxLayout()
space_check_layout.setContentsMargins(8, 8, 8, 8)
space_check_layout.setSpacing(6)
self.settings_space_check_checkbox = QCheckBox("Enable space check before backup (2gb)")
space_check_layout.addWidget(self.settings_space_check_checkbox)
# Opt-in auto-update check. No network requests happen unless this is
# enabled OR the user clicks the update indicator manually.
self.settings_check_updates_checkbox = QCheckBox("Check for updates on startup (via GitHub Releases)")
space_check_layout.addWidget(self.settings_check_updates_checkbox)
space_check_group.setLayout(space_check_layout)
settings_grid.addWidget(space_check_group, 3, 0)
# ROW 3, COL 1: UI Settings
ui_settings_group = QGroupBox("UI Settings")
ui_settings_layout = QVBoxLayout()
ui_settings_layout.setContentsMargins(8, 8, 8, 8)
ui_settings_layout.setSpacing(6)
self.settings_global_drag_checkbox = QCheckBox("Enable global mouse drag-to-show effect")
self.settings_shorten_paths_checkbox = QCheckBox("Shorten save paths in selection dialogs")
ui_settings_layout.addWidget(self.settings_global_drag_checkbox)
ui_settings_layout.addWidget(self.settings_shorten_paths_checkbox)
ui_settings_group.setLayout(ui_settings_layout)
settings_grid.addWidget(ui_settings_group, 3, 1)
# ROW 4, COL 0: System Tray Settings
tray_settings_group = QGroupBox("System Tray")
tray_settings_layout = QVBoxLayout()
tray_settings_layout.setContentsMargins(8, 8, 8, 8)
tray_settings_layout.setSpacing(6)
self.settings_minimize_to_tray_checkbox = QCheckBox("Minimize to tray on close")
tray_settings_layout.addWidget(self.settings_minimize_to_tray_checkbox)
tray_settings_group.setLayout(tray_settings_layout)
settings_grid.addWidget(tray_settings_group, 4, 0)
# ROW 4, COL 1: Profile Appearance
profile_ui_group = QGroupBox("Profile Appearance")
profile_ui_layout = QVBoxLayout()
profile_ui_layout.setContentsMargins(8, 8, 8, 8)
profile_ui_layout.setSpacing(6)
self.settings_show_icons_checkbox = QCheckBox("Show game icons in profile list")
profile_ui_layout.addWidget(self.settings_show_icons_checkbox)
profile_ui_group.setLayout(profile_ui_layout)
settings_grid.addWidget(profile_ui_group, 4, 1)
settings_main_layout.addLayout(settings_grid)
# No stretch - let the grid breathe naturally
# Exit and Save buttons
settings_buttons_row = QHBoxLayout()
self.settings_exit_button = QPushButton("Exit")
self.settings_save_button = QPushButton("Save")
settings_buttons_row.addStretch(1)
settings_buttons_row.addWidget(self.settings_exit_button)
settings_buttons_row.addWidget(self.settings_save_button)
settings_main_layout.addLayout(settings_buttons_row)
self.settings_panel_group.setLayout(settings_main_layout)
self.settings_panel_group.setVisible(False)
content_layout.addWidget(self.settings_panel_group, stretch=1)
# --- End Inline Settings Panel ---
# --- Inline Controller Settings Panel (hidden by default) ---
self.controller_panel_group = ControllerPanel(parent=self)
content_layout.addWidget(self.controller_panel_group, stretch=1)
# Convenience aliases used by the rest of the class and by gui_handlers
self.controller_enabled_switch = self.controller_panel_group.controller_enabled_switch
self.ctrl_mapping_combos = self.controller_panel_group.ctrl_mapping_combos
self.controller_exit_button = self.controller_panel_group.exit_button
self.controller_save_button = self.controller_panel_group.save_button
# --- End Inline Controller Settings Panel ---
# --- Inline Cloud Save Panel (hidden by default) ---
self.cloud_panel = CloudSavePanel(
backup_base_dir=self.current_settings.get("backup_base_dir", ""),
profiles=self.profiles,
parent=self
)
self.cloud_panel.setVisible(False)
content_layout.addWidget(self.cloud_panel, stretch=1)
# --- End Inline Cloud Save Panel ---
actions_group = QGroupBox("Actions")
self.actions_group = actions_group
actions_layout = QHBoxLayout()
# Use margins to shorten buttons slightly from the edges without making them tiny
actions_layout.setContentsMargins(20, 8, 20, 8)
actions_layout.setSpacing(20)
# Allow buttons to expand naturally — sizes unchanged
self.backup_button.setMaximumWidth(16777215) # Reset max width to default (QWIDGETSIZE_MAX)
self.restore_button.setMaximumWidth(16777215)
self.manage_backups_button.setMaximumWidth(16777215)
actions_layout.addWidget(self.backup_button)
actions_layout.addWidget(self.restore_button)
actions_layout.addWidget(self.manage_backups_button)
actions_group.setLayout(actions_layout)
# Add the toggle button as a child of actions_group (not backup_button)
# This allows it to remain enabled even when backup_button is disabled
self.backup_mode_toggle.setParent(actions_group)
self.backup_mode_toggle.raise_() # Ensure it's on top
# Install event filter on actions_group to reposition toggle when layout changes
actions_group.installEventFilter(self)
content_layout.addWidget(actions_group)
general_group = QGroupBox("General")
self.general_group = general_group
general_layout = QHBoxLayout()
general_layout.setContentsMargins(6, 6, 6, 6)
general_layout.setSpacing(6)
general_layout.addWidget(self.new_profile_button)
general_layout.addWidget(self.steam_button)
general_layout.addWidget(self.open_backup_dir_button) # Moved back here
general_group.setLayout(general_layout)
# --- New right-side Cloud group next to General with a light separator ---
self.cloud_group = QGroupBox("") # frameless title to visually group the Cloud button
cloud_layout = QHBoxLayout()
cloud_layout.setContentsMargins(6, 6, 6, 6)
cloud_layout.setSpacing(6)
# Reduce Cloud button width slightly (about 15-20%)
self.cloud_button.setMaximumWidth(150) # Limit max width
self.cloud_button.setStyleSheet("padding-left: 14px; padding-right: 14px;")
cloud_layout.addWidget(self.cloud_button)
self.cloud_group.setLayout(cloud_layout)
# Make the cloud group take minimal space
self.cloud_group.setMaximumWidth(170) # Slightly larger than button to account for margins
self.cloud_group.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Preferred)
# Invisible spacer between General and Cloud (replaces visible separator)
separator = QFrame()
separator.setFrameShape(QFrame.Shape.NoFrame)
separator.setFixedWidth(2) # Just spacing, no visible line
separator.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Expanding)
separator.setStyleSheet("QFrame { background: transparent; border: none; }")
# Row container to place General (left) and Cloud (right of it)
self.general_cloud_row = QWidget()
general_cloud_row_layout = QHBoxLayout()
general_cloud_row_layout.setContentsMargins(0, 0, 0, 0)
general_cloud_row_layout.setSpacing(6)
general_cloud_row_layout.addWidget(general_group)
general_cloud_row_layout.addWidget(separator)
general_cloud_row_layout.addWidget(self.cloud_group)
self.general_cloud_row.setLayout(general_cloud_row_layout)