Skip to content

Commit

Permalink
feature(ui): connect to github issue form
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Apr 29, 2024
1 parent b223478 commit e15273f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
27 changes: 21 additions & 6 deletions qtribu/gui/form_rdp_news.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from qgis.PyQt import uic
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import QDialog
from qgis.PyQt.QtWidgets import QDialog, QDialogButtonBox

# plugin
from qtribu.__about__ import DIR_PLUGIN_ROOT
Expand Down Expand Up @@ -75,13 +75,19 @@ def __init__(self, parent=None):
)
)

# connect help button
# connect standard buttons
self.btn_box: QDialogButtonBox = self.btn_box
self.btn_box.helpRequested.connect(
partial(
open_url_in_browser,
"https://contribuer.geotribu.fr/rdp/add_news/",
)
)
self.btn_box.button(QDialogButtonBox.Open).setText(self.tr("Load draft"))
self.btn_box.button(QDialogButtonBox.Open).clicked.connect(self.on_btn_open)
self.btn_box.button(QDialogButtonBox.Save).setText(self.tr("Save draft"))
self.btn_box.button(QDialogButtonBox.Ok).setText(self.tr("Submit"))
self.btn_box.button(QDialogButtonBox.Ok).setDefault(True)

def cbb_icon_populate(self) -> None:
"""Populate combobox of news icons."""
Expand Down Expand Up @@ -164,11 +170,20 @@ def generate_preview(self) -> None:
self.txt_preview.clear()
self.txt_preview.setMarkdown(md_txt)

def accept(self) -> bool:
"""Auto-connected to the OK button (within the button box), i.e. the `accepted`
signal. Check if required form fields are correctly filled.
def on_btn_open(self):

:return: False if some check fails. True and emit accepted() signal if everything is ok.
self.log("piouou")

def on_btn_save(self):

self.log("piouou")

def on_btn_submit(self) -> bool:
"""Check if required form fields are correctly filled and submit to Github issue
form.
:return: False if some check fails. True and emit accepted() signal if
everything is ok.
:rtype: bool
"""
invalid_fields = []
Expand Down
23 changes: 5 additions & 18 deletions qtribu/gui/form_rdp_news.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<string>GeoRDP - News Form</string>
</property>
<property name="windowOpacity">
<double>0.98</double>
<double>0.980000000000000</double>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
Expand Down Expand Up @@ -299,6 +299,9 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="AuthoringWidget" name="wdg_author" native="true"/>
</item>
<item row="9" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
Expand All @@ -318,7 +321,7 @@ p, li { white-space: pre-wrap; }
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok|QDialogButtonBox::Open|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
Expand Down Expand Up @@ -385,22 +388,6 @@ p, li { white-space: pre-wrap; }
</customwidgets>
<resources/>
<connections>
<connection>
<sender>btn_box</sender>
<signal>accepted()</signal>
<receiver>dlg_form_rdp_news</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>btn_box</sender>
<signal>rejected()</signal>
Expand Down

0 comments on commit e15273f

Please sign in to comment.