[add] style settings option

This commit is contained in:
Marcel Paffrath 2017-09-11 13:27:32 +02:00
parent d93a571a51
commit f0e4ba5ab2
2 changed files with 29 additions and 5 deletions

View File

@ -554,9 +554,9 @@ class MainWindow(QMainWindow):
self.pg = pg
# init style
self.set_style('dark')
#self.set_style('bright')
#self.set_style('default')
settings = QSettings()
style = settings.value('style')
self.set_style(style)
# add event combo box and ref/test buttons
self.eventBox = self.createEventBox()
@ -698,11 +698,13 @@ class MainWindow(QMainWindow):
stylecolors['stylesheet'] = stylesheet
def set_style(self, stylename='default'):
def set_style(self, stylename=None):
if not stylename:
stylename = 'default'
if not stylename in self._styles:
qmb = QMessageBox.warning(self, 'Could not find style',
'Could not find style with name {}. Using default.'.format(stylename))
self.set_style()
self.set_style('default')
return
style = self._styles[stylename]
@ -740,6 +742,10 @@ class MainWindow(QMainWindow):
pg.setConfigOption('background', bg_color)
pg.setConfigOption('foreground', line_color)
settings = QSettings()
settings.setValue('style', stylename)
settings.sync()
@property
def metadata(self):
return self._metadata
@ -3182,6 +3188,7 @@ def create_window():
# window.show()
return app, app_created
def main(args=None):
project_filename = None
#args.project_filename = 'C:/Shared/AlpArray/alparray_data/project_alparray_test.plp'

View File

@ -3422,6 +3422,7 @@ class SubmitLocal(QWidget):
class PropertiesDlg(QDialog):
def __init__(self, parent=None, infile=None, inputs=None):
super(PropertiesDlg, self).__init__(parent)
self._pylot_mainwindow = self.parent()
self.infile = infile
self.inputs = inputs
@ -3722,14 +3723,26 @@ class PhasesTab(PropTab):
class GraphicsTab(PropTab):
def __init__(self, parent=None):
super(GraphicsTab, self).__init__(parent)
self.pylot_mainwindow = parent._pylot_mainwindow
self.init_layout()
self.add_pg_cb()
self.add_nth_sample()
self.add_style_settings()
self.setLayout(self.main_layout)
def init_layout(self):
self.main_layout = QGridLayout()
def add_style_settings(self):
styles = self.pylot_mainwindow._styles
label = QtGui.QLabel('Application style (might require Application restart):')
self.style_cb = QComboBox()
for stylename, style in styles.items():
self.style_cb.addItem(stylename, style)
self.main_layout.addWidget(label, 2, 0)
self.main_layout.addWidget(self.style_cb, 2, 1)
self.style_cb.activated.connect(self.set_current_style)
def add_nth_sample(self):
settings = QSettings()
nth_sample = settings.value("nth_sample")
@ -3763,6 +3776,10 @@ class GraphicsTab(PropTab):
self.main_layout.addWidget(label, 0, 0)
self.main_layout.addWidget(self.checkbox_pg, 0, 1)
def set_current_style(self):
selected_style = self.style_cb.currentText()
self.pylot_mainwindow.set_style(selected_style)
def getValues(self):
values = {'nth_sample': self.spinbox_nth_sample.value(),
'pyqtgraphic': self.checkbox_pg.isChecked()}