Skip to content

Commit

Permalink
Merge pull request #611 from Gustry/qt6
Browse files Browse the repository at this point in the history
Enable Qt6 on the plugin
  • Loading branch information
Gustry authored Oct 30, 2024
2 parents 92ff01b + 4b886ba commit 3cb4fd2
Show file tree
Hide file tree
Showing 44 changed files with 254 additions and 253 deletions.
4 changes: 2 additions & 2 deletions lizmap/dialogs/dock_html_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, parent, *__args):
self.layout.addLayout(horizontal)

self.web_view = QWebView(self.dock)
size_policy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.MinimumExpanding)
size_policy = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.MinimumExpanding)
size_policy.setHorizontalStretch(0)
size_policy.setVerticalStretch(0)
size_policy.setHeightForWidth(self.web_view.sizePolicy().hasHeightForWidth())
Expand All @@ -95,7 +95,7 @@ def __init__(self, parent, *__args):

self.setWidget(self.dock)

self.layer.setFilters(QgsMapLayerProxyModel.VectorLayer)
self.layer.setFilters(QgsMapLayerProxyModel.Filter.VectorLayer)
# noinspection PyUnresolvedReferences
self.layer.layerChanged.connect(self.current_layer_changed)
self.current_layer_changed()
Expand Down
6 changes: 3 additions & 3 deletions lizmap/dialogs/html_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def __init__(self):
layout.addWidget(self.editor)

self.button_box = QDialogButtonBox()
self.button_box.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
self.button_box.setStandardButtons(QDialogButtonBox.StandardButton.Cancel | QDialogButtonBox.StandardButton.Ok)
# noinspection PyArgumentList
layout.addWidget(self.button_box)

self.setLayout(layout)

accept_button = self.button_box.button(QDialogButtonBox.Ok)
accept_button = self.button_box.button(QDialogButtonBox.StandardButton.Ok)
accept_button.clicked.connect(self.accept)
cancel_button = self.button_box.button(QDialogButtonBox.Cancel)
cancel_button = self.button_box.button(QDialogButtonBox.StandardButton.Cancel)
cancel_button.clicked.connect(self.reject)

def set_layer(self, layer: QgsVectorLayer):
Expand Down
4 changes: 2 additions & 2 deletions lizmap/dialogs/html_maptip.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def __init__(self, layer: QgsVectorLayer):
self.setupUi(self)
self.layer = layer

accept_button = self.button_box.button(QDialogButtonBox.Ok)
accept_button = self.button_box.button(QDialogButtonBox.StandardButton.Ok)
accept_button.clicked.connect(self.accept)
cancel_button = self.button_box.button(QDialogButtonBox.Cancel)
cancel_button = self.button_box.button(QDialogButtonBox.StandardButton.Cancel)
cancel_button.clicked.connect(self.reject)

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions lizmap/dialogs/lizmap_popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def __init__(self, content):
QDialog.__init__(self)
self.setupUi(self)

accept_button = self.bbConfigurePopup.button(QDialogButtonBox.Ok)
accept_button = self.bbConfigurePopup.button(QDialogButtonBox.StandardButton.Ok)
accept_button.clicked.connect(self.accept)
cancel_button = self.bbConfigurePopup.button(QDialogButtonBox.Cancel)
cancel_button = self.bbConfigurePopup.button(QDialogButtonBox.StandardButton.Cancel)
cancel_button.clicked.connect(self.reject)

self.groupBox.setStyleSheet(COMPLETE_STYLE_SHEET)
Expand Down
74 changes: 37 additions & 37 deletions lizmap/dialogs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def __init__(self, parent=None, is_dev_version=True, lwc_version: LwcVersions =
self.dataviz_feature_picker = QgsFeaturePickerWidget()

self.feature_picker_layout.addWidget(self.dataviz_feature_picker)
self.feature_picker_layout.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
self.feature_picker_layout.addItem(QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding))

self.warning_old_server.setVisible(False)

Expand Down Expand Up @@ -172,7 +172,7 @@ def __init__(self, parent=None, is_dev_version=True, lwc_version: LwcVersions =
self.button_helper_group.setToolTip(tr('Select features having at least one group not matching on the server'))
self.button_helper_group.clicked.connect(self.select_unknown_features_group)
self.button_helper_group.setIcon(QIcon(":images/themes/default/mActionToggleSelectedLayers.svg"))
self.helper_layer_group.setFilters(QgsMapLayerProxyModel.VectorLayer)
self.helper_layer_group.setFilters(QgsMapLayerProxyModel.Filter.VectorLayer)
tooltip = tr("The layer to check group IDs")
self.helper_layer_group.setToolTip(tooltip)
self.helper_field_group.setFilters(QgsFieldProxyModel.String)
Expand Down Expand Up @@ -248,17 +248,17 @@ def __init__(self, parent=None, is_dev_version=True, lwc_version: LwcVersions =
self.button_simplify_geom.clicked.connect(self.fix_simplify_geom_provider)
self.button_simplify_geom.setIcon(QIcon(":images/themes/default/mIconPostgis.svg"))

self.buttonBox.button(QDialogButtonBox.Help).setToolTip(tr(
self.buttonBox.button(QDialogButtonBox.StandardButton.Help).setToolTip(tr(
'Open the help in the web-browser'
))
self.buttonBox.button(QDialogButtonBox.Ok).setToolTip(tr(
self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setToolTip(tr(
'The Lizmap configuration file is generated and the dialog is closed, except if there is at least one '
'blocking check.'
))
self.buttonBox.button(QDialogButtonBox.Cancel).setToolTip(tr(
self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setToolTip(tr(
'The Lizmap configuration file is not generated and the dialog is closed.'
))
self.buttonBox.button(QDialogButtonBox.Apply).setToolTip(tr(
self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).setToolTip(tr(
'The Lizmap configuration file is generated, but the dialog stays opened.'
))
self.checkbox_save_project.setToolTip(tr(
Expand Down Expand Up @@ -487,7 +487,7 @@ def check_api_key_address(self):
'However, you have not provided any API key for this provider. Please add one in the '
'"Basemaps" panel to use this provider.'
),
QMessageBox.Ok
QMessageBox.StandardButton.Ok
)

def block_signals_address(self, flag: bool):
Expand Down Expand Up @@ -856,106 +856,106 @@ def setup_icons(self):
# Information
# It must be the first tab, with index 0.
icon = QIcon()
icon.addFile(resources_path('icons', '03-metadata-white'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '03-metadata-dark'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', '03-metadata-white'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', '03-metadata-dark'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.Information).setIcon(icon)
self.mOptionsListWidget.item(Panels.Information).setData(Qt.UserRole, 'info')

# Map options
icon = QIcon()
icon.addFile(resources_path('icons', '15-baselayer-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '15-baselayer-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', '15-baselayer-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', '15-baselayer-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.MapOptions).setIcon(icon)
self.mOptionsListWidget.item(Panels.MapOptions).setData(Qt.UserRole, 'map-options')

# Layers
icon = QIcon()
icon.addFile(resources_path('icons', '02-switcher-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '02-switcher-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', '02-switcher-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', '02-switcher-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.Layers).setIcon(icon)
self.mOptionsListWidget.item(Panels.Layers).setData(Qt.UserRole, 'layers')

# Base layer
icon = QIcon()
icon.addFile(resources_path('icons', '02-switcher-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '02-switcher-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', '02-switcher-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', '02-switcher-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.Basemap).setIcon(icon)
self.mOptionsListWidget.item(Panels.Basemap).setData(Qt.UserRole, 'base-layers')

# Attribute table
icon = QIcon()
icon.addFile(resources_path('icons', '11-attribute-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '11-attribute-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', '11-attribute-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', '11-attribute-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.AttributeTable).setIcon(icon)
self.mOptionsListWidget.item(Panels.AttributeTable).setData(Qt.UserRole, 'attribute-table')

# Layer editing
icon = QIcon()
icon.addFile(resources_path('icons', '10-edition-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '10-edition-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', '10-edition-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', '10-edition-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.Editing).setIcon(icon)
self.mOptionsListWidget.item(Panels.Editing).setData(Qt.UserRole, 'layer-editing')

# Layouts
icon = QIcon()
icon.addFile(resources_path('icons', '08-print-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '08-print-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', '08-print-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', '08-print-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.Layouts).setIcon(icon)
self.mOptionsListWidget.item(Panels.Layouts).setData(Qt.UserRole, 'layouts')

# Filter data with form
icon = QIcon()
icon.addFile(resources_path('icons', 'filter-icon-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', 'filter-icon-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', 'filter-icon-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', 'filter-icon-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.FormFiltering).setIcon(icon)
self.mOptionsListWidget.item(Panels.FormFiltering).setData(Qt.UserRole, 'filter-data-form')

# Dataviz
icon = QIcon()
icon.addFile(resources_path('icons', 'dataviz-icon-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', 'dataviz-icon-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', 'dataviz-icon-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', 'dataviz-icon-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.Dataviz).setIcon(icon)
self.mOptionsListWidget.item(Panels.Dataviz).setData(Qt.UserRole, 'dataviz')

# Filter layer by user
icon = QIcon()
icon.addFile(resources_path('icons', '12-user-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '12-user-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', '12-user-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', '12-user-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.FilteredLayers).setIcon(icon)
self.mOptionsListWidget.item(Panels.FilteredLayers).setData(Qt.UserRole, 'filter-data-user')

# Actions
icon = QIcon()
icon.addFile(resources_path('icons', 'actions-white.svg'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', 'actions-dark.svg'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', 'actions-white.svg'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', 'actions-dark.svg'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.Actions).setIcon(icon)
self.mOptionsListWidget.item(Panels.Actions).setData(Qt.UserRole, 'actions')

# Time manager
icon = QIcon()
icon.addFile(resources_path('icons', '13-timemanager-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '13-timemanager-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', '13-timemanager-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', '13-timemanager-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.TimeManager).setIcon(icon)
self.mOptionsListWidget.item(Panels.TimeManager).setData(Qt.UserRole, 'time-manager')

# Atlas
icon = QIcon()
icon.addFile(resources_path('icons', 'atlas-icon-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', 'atlas-icon-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', 'atlas-icon-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', 'atlas-icon-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.Atlas).setIcon(icon)
self.mOptionsListWidget.item(Panels.Atlas).setData(Qt.UserRole, 'atlas')

# Locate by layer
icon = QIcon()
icon.addFile(resources_path('icons', '04-locate-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '04-locate-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', '04-locate-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', '04-locate-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.LocateByLayer).setIcon(icon)
self.mOptionsListWidget.item(Panels.LocateByLayer).setData(Qt.UserRole, 'locate-by-layer')

# Tooltip layer
icon = QIcon()
icon.addFile(resources_path('icons', '16-tooltip-white.png'), mode=QIcon.Normal)
icon.addFile(resources_path('icons', '16-tooltip-dark.png'), mode=QIcon.Selected)
icon.addFile(resources_path('icons', '16-tooltip-white.png'), mode=QIcon.Mode.Normal)
icon.addFile(resources_path('icons', '16-tooltip-dark.png'), mode=QIcon.Mode.Selected)
self.mOptionsListWidget.item(Panels.ToolTip).setIcon(icon)
self.mOptionsListWidget.item(Panels.ToolTip).setData(Qt.UserRole, 'tooltip-layer')

Expand Down
2 changes: 1 addition & 1 deletion lizmap/dialogs/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, link: str):

self.open_link.clicked.connect(self.open_website)

accept_button = self.button_box.button(QDialogButtonBox.Ignore)
accept_button = self.button_box.button(QDialogButtonBox.StandardButton.Ignore)
accept_button.clicked.connect(self.accept)

def open_website(self):
Expand Down
2 changes: 1 addition & 1 deletion lizmap/dialogs/scroll_message_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ def __init__(self, parent: QDialog, *args, **kwargs):
scroll.setMinimumSize(400, 200)
grid.addWidget(scroll, 0, 1)
children[1].setText('')
self.exec_()
self.exec()
10 changes: 5 additions & 5 deletions lizmap/dialogs/server_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def __init__(self, auth_id, parent=None):
layout.addWidget(self.password_edit)

# Progress bar
layout.addSpacerItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
layout.addSpacerItem(QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding))
self.progress = QProgressBar()
self.progress.setMinimum(0)
self.progress.setValue(0)
Expand Down Expand Up @@ -779,9 +779,9 @@ def __init__(self, parent=None):
# noinspection PyArgumentList
super().__init__(parent)
self.setWindowTitle(tr("Lizmap Web Client instance"))
self.setWizardStyle(QWizard.ClassicStyle)
self.setOption(QWizard.NoBackButtonOnStartPage)
self.setOption(QWizard.HaveHelpButton)
self.setWizardStyle(QWizard.WizardStyle.ClassicStyle)
self.setOption(QWizard.WizardOption.NoBackButtonOnStartPage)
self.setOption(QWizard.WizardOption.HaveHelpButton)

self.setMinimumSize(800, 550)

Expand Down Expand Up @@ -1231,4 +1231,4 @@ def current_url(self):
app = QApplication(sys.argv)
wizard = ServerWizard()
wizard.show()
sys.exit(app.exec_())
sys.exit(app.exec())
10 changes: 5 additions & 5 deletions lizmap/dialogs/wizard_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ def __init__(self, helper: str, current_acl: str, server_groups: dict = None):
self.label_additional.setToolTip(tooltip)

# Server groups
self.list.setSelectionMode(QAbstractItemView.MultiSelection)
self.list.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.list.setSelectionBehavior(QAbstractItemView.SelectRows)
self.list.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection)
self.list.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
self.list.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
self.list.setAlternatingRowColors(True)
self.list.itemSelectionChanged.connect(self.update_preview)

# Additional groups
self.additional.textChanged.connect(self.update_preview)

accept_button = self.buttons.button(QDialogButtonBox.Ok)
accept_button = self.buttons.button(QDialogButtonBox.StandardButton.Ok)
accept_button.clicked.connect(self.accept)
cancel_button = self.buttons.button(QDialogButtonBox.Cancel)
cancel_button = self.buttons.button(QDialogButtonBox.StandardButton.Cancel)
cancel_button.clicked.connect(self.reject)

self.populate_widgets(current_acl, server_groups)
Expand Down
14 changes: 7 additions & 7 deletions lizmap/drag_drop_dataviz_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def __init__(
# Drag and drop
self.tree.setDragEnabled(True)
self.tree.setAcceptDrops(True)
self.tree.setDragDropMode(QAbstractItemView.InternalMove)
self.tree.setSelectionBehavior(QAbstractItemView.SelectRows)
self.tree.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)
self.tree.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)

def add_current_plot_from_combo(self):
""" Button to add the current plot from the combobox into the tree widget. """
Expand Down Expand Up @@ -220,10 +220,10 @@ def remove_item(self):
children.append(current_item.child(child))

box = QMessageBox(self.parent)
box.setIcon(QMessageBox.Question)
box.setIcon(QMessageBox.Icon.Question)
box.setWindowIcon(QIcon(resources_path('icons', 'icon.png')), )
box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
box.setDefaultButton(QMessageBox.No)
box.setStandardButtons(QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
box.setDefaultButton(QMessageBox.StandardButton.No)

if current_item.data(0, Qt.UserRole) == Container.Container:
box.setWindowTitle(tr('Remove the container'))
Expand All @@ -235,8 +235,8 @@ def remove_item(self):
box.setWindowTitle(tr('Remove the plot'))
box.setText(tr('Are you sure you want to remove the plot from the layout?'))

result = box.exec_()
if result == QMessageBox.No:
result = box.exec()
if result == QMessageBox.StandardButton.No:
return

for child in children:
Expand Down
2 changes: 1 addition & 1 deletion lizmap/forms/atlas_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, parent=None, unicity=None, lwc_version: LwcVersions = None):
self.config.add_layer_label('triggerFilter', self.label_trigger)
self.config.add_layer_label('duration', self.label_duration)

self.layer.setFilters(QgsMapLayerProxyModel.VectorLayer)
self.layer.setFilters(QgsMapLayerProxyModel.Filter.VectorLayer)
self.primary_key.setAllowEmptyFieldName(False)
self.feature_label.setAllowEmptyFieldName(False)
self.sort_field.setAllowEmptyFieldName(False)
Expand Down
Loading

0 comments on commit 3cb4fd2

Please sign in to comment.