Skip to content

Commit e4101e3

Browse files
authored
Merge pull request #208 from geotribu/packaging/make-qtribu-compatible-with-qt6
Packaging : make QTribu compatible with qt6
2 parents 8adde2d + 639a709 commit e4101e3

22 files changed

+286
-177
lines changed

.github/workflows/linter.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,29 @@ jobs:
4545
flake8 ${{ env.PROJECT_FOLDER }} --count --select=E9,F63,F7,F82 --show-source --statistics
4646
# exit-zero treats all errors as warnings.
4747
flake8 ${{ env.PROJECT_FOLDER }} --count --exit-zero --statistics
48+
49+
qt6-check:
50+
name: PyQt6 6️⃣
51+
runs-on: ubuntu-latest
52+
container:
53+
image: registry.gitlab.com/oslandia/qgis/pyqgis-4-checker/pyqgis-qt-checker:latest
54+
volumes:
55+
- /tmp/.X11-unix:/tmp/.X11-unix
56+
- ${{ github.workspace }}:/home/pyqgisdev/
57+
options: --user root
58+
steps:
59+
- name: Get source code
60+
uses: actions/checkout@v4
61+
62+
- name: Check PyQt5 to PyQt6 compatibility.
63+
run: |
64+
pyqt5_to_pyqt6.py --dry_run ${{ env.PROJECT_FOLDER }}/
65+
pyqt5_to_pyqt6.py --logfile pyqt6_checker.log ${{ env.PROJECT_FOLDER }}/
66+
67+
- name: Upload script report if script fails
68+
uses: actions/upload-artifact@v4
69+
if: ${{ failure() }}
70+
with:
71+
name: pyqt6-checker-error-report
72+
path: pyqt6_checker.log
73+
retention-days: 7

CHANGELOG.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,39 @@ Unreleased
1414

1515
### Features and enhancements 🎉
1616

17-
* feature(qchat): auto-reconnect to last room when QGIS starts by @gounux in https://github.com/geotribu/qtribu/pull/209
18-
* feature(qchat): handle users registration by @gounux in https://github.com/geotribu/qtribu/pull/200
19-
* feature(qchat): like message by @gounux in https://github.com/geotribu/qtribu/pull/210
20-
* feature(qchat): re-arrange websocket message to allow image communications by @gounux in https://github.com/geotribu/qtribu/pull/211
21-
* refactor(qchat): use custom tree widget items by @gounux in https://github.com/geotribu/qtribu/pull/212
22-
* feature(qchat): send a geojson layer through websocket by @gounux in https://github.com/geotribu/qtribu/pull/213
23-
* refactor(qchat): use self.settings instead of PlgOptionsManager by @gounux in https://github.com/geotribu/qtribu/pull/217
24-
* ui(qchat): vertically optimize the QChat widget by @gounux in https://github.com/geotribu/qtribu/pull/216
25-
* feature(qchat): send and receive a crs message by @gounux in https://github.com/geotribu/qtribu/pull/219
26-
* feature(qchat): send and receive a bbox message by @gounux in https://github.com/geotribu/qtribu/pull/220
27-
* trad(qchat): add QChat fr translations by @gounux in https://github.com/geotribu/qtribu/pull/222
28-
* ui(qchat): set fixed height for an image chat item by @gounux in https://github.com/geotribu/qtribu/pull/221
17+
* feature(qchat): auto-reconnect to last room when QGIS starts by @gounux in <https://github.com/geotribu/qtribu/pull/209>
18+
* feature(qchat): handle users registration by @gounux in <https://github.com/geotribu/qtribu/pull/200>
19+
* feature(qchat): like message by @gounux in <https://github.com/geotribu/qtribu/pull/210>
20+
* feature(qchat): re-arrange websocket message to allow image communications by @gounux in <https://github.com/geotribu/qtribu/pull/211>
21+
* refactor(qchat): use custom tree widget items by @gounux in <https://github.com/geotribu/qtribu/pull/212>
22+
* feature(qchat): send a geojson layer through websocket by @gounux in <https://github.com/geotribu/qtribu/pull/213>
23+
* refactor(qchat): use self.settings instead of PlgOptionsManager by @gounux in <https://github.com/geotribu/qtribu/pull/217>
24+
* ui(qchat): vertically optimize the QChat widget by @gounux in <https://github.com/geotribu/qtribu/pull/216>
25+
* feature(qchat): send and receive a crs message by @gounux in <https://github.com/geotribu/qtribu/pull/219>
26+
* feature(qchat): send and receive a bbox message by @gounux in <https://github.com/geotribu/qtribu/pull/220>
27+
* trad(qchat): add QChat fr translations by @gounux in <https://github.com/geotribu/qtribu/pull/222>
28+
* ui(qchat): set fixed height for an image chat item by @gounux in <https://github.com/geotribu/qtribu/pull/221>
2929

3030
### Bugs fixes 🐛
3131

32-
* fix(qchat): add type key check when receiving a message by @gounux in https://github.com/geotribu/qtribu/pull/218
32+
* fix(qchat): add type key check when receiving a message by @gounux in <https://github.com/geotribu/qtribu/pull/218>
33+
34+
## 1.0.0 - 2024-10-11
35+
36+
### Bugs fixes 🐛
37+
38+
* fix(qchat): use mp3 instead of ogg by @gounux in <https://github.com/geotribu/qtribu/pull/198>
39+
40+
### Features and enhancements 🎉
41+
42+
* improve(qchat): play sound only on mention by @gounux in <https://github.com/geotribu/qtribu/pull/199>
43+
* update(ui): move misc groupbox to bottom in settings dialog by @Guts in <https://github.com/geotribu/qtribu/pull/205>
44+
* UI: display avatars right into combobox by @Guts in <https://github.com/geotribu/qtribu/pull/206>
45+
* update(i18n): refine translation to prepare next stable release by @Guts in <https://github.com/geotribu/qtribu/pull/207>
46+
47+
### Tooling 🔧
48+
49+
* update(ci): rm deprecated `set-output` command by @Guts in <https://github.com/geotribu/qtribu/pull/203>
3350

3451
## 1.0.0 - 2024-10-11
3552

qtribu/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def plugin_metadata_as_dict() -> dict:
4444
Returns:
4545
dict: dict of dicts.
4646
"""
47-
config = ConfigParser()
47+
config = ConfigParser(interpolation=None)
4848
if PLG_METADATA_FILE.is_file():
4949
config.read(PLG_METADATA_FILE.resolve(), encoding="UTF-8")
5050
return {s: dict(config.items(s)) for s in config.sections()}

qtribu/gui/dck_qchat.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from typing import Optional
99

1010
# PyQGIS
11-
from PyQt5 import QtWebSockets # noqa QGS103
1211
from qgis.core import Qgis, QgsApplication, QgsJsonExporter, QgsMapLayer, QgsProject
1312
from qgis.gui import QgisInterface, QgsDockWidget
1413
from qgis.PyQt import uic
@@ -23,6 +22,7 @@
2322
QWidget,
2423
)
2524

25+
# plugin
2626
from qtribu.__about__ import __title__
2727
from qtribu.constants import (
2828
ADMIN_MESSAGES_NICKNAME,
@@ -64,8 +64,6 @@
6464
)
6565
from qtribu.logic.qchat_websocket import QChatWebsocket
6666
from qtribu.tasks.dizzy import DizzyTask
67-
68-
# plugin
6967
from qtribu.toolbelt import PlgLogger, PlgOptionsManager
7068
from qtribu.toolbelt.commons import open_url_in_webviewer, play_resource_sound
7169
from qtribu.toolbelt.preferences import PlgSettingsStructure
@@ -88,8 +86,8 @@ class QChatWidget(QgsDockWidget):
8886
def __init__(
8987
self,
9088
iface: QgisInterface,
91-
parent: QWidget = None,
92-
auto_reconnect_room: str = None,
89+
parent: Optional[QWidget] = None,
90+
auto_reconnect_room: Optional[str] = None,
9391
):
9492
"""QWidget to see and post messages on chat
9593
@@ -137,7 +135,7 @@ def __init__(
137135
)
138136
self.twg_chat.itemClicked.connect(self.on_message_clicked)
139137
self.twg_chat.itemDoubleClicked.connect(self.on_message_double_clicked)
140-
self.twg_chat.setContextMenuPolicy(Qt.CustomContextMenu)
138+
self.twg_chat.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
141139
self.twg_chat.customContextMenuRequested.connect(
142140
self.on_custom_context_menu_requested
143141
)
@@ -260,7 +258,7 @@ def on_widget_opened(self) -> None:
260258
self.cbb_room.addItem(room)
261259
except Exception as exc:
262260
self.iface.messageBar().pushCritical(self.tr("QChat error"), str(exc))
263-
self.log(message=str(exc), log_level=Qgis.Critical)
261+
self.log(message=str(exc), log_level=Qgis.MessageLevel.Critical)
264262
finally:
265263
self.current_room = MARKER_VALUE
266264

@@ -304,7 +302,7 @@ def on_rules_button_clicked(self) -> None:
304302
)
305303
except Exception as exc:
306304
self.iface.messageBar().pushCritical(self.tr("QChat error"), str(exc))
307-
self.log(message=str(exc), log_level=Qgis.Critical)
305+
self.log(message=str(exc), log_level=Qgis.MessageLevel.Critical)
308306

309307
def on_status_button_clicked(self) -> None:
310308
"""
@@ -330,7 +328,7 @@ def on_status_button_clicked(self) -> None:
330328
)
331329
QMessageBox.information(self, self.tr("QChat instance status"), text)
332330
except Exception as exc:
333-
self.log(message=str(exc), log_level=Qgis.Critical)
331+
self.log(message=str(exc), log_level=Qgis.MessageLevel.Critical)
334332

335333
def on_settings_button_clicked(self) -> None:
336334
"""
@@ -367,7 +365,7 @@ def on_room_changed(self) -> None:
367365
message=self.tr(
368366
"QChat nickname not set or too short (between {min} and {max} characters). Please open settings to fix it."
369367
).format(min=self.min_author_length, max=self.max_author_length),
370-
log_level=Qgis.Warning,
368+
log_level=Qgis.MessageLevel.Warning,
371369
push=self.settings.notify_push_info,
372370
duration=self.settings.notify_push_duration,
373371
button=True,
@@ -410,7 +408,7 @@ def on_connect_button_clicked(self) -> None:
410408
message=self.tr(
411409
"QChat nickname not set or too short (between {min} and {max} characters). Please open settings to fix it."
412410
).format(min=self.min_author_length, max=self.max_author_length),
413-
log_level=Qgis.Warning,
411+
log_level=Qgis.MessageLevel.Warning,
414412
push=self.settings.notify_push_info,
415413
duration=self.settings.notify_push_duration,
416414
button=True,
@@ -493,7 +491,7 @@ def on_ws_error(self, error_code: int) -> None:
493491
self.add_admin_message(self.qchat_ws.error_string())
494492
self.log(
495493
message=f"{error_code}: {self.qchat_ws.error_string()}",
496-
log_level=Qgis.Critical,
494+
log_level=Qgis.MessageLevel.Critical,
497495
)
498496

499497
# region websocket message received
@@ -504,7 +502,7 @@ def on_uncompliant_message_received(self, message: QChatUncompliantMessage) -> N
504502
reason=message.reason
505503
),
506504
application=self.tr("QChat"),
507-
log_level=Qgis.Critical,
505+
log_level=Qgis.MessageLevel.Critical,
508506
push=self.settings.notify_push_info,
509507
duration=self.settings.notify_push_duration,
510508
)
@@ -534,7 +532,7 @@ def on_text_message_received(self, message: QChatTextMessage) -> None:
534532
"You were mentionned by {sender}: {message}"
535533
).format(sender=message.author, message=message.text),
536534
application=self.tr("QChat"),
537-
log_level=Qgis.Info,
535+
log_level=Qgis.MessageLevel.Info,
538536
push=self.settings.notify_push_info,
539537
duration=self.settings.notify_push_duration,
540538
)
@@ -602,7 +600,7 @@ def on_like_message_received(self, message: QChatLikeMessage) -> None:
602600
liker_author=message.liker_author, message=message.message
603601
),
604602
application=self.tr("QChat"),
605-
log_level=Qgis.Success,
603+
log_level=Qgis.MessageLevel.Success,
606604
push=self.settings.notify_push_info,
607605
duration=self.settings.notify_push_duration,
608606
)
@@ -777,7 +775,7 @@ def on_list_users_button_clicked(self) -> None:
777775
)
778776
except Exception as exc:
779777
self.iface.messageBar().pushCritical(self.tr("QChat error"), str(exc))
780-
self.log(message=str(exc), log_level=Qgis.Critical)
778+
self.log(message=str(exc), log_level=Qgis.MessageLevel.Critical)
781779

782780
def on_clear_chat_button_clicked(self) -> None:
783781
"""
@@ -798,7 +796,7 @@ def on_send_button_clicked(self) -> None:
798796
if not nickname:
799797
self.log(
800798
message=self.tr("Nickname not set : please open settings and set it"),
801-
log_level=Qgis.Warning,
799+
log_level=Qgis.MessageLevel.Warning,
802800
push=self.settings.notify_push_info,
803801
duration=self.settings.notify_push_duration,
804802
button=True,
@@ -812,7 +810,7 @@ def on_send_button_clicked(self) -> None:
812810
message=self.tr(
813811
"Nickname too short: must be at least 3 characters. Please open settings and set it"
814812
),
815-
log_level=Qgis.Warning,
813+
log_level=Qgis.MessageLevel.Warning,
816814
push=self.settings.notify_push_info,
817815
duration=self.settings.notify_push_duration,
818816
button=True,
@@ -950,7 +948,7 @@ def check_cheatcode(self, text: str) -> bool:
950948
self.log(
951949
message=self.tr("Your QGIS Pro license is about to expire"),
952950
application="QGIS Pro",
953-
log_level=Qgis.Warning,
951+
log_level=Qgis.MessageLevel.Warning,
954952
push=self.settings.notify_push_info,
955953
duration=self.settings.notify_push_duration,
956954
button=True,
@@ -968,7 +966,7 @@ def check_cheatcode(self, text: str) -> bool:
968966
def on_renew_clicked(self) -> None:
969967
msg_box = QMessageBox()
970968
msg_box.setWindowTitle("QGIS")
971-
msg_box.setIcon(QMessageBox.Information)
969+
msg_box.setIcon(QMessageBox.Icon.Information)
972970
msg_box.setText(
973971
self.tr(
974972
"""No... it was a joke!
@@ -980,9 +978,9 @@ def on_renew_clicked(self) -> None:
980978
"""
981979
)
982980
)
983-
msg_box.setStandardButtons(QMessageBox.Yes)
981+
msg_box.setStandardButtons(QMessageBox.StandardButton.Yes)
984982
return_value = msg_box.exec()
985-
if return_value == QMessageBox.Yes:
983+
if return_value == QMessageBox.StandardButton.Yes:
986984
open_url_in_webviewer("https://qgis.org/funding/donate/", "qgis.org")
987985

988986
def generate_qaction_send_geojson_layer(self, menu: QMenu) -> None:
@@ -1002,7 +1000,7 @@ def on_send_layer_to_qchat(self) -> None:
10021000
"Not connected to QChat. Please connect to a room first"
10031001
),
10041002
application="QChat",
1005-
log_level=Qgis.Critical,
1003+
log_level=Qgis.MessageLevel.Critical,
10061004
push=self.settings.notify_push_info,
10071005
duration=self.settings.notify_push_duration,
10081006
)
@@ -1012,16 +1010,16 @@ def on_send_layer_to_qchat(self) -> None:
10121010
self.log(
10131011
message=self.tr("No active layer in current QGIS project"),
10141012
application=self.tr("QChat"),
1015-
log_level=Qgis.Critical,
1013+
log_level=Qgis.MessageLevel.Critical,
10161014
push=self.settings.notify_push_info,
10171015
duration=self.settings.notify_push_duration,
10181016
)
10191017
return
1020-
if layer.type() != QgsMapLayer.VectorLayer:
1018+
if layer.type() != QgsMapLayer.LayerType.VectorLayer:
10211019
self.log(
10221020
message=self.tr("Only vector layers can be sent on QChat"),
10231021
application=self.tr("QChat"),
1024-
log_level=Qgis.Critical,
1022+
log_level=Qgis.MessageLevel.Critical,
10251023
push=self.settings.notify_push_info,
10261024
duration=self.settings.notify_push_duration,
10271025
)

qtribu/gui/dlg_settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def load_settings(self) -> None:
155155

156156
# qchat
157157
instance_index = self.cbb_qchat_instance_uri.findText(
158-
settings.qchat_instance_uri, Qt.MatchFixedString
158+
settings.qchat_instance_uri, Qt.MatchFlag.MatchFixedString
159159
)
160160
if instance_index >= 0:
161161
self.cbb_qchat_instance_uri.setCurrentIndex(instance_index)
@@ -171,7 +171,7 @@ def load_settings(self) -> None:
171171
self.ckb_play_sounds.setChecked(settings.qchat_play_sounds)
172172
self.hsl_sound_volume.setValue(settings.qchat_sound_volume)
173173
beep_index = self.cbb_ring_tone.findText(
174-
settings.qchat_ring_tone, Qt.MatchFixedString
174+
settings.qchat_ring_tone, Qt.MatchFlag.MatchFixedString
175175
)
176176
if beep_index >= 0:
177177
self.cbb_ring_tone.setCurrentIndex(beep_index)
@@ -213,7 +213,7 @@ def show_instance_rules(self) -> None:
213213
),
214214
)
215215
except Exception as e:
216-
self.log(message=str(e), log_level=Qgis.Critical)
216+
self.log(message=str(e), log_level=Qgis.MessageLevel.Critical)
217217

218218
def discover_instances(self) -> None:
219219
"""
@@ -234,7 +234,7 @@ def discover_instances(self) -> None:
234234
msg,
235235
)
236236
except Exception as e:
237-
self.log(message=str(e), log_level=Qgis.Critical)
237+
self.log(message=str(e), log_level=Qgis.MessageLevel.Critical)
238238

239239
def on_ring_tone_changed(self) -> None:
240240
"""

qtribu/gui/form_article.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from typing import Optional, Union
1313

1414
# PyQGIS
15+
from qgis.core import Qgis
1516
from qgis.PyQt import uic
1617
from qgis.PyQt.QtWidgets import QDialog, QDialogButtonBox, QWidget
1718

@@ -62,9 +63,13 @@ def __init__(self, parent: Optional[QWidget] = None):
6263
"https://contribuer.geotribu.fr/articles/workflow/",
6364
)
6465
)
65-
self.btn_box.button(QDialogButtonBox.Ok).clicked.connect(self.on_btn_submit)
66-
self.btn_box.button(QDialogButtonBox.Ok).setDefault(True)
67-
self.btn_box.button(QDialogButtonBox.Ok).setText(self.tr("Submit"))
66+
self.btn_box.button(QDialogButtonBox.StandardButton.Ok).clicked.connect(
67+
self.on_btn_submit
68+
)
69+
self.btn_box.button(QDialogButtonBox.StandardButton.Ok).setDefault(True)
70+
self.btn_box.button(QDialogButtonBox.StandardButton.Ok).setText(
71+
self.tr("Submit")
72+
)
6873

6974
def check_required_fields(self) -> bool:
7075
invalid_fields = []
@@ -121,7 +126,7 @@ def check_required_fields(self) -> bool:
121126
parent_location=self,
122127
message=self.tr("Some of required fields are incorrectly filled."),
123128
push=True,
124-
log_level=2,
129+
log_level=Qgis.MessageLevel.Critical,
125130
duration=20,
126131
button=True,
127132
button_label=self.tr("See details..."),
@@ -169,7 +174,7 @@ def on_btn_submit(self) -> Union[bool, str, None]:
169174
if url_opened:
170175
self.log(
171176
message=self.tr("Issue form URL opened in default system web browser."),
172-
log_level=4,
177+
log_level=Qgis.MessageLevel.NoLevel,
173178
)
174179
super().accept()
175180
return True
@@ -182,6 +187,6 @@ def on_btn_submit(self) -> Union[bool, str, None]:
182187
),
183188
push=True,
184189
duration=10,
185-
log_level=2,
190+
log_level=Qgis.MessageLevel.Critical,
186191
)
187192
return False

0 commit comments

Comments
 (0)