File tree Expand file tree Collapse file tree 4 files changed +14
-4
lines changed
Expand file tree Collapse file tree 4 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 11QCHAT_NICKNAME_MINLENGTH : int = 3
2+ QCHAT_NICKNAME_MAXLENGTH_DEFAULT : int = 32
23ADMIN_MESSAGES_NICKNAME : str = "admin"
34ADMIN_MESSAGES_AVATAR : str = "mIconWarning.svg"
45ERROR_MESSAGES_COLOR : str = "#ff0000"
Original file line number Diff line number Diff line change 4141 QCHAT_MESSAGE_TYPE_NEWCOMER ,
4242 QCHAT_MESSAGE_TYPE_POSITION ,
4343 QCHAT_MESSAGE_TYPE_TEXT ,
44+ QCHAT_NICKNAME_MAXLENGTH_DEFAULT ,
4445 QCHAT_NICKNAME_MINLENGTH ,
4546)
4647from qchat .gui .qchat_tree_widget_items import (
@@ -252,8 +253,8 @@ def on_widget_opened(self) -> None:
252253 self .max_author_length = rules ["max_author_length" ]
253254 except Exception as exc :
254255 self .iface .messageBar ().pushCritical (self .tr ("QChat error" ), str (exc ))
255- self .min_author_length = 3
256- self .max_author_length = 32
256+ self .min_author_length = QCHAT_NICKNAME_MINLENGTH
257+ self .max_author_length = QCHAT_NICKNAME_MAXLENGTH_DEFAULT
257258
258259 # clear channel combobox items
259260 self .cbb_channel .clear () # delete all items from comboBox
Original file line number Diff line number Diff line change 1212
1313# alphanumeric
1414_alphanum_qreg = QRegularExpression ("[a-z-A-Z-0-9-_]+" )
15+ _alphanum_excl = r"[^a-zA-Z0-9-_]"
1516QVAL_ALPHANUM = QRegularExpressionValidator (_alphanum_qreg )
1617
1718# alphanumeric extended
Original file line number Diff line number Diff line change 22
33"""Plugin settings."""
44
5+ import re
6+
57# standard
68from dataclasses import asdict , dataclass , fields
79from getpass import getuser
810
911# PyQGIS
1012from qgis .core import QgsSettings
1113
12- # package
1314import qchat .toolbelt .log_handler as log_hdlr
1415from qchat .__about__ import __title__ , __version__
16+
17+ # package
18+ from qchat .constants import QCHAT_NICKNAME_MAXLENGTH_DEFAULT
19+ from qchat .gui .gui_commons import _alphanum_excl
1520from qchat .toolbelt .env_var_parser import EnvVarParser
1621
1722# ############################################################################
@@ -60,7 +65,9 @@ class PlgSettingsStructure:
6065 f"utm_source=QGIS&utm_medium={ __title__ } &utm_campaign=plugin_{ __version__ } "
6166 )
6267
63- nickname : str = getuser ()
68+ nickname : str = re .sub (_alphanum_excl , "_" , getuser ())[
69+ :QCHAT_NICKNAME_MAXLENGTH_DEFAULT
70+ ]
6471 avatar : str = "mGeoPackage.svg"
6572
6673 instance_uri : str = "https://qchat.geotribu.net"
You can’t perform that action at this time.
0 commit comments