Reordered settings and formatting fixes.

This commit is contained in:
Ricky 2016-11-15 01:53:34 -08:00
parent 0bfb73d20c
commit b23d7a8772

View File

@ -43,15 +43,23 @@ class PreferencesDialog(QtGui.QDialog):
splitter.addWidget(self.list_panes) splitter.addWidget(self.list_panes)
splitter.addWidget(self.stacked_panes) splitter.addWidget(self.stacked_panes)
for section_name in self.config.sections(): # Follow same order as defaults:
item = QtGui.QTreeWidgetItem(section_name) section_panes = {}
item.setText(0, section_name) for section in self.config.sections():
pane = PreferencesPaneWidget(section_name) item = QtGui.QTreeWidgetItem(section)
item.setText(0, section)
section_panes[section] = PreferencesPaneWidget(section)
self.list_panes.addTopLevelItem(item) self.list_panes.addTopLevelItem(item)
self.stacked_panes.addWidget(pane) self.stacked_panes.addWidget(section_panes[section])
for name, value in self.config.items(section_name):
pane.addItem(name, value) for setting, default in config.CONFIG_DEFAULT_OPTIONS:
section, key = setting.split(".")
section_panes[section].addItem(key, self.config.get(section, key))
for key, value in self.config.items("color"):
section_panes["color"].addItem(key, value)
self.list_panes.currentItemChanged.connect(self._pane_switch) self.list_panes.currentItemChanged.connect(self._pane_switch)
self.list_panes.setCurrentItem(self.list_panes.topLevelItem(0))
hbox = QtGui.QHBoxLayout() hbox = QtGui.QHBoxLayout()
self.dialog_buttons = QtGui.QDialogButtonBox() self.dialog_buttons = QtGui.QDialogButtonBox()
@ -100,18 +108,10 @@ class PreferencesTreeWidget(QtGui.QTreeWidget):
QtGui.QTreeWidget.__init__(*(self,) + args) QtGui.QTreeWidget.__init__(*(self,) + args)
self.setHeaderLabel(header_label) self.setHeaderLabel(header_label)
self.setRootIsDecorated(False) self.setRootIsDecorated(False)
self.setMaximumWidth(90)
def switch_prev_buffer(self): self.setTextElideMode(QtCore.Qt.ElideNone)
if self.currentRow() > 0: self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setCurrentRow(self.currentRow() - 1) self.setFocusPolicy(QtCore.Qt.NoFocus)
else:
self.setCurrentRow(self.count() - 1)
def switch_next_buffer(self):
if self.currentRow() < self.count() - 1:
self.setCurrentRow(self.currentRow() + 1)
else:
self.setCurrentRow(0)
class PreferencesColorEdit(QtGui.QPushButton): class PreferencesColorEdit(QtGui.QPushButton):
@ -164,18 +164,19 @@ class PreferencesPaneWidget(QtGui.QWidget):
self.grid.setColumnStretch(2, 1) self.grid.setColumnStretch(2, 1)
self.grid.setSpacing(10) self.grid.setSpacing(10)
self.checkboxes = ("ssl", "autoconnect", "statusbar", "topic", self.checkboxes = ("ssl", "autoconnect", "statusbar", "topic",
"menubar", "toolbar", "nicklist", "debug") "menubar", "toolbar", "nicklist", "debug")
self.comboboxes = {"style": QtGui.QStyleFactory.keys(), self.comboboxes = {"style": QtGui.QStyleFactory.keys(),
"buffer_list": ["left", "right"]} "buffer_list": ["left", "right"]}
def addItem(self, key, value): def addItem(self, key, value):
"""Add a key-value pair.""" """Add a key-value pair."""
line = len(self.fields) line = len(self.fields)
name = key.capitalize().replace("_", " ")
start = 0 start = 0
if self.section_name == "color": if self.section_name == "color":
start = 2 * (line % 2) start = 2 * (line % 2)
line = line // 2 line = line // 2
self.grid.addWidget(QtGui.QLabel(key.capitalize()), line, start + 0) self.grid.addWidget(QtGui.QLabel(name), line, start + 0)
if self.section_name == "color": if self.section_name == "color":
edit = PreferencesColorEdit() edit = PreferencesColorEdit()
edit.setFixedWidth(edit.sizeHint().height()) edit.setFixedWidth(edit.sizeHint().height())