Added "view" menu, toggle for menubar and topic and fullscreen
This commit is contained in:
parent
473336e643
commit
68cdba2d28
@ -184,6 +184,14 @@ class Buffer(QtCore.QObject):
|
||||
if self.data:
|
||||
self.bufferInput.emit(self.data['full_name'], text)
|
||||
|
||||
def update_config(self):
|
||||
"""Match visibility to configuration, faster than a nicklist refresh"""
|
||||
if (self.config):
|
||||
nicklist_visible = self.config.get("look", "nicklist") != "off"
|
||||
topic_visible = self.config.get("look", "topic") != "off"
|
||||
self.widget.nicklist.setVisible(nicklist_visible)
|
||||
self.widget.title.setVisible(topic_visible)
|
||||
|
||||
def nicklist_add_item(self, parent, group, prefix, name, visible):
|
||||
"""Add a group/nick in nicklist."""
|
||||
if group:
|
||||
@ -223,12 +231,6 @@ 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()
|
||||
@ -253,7 +255,7 @@ class Buffer(QtCore.QObject):
|
||||
item = QtGui.QListWidgetItem(icon, nick['name'])
|
||||
self.widget.nicklist.addItem(item)
|
||||
if self.config and self.config.get("look",
|
||||
"nick_list") == "off":
|
||||
"nicklist") == "off":
|
||||
self.widget.nicklist.setVisible(False)
|
||||
else:
|
||||
self.widget.nicklist.setVisible(True)
|
||||
|
@ -38,8 +38,10 @@ CONFIG_DEFAULT_OPTIONS = (('relay.server', ''),
|
||||
('look.debug', 'off'),
|
||||
('look.style', ''),
|
||||
('look.buffer_list', 'left'),
|
||||
('look.nick_list', 'on'),
|
||||
('look.nicklist', 'on'),
|
||||
('look.toolbar', 'on'),
|
||||
('look.menubar', 'on'),
|
||||
('look.topic', 'on'),
|
||||
('look.statusbar', 'off'))
|
||||
|
||||
# Default colors for WeeChat color options (option name, #rgb value)
|
||||
|
@ -78,7 +78,7 @@ class PreferencesDialog(QtGui.QDialog):
|
||||
def _save_and_close(self):
|
||||
for widget in (self.stacked_panes.widget(i)
|
||||
for i in range(self.stacked_panes.count())):
|
||||
for key, field in widget.fields.iteritems():
|
||||
for key, field in widget.fields.items():
|
||||
if isinstance(field, QtGui.QComboBox):
|
||||
text = field.itemText(field.currentIndex())
|
||||
else:
|
||||
|
@ -29,7 +29,10 @@ except ImportError:
|
||||
|
||||
def _pyside_import_module(moduleName):
|
||||
pyside = __import__('PySide', globals(), locals(), [moduleName], -1)
|
||||
return getattr(pyside, moduleName)
|
||||
mod = getattr(pyside, moduleName)
|
||||
if moduleName == "QtGui":
|
||||
mod.QWIDGETSIZE_MAX = ((1 << 24) - 1)
|
||||
return mod
|
||||
|
||||
|
||||
def _pyqt4_import_module(moduleName):
|
||||
|
@ -122,6 +122,27 @@ class MainWindow(QtGui.QMainWindow):
|
||||
'application-exit.png', 'Quit application',
|
||||
'Ctrl+Q', self.close],
|
||||
}
|
||||
# toggleable actions
|
||||
self.toggles_def = {
|
||||
'show menubar': [
|
||||
'look.menubar', 'Show Menubar',
|
||||
'Ctrl+M', self.toggle_menubar],
|
||||
'show toolbar': [
|
||||
'look.toolbar', 'Show Toolbar',
|
||||
False, self.toggle_toolbar],
|
||||
'show status bar': [
|
||||
'look.statusbar', 'Show Status Bar',
|
||||
False, self.toggle_statusbar],
|
||||
'show topic': [
|
||||
'look.topic', 'Show Topic',
|
||||
False, self.toggle_topic],
|
||||
'show nick list': [
|
||||
'look.nicklist', 'Show Nick List',
|
||||
'Ctrl+F7', self.toggle_nicklist],
|
||||
'fullscreen': [
|
||||
False, 'Fullscreen',
|
||||
'F11', self.toggle_fullscreen],
|
||||
}
|
||||
self.actions = {}
|
||||
for name, action in list(actions_def.items()):
|
||||
self.actions[name] = QtGui.QAction(
|
||||
@ -131,6 +152,13 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.actions[name].setStatusTip(action[1])
|
||||
self.actions[name].setShortcut(action[2])
|
||||
self.actions[name].triggered.connect(action[3])
|
||||
for name, action in list(self.toggles_def.items()):
|
||||
self.actions[name] = QtGui.QAction(name.capitalize(), self)
|
||||
self.actions[name].setStatusTip(action[1])
|
||||
self.actions[name].setCheckable(True)
|
||||
if action[2]:
|
||||
self.actions[name].setShortcut(action[2])
|
||||
self.actions[name].triggered.connect(action[3])
|
||||
|
||||
# menu
|
||||
self.menu = self.menuBar()
|
||||
@ -140,6 +168,15 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.actions['preferences'],
|
||||
self.actions['save connection'],
|
||||
self.actions['quit']])
|
||||
menu_view = self.menu.addMenu('&View')
|
||||
menu_view.addActions([self.actions['show menubar'],
|
||||
self.actions['show toolbar'],
|
||||
self.actions['show status bar'],
|
||||
self._actions_separator(),
|
||||
self.actions['show topic'],
|
||||
self.actions['show nick list'],
|
||||
self._actions_separator(),
|
||||
self.actions['fullscreen']])
|
||||
menu_window = self.menu.addMenu('&Window')
|
||||
menu_window.addAction(self.actions['debug'])
|
||||
menu_help = self.menu.addMenu('&Help')
|
||||
@ -184,6 +221,12 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
self.show()
|
||||
|
||||
def _actions_separator(self):
|
||||
"""Create a new QAction separator."""
|
||||
sep = QtGui.QAction("", self)
|
||||
sep.setSeparator(True)
|
||||
return sep
|
||||
|
||||
def apply_preferences(self):
|
||||
"""Apply non-server options from preferences."""
|
||||
app = QtCore.QCoreApplication.instance()
|
||||
@ -191,9 +234,16 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.toolbar.show()
|
||||
else:
|
||||
self.toolbar.hide()
|
||||
# Change the height to avoid losing all hotkeys:
|
||||
if self.config.getboolean('look', 'menubar'):
|
||||
self.menu.setMaximumHeight(QtGui.QWIDGETSIZE_MAX)
|
||||
else:
|
||||
self.menu.setFixedHeight(1)
|
||||
# Apply the selected qt style here so it will update without a restart
|
||||
if self.config.get('look', 'style'):
|
||||
app.setStyle(QtGui.QStyleFactory.create(
|
||||
self.config.get('look', 'style')))
|
||||
# Statusbar:
|
||||
if self.config.getboolean('look', 'statusbar'):
|
||||
self.statusBar().show()
|
||||
else:
|
||||
@ -203,9 +253,15 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.splitter.insertWidget(1, self.list_buffers)
|
||||
else:
|
||||
self.splitter.insertWidget(1, self.stacked_buffers)
|
||||
# Update visibility of all nicklists:
|
||||
# Update visibility of all nicklists/topics:
|
||||
for buffer in self.buffers:
|
||||
buffer.nicklist_update_config()
|
||||
buffer.update_config()
|
||||
# Update toggle state for menubar:
|
||||
for name, action in list(self.toggles_def.items()):
|
||||
if action[0]:
|
||||
ac = action[0].split(".")
|
||||
toggle = self.config.get(ac[0], ac[1])
|
||||
self.actions[name].setChecked(toggle == "on")
|
||||
|
||||
def _buffer_switch(self, index):
|
||||
"""Switch to a buffer."""
|
||||
@ -287,6 +343,39 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.connection_dialog.dialog_buttons.accepted.connect(
|
||||
self.connect_weechat)
|
||||
|
||||
def toggle_setting(self, section, option):
|
||||
"""Toggles any boolean setting."""
|
||||
val = self.config.getboolean(section, option)
|
||||
self.config.set(section, option, "off" if val else "on")
|
||||
self.apply_preferences()
|
||||
|
||||
def toggle_menubar(self):
|
||||
"""Toggle menubar."""
|
||||
self.toggle_setting('look', 'menubar')
|
||||
|
||||
def toggle_toolbar(self):
|
||||
"""Toggle toolbar."""
|
||||
self.toggle_setting('look', 'toolbar')
|
||||
|
||||
def toggle_statusbar(self):
|
||||
"""Toggle statusbar."""
|
||||
self.toggle_setting('look', 'statusbar')
|
||||
|
||||
def toggle_topic(self):
|
||||
"""Toggle topic."""
|
||||
self.toggle_setting('look', 'topic')
|
||||
|
||||
def toggle_nicklist(self):
|
||||
"""Toggle nicklist."""
|
||||
self.toggle_setting('look', 'nicklist')
|
||||
|
||||
def toggle_fullscreen(self):
|
||||
"""Toggle fullscreen."""
|
||||
if self.isFullScreen():
|
||||
self.showNormal()
|
||||
else:
|
||||
self.showFullScreen()
|
||||
|
||||
def connect_weechat(self):
|
||||
"""Connect to WeeChat."""
|
||||
self.network.connect_weechat(
|
||||
|
Loading…
Reference in New Issue
Block a user