Skip to content

Commit

Permalink
Fix Qt QAction import
Browse files Browse the repository at this point in the history
In PySide2 QAction is available under `PySide2.QtWidgets`[1] whereas in
PySide6 it resides under `PySide6.QtGui`[2].

Closes #788

[1]: https://doc.qt.io/qtforpython-5/PySide2/QtWidgets/QAction.html#PySide2.QtWidgets.PySide2.QtWidgets.QAction
[2]: https://doc.qt.io/qtforpython-6/PySide6/QtGui/QAction.html
  • Loading branch information
naglis authored and apyrgio committed May 14, 2024
1 parent 8694fb2 commit 210405b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ since 0.4.1, and this project adheres to [Semantic Versioning](https://semver.or
### Fixed

- Fix a deprecation warning in PySide6, thanks to [@naglis](https://github.com/naglis) ([issue #595](https://github.com/freedomofpress/dangerzone/issues/595))
- Make update notifications work in systems with PySide2, thanks to [@naglis](https://github.com/naglis) ([issue #788](https://github.com/freedomofpress/dangerzone/issues/788))

## Dangerzone 0.6.1

Expand Down
7 changes: 5 additions & 2 deletions dangerzone/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
# FIXME: See https://github.com/freedomofpress/dangerzone/issues/320 for more details.
if typing.TYPE_CHECKING:
from PySide2 import QtCore, QtGui, QtSvg, QtWidgets
from PySide2.QtWidgets import QAction
else:
try:
from PySide6 import QtCore, QtGui, QtSvg, QtWidgets
from PySide6.QtGui import QAction
except ImportError:
from PySide2 import QtCore, QtGui, QtSvg, QtWidgets
from PySide2.QtWidgets import QAction

from .. import errors
from ..document import SAFE_EXTENSION, Document
Expand Down Expand Up @@ -267,7 +270,7 @@ def handle_updates(self, report: UpdateReport) -> None:
)
sep = hamburger_menu.insertSeparator(hamburger_menu.actions()[0])
# FIXME: Add red bubble next to the text.
error_action = QtGui.QAction("Update error", hamburger_menu) # type: ignore [attr-defined]
error_action = QAction("Update error", hamburger_menu)
error_action.setIcon(
QtGui.QIcon(self.load_svg_image("hamburger_menu_update_dot_error.svg"))
)
Expand All @@ -288,7 +291,7 @@ def handle_updates(self, report: UpdateReport) -> None:
)

sep = hamburger_menu.insertSeparator(hamburger_menu.actions()[0])
success_action = QtGui.QAction("New version available", hamburger_menu) # type: ignore [attr-defined]
success_action = QAction("New version available", hamburger_menu)
success_action.setIcon(
QtGui.QIcon(
self.load_svg_image("hamburger_menu_update_dot_available.svg")
Expand Down

0 comments on commit 210405b

Please sign in to comment.