Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use eqt FormDialog #318

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Alternatively, if you would only like to install the dvc executable and not the

1. Install miniconda<https://docs.conda.io/en/latest/miniconda.html>
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``

Expand Down
6 changes: 4 additions & 2 deletions src/idvc/dvc_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@

class MainWindow(QMainWindow):
def __init__(self):
"""Creates an instance of the setting form dialog."""
QMainWindow.__init__(self)

self.threadpool = QThreadPool()
Expand Down Expand Up @@ -172,7 +173,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
Expand All @@ -181,6 +182,7 @@ def __init__(self):

self.SetAppStyle()

self.settings_window = SettingsWindow(self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the creation of the dialog in init.

if self.settings.value("first_app_load") != "False":
self.OpenSettings()
# self.settings.setValue("first_app_load", False)
Expand Down Expand Up @@ -223,7 +225,7 @@ def CreateWorkingTempFolder(self):
os.mkdir("Results")

def OpenSettings(self):
self.settings_window = SettingsWindow(self)
"""Shows the settings dialog."""
self.settings_window.show()

def InitialiseSessionVars(self):
Expand Down
75 changes: 34 additions & 41 deletions src/idvc/ui/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand Down