From d1f06a21dab77247aa4d667019653fb2f14af94f Mon Sep 17 00:00:00 2001 From: Edoardo Pasca <14138589+paskino@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:07:07 +0100 Subject: [PATCH 1/3] use eqt FormDialog closes #317 --- src/idvc/dvc_interface.py | 5 +-- src/idvc/ui/dialogs.py | 75 ++++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/src/idvc/dvc_interface.py b/src/idvc/dvc_interface.py index 876bdd21..27a56afe 100644 --- a/src/idvc/dvc_interface.py +++ b/src/idvc/dvc_interface.py @@ -172,7 +172,7 @@ def __init__(self): self.CreateWorkingTempFolder() #Load Settings: - self.settings = QSettings("CCPi", "DVC Interface v20.7.2") + self.settings = QSettings("CCPi", "DVC Interface v24.0.1") if self.settings.value("copy_files"): self.copy_files = True @@ -223,7 +223,8 @@ def CreateWorkingTempFolder(self): os.mkdir("Results") def OpenSettings(self): - self.settings_window = SettingsWindow(self) + if not hasattr(self, 'settings_window'): + self.settings_window = SettingsWindow(self) self.settings_window.show() def InitialiseSessionVars(self): diff --git a/src/idvc/ui/dialogs.py b/src/idvc/ui/dialogs.py index c4ff0d1b..384a4aad 100644 --- a/src/idvc/ui/dialogs.py +++ b/src/idvc/ui/dialogs.py @@ -5,68 +5,82 @@ import multiprocessing import vtk +from eqt.ui.FormDialog import FormDialog -class SettingsWindow(QDialog): - def __init__(self, parent): - super(SettingsWindow, self).__init__(parent) +class SettingsWindow(FormDialog): + + def __init__(self, parent, title="Settings"): + + super(SettingsWindow, self).__init__(parent, title) self.parent = parent - self.setWindowTitle("Settings") + self.dark_checkbox = QCheckBox("Dark Mode") + # populate from settings + if self.parent.settings.value("dark_mode") is not None: + if self.parent.settings.value("dark_mode") == "true": + self.dark_checkbox.setChecked(True) + else: + self.dark_checkbox.setChecked(False) + else: + self.dark_checkbox.setChecked(True) + + self.addWidget(self.dark_checkbox, '', 'darkmode') self.copy_files_checkbox = QCheckBox("Allow a copy of the image files to be stored. ") + self.addWidget(self.copy_files_checkbox, '', 'copy_file_checkbox') self.vis_size_label = QLabel("Maximum downsampled image size (GB): ") self.vis_size_entry = QDoubleSpinBox() - self.vis_size_entry.setMaximum(64.0) self.vis_size_entry.setMinimum(0.01) self.vis_size_entry.setSingleStep(0.01) - + # populate from settings if self.parent.settings.value("vis_size") is not None: self.vis_size_entry.setValue(float(self.parent.settings.value("vis_size"))) - else: self.vis_size_entry.setValue(1.0) + self.addWidget(self.vis_size_entry, self.vis_size_label, 'vis_size') - if self.parent.settings.value("dark_mode") is not None: - if self.parent.settings.value("dark_mode") == "true": - self.dark_checkbox.setChecked(True) - else: - self.dark_checkbox.setChecked(False) - else: - self.dark_checkbox.setChecked(True) - + separator = QFrame() separator.setFrameShape(QFrame.HLine) separator.setFrameShadow(QFrame.Raised) self.adv_settings_label = QLabel("Advanced") + + self.addSpanningWidget(separator,'separator') + self.addSpanningWidget(self.adv_settings_label, 'advanced_label') self.gpu_label = QLabel("Please set the size of your GPU memory.") self.gpu_size_label = QLabel("GPU Memory (GB): ") self.gpu_size_entry = QDoubleSpinBox() + self.addSpanningWidget(self.gpu_label, 'gpu_label') + self.addWidget(self.gpu_size_entry, self.gpu_size_label, 'gpu_size') + # populate from settings if self.parent.settings.value("gpu_size") is not None: self.gpu_size_entry.setValue(float(self.parent.settings.value("gpu_size"))) - else: self.gpu_size_entry.setValue(1.0) self.gpu_size_entry.setMaximum(64.0) self.gpu_size_entry.setMinimum(0.00) self.gpu_size_entry.setSingleStep(0.01) + + self.gpu_checkbox = QCheckBox("Use GPU for volume render. (Recommended) ") self.gpu_checkbox.setChecked(True) #gpu is default if self.parent.settings.value("volume_mapper") == "cpu": self.gpu_checkbox.setChecked(False) - if hasattr(self.parent, 'copy_files'): self.copy_files_checkbox.setChecked(self.parent.copy_files) + self.addWidget(self.gpu_checkbox, '', 'gpu_checkbox') + self.omp_threads_entry = QSpinBox(self) # default OMP_THREADS based on the number of cores available @@ -87,31 +101,10 @@ def __init__(self, parent): self.omp_threads_entry.setSingleStep(1) self.omp_threads_label = QLabel("OMP Threads: ") + self.addWidget(self.omp_threads_entry, self.omp_threads_label, 'use_omp') - self.layout = QVBoxLayout(self) - self.layout.addWidget(self.dark_checkbox) - self.layout.addWidget(self.copy_files_checkbox) - self.layout.addWidget(self.vis_size_label) - self.layout.addWidget(self.vis_size_entry) - self.layout.addWidget(separator) - self.layout.addWidget(self.adv_settings_label) - self.layout.addWidget(self.gpu_checkbox) - self.layout.addWidget(self.gpu_label) - self.layout.addWidget(self.gpu_size_label) - self.layout.addWidget(self.gpu_size_entry) - - self.layout.addWidget(self.omp_threads_label) - self.layout.addWidget(self.omp_threads_entry) - - - self.buttons = QDialogButtonBox( - QDialogButtonBox.Save | QDialogButtonBox.Cancel, - Qt.Horizontal, self) - self.layout.addWidget(self.buttons) - self.buttons.accepted.connect(self.accept) - self.buttons.rejected.connect(self.quit) - def accept(self): + def onOk(self): #self.parent.settings.setValue("settings_chosen", 1) if self.dark_checkbox.isChecked(): self.parent.settings.setValue("dark_mode", True) @@ -144,7 +137,7 @@ def accept(self): #print(self.parent.settings.value("copy_files")) - def quit(self): + def onCancel(self): if self.parent.settings.value("first_app_load") != "False": self.parent.CreateSessionSelector("new window") self.parent.settings.setValue("first_app_load", "False") From 83449f3760bc8b69efc20ceafb0fee0825531e97 Mon Sep 17 00:00:00 2001 From: DanicaSTFC <138598662+DanicaSTFC@users.noreply.github.com> Date: Mon, 29 Jul 2024 12:08:31 +0100 Subject: [PATCH 2/3] Update installation.rst --- docs/source/installation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index b2eaf34f..c3e75802 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -30,7 +30,7 @@ Alternatively, if you would only like to install the dvc executable and not the 1. Install miniconda 2. Open an anaconda prompt (miniconda) and type…. -3. ``conda create --name dvc-core ccpi-dvc -c ccpi -c conda-forge `` +3. ``conda create --name dvc-core ccpi-dvc -c ccpi -c conda-forge`` 4. ``activate dvc-core`` 5. ``dvc`` From a0dbf60b18916f5ab3db020529898c775e03cbf9 Mon Sep 17 00:00:00 2001 From: Danica Sugic Date: Mon, 29 Jul 2024 12:22:51 +0100 Subject: [PATCH 3/3] Move dialog instance --- src/idvc/dvc_interface.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/idvc/dvc_interface.py b/src/idvc/dvc_interface.py index 27a56afe..d89b825f 100644 --- a/src/idvc/dvc_interface.py +++ b/src/idvc/dvc_interface.py @@ -105,6 +105,7 @@ class MainWindow(QMainWindow): def __init__(self): + """Creates an instance of the setting form dialog.""" QMainWindow.__init__(self) self.threadpool = QThreadPool() @@ -181,6 +182,7 @@ def __init__(self): self.SetAppStyle() + self.settings_window = SettingsWindow(self) if self.settings.value("first_app_load") != "False": self.OpenSettings() # self.settings.setValue("first_app_load", False) @@ -223,8 +225,7 @@ def CreateWorkingTempFolder(self): os.mkdir("Results") def OpenSettings(self): - if not hasattr(self, 'settings_window'): - self.settings_window = SettingsWindow(self) + """Shows the settings dialog.""" self.settings_window.show() def InitialiseSessionVars(self):