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

Fix invocation of get font dialog #707

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ritiek
Copy link

@ritiek ritiek commented Dec 23, 2024

Fixes the following traceback when opening the get font dialog through Chat -> Set Font:

Traceback (most recent call last):
  File "/home/username/syncplay/syncplay/ui/GuiConfiguration.py", line 1030, in <lambda>
    self.chatInputFontButton.released.connect(lambda: self.fontDialog("chatInput"))
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/syncplay/syncplay/ui/GuiConfiguration.py", line 1131, in fontDialog
    font.setWeight(self.config[configName + "FontWeight"])
TypeError: 'PySide6.QtGui.QFont.setWeight' called with wrong argument types:
  PySide6.QtGui.QFont.setWeight(float)
Supported signatures:
  PySide6.QtGui.QFont.setWeight(PySide6.QtGui.QFont.Weight)

@Et0h
Copy link
Contributor

Et0h commented Dec 27, 2024

Thanks for trying to fix this issue in GuiConfiguration.py. Before it is accepted it needs to be tested to ensure it works across the variety of set-ups supported by Syncplay

What platform and combinations of Python / PySide have you tested this on?

Also, do the following lines from gui.py also need changing to use setLegacyWeight or are they fine as they are?

font.setWeight(QtGui.QFont.Bold)

font.setWeight(QtGui.QFont.Bold)

@ritiek
Copy link
Author

ritiek commented Dec 28, 2024

What platform and combinations of Python / PySide have you tested this on?

I was able to reproduce this issue on my EndeavourOS Linux with Python 3.12.3 and also on MacOS 14.2 Sonoma with Python 3.13.0, both of which seem to use PySide6 by default when syncplay is installed from source (d6de53e).

Also, do the following lines from gui.py also need changing to use setLegacyWeight or are they fine as they are?

font.setWeight(QtGui.QFont.Bold)

font.setWeight(QtGui.QFont.Bold)

These seem to be fine as they are.

Issue seems to be that setWeight in PySide6 no longer accepts int/float anymore (which is what we've been passing through self.config[configName + "FontWeight"]), and only accepts a Weight object now. Whereas the setLegacyWeight in PySide6 still accepts int/float values.
https://doc.qt.io/qtforpython-6/PySide6/QtGui/QFont.html#PySide6.QtGui.QFont.Weight
https://doc.qt.io/qtforpython-6/PySide6/QtGui/QFont.html#PySide6.QtGui.QFont.setLegacyWeight

I think the change so far will break syncplay environments that depends on PySide2 as PySide2 doesn't have the setLegacyWeight method. PySide2's setWeight accepts int/float, so we can maybe add a check to call the appropriate method depending on what PySide version is being used.
https://doc.qt.io/qtforpython-5/PySide2/QtGui/QFont.html#PySide2.QtGui.PySide2.QtGui.QFont.setWeight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants