preferences panel works for me; settings saved properly
This commit is contained in:
parent
4769b447a8
commit
540891f3d7
@ -209,7 +209,8 @@ class MainWindow(QMainWindow):
|
|||||||
QKeySequence.Save, saveIcon,
|
QKeySequence.Save, saveIcon,
|
||||||
"Save actual event data.")
|
"Save actual event data.")
|
||||||
prefsEventAction = self.createAction("Preferences", self.PyLoTprefs,
|
prefsEventAction = self.createAction("Preferences", self.PyLoTprefs,
|
||||||
QKeySequence.Preferences, None,
|
QKeySequence.Preferences,
|
||||||
|
QIcon(None),
|
||||||
"Edit PyLoT app preferences.")
|
"Edit PyLoT app preferences.")
|
||||||
quitAction = self.createAction("&Quit",
|
quitAction = self.createAction("&Quit",
|
||||||
QCoreApplication.instance().quit,
|
QCoreApplication.instance().quit,
|
||||||
|
@ -94,15 +94,36 @@ class PropertiesDlg(QDialog):
|
|||||||
self.connect(self.buttonBox, SIGNAL("rejected()"),
|
self.connect(self.buttonBox, SIGNAL("rejected()"),
|
||||||
self, SLOT("reject()"))
|
self, SLOT("reject()"))
|
||||||
|
|
||||||
|
def accept(self, *args, **kwargs):
|
||||||
|
self.apply()
|
||||||
|
self.destroy()
|
||||||
|
|
||||||
|
def reject(self, *args, **kwargs):
|
||||||
|
self.destroy()
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
settings = QSettings()
|
|
||||||
for widint in range(self.tabWidget.count()):
|
for widint in range(self.tabWidget.count()):
|
||||||
curwid = self.tabWidget.widget(widint)
|
curwid = self.tabWidget.widget(widint)
|
||||||
values = self.getValues(curwid)
|
values = curwid.getValues()
|
||||||
settings.setValue()
|
if values is not None: self.setValues(values)
|
||||||
|
|
||||||
|
def setValues(self, tabValues):
|
||||||
|
settings = QSettings()
|
||||||
|
for setting, value in tabValues.iteritems():
|
||||||
|
settings.setValue(setting, value)
|
||||||
|
settings.sync()
|
||||||
|
|
||||||
|
|
||||||
class InputsTab(QWidget):
|
class PropTab(QWidget):
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super(PropTab, self).__init__(parent)
|
||||||
|
|
||||||
|
def getValues(self):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class InputsTab(PropTab):
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(InputsTab, self).__init__(parent)
|
super(InputsTab, self).__init__(parent)
|
||||||
@ -113,42 +134,61 @@ class InputsTab(QWidget):
|
|||||||
|
|
||||||
fullNameLabel = QLabel("Full name for user '{0}'".format(login))
|
fullNameLabel = QLabel("Full name for user '{0}'".format(login))
|
||||||
|
|
||||||
parent.fullNameEdit = QLineEdit()
|
self.fullNameEdit = QLineEdit()
|
||||||
parent.fullNameEdit.setText(fulluser)
|
self.fullNameEdit.setText(fulluser)
|
||||||
|
|
||||||
dataroot = settings.value("data/dataRoot")
|
dataroot = settings.value("data/dataRoot")
|
||||||
dataDirLabel = QLabel("data directory:")
|
dataDirLabel = QLabel("data directory:")
|
||||||
parent.dataDirEdit = QLineEdit()
|
self.dataDirEdit = QLineEdit()
|
||||||
parent.dataDirEdit.setText(dataroot)
|
self.dataDirEdit.setText(dataroot)
|
||||||
parent.dataDirEdit.selectAll()
|
self.dataDirEdit.selectAll()
|
||||||
|
|
||||||
layout = QGridLayout()
|
layout = QGridLayout()
|
||||||
layout.addWidget(dataDirLabel, 0, 0)
|
layout.addWidget(dataDirLabel, 0, 0)
|
||||||
layout.addWidget(parent.dataDirEdit, 0, 1)
|
layout.addWidget(self.dataDirEdit, 0, 1)
|
||||||
layout.addWidget(fullNameLabel, 1, 0)
|
layout.addWidget(fullNameLabel, 1, 0)
|
||||||
layout.addWidget(parent.fullNameEdit, 1, 1)
|
layout.addWidget(self.fullNameEdit, 1, 1)
|
||||||
|
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
def getValues(self):
|
||||||
|
values = {}
|
||||||
|
values["data/dataRoot"] = self.dataDirEdit.text()
|
||||||
|
values["user/FullName"] = self.fullNameEdit.text()
|
||||||
|
return values
|
||||||
|
|
||||||
class OutputsTab(QWidget):
|
|
||||||
|
class OutputsTab(PropTab):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(OutputsTab, self).__init__(parent)
|
super(OutputsTab, self).__init__(parent)
|
||||||
|
|
||||||
eventOutputLabel = QLabel("event ouput format")
|
settings = QSettings()
|
||||||
eventOutputComboBox = QComboBox()
|
curval = settings.value("output/Format", None)
|
||||||
eventoutputformats = OUTPUTFORMATS.keys()
|
|
||||||
eventOutputComboBox.addItems(eventoutputformats)
|
|
||||||
|
|
||||||
|
eventOutputLabel = QLabel("event ouput format")
|
||||||
|
self.eventOutputComboBox = QComboBox()
|
||||||
|
eventoutputformats = OUTPUTFORMATS.keys()
|
||||||
|
self.eventOutputComboBox.addItems(eventoutputformats)
|
||||||
|
|
||||||
|
if curval is None:
|
||||||
|
ind = 0
|
||||||
|
else:
|
||||||
|
ind = self.eventOutputComboBox.findText(curval)
|
||||||
|
|
||||||
|
self.eventOutputComboBox.setCurrentIndex(ind)
|
||||||
layout = QGridLayout()
|
layout = QGridLayout()
|
||||||
layout.addWidget(eventOutputLabel, 0, 0)
|
layout.addWidget(eventOutputLabel, 0, 0)
|
||||||
layout.addWidget(eventOutputComboBox, 0, 1)
|
layout.addWidget(self.eventOutputComboBox, 0, 1)
|
||||||
|
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
def getValues(self):
|
||||||
|
values = {}
|
||||||
|
values["output/Format"] = self.eventOutputComboBox.currentText()
|
||||||
|
return values
|
||||||
|
|
||||||
class PhasesTab(QWidget):
|
class PhasesTab(PropTab):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(PhasesTab, self).__init__(parent)
|
super(PhasesTab, self).__init__(parent)
|
||||||
@ -156,7 +196,7 @@ class PhasesTab(QWidget):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class GraphicsTab(QWidget):
|
class GraphicsTab(PropTab):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(GraphicsTab, self).__init__(parent)
|
super(GraphicsTab, self).__init__(parent)
|
||||||
|
Loading…
Reference in New Issue
Block a user