From 131b6b9377beaccb5f2a362ff291a205ca5fa768 Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Tue, 30 Apr 2024 15:01:29 +0200 Subject: [PATCH 1/4] ui(formrdp): typos --- qtribu/gui/form_rdp_news.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qtribu/gui/form_rdp_news.py b/qtribu/gui/form_rdp_news.py index 6e1985cb..5883a63f 100644 --- a/qtribu/gui/form_rdp_news.py +++ b/qtribu/gui/form_rdp_news.py @@ -9,7 +9,7 @@ # standard from functools import partial from pathlib import Path -from typing import Union +from typing import Optional, Union from urllib.parse import urlparse # PyQGIS @@ -17,7 +17,7 @@ from qgis.PyQt import uic from qgis.PyQt.QtCore import Qt from qgis.PyQt.QtGui import QIcon -from qgis.PyQt.QtWidgets import QDialog, QDialogButtonBox +from qgis.PyQt.QtWidgets import QDialog, QDialogButtonBox, QWidget # plugin from qtribu.__about__ import DIR_PLUGIN_ROOT, __title__, __version__ @@ -34,7 +34,7 @@ class RdpNewsForm(QDialog): "https://github.com/geotribu/website/issues/new?template=RDP_NEWS.yml" ) - def __init__(self, parent=None): + def __init__(self, parent: Optional[QWidget] = None): """Constructor. :param parent: parent widget or application From 12b585f7ef4bf964ad6a82e23fa05df8bddc6248 Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Tue, 30 Apr 2024 15:02:29 +0200 Subject: [PATCH 2/4] ui(contents): add icons representing type of content --- qtribu/gui/dlg_contents.py | 14 +++++++------- qtribu/resources/images/article.svg | 2 ++ qtribu/resources/images/geordp.svg | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 qtribu/resources/images/article.svg create mode 100644 qtribu/resources/images/geordp.svg diff --git a/qtribu/gui/dlg_contents.py b/qtribu/gui/dlg_contents.py index 04a3f238..b6069f96 100644 --- a/qtribu/gui/dlg_contents.py +++ b/qtribu/gui/dlg_contents.py @@ -14,6 +14,10 @@ from qtribu.toolbelt import PlgLogger, PlgOptionsManager from qtribu.toolbelt.commons import open_url_in_browser, open_url_in_webviewer +# -- GLOBALS -- + +ICON_ARTICLE = QIcon(str(DIR_PLUGIN_ROOT.joinpath("resources/images/article.svg"))) +ICON_GEORDP = QIcon(str(DIR_PLUGIN_ROOT.joinpath("resources/images/geordp.svg"))) MARKER_VALUE = "---" @@ -243,11 +247,7 @@ def _build_tree_widget_item_from_content(content: RssItem) -> QTreeWidgetItem: ) for i in range(4): item.setToolTip(i, content.abstract) - icon_file = ( - "logo_orange_no_text" - if "Revue de presse" in content.title - else "logo_green_no_text" - ) - icon = QIcon(str(DIR_PLUGIN_ROOT / f"resources/images/{icon_file}.svg")) - item.setIcon(1, icon) + icon_file = ICON_GEORDP if "Revue de presse" in content.title else ICON_ARTICLE + + item.setIcon(1, icon_file) return item diff --git a/qtribu/resources/images/article.svg b/qtribu/resources/images/article.svg new file mode 100644 index 00000000..b8773526 --- /dev/null +++ b/qtribu/resources/images/article.svg @@ -0,0 +1,2 @@ + + diff --git a/qtribu/resources/images/geordp.svg b/qtribu/resources/images/geordp.svg new file mode 100644 index 00000000..384fa679 --- /dev/null +++ b/qtribu/resources/images/geordp.svg @@ -0,0 +1 @@ + From da1a20b6fd1040a7a18d138d0d8a7f6dcdceee15 Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Tue, 30 Apr 2024 15:14:59 +0200 Subject: [PATCH 3/4] ui(content-browser): general improvement --- qtribu/gui/dlg_contents.py | 81 ++++++++------ qtribu/gui/dlg_contents.ui | 220 +++++++++++++++++++------------------ 2 files changed, 164 insertions(+), 137 deletions(-) diff --git a/qtribu/gui/dlg_contents.py b/qtribu/gui/dlg_contents.py index b6069f96..84545c80 100644 --- a/qtribu/gui/dlg_contents.py +++ b/qtribu/gui/dlg_contents.py @@ -1,5 +1,11 @@ +#! python3 # noqa: E265 + +""" +QDialog to browse Geotribu contents. +""" + from pathlib import Path -from typing import Callable, Dict, List +from typing import Callable, Dict, List, Optional from qgis.core import QgsApplication from qgis.PyQt import QtCore, QtWidgets, uic @@ -20,11 +26,13 @@ ICON_GEORDP = QIcon(str(DIR_PLUGIN_ROOT.joinpath("resources/images/geordp.svg"))) MARKER_VALUE = "---" +# -- CLASSES -- + class GeotribuContentsDialog(QDialog): contents: Dict[int, List[RssItem]] = {} - def __init__(self, parent: QWidget = None): + def __init__(self, parent: Optional[QWidget] = None): """ QDialog for geotribu contents @@ -43,36 +51,35 @@ def __init__(self, parent: QWidget = None): # buttons actions self.form_article = None self.form_rdp_news = None - self.submit_article_button.clicked.connect(self.submit_article) - self.submit_article_button.setIcon( + self.btn_submit_article.clicked.connect(self.submit_article) + self.btn_submit_article.setIcon( QgsApplication.getThemeIcon("mActionEditTable.svg") ) - self.submit_news_button.clicked.connect(self.submit_news) - self.submit_news_button.setIcon( - QgsApplication.getThemeIcon("mActionAllEdits.svg") - ) - self.donate_button.clicked.connect(self.donate) - self.donate_button.setIcon( + self.btn_submit_news.clicked.connect(self.submit_news) + self.btn_submit_news.setIcon(QgsApplication.getThemeIcon("mActionAllEdits.svg")) + self.btn_donate.clicked.connect(self.donate) + self.btn_donate.setIcon( QgsApplication.getThemeIcon("mIconCertificateTrusted.svg") ) # search actions - self.search_line_edit.textChanged.connect(self.on_search_text_changed) + self.lne_search.textChanged.connect(self.on_search_text_changed) # authors combobox - self.authors_combobox.addItem(MARKER_VALUE) + self.cbb_authors.addItem(MARKER_VALUE) for author in self.json_feed_client.authors(): - self.authors_combobox.addItem(author) - self.authors_combobox.currentTextChanged.connect(self.on_author_changed) + self.cbb_authors.addItem(author) + self.cbb_authors.currentTextChanged.connect(self.on_author_changed) # categories combobox - self.categories_combobox.addItem(MARKER_VALUE) + self.cbb_tags.addItem(MARKER_VALUE) for cat in self.json_feed_client.categories(): - self.categories_combobox.addItem(cat) - self.categories_combobox.currentTextChanged.connect(self.on_category_changed) + if cat not in ("article", "revue de presse"): + self.cbb_tags.addItem(cat) + self.cbb_tags.currentTextChanged.connect(self.on_category_changed) # tree widget initialization - self.contents_tree_widget.setHeaderLabels( + self.tree_contents.setHeaderLabels( [ self.tr("Date"), self.tr("Title"), @@ -80,10 +87,10 @@ def __init__(self, parent: QWidget = None): self.tr("Categories"), ] ) - self.contents_tree_widget.itemClicked.connect(self.on_tree_view_item_click) + self.tree_contents.itemClicked.connect(self.on_tree_view_item_click) - self.refresh_list(lambda: self.search_line_edit.text()) - self.contents_tree_widget.expandAll() + self.refresh_list(lambda: self.lne_search.text()) + self.tree_contents.expandAll() def submit_article(self) -> None: """ @@ -159,7 +166,7 @@ def refresh_list(self, query_action: Callable[[], str]) -> None: } # clean treeview items - self.contents_tree_widget.clear() + self.tree_contents.clear() # populate treewidget items = [] @@ -171,8 +178,16 @@ def refresh_list(self, query_action: Callable[[], str]) -> None: child = self._build_tree_widget_item_from_content(content) item.addChild(child) items.append(item) - self.contents_tree_widget.insertTopLevelItems(0, items) - self.contents_tree_widget.expandAll() + self.tree_contents.insertTopLevelItems(0, items) + self.tree_contents.expandAll() + self.tableTunning() + + def tableTunning(self): + """Prettify table aspect""" + # fit to content + self.tree_contents.resizeColumnToContents(0) + self.tree_contents.resizeColumnToContents(1) + self.tree_contents.resizeColumnToContents(2) @QtCore.pyqtSlot(QtWidgets.QTreeWidgetItem, int) def on_tree_view_item_click(self, item: QTreeWidgetItem, column: int): @@ -194,7 +209,7 @@ def on_search_text_changed(self) -> None: Should get search """ # do nothing if text is too small - current = self.search_line_edit.text() + current = self.lne_search.text() if current == "": self.refresh_list(lambda: current) return @@ -209,9 +224,9 @@ def on_author_changed(self, value: str) -> None: :param value: text value of the selected author :type value: str """ - self.search_line_edit.setText("") + self.lne_search.setText("") if value == MARKER_VALUE: - self.refresh_list(lambda: self.search_line_edit.text()) + self.refresh_list(lambda: self.lne_search.text()) return self.refresh_list(lambda: value) @@ -222,9 +237,9 @@ def on_category_changed(self, value: str) -> None: :param value: text value of the selected category :type value: str """ - self.search_line_edit.setText("") + self.lne_search.setText("") if value == MARKER_VALUE: - self.refresh_list(lambda: self.search_line_edit.text()) + self.refresh_list(lambda: self.lne_search.text()) return self.refresh_list(lambda: value) @@ -236,12 +251,16 @@ def _build_tree_widget_item_from_content(content: RssItem) -> QTreeWidgetItem: :param content: content to generate item for :type content: RssItem """ + tags = ", ".join( + [t for t in content.categories if t not in ("article", "revue de presse")] + ) + item = QTreeWidgetItem( [ content.date_pub.strftime("%d %B"), content.title, - ",".join(content.author), - ",".join(content.categories), + ", ".join(content.author), + tags, content.url, ] ) diff --git a/qtribu/gui/dlg_contents.ui b/qtribu/gui/dlg_contents.ui index a29f4327..4b352692 100644 --- a/qtribu/gui/dlg_contents.ui +++ b/qtribu/gui/dlg_contents.ui @@ -6,8 +6,8 @@ 0 0 - 1080 - 640 + 1053 + 503 @@ -17,9 +17,24 @@ - Geotribu Contents + Latest Geotribu contents + + + 0.990000000000000 + + + true + + + true + + QLayout::SetMaximumSize + + + + @@ -38,100 +53,73 @@ 10 - - - - 0 - 0 - - - - Actions - - - - - - - - - 0 - 0 - - - - PointingHandCursor - - - Submit Article - - - - - - - - 0 - 0 - - - - PointingHandCursor - - - Submit News - - - - - - - - 0 - 0 - - - - PointingHandCursor - - - Donate - - - - - - - + + + + + + 0 + 0 + + + + PointingHandCursor + + + Submit News + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Submit Article + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Donate + + + + - - - - 0 - 0 - - - - - 0 - 3 - - - - - 0 - 5 - + + + - Contents + Contents search - + + true + + - + - + 0 @@ -139,56 +127,80 @@ - Search : + Search: + + + Qt::NoTextInteraction - + 0 0 + + + 255 + + Start typing a search term + true - + - Filter by author : + Filter by author: - + - + - Filter by category : + Filter by tags: - + - + + + + + + true + + + true + + + true + true true + + true + 4 @@ -235,16 +247,12 @@ - QgsCollapsibleGroupBox - QGroupBox -
qgscollapsiblegroupbox.h
+ QgsMessageBar + QWidget +
qgsmessagebar.h
1
- - contents_groupbox - submit_news_button - From 0468aa534b1fe4dc19b35144782f3fbddf27d7a3 Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Tue, 30 Apr 2024 15:16:13 +0200 Subject: [PATCH 4/4] typo: tags instead of categories --- qtribu/gui/dlg_contents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qtribu/gui/dlg_contents.py b/qtribu/gui/dlg_contents.py index 84545c80..ee9b202f 100644 --- a/qtribu/gui/dlg_contents.py +++ b/qtribu/gui/dlg_contents.py @@ -84,7 +84,7 @@ def __init__(self, parent: Optional[QWidget] = None): self.tr("Date"), self.tr("Title"), self.tr("Author(s)"), - self.tr("Categories"), + self.tr("Tags"), ] ) self.tree_contents.itemClicked.connect(self.on_tree_view_item_click)