Skip to content

Commit 7827240

Browse files
committed
refactoring(forms): modularize license and compliance widgets
1 parent f8bd58c commit 7827240

File tree

10 files changed

+490
-189
lines changed

10 files changed

+490
-189
lines changed

qtribu/constants.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#! python3 # noqa: E265
22

3-
"""
4-
Plugin constants.
5-
"""
3+
"""Plugin constants."""
64

75
# standard
86
from dataclasses import dataclass

qtribu/gui/dlg_settings.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
__uri_tracker__,
2424
__version__,
2525
)
26-
from qtribu.constants import contribution_guides_base_url
2726
from qtribu.toolbelt import PlgLogger, PlgOptionsManager
2827
from qtribu.toolbelt.commons import open_url_in_browser
2928
from qtribu.toolbelt.preferences import PlgSettingsStructure
@@ -79,20 +78,6 @@ def __init__(self, parent=None):
7978
self.btn_reset.setIcon(QIcon(QgsApplication.iconPath("mActionUndo.svg")))
8079
self.btn_reset.pressed.connect(self.reset_settings)
8180

82-
# contributing
83-
self.btn_license_open.pressed.connect(
84-
partial(
85-
open_url_in_browser,
86-
f"{contribution_guides_base_url}guides/licensing/#licence-par-defaut",
87-
)
88-
)
89-
self.btn_editorial_policy_open.pressed.connect(
90-
partial(
91-
open_url_in_browser,
92-
f"{contribution_guides_base_url}requirements/#ligne-editoriale",
93-
)
94-
)
95-
9681
# load previously saved settings
9782
self.load_settings()
9883

@@ -107,8 +92,6 @@ def apply(self):
10792
settings.notify_push_info = self.opt_notif_push_msg.isChecked()
10893
settings.notify_push_duration = self.sbx_notif_duration.value()
10994
settings.integration_qgis_news_feed = self.chb_integration_news_feed.isChecked()
110-
settings.license_global_accept = self.chb_license_global_accept.isChecked()
111-
settings.editorial_policy_accept = self.chb_editorial_policy_accept.isChecked()
11295

11396
# misc
11497
settings.debug_mode = self.opt_debug.isChecked()
@@ -119,6 +102,7 @@ def apply(self):
119102

120103
# sub widgets
121104
self.wdg_author.save_settings()
105+
self.wdg_editing_compliance.save_settings()
122106

123107
if __debug__:
124108
self.log(
@@ -135,8 +119,6 @@ def load_settings(self) -> None:
135119
self.opt_notif_push_msg.setChecked(settings.notify_push_info)
136120
self.sbx_notif_duration.setValue(settings.notify_push_duration)
137121
self.chb_integration_news_feed.setChecked(settings.integration_qgis_news_feed)
138-
self.chb_license_global_accept.setChecked(settings.license_global_accept)
139-
self.chb_editorial_policy_accept.setChecked(settings.editorial_policy_accept)
140122

141123
# misc
142124
self.opt_debug.setChecked(settings.debug_mode)

qtribu/gui/dlg_settings.ui

Lines changed: 10 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -308,61 +308,12 @@
308308
<string>Contributing</string>
309309
</property>
310310
<layout class="QGridLayout" name="gridLayout_3">
311-
<item row="0" column="0" colspan="2">
312-
<widget class="QCheckBox" name="chb_license_global_accept">
313-
<property name="minimumSize">
314-
<size>
315-
<width>0</width>
316-
<height>25</height>
317-
</size>
318-
</property>
319-
<property name="text">
320-
<string>Accept publication license globally</string>
321-
</property>
322-
</widget>
323-
</item>
324-
<item row="0" column="2">
325-
<widget class="QPushButton" name="btn_license_open">
326-
<property name="autoFillBackground">
327-
<bool>true</bool>
328-
</property>
329-
<property name="text">
330-
<string>Open GeoRDP publication license</string>
331-
</property>
332-
<property name="autoDefault">
333-
<bool>false</bool>
334-
</property>
335-
<property name="flat">
336-
<bool>false</bool>
337-
</property>
338-
</widget>
339-
</item>
340-
<item row="2" column="2">
341-
<widget class="QPushButton" name="btn_editorial_policy_open">
342-
<property name="autoFillBackground">
343-
<bool>true</bool>
344-
</property>
345-
<property name="text">
346-
<string>Open editorial policy</string>
347-
</property>
348-
<property name="autoDefault">
349-
<bool>false</bool>
350-
</property>
351-
<property name="flat">
352-
<bool>false</bool>
353-
</property>
354-
</widget>
355-
</item>
356-
<item row="2" column="0" colspan="2">
357-
<widget class="QCheckBox" name="chb_editorial_policy_accept">
358-
<property name="text">
359-
<string>I have read and understood the editorial policy</string>
360-
</property>
361-
</widget>
362-
</item>
363-
<item row="3" column="0" colspan="3">
311+
<item row="2" column="0" colspan="3">
364312
<widget class="AuthoringWidget" name="wdg_author" native="true"/>
365313
</item>
314+
<item row="0" column="0" colspan="3">
315+
<widget class="EditingPolicyWidget" name="wdg_editing_compliance" native="true"/>
316+
</item>
366317
</layout>
367318
</widget>
368319
</item>
@@ -534,6 +485,12 @@
534485
<header>qtribu.gui.wdg_authoring</header>
535486
<container>1</container>
536487
</customwidget>
488+
<customwidget>
489+
<class>EditingPolicyWidget</class>
490+
<extends>QWidget</extends>
491+
<header>qtribu.gui.wdg_editing_compliance</header>
492+
<container>1</container>
493+
</customwidget>
537494
</customwidgets>
538495
<tabstops>
539496
<tabstop>opt_browser_qt</tabstop>

qtribu/gui/form_article.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@
2525
SOURCE_REPOSITORY_URL,
2626
contribution_guides_base_url,
2727
)
28+
from qtribu.gui.wdg_authoring import AuthoringWidget
29+
from qtribu.gui.wdg_editing_compliance import EditingPolicyWidget
2830
from qtribu.toolbelt import NetworkRequestsManager, PlgLogger, PlgOptionsManager
2931
from qtribu.toolbelt.commons import open_url_in_browser
3032

3133

3234
class ArticleForm(QDialog):
3335
"""QDialog form to submit an article."""
3436

37+
# type hints for sub-widgets
38+
wdg_author: AuthoringWidget
39+
wdg_editing_compliance: EditingPolicyWidget
40+
3541
def __init__(self, parent: Optional[QWidget] = None):
3642
"""Constructor.
3743
@@ -53,17 +59,6 @@ def initGui(self) -> None:
5359
# custom icon
5460
self.setWindowIcon(ICON_ARTICLE)
5561

56-
# publication
57-
self.cbb_license.addItems(
58-
[
59-
"Creative Commons International BY-NC-SA 4.0",
60-
"Creative Commons International BY-SA 4.0",
61-
"Creative Commons International BY 4.0",
62-
"Beerware (Révision 42)",
63-
"autre - merci de préciser dans le champ libre en fin de formulaire",
64-
]
65-
)
66-
6762
# connect help button
6863
self.btn_box.helpRequested.connect(
6964
partial(
@@ -79,6 +74,13 @@ def initGui(self) -> None:
7974
self.tr("Submit")
8075
)
8176

77+
# custom sub-widget
78+
self.wdg_editing_compliance.frm_rdp.hide()
79+
self.wdg_editing_compliance.chb_transparency.setText(
80+
self.wdg_editing_compliance.chb_transparency.text()
81+
+ self.tr("\n If not, I give some details in the comment area.")
82+
)
83+
8284
# set the minimum proposed date to 2 weeks from
8385
today: QDate = QDate.currentDate()
8486
min_date: QDate = today.addDays(14)
@@ -174,16 +176,17 @@ def on_btn_submit(self) -> Union[bool, str, None]:
174176
if not self.check_required_fields():
175177
return False
176178

177-
completed_url = (
178-
f"{self.ISSUE_FORM_BASE_URL}"
179+
completed_url: str = (
180+
f"{self.issue_form_url}"
179181
f"&in_author_name={self.wdg_author.lne_firstname.text()} "
180182
f"{self.wdg_author.lne_lastname.text()}"
181183
f"&in_author_mail={self.wdg_author.lne_email.text()}"
182184
f"&in_author_linkedin={self.wdg_author.lne_linkedin_account.text()}"
183185
f"&in_author_mastodon={self.wdg_author.lne_mastodon_account.text()}"
184186
f"&in_author_twitter={self.wdg_author.lne_twitter_account.text()}"
185187
f"&in_author_license=true"
186-
f"&cb_author_content_relationship={self.chb_transparency.isChecked()}"
188+
f"&cb_author_content_relationship={self.wdg_editing_compliance.chb_transparency.isChecked()}"
189+
f"&cb_author_aware_ai_guidelines={self.wdg_editing_compliance.chb_genai_editing_policy.isChecked()}"
187190
f"&in_art_title={self.lne_title.text()}"
188191
f"&in_art_date={self.dte_proposed_date.date().toString('dd/MM/yyyy')}"
189192
f"&tx_art_content={self.txt_description.toPlainText()}"
@@ -192,7 +195,7 @@ def on_btn_submit(self) -> Union[bool, str, None]:
192195
f"&title=[Proposition] {self.lne_title.text()} - {__title__} {__version__}"
193196
)
194197
self.log(message=f"Opening issue form: {completed_url}", log_level=4)
195-
url_opened = open_url_in_browser(url=completed_url)
198+
url_opened: bool = open_url_in_browser(url=completed_url)
196199
if url_opened:
197200
self.log(
198201
message=self.tr("Issue form URL opened in default system web browser."),

qtribu/gui/form_article.ui

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>705</width>
10-
<height>739</height>
9+
<width>968</width>
10+
<height>823</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -45,8 +45,8 @@
4545
<rect>
4646
<x>0</x>
4747
<y>0</y>
48-
<width>687</width>
49-
<height>658</height>
48+
<width>950</width>
49+
<height>738</height>
5050
</rect>
5151
</property>
5252
<layout class="QVBoxLayout" name="verticalLayout">
@@ -190,51 +190,23 @@
190190
<string>Publication</string>
191191
</property>
192192
<layout class="QFormLayout" name="formLayout_4">
193-
<item row="0" column="0">
194-
<widget class="QLabel" name="lbl_license">
195-
<property name="font">
196-
<font>
197-
<pointsize>11</pointsize>
198-
<weight>75</weight>
199-
<bold>true</bold>
200-
</font>
201-
</property>
202-
<property name="text">
203-
<string>License:</string>
204-
</property>
205-
</widget>
206-
</item>
207-
<item row="2" column="1">
208-
<widget class="QPlainTextEdit" name="txt_comment">
209-
<property name="maximumBlockCount">
210-
<number>300</number>
211-
</property>
212-
</widget>
193+
<item row="0" column="0" colspan="2">
194+
<widget class="EditingPolicyWidget" name="wdg_editing_compliance" native="true"/>
213195
</item>
214-
<item row="2" column="0">
196+
<item row="1" column="0">
215197
<widget class="QLabel" name="lbl_comment">
216198
<property name="text">
217199
<string>Comment:</string>
218200
</property>
219201
</widget>
220202
</item>
221-
<item row="1" column="0">
222-
<widget class="QLabel" name="lbl_transparency">
223-
<property name="text">
224-
<string>Transparency:</string>
225-
</property>
226-
</widget>
227-
</item>
228203
<item row="1" column="1">
229-
<widget class="QCheckBox" name="chb_transparency">
230-
<property name="text">
231-
<string>I'm sure that the content fit with editing rules. If not, I give some details in the comment area.</string>
204+
<widget class="QPlainTextEdit" name="txt_comment">
205+
<property name="maximumBlockCount">
206+
<number>300</number>
232207
</property>
233208
</widget>
234209
</item>
235-
<item row="0" column="1">
236-
<widget class="QComboBox" name="cbb_license"/>
237-
</item>
238210
</layout>
239211
</widget>
240212
</item>
@@ -299,6 +271,12 @@
299271
<header>qgsmessagebar.h</header>
300272
<container>1</container>
301273
</customwidget>
274+
<customwidget>
275+
<class>EditingPolicyWidget</class>
276+
<extends>QWidget</extends>
277+
<header>qtribu.gui.wdg_editing_compliance</header>
278+
<container>1</container>
279+
</customwidget>
302280
</customwidgets>
303281
<resources/>
304282
<connections>

0 commit comments

Comments
 (0)