Added option to change nicklist visibility

This commit is contained in:
Ricky 2016-11-14 02:08:06 -08:00
parent cbc372c033
commit 473336e643
3 changed files with 18 additions and 3 deletions

View File

@ -149,9 +149,10 @@ class Buffer(QtCore.QObject):
bufferInput = qt_compat.Signal(str, str)
def __init__(self, data={}):
def __init__(self, data={}, config=False):
QtCore.QObject.__init__(self)
self.data = data
self.config = config
self.nicklist = {}
self.widget = BufferWidget(display_nicklist=self.data.get('nicklist',
0))
@ -222,6 +223,12 @@ class Buffer(QtCore.QObject):
nick['visible'] = visible
break
def nicklist_update_config(self):
"""Match nicklist to configuration, quicker than a refresh"""
if (self.config):
setting = self.config.get("look", "nick_list") != "off"
self.widget.nicklist.setVisible(setting)
def nicklist_refresh(self):
"""Refresh nicklist."""
self.widget.nicklist.clear()
@ -245,4 +252,8 @@ class Buffer(QtCore.QObject):
icon = QtGui.QIcon(pixmap)
item = QtGui.QListWidgetItem(icon, nick['name'])
self.widget.nicklist.addItem(item)
self.widget.nicklist.setVisible(True)
if self.config and self.config.get("look",
"nick_list") == "off":
self.widget.nicklist.setVisible(False)
else:
self.widget.nicklist.setVisible(True)

View File

@ -38,6 +38,7 @@ CONFIG_DEFAULT_OPTIONS = (('relay.server', ''),
('look.debug', 'off'),
('look.style', ''),
('look.buffer_list', 'left'),
('look.nick_list', 'on'),
('look.toolbar', 'on'),
('look.statusbar', 'off'))

View File

@ -203,6 +203,9 @@ class MainWindow(QtGui.QMainWindow):
self.splitter.insertWidget(1, self.list_buffers)
else:
self.splitter.insertWidget(1, self.stacked_buffers)
# Update visibility of all nicklists:
for buffer in self.buffers:
buffer.nicklist_update_config()
def _buffer_switch(self, index):
"""Switch to a buffer."""
@ -516,7 +519,7 @@ class MainWindow(QtGui.QMainWindow):
def create_buffer(self, item):
"""Create a new buffer."""
buf = Buffer(item)
buf = Buffer(item, self.config)
buf.bufferInput.connect(self.buffer_input)
buf.widget.input.bufferSwitchPrev.connect(
self.list_buffers.switch_prev_buffer)