Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay Showing Main Windows (until after Theme is applied) #5574

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/classes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,6 @@ def gui(self):
log.debug("Creating main interface window")
self.window = MainWindow()

# Instantiate Theme Manager (Singleton)
theme_name = self.settings.get("theme")
theme = self.theme_manager.apply_theme(theme_name)

# Update theme in settings
self.settings.set("theme", theme.name)

# Check for gui launch failures
if self.mode == "quit":
self.window.close()
Expand All @@ -273,6 +266,9 @@ def gui(self):
# Connect our exit signals
self.aboutToQuit.connect(self.cleanup)

# Show main window
self.window.show()

args = self.args
if len(args) < 2:
# Recover backup file (this can't happen until after the Main Window has completely loaded)
Expand Down
6 changes: 3 additions & 3 deletions src/themes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def set_dock_margins(self, content_margins=None, layout_margins=None, object_nam
if child.objectName().startswith("dock") and child.objectName().endswith("Contents"):
# Set content margins on QDock* widget
child.setContentsMargins(*content_margins)
if child.layout() and layout_margins:
# Set content margins on the QDock Layout (which has additional margins)
child.layout().setContentsMargins(*layout_margins)
if child.layout() and layout_margins:
# Set content margins on the QDock Layout (which has additional margins)
child.layout().setContentsMargins(*layout_margins)

def set_toolbar_buttons(self, toolbar, icon_size=24, settings=None):
"""Iterate through toolbar button settings, and apply them to each button.
Expand Down
18 changes: 7 additions & 11 deletions src/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -3482,23 +3482,19 @@ def __init__(self, *args):
self.toolBar.topLevelChanged.connect(
functools.partial(self.freezeMainToolBar, None))

# Show window
self.show()

# Create tutorial manager
self.tutorial_manager = TutorialManager(self)

# Apply theme
theme_name = s.get("theme")
theme = get_app().theme_manager.apply_theme(theme_name)
s.set("theme", theme.name)

# Apply saved window geometry/state from settings
if self.saved_geometry:
try:
QTimer.singleShot(100, functools.partial(self.restoreGeometry, self.saved_geometry))
except Exception as e:
log.error(f"Error restoring window geometry: {e}")
self.restoreGeometry(self.saved_geometry)
if self.saved_state:
try:
QTimer.singleShot(100, functools.partial(self.restoreState, self.saved_state))
except Exception as e:
log.error(f"Error restoring window state: {e}")
QTimer.singleShot(0, functools.partial(self.restoreState, self.saved_state))

# Save settings
s.save()
Expand Down
Loading