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

Refactor gui settings #314

Merged
merged 15 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
14 changes: 7 additions & 7 deletions gui/azure_config_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
az_blob_tier = ['none','hot','cool','archive']

class azureAdvancedSettingsWidget(widgetCustomFunctions, Ui_Form):
def __init__(self):
def __init__(self,configSettings):
super().__init__()
self.setupUi(self)
self.setWindowTitle("Advanced Azure Config Settings")
self.settings = QSettings(QSettings.Format.IniFormat,QSettings.Scope.UserScope,"CloudFUSE", "settings")
self.settings = configSettings
self.myWindow = QSettings("CloudFUSE", "AzAdvancedWindow")
self.initWindowSizePos()
self.populateOptions()
Expand All @@ -56,9 +56,9 @@ def __init__(self):


def populateOptions(self):
fileCache = self.settings.value('file_cache')
azStorage = self.settings.value('azstorage')
libfuse = self.settings.value('libfuse')
fileCache = self.settings['file_cache']
azStorage = self.settings['azstorage']
libfuse = self.settings['libfuse']

self.setCheckboxFromSetting(self.checkBox_libfuse_disableWriteback,libfuse['disable-writeback-cache'])
self.setCheckboxFromSetting(self.checkBox_libfuse_networkshare, libfuse['network-share'])
Expand Down Expand Up @@ -107,7 +107,7 @@ def populateOptions(self):
self.checkBox_libfuse_networkshare.setToolTip("Network share is only supported on Windows")

def updateOptionalAzStorage(self):
azStorage = self.settings.value('azstorage')
azStorage = self.settings['azstorage']
azStorage['block-size-mb'] = self.spinBox_azure_blockSize.value()
azStorage['max-concurrency'] = self.spinBox_azure_maxConcurrency.value()
azStorage['block-list-on-mount-sec'] = self.spinBox_azure_blockOnMount.value()
Expand All @@ -131,7 +131,7 @@ def updateOptionalAzStorage(self):
azStorage['auth-resource'] = self.lineEdit_azure_authResource.text()

azStorage['tier'] = az_blob_tier[self.dropDown_azure_blobTier.currentIndex()]
self.settings.setValue('azstorage',azStorage)
self.settings['azstorage'] = azStorage

def updateSettingsFromUIChoices(self):
self.updateOptionalAzStorage()
Expand Down
44 changes: 22 additions & 22 deletions gui/azure_config_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
azStorageType = ["block", "adls"]
libfusePermissions = [0o777,0o666,0o644,0o444]

class azureSettingsWidget(defaultSettingsManager,widgetCustomFunctions, Ui_Form):
def __init__(self):
class azureSettingsWidget(widgetCustomFunctions, Ui_Form):
def __init__(self,configSettings):
super().__init__()
self.setupUi(self)
self.setWindowTitle("Azure Config Settings")
self.myWindow = QSettings("CloudFUSE", "AzcWindow")
self.settings = configSettings
self.initWindowSizePos()
self.initSettingsFromConfig()
# Hide the pipeline mode groupbox depending on the default select is
self.showAzureModeSettings()
self.showModeSettings()
Expand Down Expand Up @@ -79,7 +79,7 @@ def __init__(self):
# Set up slots

def updateAzStorage(self):
azStorage = self.settings.value('azstorage')
azStorage = self.settings['azstorage']
azStorage['account-key'] = self.lineEdit_azure_accountKey.text()
azStorage['sas'] = self.lineEdit_azure_sasStorage.text()
azStorage['account-name'] = self.lineEdit_azure_accountName.text()
Expand All @@ -93,10 +93,10 @@ def updateAzStorage(self):
azStorage['clientsecret'] = self.lineEdit_azure_spnClientSecret.text()
azStorage['type'] = azStorageType[self.dropDown_azure_storageType.currentIndex()]
azStorage['mode'] = bucketModeChoices[self.dropDown_azure_modeSetting.currentIndex()]
self.settings.setValue('azstorage',azStorage)
self.settings['azstorage'] = azStorage

def openAdvanced(self):
self.moreSettings = azureAdvancedSettingsWidget()
self.moreSettings = azureAdvancedSettingsWidget(self.settings)
self.moreSettings.setWindowModality(Qt.ApplicationModal)
self.moreSettings.show()

Expand All @@ -105,14 +105,14 @@ def openAdvanced(self):
# There is one slot for the signal to be pointed at which is why showmodesettings is used.
def showModeSettings(self):
self.hideModeBoxes()
components = self.settings.value('components')
components = self.settings['components']
pipelineIndex = self.dropDown_pipeline.currentIndex()
components[1] = pipelineChoices[pipelineIndex]
if pipelineChoices[pipelineIndex] == 'file_cache':
self.groupbox_fileCache.setVisible(True)
elif pipelineChoices[pipelineIndex] == 'stream':
self.groupbox_streaming.setVisible(True)
self.settings.setValue('components',components)
self.settings['components'] = components

def showAzureModeSettings(self):
self.hideAzureBoxes()
Expand All @@ -129,23 +129,23 @@ def showAzureModeSettings(self):

# This widget will not display all the options in settings, only the ones written in the UI file.
def populateOptions(self):
fileCache = self.settings.value('file_cache')
azStorage = self.settings.value('azstorage')
libfuse = self.settings.value('libfuse')
stream = self.settings.value('stream')
fileCache = self.settings['file_cache']
azStorage = self.settings['azstorage']
libfuse = self.settings['libfuse']
stream = self.settings['stream']

# The QCombo (dropdown selection) uses indices to determine the value to show the user. The pipelineChoices, libfusePermissions, azStorage and bucketMode
# reflect the index choices in human words without having to reference the UI.
# Get the value in the settings and translate that to the equivalent index in the lists.
self.dropDown_pipeline.setCurrentIndex(pipelineChoices.index(self.settings.value('components')[1]))
self.dropDown_libfuse_permissions.setCurrentIndex(libfusePermissions.index(self.settings.value('libfuse')['default-permission']))
self.dropDown_azure_storageType.setCurrentIndex(azStorageType.index(self.settings.value('azstorage')['type']))
self.dropDown_azure_modeSetting.setCurrentIndex(bucketModeChoices.index(self.settings.value('azstorage')['mode']))
self.dropDown_pipeline.setCurrentIndex(pipelineChoices.index(self.settings['components'][1]))
self.dropDown_libfuse_permissions.setCurrentIndex(libfusePermissions.index(self.settings['libfuse']['default-permission']))
self.dropDown_azure_storageType.setCurrentIndex(azStorageType.index(self.settings['azstorage']['type']))
self.dropDown_azure_modeSetting.setCurrentIndex(bucketModeChoices.index(self.settings['azstorage']['mode']))

self.setCheckboxFromSetting(self.checkBox_multiUser,self.settings.value('allow-other'))
self.setCheckboxFromSetting(self.checkBox_nonEmptyDir,self.settings.value('nonempty'))
self.setCheckboxFromSetting(self.checkBox_daemonForeground,self.settings.value('foreground'))
self.setCheckboxFromSetting(self.checkBox_readOnly,self.settings.value('read-only'))
self.setCheckboxFromSetting(self.checkBox_multiUser,self.settings['allow-other'])
self.setCheckboxFromSetting(self.checkBox_nonEmptyDir,self.settings['nonempty'])
self.setCheckboxFromSetting(self.checkBox_daemonForeground,self.settings['foreground'])
self.setCheckboxFromSetting(self.checkBox_readOnly,self.settings['read-only'])
self.setCheckboxFromSetting(self.checkBox_streaming_fileCachingLevel,stream['file-caching'])
self.setCheckboxFromSetting(self.checkBox_libfuse_ignoreAppend,libfuse['ignore-open-flags'])

Expand Down Expand Up @@ -193,8 +193,8 @@ def resetDefaults(self):
# Reset these defaults
checkChoice = self.popupDoubleCheckReset()
if checkChoice == QtWidgets.QMessageBox.Yes:
self.setAzureSettings()
self.setComponentSettings()
defaultSettingsManager.setAzureSettings(self, self.settings)
defaultSettingsManager.setComponentSettings(self, self.settings)
self.populateOptions()

def updateSettingsFromUIChoices(self):
Expand Down
Loading
Loading