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

SG-30560 Code Cleanup: Removing Qt4/PySide/PyQt4 compatibility in Toolkit #973

Merged
merged 13 commits into from
Jun 20, 2024
Merged
11 changes: 0 additions & 11 deletions python/tank/authentication/login_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,17 +419,6 @@ def _on_site_changed(self):
Called when the user is done editing the site. It will refresh the
list of recent users.
"""

# When running with PySide/Qt4, the editingFinished event is trigger
# even if the text field has not changed.
# This is not the case in PySide2/Qt5 or PySide6/Qt6.
if (
qt_version_tuple[0] == 4
and self._get_current_site() == self.host_selected
):
logger.debug("_on_site_changed - host has not changed")
return

self.ui.login.clear()
self._populate_user_dropdown(self._get_current_site())
self._update_ui_according_to_site_support()
Expand Down
11 changes: 3 additions & 8 deletions python/tank/authentication/resources/login_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ QPushButton.main:pressed
</widget>
</item>
<item>
<widget class="Qt5LikeLineEdit" name="password">
<widget class="QLineEdit" name="password">
<property name="minimumSize">
<size>
<width>308</width>
Expand Down Expand Up @@ -437,7 +437,7 @@ QPushButton.main:pressed
</widget>
</item>
<item>
<widget class="Qt5LikeLineEdit" name="_2fa_code">
<widget class="QLineEdit" name="_2fa_code">
<property name="accessibleName">
<string>2fa code</string>
</property>
Expand Down Expand Up @@ -594,7 +594,7 @@ QPushButton.main:pressed
</widget>
</item>
<item>
<widget class="Qt5LikeLineEdit" name="backup_code">
<widget class="QLineEdit" name="backup_code">
<property name="accessibleName">
<string>backup code</string>
</property>
Expand Down Expand Up @@ -774,11 +774,6 @@ QPushButton.main:pressed
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Qt5LikeLineEdit</class>
<extends>QLineEdit</extends>
<header>.qt5_like_line_edit</header>
</customwidget>
<customwidget>
<class>RecentBox</class>
<extends>QComboBox</extends>
Expand Down
337 changes: 97 additions & 240 deletions python/tank/authentication/sso_saml2/core/sso_saml2_core.py
eduardoChaucaGallegos marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions python/tank/authentication/ui/login_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def setupUi(self, LoginDialog):
self.login = RecentBox(self.credentials)
self.login.setObjectName("login")
self.verticalLayout_7.addWidget(self.login)
self.password = Qt5LikeLineEdit(self.credentials)
self.password = QtGui.QLineEdit(self.credentials)
self.password.setMinimumSize(QtCore.QSize(308, 0))
self.password.setEchoMode(QtGui.QLineEdit.Password)
self.password.setObjectName("password")
Expand Down Expand Up @@ -264,7 +264,7 @@ def setupUi(self, LoginDialog):
self._2fa_message.setMargin(0)
self._2fa_message.setObjectName("_2fa_message")
self.verticalLayout.addWidget(self._2fa_message)
self._2fa_code = Qt5LikeLineEdit(self.widget_2)
self._2fa_code = QtGui.QLineEdit(self.widget_2)
self._2fa_code.setObjectName("_2fa_code")
self.verticalLayout.addWidget(self._2fa_code)
self.invalid_code = QtGui.QLabel(self.widget_2)
Expand Down Expand Up @@ -333,7 +333,7 @@ def setupUi(self, LoginDialog):
self._2fa_message_2.setMargin(0)
self._2fa_message_2.setObjectName("_2fa_message_2")
self.verticalLayout_5.addWidget(self._2fa_message_2)
self.backup_code = Qt5LikeLineEdit(self.widget_4)
self.backup_code = QtGui.QLineEdit(self.widget_4)
self.backup_code.setText("")
self.backup_code.setObjectName("backup_code")
self.verticalLayout_5.addWidget(self.backup_code)
Expand Down Expand Up @@ -435,5 +435,4 @@ def retranslateUi(self, LoginDialog):

from .aspect_preserving_label import AspectPreservingLabel
from .recent_box import RecentBox
from .qt5_like_line_edit import Qt5LikeLineEdit
from . import resources_rc
96 changes: 0 additions & 96 deletions python/tank/authentication/ui/qt5_like_line_edit.py

This file was deleted.

5 changes: 2 additions & 3 deletions python/tank/authentication/ui/recent_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"""

from .qt_abstraction import QtGui
from .qt5_like_line_edit import Qt5LikeLineEdit
from .completion_filter_proxy import CompletionFilterProxy


Expand All @@ -35,8 +34,8 @@ def __init__(self, parent):

self.setEditable(True)

# Using Qt5LikeLineEdit so we have a placeholder even when the line edit is selected.
self.setLineEdit(Qt5LikeLineEdit(self))
# Using QLineEdit so we have a placeholder even when the line edit is selected.
self.setLineEdit(QtGui.QLineEdit(self))

# Create a model sorted alphabetically for the recent items.
self._recent_items_model = QtGui.QStringListModel(self)
Expand Down
104 changes: 1 addition & 103 deletions python/tank/platform/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,17 +642,6 @@ def has_qt6(self):
"""
return self.__has_qt6

@property
def has_qt4(self):
"""
Indicates that the host application has access to Qt 4 and that the ``sgtk.platform.qt`` module
has been populated with the Qt 4 modules and information.

:returns bool: boolean value indicating if Qt 4 is available.
"""
# Check if Qt was imported. Then checks if a Qt4 compatible api is available.
return hasattr(qt, "QtGui") and hasattr(qt.QtGui, "QApplication")

@property
def metrics_dispatch_allowed(self):
"""
Expand Down Expand Up @@ -2215,7 +2204,6 @@ def _initialize_dark_look_and_feel(self):
(for Qt5/Qt6), and set it up with a standard dark palette and supporting
stylesheet.

`Qt4 setStyle documentation <http://doc.qt.io/archives/qt-4.8/qapplication.html#setStyle-2>`_
`Qt5 setStyle documentation <https://doc.qt.io/qt-5.10/qapplication.html#setStyle-1>`_
`Qt6 setStyle documentation <https://doc.qt.io/qt-6/qapplication.html#setStyle-1>`_

Expand All @@ -2227,12 +2215,9 @@ def _initialize_dark_look_and_feel(self):
if self.has_qt5 or self.has_qt6:
self.log_debug("Applying Qt5/Qt6-specific styling (Fusion)...")
self.__initialize_dark_look_and_feel_qt5_qt6()
elif self.has_qt4:
carlos-villavicencio-adsk marked this conversation as resolved.
Show resolved Hide resolved
self.log_debug("Applying Qt4-specific styling...")
self.__initialize_dark_look_and_feel_qt4()
else:
self.log_warning(
"Neither Qt4 or Qt5 is available. Toolkit styling will not be applied."
"Neither Qt5 or Qt6 is available. Toolkit styling will not be applied."
)

def __initialize_dark_look_and_feel_qt5_qt6(self):
Expand Down Expand Up @@ -2415,93 +2400,6 @@ def __initialize_dark_look_and_feel_qt5_qt6(self):
# used with the fusion style.
app.setStyleSheet(".QWidget { font-size: 11px; }")

def __initialize_dark_look_and_feel_qt4(self):
"""
Applies a dark style for Qt4 environments. This sets the "plastique"
style at the application level, and then loads a Maya-2014-like QPalette
to give a consistent dark theme to all widgets owned by the current
application. Lastly, a stylesheet is read from disk and applied.
"""
from .qt import QtGui, QtCore

# Since know we have a QApplication at this point, go ahead and make
# sure the bundled fonts are loaded
self._ensure_core_fonts_loaded()

# initialize our style
QtGui.QApplication.setStyle("plastique")

# Read in a serialized version of a palette
# this file was generated in the following way:
#
# Inside of maya 2014, the following code was executed:
#
# from PySide import QtGui, QtCore
# app = QtCore.QCoreApplication.instance()
# fh = QtCore.QFile("/tmp/palette.dump")
# fh.open(QtCore.QIODevice.WriteOnly)
# out = QtCore.QDataStream(fh)
# out.__lshift__( app.palette() )
# fh.close()
#
# When we load this up in our engine, we will get a look
# and feel similar to that of maya.

try:
# open palette file
palette_file = self.__get_platform_resource_path("dark_palette.qpalette")
fh = QtCore.QFile(palette_file)
fh.open(QtCore.QIODevice.ReadOnly)
file_in = QtCore.QDataStream(fh)

# deserialize the palette
# (store it for GC purposes)
self._dark_palette = QtGui.QPalette()
file_in.__rshift__(self._dark_palette)
fh.close()

# set the std selection bg color to be 'PTR blue'
highlight_color = QtGui.QBrush(
QtGui.QColor(constants.SG_STYLESHEET_CONSTANTS["SG_HIGHLIGHT_COLOR"])
)
self._dark_palette.setBrush(QtGui.QPalette.Highlight, highlight_color)

# update link colors
fg_color = self._dark_palette.color(QtGui.QPalette.Text)
self._dark_palette.setColor(QtGui.QPalette.Link, fg_color)
self._dark_palette.setColor(QtGui.QPalette.LinkVisited, fg_color)

self._dark_palette.setBrush(
QtGui.QPalette.HighlightedText, QtGui.QBrush(QtGui.QColor("#FFFFFF"))
)

# and associate it with the qapplication
QtGui.QApplication.setPalette(self._dark_palette)

except Exception as e:
self.log_error(
"The standard toolkit dark palette could not be set up! The look and feel of your "
"toolkit apps may be sub standard. Please contact support. Details: %s"
% e
)

try:
# read css
css_file = self.__get_platform_resource_path("dark_palette.css")
f = open(css_file)
css_data = f.read()
f.close()
css_data = self._resolve_sg_stylesheet_tokens(css_data)
app = QtCore.QCoreApplication.instance()

app.setStyleSheet(css_data)
except Exception as e:
self.log_error(
"The standard toolkit dark stylesheet could not be set up! The look and feel of your "
"toolkit apps may be sub standard. Please contact support. Details: %s"
% e
)

def _get_standard_qt_stylesheet(self):
"""
**********************************************************************
Expand Down
Loading
Loading