From e15273fbefdfb2575f5077bc27c9bced7fec9102 Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Mon, 29 Apr 2024 14:03:45 +0200 Subject: [PATCH] feature(ui): connect to github issue form --- qtribu/gui/form_rdp_news.py | 27 +++++++++++++++++++++------ qtribu/gui/form_rdp_news.ui | 23 +++++------------------ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/qtribu/gui/form_rdp_news.py b/qtribu/gui/form_rdp_news.py index 75815b8a..5de77103 100644 --- a/qtribu/gui/form_rdp_news.py +++ b/qtribu/gui/form_rdp_news.py @@ -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 @@ -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.""" @@ -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 = [] diff --git a/qtribu/gui/form_rdp_news.ui b/qtribu/gui/form_rdp_news.ui index 7a77cc43..cdb70d21 100644 --- a/qtribu/gui/form_rdp_news.ui +++ b/qtribu/gui/form_rdp_news.ui @@ -14,7 +14,7 @@ GeoRDP - News Form - 0.98 + 0.980000000000000 @@ -299,6 +299,9 @@ p, li { white-space: pre-wrap; } + + + @@ -318,7 +321,7 @@ p, li { white-space: pre-wrap; } Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok|QDialogButtonBox::Open|QDialogButtonBox::Save @@ -385,22 +388,6 @@ p, li { white-space: pre-wrap; } - - btn_box - accepted() - dlg_form_rdp_news - accept() - - - 248 - 254 - - - 157 - 274 - - - btn_box rejected()