From a5a712d6ad7f66c77cce2cfbf74cbfef29cd8e48 Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Mon, 31 Jul 2023 10:17:44 +0200
Subject: [PATCH] About: Add AUTHORS files and authors list into about window.

---
 AUTHORS                  |  3 +++
 packages/linux.sh        |  1 +
 packages/windows.bat     |  1 +
 src/AUTHORS              |  1 +
 src/View/About/Window.py | 36 +++++++++++++++++++++++++++---------
 src/View/ui/about.ui     |  2 +-
 6 files changed, 34 insertions(+), 10 deletions(-)
 create mode 100644 AUTHORS
 create mode 120000 src/AUTHORS

diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 00000000..0ce9cdac
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+Sylvain COULIBALY, INRAE, 2020 - 2022
+Théophile TERRAZ, INRAE, 2022 - 2023
+Pierre-Antoine ROUBY, INRAE, 2023
\ No newline at end of file
diff --git a/packages/linux.sh b/packages/linux.sh
index 9924eb0b..938e4ff9 100755
--- a/packages/linux.sh
+++ b/packages/linux.sh
@@ -36,6 +36,7 @@ mkdir -p dist/pamhyr/lang
 cp -r ../src/lang/*.qm dist/pamhyr/lang/
 
 cp ../VERSION dist/pamhyr/
+cp ../AUTHORS dist/pamhyr/
 
 echo " *** MAKE SRC PACKAGE"
 
diff --git a/packages/windows.bat b/packages/windows.bat
index c5d150df..84d55613 100644
--- a/packages/windows.bat
+++ b/packages/windows.bat
@@ -16,6 +16,7 @@ copy /y ..\src\View\ui\Widgets\*.ui dist\pamhyr\View\ui\Widgets
 copy /y ..\src\View\ui\*.ui dist\pamhyr\View\ui\
 copy /y ..\src\lang\*.qm dist\pamhyr\lang\
 copy /y ..\VERSION dist\pamhyr\
+copy /y ..\AUTHORS dist\pamhyr\
 
 rem Make installer
 "C:\Program Files (x86)\NSIS\makensis.exe" pamhyr.nsi
diff --git a/src/AUTHORS b/src/AUTHORS
new file mode 120000
index 00000000..9eadf712
--- /dev/null
+++ b/src/AUTHORS
@@ -0,0 +1 @@
+../AUTHORS
\ No newline at end of file
diff --git a/src/View/About/Window.py b/src/View/About/Window.py
index 2ff5f3ce..a1784509 100644
--- a/src/View/About/Window.py
+++ b/src/View/About/Window.py
@@ -5,24 +5,42 @@ import logging
 
 from View.ASubWindow import ASubWindow
 
+from PyQt5.QtCore import QCoreApplication
+
+_translate = QCoreApplication.translate
 logger = logging.getLogger()
 
 class AboutWindow(ASubWindow):
+    def _path_file(self, filename):
+        return os.path.abspath(
+            os.path.join(
+                os.path.dirname(__file__),
+                "..", "..", filename
+            )
+        )
+
+
     def __init__(self, title="About", parent=None):
         super(AboutWindow, self).__init__(name=title, ui="about", parent=parent)
         self.ui.setWindowTitle(title)
 
-        with open(
-                os.path.abspath(
-                    os.path.join(
-                        os.path.dirname(__file__),
-                        "..", "..", "VERSION"
-                    )
-                ), "r"
-        ) as f:
+        # Version
+        with open(self._path_file("VERSION"), "r") as f:
             version = f.readline()
-            logger.info(version)
+            logger.info(f"version:  {version}")
 
             label = self.get_label_text("label_version")
             label = label.replace("@version", version.strip())
             self.set_label_text("label_version", label)
+
+        # Authors
+        with open(self._path_file("AUTHORS"), "r") as f:
+            label = ""
+            try:
+                while True:
+                    author = next(f).strip()
+                    logger.info(f"author: {author}")
+                    label = f"\n  © {author}" + label
+            except StopIteration:
+                label = _translate("About", "Contributors: ") + label
+                self.set_label_text("label_copyright", label)
diff --git a/src/View/ui/about.ui b/src/View/ui/about.ui
index 7d9ab7b6..579e0095 100644
--- a/src/View/ui/about.ui
+++ b/src/View/ui/about.ui
@@ -46,7 +46,7 @@
      <item>
       <widget class="QLabel" name="label_copyright">
        <property name="text">
-        <string>© Pierre-Antoine ROUBY - INRAE -2023</string>
+        <string>...</string>
        </property>
       </widget>
      </item>
-- 
GitLab