Skip to content

Commit

Permalink
Merge pull request #5574 from OpenShot/delay-show-main-window
Browse files Browse the repository at this point in the history
Delay Showing Main Windows (until after Theme is applied)
  • Loading branch information
jonoomph authored Jul 8, 2024
2 parents db38836 + 3b895a2 commit 06e6d0d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
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

0 comments on commit 06e6d0d

Please sign in to comment.