Skip to content

Commit

Permalink
Merge pull request #5542 from OpenShot/fixing-update-action
Browse files Browse the repository at this point in the history
Fix Style of "Update Available" for different themes
  • Loading branch information
jonoomph committed Jun 19, 2024
2 parents 9a5dc2f + 697bb96 commit 54671e2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/themes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def set_toolbar_buttons(self, toolbar, icon_size=24, settings=None):
button_icon = setting.get("icon", None)
button_style = setting.get("style", None)
button_stylesheet = setting.get("stylesheet", None)
button_visible = setting.get("visible", True)
widget = setting.get("widget", None)
expand = setting.get("expand", False)
divide = setting.get("divide", False)
Expand All @@ -130,7 +131,9 @@ def set_toolbar_buttons(self, toolbar, icon_size=24, settings=None):
# Create button from action
if button_action:
toolbar.addAction(button_action)
button_action.setVisible(button_visible)
button = toolbar.widgetForAction(button_action)
button.setObjectName(f"tool-{button_action.objectName()}")
if button_icon:
qicon_instance = self.create_svg_icon(button_icon, qsize_icon)
button_action.setIcon(qicon_instance)
Expand Down
3 changes: 3 additions & 0 deletions src/themes/cosmic/images/warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/themes/cosmic/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ def apply_theme(self):
{"expand": True},
{"action": self.app.window.actionSave, "icon": "themes/cosmic/images/tool-save-project.svg", "style": Qt.ToolButtonTextBesideIcon},
{"action": self.app.window.actionExportVideo, "icon": "themes/cosmic/images/tool-export.svg", "style": Qt.ToolButtonTextBesideIcon, "stylesheet": "QToolButton { background-color: #0078FF; color: #FFFFFF; }"},
{"action": self.app.window.actionUpdate, "icon": "themes/cosmic/images/warning.svg", "visible": False, "style": Qt.ToolButtonTextBesideIcon, "stylesheet": "QToolButton { background-color: #141923; color: #FABE0A; }"}
]
self.set_toolbar_buttons(self.app.window.toolBar, icon_size=20, settings=toolbar_buttons)

Expand Down
26 changes: 16 additions & 10 deletions src/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2942,21 +2942,27 @@ def foundCurrentVersion(self, version):

# Compare versions (alphabetical compare of version strings should work fine)
if info.VERSION < version:
# Add spacer and 'New Version Available' toolbar button (default hidden)
spacer = QWidget(self)
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
self.toolBar.addWidget(spacer)

# Update text for QAction
self.actionUpdate.setVisible(True)
self.actionUpdate.setText(_("Update Available"))
self.actionUpdate.setToolTip(_("Update Available: <b>%s</b>") % version)

# Add update available button (with icon and text)
updateButton = QToolButton()
updateButton.setDefaultAction(self.actionUpdate)
updateButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.toolBar.addWidget(updateButton)
# Add toolbar button for non-cosmic dusk themes
# Cosmic dusk has a hidden toolbar button which is made visible
# by the setVisible() call above this
from themes.manager import ThemeManager, ThemeName
theme = ThemeManager().get_current_theme()
if theme and theme.name != ThemeName.COSMIC.value:
# Add spacer and 'New Version Available' toolbar button (default hidden)
spacer = QWidget(self)
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
self.toolBar.addWidget(spacer)

# Add update available button (with icon and text)
updateButton = QToolButton(self)
updateButton.setDefaultAction(self.actionUpdate)
updateButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.toolBar.addWidget(updateButton)

# Initialize sentry exception tracing (now that we know the current version)
from classes import sentry
Expand Down

0 comments on commit 54671e2

Please sign in to comment.