Reorder tab stuff in config.

This commit is contained in:
Florian Bruhin 2014-08-06 08:10:32 +02:00
parent 1217ed26ad
commit 13b6fe24eb
5 changed files with 35 additions and 35 deletions

View File

@ -534,7 +534,7 @@ class CommandDispatcher:
newidx = self._tabs.currentIndex() - count newidx = self._tabs.currentIndex() - count
if newidx >= 0: if newidx >= 0:
self._tabs.setCurrentIndex(newidx) self._tabs.setCurrentIndex(newidx)
elif config.get('tabbar', 'wrap'): elif config.get('tabs', 'wrap'):
self._tabs.setCurrentIndex(newidx % self._tabs.count()) self._tabs.setCurrentIndex(newidx % self._tabs.count())
else: else:
raise CommandError("First tab") raise CommandError("First tab")
@ -549,7 +549,7 @@ class CommandDispatcher:
newidx = self._tabs.currentIndex() + count newidx = self._tabs.currentIndex() + count
if newidx < self._tabs.count(): if newidx < self._tabs.count():
self._tabs.setCurrentIndex(newidx) self._tabs.setCurrentIndex(newidx)
elif config.get('tabbar', 'wrap'): elif config.get('tabs', 'wrap'):
self._tabs.setCurrentIndex(newidx % self._tabs.count()) self._tabs.setCurrentIndex(newidx % self._tabs.count())
else: else:
raise CommandError("Last tab") raise CommandError("Last tab")

View File

@ -67,7 +67,7 @@ SECTION_DESC = {
'input': "Options related to input modes.", 'input': "Options related to input modes.",
'network': "Settings related to the network.", 'network': "Settings related to the network.",
'completion': "Options related to completion and command history.", 'completion': "Options related to completion and command history.",
'tabbar': "Configuration of the tab bar.", 'tabs': "Configuration of the tab bar.",
'storage': "Settings related to cache and storage.", 'storage': "Settings related to cache and storage.",
'permissions': "Loaded plugins/scripts and allowed actions.", 'permissions': "Loaded plugins/scripts and allowed actions.",
'hints': "Hinting settings.", 'hints': "Hinting settings.",
@ -191,10 +191,6 @@ DATA = OrderedDict([
SettingValue(types.Bool(), 'true'), SettingValue(types.Bool(), 'true'),
"Whether to save the config automatically on quit."), "Whether to save the config automatically on quit."),
('background-tabs',
SettingValue(types.Bool(), 'false'),
"Whether to open new tabs (middleclick/ctrl+click) in background."),
('editor', ('editor',
SettingValue(types.ShellCommand(placeholder=True), 'gvim -f "{}"'), SettingValue(types.ShellCommand(placeholder=True), 'gvim -f "{}"'),
"The editor (and arguments) to use for the `open-editor` command.\n\n" "The editor (and arguments) to use for the `open-editor` command.\n\n"
@ -373,18 +369,10 @@ DATA = OrderedDict([
"chain."), "chain."),
)), )),
('tabbar', sect.KeyValue( ('tabs', sect.KeyValue(
('movable', ('background-tabs',
SettingValue(types.Bool(), 'true'), SettingValue(types.Bool(), 'false'),
"Whether tabs should be movable."), "Whether to open new tabs (middleclick/ctrl+click) in background."),
('close-mouse-button',
SettingValue(types.CloseButton(), 'middle'),
"On which mouse button to close tabs."),
('position',
SettingValue(types.Position(), 'north'),
"The position of the tab bar."),
('select-on-remove', ('select-on-remove',
SettingValue(types.SelectOnRemove(), 'previous'), SettingValue(types.SelectOnRemove(), 'previous'),
@ -406,6 +394,18 @@ DATA = OrderedDict([
SettingValue(types.Bool(), 'true'), SettingValue(types.Bool(), 'true'),
"Whether to wrap when changing tabs."), "Whether to wrap when changing tabs."),
('movable',
SettingValue(types.Bool(), 'true'),
"Whether tabs should be movable."),
('close-mouse-button',
SettingValue(types.CloseButton(), 'middle'),
"On which mouse button to close tabs."),
('position',
SettingValue(types.Position(), 'north'),
"The position of the tab bar."),
('show-favicons', ('show-favicons',
SettingValue(types.Bool(), 'true'), SettingValue(types.Bool(), 'true'),
"Whether to show favicons in the tab bar."), "Whether to show favicons in the tab bar."),

View File

@ -236,7 +236,7 @@ class TabbedBrowser(TabWidget):
Args: Args:
tab: The QWebView to be closed. tab: The QWebView to be closed.
""" """
last_close = config.get('tabbar', 'last-close') last_close = config.get('tabs', 'last-close')
if self.count() > 1: if self.count() > 1:
self._remove_tab(tab) self._remove_tab(tab)
elif last_close == 'quit': elif last_close == 'quit':
@ -327,9 +327,9 @@ class TabbedBrowser(TabWidget):
self._connect_tab_signals(tab) self._connect_tab_signals(tab)
self._tabs.append(tab) self._tabs.append(tab)
if explicit: if explicit:
pos = config.get('tabbar', 'new-tab-position-explicit') pos = config.get('tabs', 'new-tab-position-explicit')
else: else:
pos = config.get('tabbar', 'new-tab-position') pos = config.get('tabs', 'new-tab-position')
if pos == 'left': if pos == 'left':
idx = self._tab_insert_idx_left idx = self._tab_insert_idx_left
# On first sight, we'd think we have to decrement # On first sight, we'd think we have to decrement
@ -355,7 +355,7 @@ class TabbedBrowser(TabWidget):
if url is not None: if url is not None:
tab.openurl(url) tab.openurl(url)
if background is None: if background is None:
background = config.get('general', 'background-tabs') background = config.get('tabs', 'background-tabs')
if not background: if not background:
self.setCurrentWidget(tab) self.setCurrentWidget(tab)
tab.show() tab.show()
@ -393,7 +393,7 @@ class TabbedBrowser(TabWidget):
for tab in self._tabs: for tab in self._tabs:
tab.on_config_changed(section, option) tab.on_config_changed(section, option)
if (section, option) == ('tabbar', 'show-favicons'): if (section, option) == ('tabbar', 'show-favicons'):
show = config.get('tabbar', 'show-favicons') show = config.get('tabs', 'show-favicons')
for i, tab in enumerate(self.widgets): for i, tab in enumerate(self.widgets):
if show: if show:
self.setTabIcon(i, tab.icon()) self.setTabIcon(i, tab.icon())
@ -479,7 +479,7 @@ class TabbedBrowser(TabWidget):
Args: Args:
tab: The WebView where the title was changed. tab: The WebView where the title was changed.
""" """
if not config.get('tabbar', 'show-favicons'): if not config.get('tabs', 'show-favicons'):
return return
try: try:
idx = self.indexOf(tab) idx = self.indexOf(tab)

View File

@ -69,10 +69,10 @@ class TabWidget(QTabWidget):
'previous': QTabBar.SelectPreviousTab, 'previous': QTabBar.SelectPreviousTab,
} }
tabbar = self.tabBar() tabbar = self.tabBar()
self.setMovable(config.get('tabbar', 'movable')) self.setMovable(config.get('tabs', 'movable'))
self.setTabsClosable(False) self.setTabsClosable(False)
posstr = config.get('tabbar', 'position') posstr = config.get('tabs', 'position')
selstr = config.get('tabbar', 'select-on-remove') selstr = config.get('tabs', 'select-on-remove')
position = position_conv[posstr] position = position_conv[posstr]
self.setTabPosition(position) self.setTabPosition(position)
tabbar.vertical = position in (QTabWidget.West, QTabWidget.East) tabbar.vertical = position in (QTabWidget.West, QTabWidget.East)
@ -141,7 +141,7 @@ class TabBar(QTabBar):
def mousePressEvent(self, e): def mousePressEvent(self, e):
"""Override mousePressEvent to close tabs if configured.""" """Override mousePressEvent to close tabs if configured."""
button = config.get('tabbar', 'close-mouse-button') button = config.get('tabs', 'close-mouse-button')
if (e.button() == Qt.RightButton and button == 'right' or if (e.button() == Qt.RightButton and button == 'right' or
e.button() == Qt.MiddleButton and button == 'middle'): e.button() == Qt.MiddleButton and button == 'middle'):
idx = self.tabAt(e.pos()) idx = self.tabAt(e.pos())
@ -196,7 +196,7 @@ class TabBar(QTabBar):
minimum_size = self.minimumTabSizeHint(index) minimum_size = self.minimumTabSizeHint(index)
height = self.fontMetrics().height() height = self.fontMetrics().height()
if self.vertical: if self.vertical:
confwidth = str(config.get('tabbar', 'width')) confwidth = str(config.get('tabs', 'width'))
if confwidth.endswith('%'): if confwidth.endswith('%'):
perc = int(confwidth.rstrip('%')) perc = int(confwidth.rstrip('%'))
width = QApplication.instance().mainwindow.width() * perc / 100 width = QApplication.instance().mainwindow.width() * perc / 100
@ -299,10 +299,10 @@ class TabBarStyle(QCommonStyle):
elif element == QStyle.CE_TabBarTabShape: elif element == QStyle.CE_TabBarTabShape:
p.fillRect(opt.rect, opt.palette.window()) p.fillRect(opt.rect, opt.palette.window())
indicator_color = opt.palette.base().color() indicator_color = opt.palette.base().color()
indicator_width = config.get('tabbar', 'indicator-width') indicator_width = config.get('tabs', 'indicator-width')
if indicator_color.isValid() and indicator_width != 0: if indicator_color.isValid() and indicator_width != 0:
topleft = opt.rect.topLeft() topleft = opt.rect.topLeft()
topleft += QPoint(config.get('tabbar', 'indicator-space'), 2) topleft += QPoint(config.get('tabs', 'indicator-space'), 2)
p.fillRect(topleft.x(), topleft.y(), indicator_width, p.fillRect(topleft.x(), topleft.y(), indicator_width,
opt.rect.height() - 4, indicator_color) opt.rect.height() - 4, indicator_color)
# We use super() rather than self._style here because we don't want # We use super() rather than self._style here because we don't want
@ -383,11 +383,11 @@ class TabBarStyle(QCommonStyle):
icon_rect = QRect() icon_rect = QRect()
text_rect = QRect(opt.rect) text_rect = QRect(opt.rect)
qt_ensure_valid(text_rect) qt_ensure_valid(text_rect)
indicator_width = config.get('tabbar', 'indicator-width') indicator_width = config.get('tabs', 'indicator-width')
text_rect.adjust(padding, 0, 0, 0) text_rect.adjust(padding, 0, 0, 0)
if indicator_width != 0: if indicator_width != 0:
text_rect.adjust(indicator_width + text_rect.adjust(indicator_width +
config.get('tabbar', 'indicator-space'), 0, 0, 0) config.get('tabs', 'indicator-space'), 0, 0, 0)
if not opt.icon.isNull(): if not opt.icon.isNull():
icon_rect = self._get_icon_rect(opt, text_rect) icon_rect = self._get_icon_rect(opt, text_rect)
text_rect.adjust(icon_rect.width() + padding, 0, 0, 0) text_rect.adjust(icon_rect.width() + padding, 0, 0, 0)

View File

@ -266,7 +266,7 @@ class WebView(QWebView):
self.open_target)) self.open_target))
elif (e.button() == Qt.MidButton or elif (e.button() == Qt.MidButton or
e.modifiers() & Qt.ControlModifier): e.modifiers() & Qt.ControlModifier):
if config.get('general', 'background-tabs'): if config.get('tabs', 'background-tabs'):
self.open_target = ClickTarget.tab_bg self.open_target = ClickTarget.tab_bg
else: else:
self.open_target = ClickTarget.tab self.open_target = ClickTarget.tab