From 7d56dc856918b0b8e842ff98f9b522ace738c660 Mon Sep 17 00:00:00 2001
From: Oscar Gustafsson <oscar.gustafsson@gmail.com>
Date: Wed, 10 May 2023 12:29:49 +0200
Subject: [PATCH] Add qtgallery

---
 README.md                              |  1 +
 b_asic/scheduler_gui/main_window.py    |  2 +-
 b_asic/scheduler_gui/main_window.ui    |  3 +++
 b_asic/scheduler_gui/ui_main_window.py |  1 +
 docs_sphinx/conf.py                    | 19 +++++++++++++++++++
 examples/secondorderdirectformiir.py   |  4 ++++
 requirements_doc.txt                   |  1 +
 7 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index fb3ee09e..e86058a0 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,7 @@ To generate the documentation, the following additional packages are required:
     -   [Sphinx-Gallery](https://sphinx-gallery.github.io/)
     -   [mplsignal](https://mplsignal.readthedocs.io/)
     -   [jupyters-sphinx](https://jupyter-sphinx.readthedocs.io/)
+    -   [qtgallery](https://github.com/ixjlyons/qtgallery)
 
 ### Using setuptools to create a package
 
diff --git a/b_asic/scheduler_gui/main_window.py b/b_asic/scheduler_gui/main_window.py
index a182ad2e..a2c81fa0 100644
--- a/b_asic/scheduler_gui/main_window.py
+++ b/b_asic/scheduler_gui/main_window.py
@@ -577,7 +577,7 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
         'hide_exit_dialog' in settings.
         """
         settings = QSettings()
-        hide_dialog = settings.value("scheduler/hide_exit_dialog", False, bool)
+        hide_dialog = settings.value("scheduler/hide_exit_dialog", True, bool)
         ret = QMessageBox.StandardButton.Yes
 
         if not hide_dialog:
diff --git a/b_asic/scheduler_gui/main_window.ui b/b_asic/scheduler_gui/main_window.ui
index 4bd2dd0c..6b230226 100644
--- a/b_asic/scheduler_gui/main_window.ui
+++ b/b_asic/scheduler_gui/main_window.ui
@@ -385,6 +385,9 @@
    <property name="checkable">
     <bool>true</bool>
    </property>
+   <property name="checked">
+    <bool>true</bool>
+   </property>
    <property name="icon">
     <iconset theme="view-close">
      <normaloff>../../../.designer/backup</normaloff>../../../.designer/backup</iconset>
diff --git a/b_asic/scheduler_gui/ui_main_window.py b/b_asic/scheduler_gui/ui_main_window.py
index 1409e7fc..f636678e 100644
--- a/b_asic/scheduler_gui/ui_main_window.py
+++ b/b_asic/scheduler_gui/ui_main_window.py
@@ -186,6 +186,7 @@ class Ui_MainWindow(object):
         self.menu_save_as.setObjectName("menu_save_as")
         self.menu_exit_dialog = QtWidgets.QAction(MainWindow)
         self.menu_exit_dialog.setCheckable(True)
+        self.menu_exit_dialog.setChecked(True)
         icon = QtGui.QIcon.fromTheme("view-close")
         self.menu_exit_dialog.setIcon(icon)
         self.menu_exit_dialog.setObjectName("menu_exit_dialog")
diff --git a/docs_sphinx/conf.py b/docs_sphinx/conf.py
index aae9c64e..dc42428a 100644
--- a/docs_sphinx/conf.py
+++ b/docs_sphinx/conf.py
@@ -5,8 +5,11 @@
 
 # -- Project information -----------------------------------------------------
 # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
+
 import shutil
 
+import qtgallery
+
 project = 'B-ASIC'
 copyright = '2020-2023, Oscar Gustafsson et al'
 author = 'Oscar Gustafsson et al'
@@ -25,6 +28,7 @@ extensions = [
     'sphinx_gallery.gen_gallery',
     'numpydoc',  # Needs to be loaded *after* autodoc.
     'jupyter_sphinx',
+    'qtgallery',
 ]
 
 templates_path = ['_templates']
@@ -66,4 +70,19 @@ sphinx_gallery_conf = {
     'filename_pattern': '.',
     'doc_module': ('b_asic',),
     'reference_url': {'b_asic': None},
+    'image_scrapers': (
+        'matplotlib',
+        qtgallery.qtscraper,
+    ),
+    'reset_modules': (
+        'matplotlib',
+        qtgallery.reset_qapp,
+    ),
+}
+
+qtgallery_conf = {
+    "xvfb_size": (640, 480),
+    "xvfb_color_depth": 24,
+    "xfvb_use_xauth": False,
+    "xfvb_extra_args": [],
 }
diff --git a/examples/secondorderdirectformiir.py b/examples/secondorderdirectformiir.py
index e78a48f3..cf481598 100644
--- a/examples/secondorderdirectformiir.py
+++ b/examples/secondorderdirectformiir.py
@@ -41,3 +41,7 @@ sfg.set_execution_time_of_type(Addition.type_name(), 1)
 
 schedule = Schedule(sfg, cyclic=True)
 schedule.show()
+
+# %%
+# To edit the schedule in the GUI use:
+schedule.edit()
diff --git a/requirements_doc.txt b/requirements_doc.txt
index 5112621b..3bffd7ca 100644
--- a/requirements_doc.txt
+++ b/requirements_doc.txt
@@ -4,3 +4,4 @@ numpydoc
 sphinx-gallery
 mplsignal
 jupyter-sphinx
+qtgallery
-- 
GitLab