Skip to content

Commit

Permalink
Merge pull request #879 from zariiii9003/update_pyside6
Browse files Browse the repository at this point in the history
Use PySide6 Scoped Enums
  • Loading branch information
danielhrisca authored Oct 19, 2023
2 parents b084222 + 71833ef commit 7a83e0a
Show file tree
Hide file tree
Showing 50 changed files with 1,649 additions and 1,459 deletions.
8 changes: 4 additions & 4 deletions src/asammdf/gui/dialogs/advanced_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
self.case_sensitivity_pattern.setCurrentText("Case sensitive")
else:
self.case_sensitivity_pattern.setCurrentText("Case insensitive")
self.raw.setCheckState(QtCore.Qt.Checked if pattern["raw"] else QtCore.Qt.Unchecked)
self.raw.setCheckState(QtCore.Qt.CheckState.Checked if pattern["raw"] else QtCore.Qt.CheckState.Unchecked)
self.name.setText(pattern["name"])
self.ranges = pattern["ranges"]
self.integer_format.setCurrentText(pattern.get("integer_format", "phys"))
Expand All @@ -116,13 +116,13 @@ def __init__(
self.matches.setColumnWidth(self.SourceNameColumn, 170)
self.matches.setColumnWidth(self.SourcePathColumn, 170)

self.setWindowFlag(QtCore.Qt.WindowMaximizeButtonHint, True)
self.setWindowFlag(QtCore.Qt.WindowType.WindowMaximizeButtonHint, True)

self.showMaximized()

def search_text_changed(self):
text = self.search_box.text().strip()
extened_search = self.extended_search.checkState() == QtCore.Qt.Checked
extened_search = self.extended_search.checkState() == QtCore.Qt.CheckState.Checked

if len(text) >= 2:
self.matches.collapseAll()
Expand Down Expand Up @@ -337,7 +337,7 @@ def _apply_pattern(self, event):
"case_sensitive": self.case_sensitivity_pattern.currentText() == "Case sensitive",
"filter_type": self.filter_type.currentText(),
"filter_value": self.filter_value.value(),
"raw": self.raw.checkState() == QtCore.Qt.Checked,
"raw": self.raw.checkState() == QtCore.Qt.CheckState.Checked,
"ranges": self.ranges,
"name": self.name.text().strip(),
"integer_format": self.integer_format.currentText(),
Expand Down
6 changes: 4 additions & 2 deletions src/asammdf/gui/dialogs/bus_database_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(
self.setObjectName("BusDatabaseManagerDialog")
self.resize(404, 294)
self.setSizeGripEnabled(True)
self.setWindowFlags(QtCore.Qt.Window)
self.setWindowFlags(QtCore.Qt.WindowType.Window)
self.verticalLayout = QtWidgets.QVBoxLayout(self)

self._settings = QtCore.QSettings()
Expand All @@ -39,7 +39,9 @@ def __init__(

self.horLayout = QtWidgets.QHBoxLayout(self)

spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
spacer = QtWidgets.QSpacerItem(
40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum
)
self.apply_btn = QtWidgets.QPushButton("Apply")
self.cancel_btn = QtWidgets.QPushButton("Cancel")
self.horLayout.addSpacerItem(spacer)
Expand Down
4 changes: 2 additions & 2 deletions src/asammdf/gui/dialogs/channel_group_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ChannelGroupInfoDialog(QtWidgets.QDialog):
def __init__(self, mdf, group, index, *args, **kwargs):
super().__init__(*args, **kwargs)

self.setWindowFlags(QtCore.Qt.Window)
self.setWindowFlags(QtCore.Qt.WindowType.Window)

layout = QtWidgets.QVBoxLayout()
self.setLayout(layout)
Expand All @@ -20,7 +20,7 @@ def __init__(self, mdf, group, index, *args, **kwargs):
self.setStyleSheet('font: 8pt "Consolas";}')

icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/info.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(QtGui.QPixmap(":/info.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)

self.setWindowIcon(icon)
self.setGeometry(240, 60, 1200, 600)
4 changes: 2 additions & 2 deletions src/asammdf/gui/dialogs/channel_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ChannelInfoDialog(QtWidgets.QDialog):
def __init__(self, channel, *args, **kwargs):
super().__init__(*args, **kwargs)

self.setWindowFlags(QtCore.Qt.Window)
self.setWindowFlags(QtCore.Qt.WindowType.Window)

layout = QtWidgets.QVBoxLayout()
self.setLayout(layout)
Expand All @@ -20,7 +20,7 @@ def __init__(self, channel, *args, **kwargs):
self.setStyleSheet('font: 8pt "Consolas";}')

icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/info.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(QtGui.QPixmap(":/info.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)

self.setWindowIcon(icon)
self.setGeometry(240, 60, 1200, 600)
4 changes: 2 additions & 2 deletions src/asammdf/gui/dialogs/conversion_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def __init__(self, channel_name="", conversion=None, *args, **kwargs):

self.pressed_button = None

self.setWindowFlag(QtCore.Qt.WindowMinimizeButtonHint, True)
self.setWindowFlag(QtCore.Qt.WindowMaximizeButtonHint, True)
self.setWindowFlag(QtCore.Qt.WindowType.WindowMinimizeButtonHint, True)
self.setWindowFlag(QtCore.Qt.WindowType.WindowMaximizeButtonHint, True)

def apply(self, event):
if self.tabs.currentIndex() == 1:
Expand Down
26 changes: 15 additions & 11 deletions src/asammdf/gui/dialogs/define_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ def __init__(
super().__init__(*args, **kwargs)
self.setupUi(self)

self.setWindowFlags(QtCore.Qt.WindowMinMaxButtonsHint | self.windowFlags())
self.setWindowFlags(QtCore.Qt.WindowType.WindowMinMaxButtonsHint | self.windowFlags())

self.mdf = mdf
self.result = None
self.pressed_button = None
self.origin_uuid = origin_uuid or (mdf.uuid if mdf else os.urandom(6).hex())

self.arg_widgets = []
spacer = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
spacer = QtWidgets.QSpacerItem(
20, 20, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding
)
self.arg_layout.addItem(spacer, len(self.arg_widgets) + 2, 0)
self.arg_widgets.append(spacer)

Expand Down Expand Up @@ -174,7 +176,7 @@ def function_changed(self, *args):
func = locals()[name]

icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/search.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(QtGui.QPixmap(":/search.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)

parameters = list(inspect.signature(func).parameters)[:-1]
for i, arg_name in enumerate(parameters, 2):
Expand All @@ -189,7 +191,9 @@ def function_changed(self, *args):

self.arg_widgets.append((label, text_edit, button))

spacer = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
spacer = QtWidgets.QSpacerItem(
20, 20, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding
)

self.arg_layout.addItem(spacer, len(self.arg_widgets) + 2, 0)
self.arg_widgets.append(spacer)
Expand Down Expand Up @@ -239,19 +243,19 @@ def show_definition(self, *args):
PythonHighlighter(info.document())
info.setReadOnly(True)
info.setLineWrapMode(info.NoWrap)
info.setWindowFlags(QtCore.Qt.WindowMinMaxButtonsHint | info.windowFlags())
info.setWindowFlags(QtCore.Qt.WindowType.WindowMinMaxButtonsHint | info.windowFlags())
info.setWindowTitle(f"{function} definition")
info.setWindowModality(QtCore.Qt.ApplicationModal)
info.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)

p = info.palette()
for active in (QtGui.QPalette.Active, QtGui.QPalette.Inactive):
p.setColor(active, QtGui.QPalette.Base, QtGui.QColor("#131314"))
p.setColor(active, QtGui.QPalette.WindowText, QtGui.QColor("#ffffff"))
p.setColor(active, QtGui.QPalette.Text, QtGui.QColor("#ffffff"))
for active in (QtGui.QPalette.ColorGroup.Active, QtGui.QPalette.ColorGroup.Inactive):
p.setColor(active, QtGui.QPalette.ColorRole.Base, QtGui.QColor("#131314"))
p.setColor(active, QtGui.QPalette.ColorRole.WindowText, QtGui.QColor("#ffffff"))
p.setColor(active, QtGui.QPalette.ColorRole.Text, QtGui.QColor("#ffffff"))
info.setPalette(p)

icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/info.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(QtGui.QPixmap(":/info.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
info.setWindowIcon(icon)

info.show()
Expand Down
2 changes: 1 addition & 1 deletion src/asammdf/gui/dialogs/dependencies_dlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _setup_widgets(self) -> None:
self.setMinimumHeight(500)

icon = QIcon()
icon.addFile(":/asammdf.png", QSize(), QIcon.Normal, QIcon.Off)
icon.addFile(":/asammdf.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.setWindowIcon(icon)

headers = ["package", "required", "installed", "summary", "url"]
Expand Down
4 changes: 2 additions & 2 deletions src/asammdf/gui/dialogs/error_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, title, message, trace, *args, **kwargs):
self.trace.setReadOnly(True)

icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/error.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(QtGui.QPixmap(":/error.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)

self.setWindowIcon(icon)

Expand Down Expand Up @@ -80,7 +80,7 @@ def count_down(self):
self.close()

def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_F1:
if event.key() == QtCore.Qt.Key.Key_F1:
self.timer.stop()
self.status.clear()
else:
Expand Down
6 changes: 4 additions & 2 deletions src/asammdf/gui/dialogs/functions_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ def __init__(
self.setObjectName("FunctionsManagerDialog")
self.resize(404, 294)
self.setSizeGripEnabled(True)
self.setWindowFlags(QtCore.Qt.Window)
self.setWindowFlags(QtCore.Qt.WindowType.Window)
self.verticalLayout = QtWidgets.QVBoxLayout(self)
self.widget = FunctionsManager(deepcopy(definitions), channels, selected_definition)

self.verticalLayout.addWidget(self.widget)

self.horLayout = QtWidgets.QHBoxLayout(self)

spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
spacer = QtWidgets.QSpacerItem(
40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum
)
self.apply_btn = QtWidgets.QPushButton("Apply")
self.cancel_btn = QtWidgets.QPushButton("Cancel")
self.horLayout.addSpacerItem(spacer)
Expand Down
32 changes: 16 additions & 16 deletions src/asammdf/gui/dialogs/messagebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, *args, **kwargs):
self.timer.start(1000)

def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_F1:
if event.key() == QtCore.Qt.Key.Key_F1:
self.timer.stop()
self.setText(self.original_text)
else:
Expand Down Expand Up @@ -78,9 +78,9 @@ def about(
parent,
title,
text,
buttons=QtWidgets.QMessageBox.Ok,
defaultButton=QtWidgets.QMessageBox.Ok,
escapeButton=QtWidgets.QMessageBox.Ok,
buttons=QtWidgets.QMessageBox.StandardButton.Ok,
defaultButton=QtWidgets.QMessageBox.StandardButton.Ok,
escapeButton=QtWidgets.QMessageBox.StandardButton.Ok,
timeout=DEFAULT_TIMEOUT,
):
msg = cls(
Expand All @@ -101,9 +101,9 @@ def critical(
parent,
title,
text,
buttons=QtWidgets.QMessageBox.Ok,
defaultButton=QtWidgets.QMessageBox.Ok,
escapeButton=QtWidgets.QMessageBox.Ok,
buttons=QtWidgets.QMessageBox.StandardButton.Ok,
defaultButton=QtWidgets.QMessageBox.StandardButton.Ok,
escapeButton=QtWidgets.QMessageBox.StandardButton.Ok,
timeout=DEFAULT_TIMEOUT,
):
msg = cls(
Expand All @@ -125,9 +125,9 @@ def information(
parent,
title,
text,
buttons=QtWidgets.QMessageBox.Ok,
defaultButton=QtWidgets.QMessageBox.Ok,
escapeButton=QtWidgets.QMessageBox.Ok,
buttons=QtWidgets.QMessageBox.StandardButton.Ok,
defaultButton=QtWidgets.QMessageBox.StandardButton.Ok,
escapeButton=QtWidgets.QMessageBox.StandardButton.Ok,
timeout=DEFAULT_TIMEOUT,
):
msg = cls(
Expand All @@ -148,9 +148,9 @@ def question(
parent,
title,
text,
buttons=QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
defaultButton=QtWidgets.QMessageBox.No,
escapeButton=QtWidgets.QMessageBox.No,
buttons=QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No,
defaultButton=QtWidgets.QMessageBox.StandardButton.No,
escapeButton=QtWidgets.QMessageBox.StandardButton.No,
timeout=DEFAULT_TIMEOUT,
):
msg = cls(
Expand All @@ -171,9 +171,9 @@ def warning(
parent,
title,
text,
buttons=QtWidgets.QMessageBox.Ok,
defaultButton=QtWidgets.QMessageBox.Ok,
escapeButton=QtWidgets.QMessageBox.Ok,
buttons=QtWidgets.QMessageBox.StandardButton.Ok,
defaultButton=QtWidgets.QMessageBox.StandardButton.Ok,
escapeButton=QtWidgets.QMessageBox.StandardButton.Ok,
timeout=DEFAULT_TIMEOUT,
):
msg = cls(
Expand Down
8 changes: 6 additions & 2 deletions src/asammdf/gui/dialogs/multi_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ class MultiSearch(Ui_MultiSearchDialog, QtWidgets.QDialog):
def __init__(self, channels_dbs, measurements, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setupUi(self)
self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowMinMaxButtonsHint)
self.setWindowFlags(
self.windowFlags()
| QtCore.Qt.WindowType.WindowSystemMenuHint
| QtCore.Qt.WindowType.WindowMinMaxButtonsHint
)

for widget in (
self.apply_btn,
Expand All @@ -30,7 +34,7 @@ def __init__(self, channels_dbs, measurements, *args, **kwargs):
self.channels_dbs = channels_dbs
self.measurements = measurements

self.matches.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.matches.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection)

self.apply_btn.clicked.connect(self._apply)
self.add_btn.clicked.connect(self._add)
Expand Down
6 changes: 5 additions & 1 deletion src/asammdf/gui/dialogs/range_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ class RangeEditor(Ui_RangeDialog, QtWidgets.QDialog):
def __init__(self, name, unit="", ranges=None, brush=False, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setupUi(self)
self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowMinMaxButtonsHint)
self.setWindowFlags(
self.windowFlags()
| QtCore.Qt.WindowType.WindowSystemMenuHint
| QtCore.Qt.WindowType.WindowMinMaxButtonsHint
)

self.name = name
self.unit = unit
Expand Down
6 changes: 3 additions & 3 deletions src/asammdf/gui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def close(self):
self.destroy()

def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Escape and event.modifiers() == QtCore.Qt.NoModifier:
if event.key() == QtCore.Qt.Key.Key_Escape and event.modifiers() == QtCore.Qt.KeyboardModifier.NoModifier:
self.close()
else:
super().keyPressEvent(event)
Expand All @@ -324,12 +324,12 @@ def keyPressEvent(self, event):
def setup_progress(parent, title="", message="", icon_name="", autoclose=False):
progress = ProgressDialog(message, "Cancel", 0, 100, parent)

progress.setWindowModality(QtCore.Qt.ApplicationModal)
progress.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
progress.setCancelButton(None)
progress.setAutoClose(autoclose)
progress.setWindowTitle(title)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(f":/{icon_name}.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(QtGui.QPixmap(f":/{icon_name}.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
progress.setWindowIcon(icon)
progress.setMinimumWidth(600)

Expand Down
2 changes: 1 addition & 1 deletion src/asammdf/gui/widgets/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def extract(self, event=None):
self,
"Attachment password",
"The attachment is encrypted. Please provide the password:",
QtWidgets.QLineEdit.Password,
QtWidgets.QLineEdit.EchoMode.Password,
)
if ok and text:
password = text
Expand Down
Loading

0 comments on commit 7a83e0a

Please sign in to comment.