-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UX - Start resurecting the log panel : display estimated metadata and…
… simplify geometries
- Loading branch information
Showing
6 changed files
with
220 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,7 @@ class Html(Enum): | |
H3 = 'h3' | ||
H4 = 'h4' | ||
Strong = 'strong' | ||
Li = 'li' | ||
|
||
|
||
@unique | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
__email__ = '[email protected]' | ||
|
||
import logging | ||
import sys | ||
|
||
from pathlib import Path | ||
from typing import Optional | ||
|
@@ -21,14 +20,15 @@ | |
) | ||
from qgis.utils import iface | ||
|
||
from lizmap.log_panel import LogPanel | ||
|
||
try: | ||
from qgis.PyQt.QtWebKitWidgets import QWebView | ||
WEBKIT_AVAILABLE = True | ||
except ModuleNotFoundError: | ||
WEBKIT_AVAILABLE = False | ||
|
||
from lizmap.definitions.definitions import ( | ||
Html, | ||
LwcVersions, | ||
RepositoryComboData, | ||
ServerComboData, | ||
|
@@ -70,9 +70,6 @@ def __init__(self, parent=None): | |
self.feature_picker_layout.addWidget(self.dataviz_feature_picker) | ||
self.feature_picker_layout.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)) | ||
|
||
# clear log button clicked | ||
self.button_clear_log.clicked.connect(self.clear_log) | ||
|
||
# IGN and google | ||
self.inIgnKey.textChanged.connect(self.check_ign_french_free_key) | ||
self.inIgnKey.textChanged.connect(self.check_api_key_address) | ||
|
@@ -88,6 +85,9 @@ def __init__(self, parent=None): | |
self.label_link.setToolTip(tooltip) | ||
self.inLayerLink.setToolTip(tooltip) | ||
|
||
self.log_panel = LogPanel(self.out_log) | ||
self.button_clear_log.clicked.connect(self.log_panel.clear) | ||
|
||
self.check_project_thumbnail() | ||
self.setup_icons() | ||
|
||
|
@@ -400,6 +400,7 @@ def setup_icons(self): | |
i = 0 | ||
|
||
# Information | ||
# It must be the first tab, wiht 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) | ||
|
@@ -498,6 +499,7 @@ def setup_icons(self): | |
i += 1 | ||
|
||
# Log | ||
# It must be the last tab, with the higher index | ||
# noinspection PyCallByClass,PyArgumentList | ||
icon = QIcon(QgsApplication.iconPath('mMessageLog.svg')) | ||
self.mOptionsListWidget.item(i).setIcon(icon) | ||
|
@@ -583,15 +585,3 @@ def activateWindow(self): | |
self.check_project_thumbnail() | ||
LOGGER.info("Opening the Lizmap dialog.") | ||
super().activateWindow() | ||
|
||
def append_log(self, msg, style: Html = None, abort=None): | ||
""" Append text to the log. """ | ||
if abort: | ||
sys.stdout = sys.stderr | ||
if style: | ||
msg = '<{0}>{1}</{0}>'.format(style.value, msg) | ||
self.out_log.append(msg) | ||
|
||
def clear_log(self): | ||
""" Clear the content of the text area log. """ | ||
self.out_log.clear() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
__copyright__ = 'Copyright 2023, 3Liz' | ||
__license__ = 'GPL version 3' | ||
__email__ = '[email protected]' | ||
|
||
import sys | ||
|
||
from qgis.core import Qgis | ||
from qgis.PyQt.QtCore import QDateTime, QLocale | ||
from qgis.PyQt.QtWidgets import QTextEdit | ||
|
||
from lizmap.definitions.definitions import Html | ||
|
||
|
||
class LogPanel: | ||
|
||
def __init__(self, widget: QTextEdit): | ||
self.widget = widget | ||
|
||
def separator(self): | ||
""" Add a horizontal separator. """ | ||
# TODO, check for a proper HTML | ||
self.widget.append('=' * 20) | ||
|
||
def append( | ||
self, | ||
msg: str, | ||
style: Html = None, | ||
abort=None, | ||
time: bool = False, | ||
level: Qgis.MessageLevel = Qgis.Info, | ||
): | ||
""" Append text to the log. """ | ||
if abort: | ||
sys.stdout = sys.stderr | ||
|
||
if time: | ||
now = QDateTime.currentDateTime() | ||
now_str = now.toString(QLocale().timeFormat(QLocale.ShortFormat)) | ||
self.widget.append(now_str) | ||
|
||
if level == Qgis.Warning: | ||
# byte_array = QByteArray() | ||
# QBuffer | ||
# buffer( & byteArray); | ||
# pixmap.save( & buffer, "PNG"); | ||
# QString | ||
# msg += "<img src=\"data:image/png;base64," + byte_array.toBase64() + "\"/>"; | ||
# msg = '<img src="{}">'.format(":images/themes/default/mIconWarning.svg") | ||
pass | ||
|
||
if style: | ||
output = '' | ||
if style in (Html.H1, Html.H2, Html.H3): | ||
output += '<br>' | ||
output += '<{0}>{1}</{0}>'.format(style.value, msg) | ||
msg = output | ||
|
||
self.widget.append(msg) | ||
|
||
def clear(self): | ||
""" Clear the content of the text area log. """ | ||
self.widget.clear() | ||
|
||
|
||
if __name__ == '__main__': | ||
""" For manual tests. """ | ||
from qgis.PyQt.QtWidgets import QApplication, QDialog, QHBoxLayout | ||
app = QApplication(sys.argv) | ||
dialog = QDialog() | ||
layout = QHBoxLayout() | ||
dialog.setLayout(layout) | ||
edit = QTextEdit() | ||
layout.addWidget(edit) | ||
logger = LogPanel(edit) | ||
logger.append("Title", Html.H2, time=True) | ||
dialog.exec_() | ||
sys.exit(app.exec_()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.