Skip to content

Commit 244dfc0

Browse files
feat: make plugin compliant with Qt6
1 parent f8a65b0 commit 244dfc0

File tree

8 files changed

+37
-31
lines changed

8 files changed

+37
-31
lines changed

qgist/msg.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
# IMPORT (External Dependencies)
2929
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3030

31-
from PyQt5.Qt import QWidget
32-
from PyQt5.QtWidgets import QMessageBox
31+
from qgis.PyQt.QtWidgets import QMessageBox, QWidget
3332

3433

3534
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -44,29 +43,36 @@
4443
# ROUTINES
4544
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4645

47-
def msg_critical(exception, widget = None):
4846

49-
_msg('critical', translate('global', 'Critical error'), exception, widget)
47+
def msg_critical(exception, widget=None):
5048

51-
def msg_warning(exception, widget = None):
49+
_msg("critical", translate("global", "Critical error"), exception, widget)
5250

53-
_msg('warning', translate('global', 'Warning'), exception, widget)
5451

55-
def _msg(msg_type, msg_title, exception, widget = None):
52+
def msg_warning(exception, widget=None):
53+
54+
_msg("warning", translate("global", "Warning"), exception, widget)
55+
56+
57+
def _msg(msg_type, msg_title, exception, widget=None):
5658

5759
if not isinstance(exception, Exception):
58-
raise QgistTypeError(translate('global', '"exception" must be of type Exception. (msg)'))
60+
raise QgistTypeError(
61+
translate("global", '"exception" must be of type Exception. (msg)')
62+
)
5963
if not isinstance(widget, QWidget) and widget is not None:
60-
raise QgistTypeError(translate('global', '"widget" must be of type QWidget or None. (msg)'))
64+
raise QgistTypeError(
65+
translate("global", '"widget" must be of type QWidget or None. (msg)')
66+
)
6167

6268
if len(exception.args) == 0:
63-
msg = translate('global', 'Internal error. No description can be provided. Please file a bug. (msg)')
69+
msg = translate(
70+
"global",
71+
"Internal error. No description can be provided. Please file a bug. (msg)",
72+
)
6473
else:
6574
msg = str(exception.args[0])
6675

6776
getattr(QMessageBox, msg_type)(
68-
widget,
69-
msg_title,
70-
msg,
71-
QMessageBox.Ok
72-
)
77+
widget, msg_title, msg, QMessageBox.StandardButton.Ok
78+
)

qgist/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
# IMPORT (External Dependencies)
3636
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3737

38-
from PyQt5.QtCore import (
38+
from qgis.PyQt.QtCore import (
3939
QCoreApplication,
4040
QSettings,
4141
QTranslator,
4242
)
43-
from PyQt5.QtWidgets import QApplication
43+
from qgis.PyQt.QtWidgets import QApplication
4444

4545

4646
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

qgist/workbench/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
# IMPORT (External Dependencies)
3737
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3838

39-
from PyQt5.QtGui import (
39+
from qgis.PyQt.QtGui import (
4040
QIcon,
4141
)
42-
from PyQt5.QtWidgets import (
42+
from qgis.PyQt.QtWidgets import (
4343
QAction,
4444
QComboBox,
4545
QHBoxLayout,
@@ -263,7 +263,7 @@ def _open_manager(self):
263263
self._ui_dict['combobox_workbench'].setEnabled(True)
264264

265265
try:
266-
manager.exec_()
266+
manager.exec()
267267
finally:
268268
self._ui_dict['combobox_workbench'].setEnabled(True)
269269

qgist/workbench/dtype_fsm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# IMPORT (External Dependencies)
2929
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3030

31-
from PyQt5.QtWidgets import (
31+
from qgis.PyQt.QtWidgets import (
3232
QMainWindow,
3333
)
3434

qgist/workbench/dtype_uielement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# IMPORT (External Dependencies)
2929
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3030

31-
from PyQt5.QtWidgets import (
31+
from qgis.PyQt.QtWidgets import (
3232
QDockWidget,
3333
QToolBar,
3434
)

qgist/workbench/dtype_workbench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# IMPORT (External Dependencies)
3636
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3737

38-
from PyQt5.QtWidgets import (
38+
from qgis.PyQt.QtWidgets import (
3939
QDockWidget,
4040
QMainWindow,
4141
QToolBar,

qgist/workbench/ui_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
# IMPORT (External Dependencies)
3636
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3737

38-
from PyQt5.QtCore import (
38+
from qgis.PyQt.QtCore import (
3939
Qt,
4040
)
41-
from PyQt5.QtWidgets import (
41+
from qgis.PyQt.QtWidgets import (
4242
QCheckBox,
4343
QComboBox,
4444
QFileDialog,
@@ -117,7 +117,7 @@ def _connect_ui(self):
117117
self._ui_dict['checkbox_unnamedwarning'].setEnabled(False)
118118
else:
119119
self._ui_dict['checkbox_unnamedwarning'].setCheckState(
120-
Qt.Checked if self._fsm.config.get('show_unnamed_warning', False) else Qt.Unchecked
120+
Qt.CheckState.Checked if self._fsm.config.get('show_unnamed_warning', False) else Qt.CheckState.Unchecked
121121
)
122122
def change_unnamedwarning():
123123
self._fsm.config['show_unnamed_warning'] = bool(self._ui_dict['checkbox_unnamedwarning'].isChecked())
@@ -286,7 +286,7 @@ def make_widgetitems(source, target):
286286
INTERNAL = uielement.name_internal,
287287
)
288288
)
289-
item_checkbox.setCheckState(Qt.Checked if uielement.visibility else Qt.Unchecked)
289+
item_checkbox.setCheckState(Qt.CheckState.Checked if uielement.visibility else Qt.CheckState.Unchecked)
290290
item_checkbox.setEnabled(uielement.existence)
291291
item_checkbox.stateChanged.connect(make_wrapper(item_checkbox, uielement.setVisible))
292292
target.setItemWidget(QListWidgetItem(target), item_checkbox)

qgist/workbench/ui_manager_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
# IMPORT (External Dependencies)
3636
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3737

38-
from PyQt5.QtCore import (
38+
from qgis.PyQt.QtCore import (
3939
QSize,
4040
Qt,
4141
)
42-
from PyQt5.QtGui import (
42+
from qgis.PyQt.QtGui import (
4343
QIcon,
4444
)
45-
from PyQt5.QtWidgets import (
45+
from qgis.PyQt.QtWidgets import (
4646
QCheckBox,
4747
QDialog,
4848
QHBoxLayout,
@@ -123,7 +123,7 @@ def _init_dialogtoolbar(ui_dict, toolbar_layout, plugin_root_fld):
123123
)))
124124
toolbutton.setIconSize(QSize(24, 24)) # TODO get icon size from QGis!!!
125125
toolbutton.setAutoRaise(True)
126-
toolbutton.setFocusPolicy(Qt.NoFocus)
126+
toolbutton.setFocusPolicy(Qt.FocusPolicy.NoFocus)
127127

128128
ui_dict['toolbutton_{NAME:s}'.format(NAME = name)] = toolbutton
129129

0 commit comments

Comments
 (0)