diff --git a/arho_feature_template/gui/components/additional_information_widget.py b/arho_feature_template/gui/components/additional_information_widget.py index fdd5590..c272bd3 100644 --- a/arho_feature_template/gui/components/additional_information_widget.py +++ b/arho_feature_template/gui/components/additional_information_widget.py @@ -15,6 +15,7 @@ ) from arho_feature_template.core.models import AdditionalInformation +from arho_feature_template.gui.components.required_field_label import RequiredFieldLabel from arho_feature_template.gui.components.value_input_widgets import ( ValueWidgetManager, ) @@ -72,7 +73,7 @@ def __init__(self, additional_information: AdditionalInformation, parent=None): if self.value_widget_manager.value_widget is not None else QLabel("Syötekenttää tälle tyypille ei ole vielä toteutettu") ) - self._add_widget(QLabel("Arvo"), widget) + self._add_widget(RequiredFieldLabel("Arvo:"), widget) def _add_widget(self, label: QLabel, widget: QWidget): self.form_layout.addRow(label, widget) diff --git a/arho_feature_template/gui/components/additional_information_widget.ui b/arho_feature_template/gui/components/additional_information_widget.ui index 2e1d78f..df109dd 100644 --- a/arho_feature_template/gui/components/additional_information_widget.ui +++ b/arho_feature_template/gui/components/additional_information_widget.ui @@ -96,7 +96,7 @@ <item row="0" column="0"> <widget class="QLabel" name="label_4"> <property name="text"> - <string>Laji</string> + <string>Laji:</string> </property> </widget> </item> diff --git a/arho_feature_template/gui/components/general_regulation_group_widget.ui b/arho_feature_template/gui/components/general_regulation_group_widget.ui index 31b7bf7..df188c0 100644 --- a/arho_feature_template/gui/components/general_regulation_group_widget.ui +++ b/arho_feature_template/gui/components/general_regulation_group_widget.ui @@ -134,7 +134,7 @@ </font> </property> <property name="text"> - <string>Nimi</string> + <string>Otsikko:</string> </property> </widget> </item> diff --git a/arho_feature_template/gui/components/plan_document_widget.ui b/arho_feature_template/gui/components/plan_document_widget.ui index 9b26f0e..e5e6839 100644 --- a/arho_feature_template/gui/components/plan_document_widget.ui +++ b/arho_feature_template/gui/components/plan_document_widget.ui @@ -79,7 +79,7 @@ <item row="0" column="0"> <widget class="QLabel" name="label"> <property name="text"> - <string>Nimi</string> + <string>Nimi:</string> </property> </widget> </item> @@ -116,7 +116,7 @@ <item row="1" column="0"> <widget class="QLabel" name="url_label"> <property name="text"> - <string>URL</string> + <string>URL:</string> </property> </widget> </item> @@ -126,7 +126,7 @@ <item row="2" column="0"> <widget class="QLabel" name="document_type_label"> <property name="text"> - <string>Tyyppi</string> + <string><span style="color: red;">*</span> Tyyppi:</string> </property> </widget> </item> @@ -136,7 +136,7 @@ <item row="3" column="0"> <widget class="QLabel" name="publicity_label"> <property name="text"> - <string>Julkisuusluokka</string> + <string><span style="color: red;">*</span> Julkisuusluokka:</string> </property> </widget> </item> @@ -146,7 +146,7 @@ <item row="4" column="0"> <widget class="QLabel" name="language_label"> <property name="text"> - <string>Kieli</string> + <string><span style="color: red;">*</span> Kieli:</string> </property> </widget> </item> @@ -162,7 +162,7 @@ <item row="8" column="0"> <widget class="QLabel" name="decision_label"> <property name="text"> - <string>Päätös</string> + <string><html><head/><body><p><span style=" color:#ff0000;">*</span> Päätös:</p></body></html></string> </property> </widget> </item> @@ -175,21 +175,21 @@ </sizepolicy> </property> <property name="text"> - <string> </string> + <string/> </property> </widget> </item> <item row="6" column="0"> <widget class="QLabel" name="personal_data_content_label"> <property name="text"> - <string>Henkilötietosisältö</string> + <string><span style="color: red;">*</span> Henkilötietosisältö:</string> </property> </widget> </item> <item row="5" column="0"> <widget class="QLabel" name="retention_time_label"> <property name="text"> - <string>Säilytysaika</string> + <string><span style="color: red;">*</span> Säilytysaika:</string> </property> </widget> </item> @@ -203,7 +203,7 @@ <item row="7" column="0"> <widget class="QLabel" name="document_date_label"> <property name="text"> - <string>Asiakirjan päivämäärä</string> + <string><html><head/><body><p><span style=" color:#ff0000;">*</span> Asiakirjan päivämäärä:</p></body></html></string> </property> </widget> </item> diff --git a/arho_feature_template/gui/components/plan_proposition_widget.ui b/arho_feature_template/gui/components/plan_proposition_widget.ui index c1b9049..d0d9d91 100644 --- a/arho_feature_template/gui/components/plan_proposition_widget.ui +++ b/arho_feature_template/gui/components/plan_proposition_widget.ui @@ -107,7 +107,7 @@ <item row="0" column="0"> <widget class="QLabel" name="value_label"> <property name="text"> - <string>Sisältö</string> + <string><span style="color: red;">*</span> Sisältö:</string> </property> </widget> </item> diff --git a/arho_feature_template/gui/components/plan_regulation_group_widget.ui b/arho_feature_template/gui/components/plan_regulation_group_widget.ui index bda291f..fc019c2 100644 --- a/arho_feature_template/gui/components/plan_regulation_group_widget.ui +++ b/arho_feature_template/gui/components/plan_regulation_group_widget.ui @@ -143,7 +143,7 @@ </font> </property> <property name="text"> - <string>Nimi</string> + <string>Otsikko:</string> </property> </widget> </item> @@ -163,7 +163,7 @@ <item row="1" column="0"> <widget class="QLabel" name="short_name_label"> <property name="text"> - <string>Lyhyt nimi</string> + <string>Lyhyt nimi:</string> </property> </widget> </item> diff --git a/arho_feature_template/gui/components/plan_regulation_widget.py b/arho_feature_template/gui/components/plan_regulation_widget.py index 34eab7a..27f77f8 100644 --- a/arho_feature_template/gui/components/plan_regulation_widget.py +++ b/arho_feature_template/gui/components/plan_regulation_widget.py @@ -16,6 +16,7 @@ ) from arho_feature_template.gui.components.additional_information_widget import AdditionalInformationWidget from arho_feature_template.gui.components.code_combobox import HierarchicalCodeComboBox +from arho_feature_template.gui.components.required_field_label import RequiredFieldLabel from arho_feature_template.gui.components.value_input_widgets import ( IntegerInputWidget, SinglelineTextInputWidget, @@ -84,12 +85,12 @@ def __init__(self, regulation: Regulation, parent=None): def _init_widgets(self): # Value input if self.config.default_value: - self._add_widget(QLabel("Arvo"), self.value_widget_manager.value_widget) + self._add_widget(RequiredFieldLabel("Arvo"), self.value_widget_manager.value_widget) if self.config.regulation_code == "sanallinenMaarays": self.type_of_verbal_regulation_widget = HierarchicalCodeComboBox() self.type_of_verbal_regulation_widget.populate_from_code_layer(VerbalRegulationType) - self._add_widget(QLabel("Sanallisen määräyksen laji"), self.type_of_verbal_regulation_widget) + self._add_widget(RequiredFieldLabel("Sanallisen määräyksen laji"), self.type_of_verbal_regulation_widget) if self.regulation.verbal_regulation_type_id is not None: self.type_of_verbal_regulation_widget.set_value(self.regulation.verbal_regulation_type_id) diff --git a/arho_feature_template/gui/components/plan_regulation_widget.ui b/arho_feature_template/gui/components/plan_regulation_widget.ui index ec97b39..93e1399 100644 --- a/arho_feature_template/gui/components/plan_regulation_widget.ui +++ b/arho_feature_template/gui/components/plan_regulation_widget.ui @@ -101,7 +101,7 @@ <item row="0" column="0"> <widget class="QLabel" name="label_4"> <property name="text"> - <string>Laji</string> + <string>Laji:</string> </property> </widget> </item> diff --git a/arho_feature_template/gui/components/required_field_label.py b/arho_feature_template/gui/components/required_field_label.py new file mode 100644 index 0000000..6ce7d36 --- /dev/null +++ b/arho_feature_template/gui/components/required_field_label.py @@ -0,0 +1,17 @@ +from __future__ import annotations + +from qgis.PyQt.QtWidgets import QLabel, QWidget + + +class RequiredFieldLabel(QLabel): + """QLabel that prefixes the text with a red asterisk.""" + + def __init__(self, text: str, parent: QWidget | None = None): + super().__init__(self._prefix(text), parent) + + def setText(self, text: str): # noqa: N802 + return super().setText(self._prefix(text)) + + @staticmethod + def _prefix(text: str) -> str: + return f'<span style="color: red;">* </span>{text}' diff --git a/arho_feature_template/gui/components/value_input_widgets.py b/arho_feature_template/gui/components/value_input_widgets.py index 0c9e086..a8fd89a 100644 --- a/arho_feature_template/gui/components/value_input_widgets.py +++ b/arho_feature_template/gui/components/value_input_widgets.py @@ -132,9 +132,9 @@ def __init__(self, title: str | None = None, code_list: str | None = None, code_ self.code_value_widget = SinglelineTextInputWidget(default_value=code_value, editable=True) layout = QFormLayout() - layout.addRow("Otsikko", self.title_widget) - layout.addRow("Koodisto", self.code_list_widget) - layout.addRow("Koodiarvo", self.code_value_widget) + layout.addRow("Otsikko:", self.title_widget) + layout.addRow("Koodisto:", self.code_list_widget) + layout.addRow('<span style="color: red;">*</span> Koodiarvo:', self.code_value_widget) self.setLayout(layout) def get_value(self) -> tuple[str | None, str | None, str | None]: diff --git a/arho_feature_template/gui/dialogs/plan_attribute_form.ui b/arho_feature_template/gui/dialogs/plan_attribute_form.ui index af09f1e..28218ab 100644 --- a/arho_feature_template/gui/dialogs/plan_attribute_form.ui +++ b/arho_feature_template/gui/dialogs/plan_attribute_form.ui @@ -80,7 +80,7 @@ <item row="0" column="0"> <widget class="QLabel" name="label"> <property name="text"> - <string>Pysyvä kaavatunnus:</string> + <string><html><head/><body><p>Pysyvä kaavatunnus:</p></body></html></string> </property> <property name="buddy"> <cstring>permanent_identifier_line_edit</cstring> @@ -97,7 +97,7 @@ <item row="1" column="0"> <widget class="QLabel" name="nimiLabel"> <property name="text"> - <string>Nimi*:</string> + <string><html><head/><body><p><span style=" color:#ff0000;">*</span> Nimi:</p></body></html></string> </property> <property name="buddy"> <cstring>name_line_edit</cstring> @@ -114,7 +114,7 @@ <item row="2" column="0"> <widget class="QLabel" name="kuvausLabel"> <property name="text"> - <string>Kuvaus:</string> + <string><html><head/><body><p>Kuvaus:</p></body></html></string> </property> <property name="buddy"> <cstring>description_text_edit</cstring> @@ -131,7 +131,7 @@ <item row="4" column="0"> <widget class="QLabel" name="tyyppiLabel"> <property name="text"> - <string>Kaavalaji*:</string> + <string><span style="color: red;">*</span> Kaavalaji:</string> </property> <property name="buddy"> <cstring>plan_type_combo_box</cstring> @@ -148,7 +148,7 @@ <item row="5" column="0"> <widget class="QLabel" name="elinkaarenTilaLabel"> <property name="text"> - <string>Elinkaaren tila*:</string> + <string><span style="color: red;">*</span> Elinkaaren tila:</string> </property> <property name="buddy"> <cstring>lifecycle_status_combo_box</cstring> @@ -165,7 +165,7 @@ <item row="3" column="0"> <widget class="QLabel" name="label_5"> <property name="text"> - <string>Organisaatio*:</string> + <string><span style="color: red;">*</span> Organisaatio:</string> </property> </widget> </item> diff --git a/arho_feature_template/gui/dialogs/plan_feature_form.ui b/arho_feature_template/gui/dialogs/plan_feature_form.ui index 3e0705c..9081504 100644 --- a/arho_feature_template/gui/dialogs/plan_feature_form.ui +++ b/arho_feature_template/gui/dialogs/plan_feature_form.ui @@ -26,7 +26,7 @@ <item row="0" column="0"> <widget class="QLabel" name="feature_name_label"> <property name="text"> - <string>Nimi</string> + <string>Nimi:</string> </property> </widget> </item> @@ -36,7 +36,7 @@ <item row="1" column="0"> <widget class="QLabel" name="feature_description_label"> <property name="text"> - <string>Kuvaus</string> + <string>Kuvaus:</string> </property> </widget> </item> @@ -53,7 +53,7 @@ <item row="2" column="0"> <widget class="QLabel" name="feature_underground_label"> <property name="text"> - <string>Maanalaisuus</string> + <string><html><head/><body><p><span style=" color:#ff0000;">*</span> Maanalaisuus:</p></body></html></string> </property> </widget> </item> diff --git a/arho_feature_template/gui/dialogs/plan_regulation_group_form.ui b/arho_feature_template/gui/dialogs/plan_regulation_group_form.ui index fddd83f..3a0ce10 100644 --- a/arho_feature_template/gui/dialogs/plan_regulation_group_form.ui +++ b/arho_feature_template/gui/dialogs/plan_regulation_group_form.ui @@ -29,7 +29,7 @@ <item row="0" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> - <string>Otsikko</string> + <string>Otsikko:</string> </property> </widget> </item> @@ -39,7 +39,7 @@ <item row="1" column="0"> <widget class="QLabel" name="label_3"> <property name="text"> - <string>Lyhyt nimi</string> + <string>Lyhyt nimi:</string> </property> </widget> </item> @@ -49,7 +49,7 @@ <item row="2" column="0"> <widget class="QLabel" name="label"> <property name="text"> - <string>Ryhmänumero</string> + <string>Ryhmänumero:</string> </property> </widget> </item> @@ -69,7 +69,7 @@ <item row="3" column="0"> <widget class="QLabel" name="label_5"> <property name="text"> - <string>Värikoodi</string> + <string>Värikoodi:</string> </property> </widget> </item> @@ -79,7 +79,7 @@ <item row="4" column="0"> <widget class="QLabel" name="label_7"> <property name="text"> - <string>Tyyppi</string> + <string><html><head/><body><p><span style=" color:#ff0000;">*</span> Tyyppi:</p></body></html></string> </property> </widget> </item> @@ -154,8 +154,8 @@ p, li { white-space: pre-wrap; } <rect> <x>0</x> <y>0</y> - <width>38</width> - <height>18</height> + <width>587</width> + <height>577</height> </rect> </property> <layout class="QVBoxLayout" name="regulations_layout"> @@ -193,8 +193,8 @@ p, li { white-space: pre-wrap; } <rect> <x>0</x> <y>0</y> - <width>120</width> - <height>49</height> + <width>851</width> + <height>577</height> </rect> </property> <layout class="QVBoxLayout" name="propositions_layout">