def doProjectPathValidate(self): """ Validate project settings. """ caption = '' enabled = True ############################################# # CHECK NAME ################################# name = self.nameField.value() path = self.pathField.value() if not name: caption = '' enabled = False else: if isdir(path): caption = "Project '{0}' already exists!".format(name) enabled = False elif not isPathValid(path): caption = "'{0}' is not a valid project name!".format(name) enabled = False ############################################# # CHECK PREFIX ################################# if enabled: if not self.prefixField.value(): caption = '' enabled = False ############################################# # CHECK IRI ################################# if enabled: if not self.iriField.value(): caption = '' enabled = False self.caption.setText(caption) self.caption.setVisible(not isEmpty(caption)) self.confirmationBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(enabled) self.setFixedSize(self.sizeHint())
def doAcceptForm(self): """ Validate project settings. """ caption = '' enabled = True ############################################# # CHECK NAME ################################# if not self.name(): caption = '' enabled = False else: if isdir(self.path()): caption = "Project '{0}' already exists!".format(self.name()) enabled = False elif not isPathValid(self.path()): caption = "'{0}' is not a valid project name!".format( self.name()) enabled = False ############################################# # CHECK PREFIX ################################# if enabled: #if not self.prefix(): if not self.prefixes(): caption = '' enabled = False ############################################# # CHECK IRI ################################# if enabled: if not self.iri(): caption = '' enabled = False self.caption.setText(caption) self.caption.setVisible(not isEmpty(caption)) self.confirmationBox.button( QtWidgets.QDialogButtonBox.Ok).setEnabled(enabled) self.setFixedSize(self.sizeHint())
def browseWorkspace(self): """ Bring up a modal window that allows the user to choose a valid workspace path. """ path = self.widget('workspace_field').value() if not isPathValid(path): path = expandPath('~') dialog = QtWidgets.QFileDialog(self) dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen) dialog.setDirectory(path) dialog.setFileMode(QtWidgets.QFileDialog.Directory) dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, True) dialog.setViewMode(QtWidgets.QFileDialog.Detail) if dialog.exec_() == QtWidgets.QFileDialog.Accepted: self.widget('workspace_field').setValue(first(dialog.selectedFiles()))
def choosePath(self): """ Bring up a modal window that allows the user to choose a valid workspace path. """ path = self.workspaceField.value() if not isPathValid(path): path = expandPath('~') dialog = QtWidgets.QFileDialog(self) dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen) dialog.setDirectory(path) dialog.setFileMode(QtWidgets.QFileDialog.Directory) dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, True) dialog.setViewMode(QtWidgets.QFileDialog.Detail) if dialog.exec_() == QtWidgets.QFileDialog.Accepted: self.workspaceField.setValue(first(dialog.selectedFiles()))
def selectPlugin(self): """ Bring up a modal window that allows the user to choose a valid plugin archive. """ path = os.path.dirname(self.pluginField.value()) if not isPathValid(path): path = expandPath('~') dialog = QtWidgets.QFileDialog(self) dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen) dialog.setDirectory(path) dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile) dialog.setViewMode(QtWidgets.QFileDialog.Detail) dialog.setNameFilters([File.Zip.value]) if dialog.exec_() == QtWidgets.QFileDialog.Accepted: self.pluginField.setValue(first(dialog.selectedFiles())) self.confirmationBox.setEnabled(not isEmpty(self.pluginField.value()))
def selectPlugin(self): """ Bring up a modal window that allows the user to choose a valid plugin archive. """ path = os.path.dirname(self.pluginField.value()) if not isPathValid(path): path = expandPath('~') dialog = QtWidgets.QFileDialog(self) dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen) dialog.setDirectory(path) dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile) dialog.setViewMode(QtWidgets.QFileDialog.Detail) dialog.setNameFilters([File.Zip.value]) if dialog.exec_() == QtWidgets.QFileDialog.Accepted: self.pluginField.setValue(first(dialog.selectedFiles())) self.confirmationBox.setEnabled( not isEmpty(self.pluginField.value()))