Fix up background_tabs, favicon_show and some custom config magic

This commit is contained in:
Florian Bruhin 2017-06-13 15:18:10 +02:00
parent 1f508d9d8f
commit 8c1b5f0581
7 changed files with 21 additions and 32 deletions

View File

@ -507,7 +507,7 @@ class CommandDispatcher:
idx = new_tabbed_browser.indexOf(newtab) idx = new_tabbed_browser.indexOf(newtab)
new_tabbed_browser.set_page_title(idx, cur_title) new_tabbed_browser.set_page_title(idx, cur_title)
if config.val.tabs.show_favicons: if config.val.tabs.favicons.show:
new_tabbed_browser.setTabIcon(idx, curtab.icon()) new_tabbed_browser.setTabIcon(idx, curtab.icon())
if config.val.tabs.tabs_are_windows: if config.val.tabs.tabs_are_windows:
new_tabbed_browser.window().setWindowIcon(curtab.icon()) new_tabbed_browser.window().setWindowIcon(curtab.icon())

View File

@ -203,7 +203,7 @@ class HintActions:
Target.window: usertypes.ClickTarget.window, Target.window: usertypes.ClickTarget.window,
Target.hover: usertypes.ClickTarget.normal, Target.hover: usertypes.ClickTarget.normal,
} }
if config.val.tabs.background_tabs: if config.val.tabs.background:
target_mapping[Target.tab] = usertypes.ClickTarget.tab_bg target_mapping[Target.tab] = usertypes.ClickTarget.tab_bg
else: else:
target_mapping[Target.tab] = usertypes.ClickTarget.tab target_mapping[Target.tab] = usertypes.ClickTarget.tab
@ -684,8 +684,7 @@ class HintManager(QObject):
Target.hover, Target.userscript, Target.spawn, Target.hover, Target.userscript, Target.spawn,
Target.download, Target.normal, Target.current]: Target.download, Target.normal, Target.current]:
pass pass
elif (target == Target.tab and elif target == Target.tab and config.val.tabs.background:
config.val.tabs.background_tabs):
pass pass
else: else:
name = target.name.replace('_', '-') name = target.name.replace('_', '-')

View File

@ -329,7 +329,7 @@ class AbstractWebElement(collections.abc.MutableMapping):
usertypes.ClickTarget.tab: Qt.ControlModifier, usertypes.ClickTarget.tab: Qt.ControlModifier,
usertypes.ClickTarget.tab_bg: Qt.ControlModifier, usertypes.ClickTarget.tab_bg: Qt.ControlModifier,
} }
if config.val.tabs.background_tabs: if config.val.tabs.background:
modifiers[usertypes.ClickTarget.tab] |= Qt.ShiftModifier modifiers[usertypes.ClickTarget.tab] |= Qt.ShiftModifier
else: else:
modifiers[usertypes.ClickTarget.tab_bg] |= Qt.ShiftModifier modifiers[usertypes.ClickTarget.tab_bg] |= Qt.ShiftModifier

View File

@ -80,10 +80,10 @@ class WebEngineView(QWebEngineView):
The new QWebEngineView object. The new QWebEngineView object.
""" """
debug_type = debug.qenum_key(QWebEnginePage, wintype) debug_type = debug.qenum_key(QWebEnginePage, wintype)
background_tabs = config.val.tabs.background_tabs background = config.val.tabs.background
log.webview.debug("createWindow with type {}, background_tabs " log.webview.debug("createWindow with type {}, background {}".format(
"{}".format(debug_type, background_tabs)) debug_type, background))
if wintype == QWebEnginePage.WebBrowserWindow: if wintype == QWebEnginePage.WebBrowserWindow:
# Shift-Alt-Click # Shift-Alt-Click
@ -95,13 +95,13 @@ class WebEngineView(QWebEngineView):
elif wintype == QWebEnginePage.WebBrowserTab: elif wintype == QWebEnginePage.WebBrowserTab:
# Middle-click / Ctrl-Click with Shift # Middle-click / Ctrl-Click with Shift
# FIXME:qtwebengine this also affects target=_blank links... # FIXME:qtwebengine this also affects target=_blank links...
if background_tabs: if background:
target = usertypes.ClickTarget.tab target = usertypes.ClickTarget.tab
else: else:
target = usertypes.ClickTarget.tab_bg target = usertypes.ClickTarget.tab_bg
elif wintype == QWebEnginePage.WebBrowserBackgroundTab: elif wintype == QWebEnginePage.WebBrowserBackgroundTab:
# Middle-click / Ctrl-Click # Middle-click / Ctrl-Click
if background_tabs: if background:
target = usertypes.ClickTarget.tab_bg target = usertypes.ClickTarget.tab_bg
else: else:
target = usertypes.ClickTarget.tab target = usertypes.ClickTarget.tab

View File

@ -285,10 +285,10 @@ class WebView(QWebView):
This is implemented here as we don't need it for QtWebEngine. This is implemented here as we don't need it for QtWebEngine.
""" """
if e.button() == Qt.MidButton or e.modifiers() & Qt.ControlModifier: if e.button() == Qt.MidButton or e.modifiers() & Qt.ControlModifier:
background_tabs = config.val.tabs.background_tabs background = config.val.tabs.background
if e.modifiers() & Qt.ShiftModifier: if e.modifiers() & Qt.ShiftModifier:
background_tabs = not background_tabs background = not background
if background_tabs: if background:
target = usertypes.ClickTarget.tab_bg target = usertypes.ClickTarget.tab_bg
else: else:
target = usertypes.ClickTarget.tab target = usertypes.ClickTarget.tab

View File

@ -430,7 +430,7 @@ class TabbedBrowser(tabwidget.TabWidget):
tab.openurl(url) tab.openurl(url)
if background is None: if background is None:
background = config.val.tabs.background_tabs background = config.val.tabs.background
if background: if background:
# Make sure the background tab has the correct initial size. # Make sure the background tab has the correct initial size.
# With a foreground tab, it's going to be resized correctly by the # With a foreground tab, it's going to be resized correctly by the
@ -516,7 +516,7 @@ class TabbedBrowser(tabwidget.TabWidget):
else: else:
self.setTabIcon(idx, QIcon()) self.setTabIcon(idx, QIcon())
if (config.val.tabs.tabs_are_windows and if (config.val.tabs.tabs_are_windows and
config.val.tabs.show_favicons): config.val.tabs.favicons.show):
self.window().setWindowIcon(self.default_window_icon) self.window().setWindowIcon(self.default_window_icon)
if idx == self.currentIndex(): if idx == self.currentIndex():
self.update_window_title() self.update_window_title()
@ -580,7 +580,7 @@ class TabbedBrowser(tabwidget.TabWidget):
tab: The WebView where the title was changed. tab: The WebView where the title was changed.
icon: The new icon icon: The new icon
""" """
if not config.val.tabs.show_favicons: if not config.val.tabs.favicons.show:
return return
try: try:
idx = self._tab_index(tab) idx = self._tab_index(tab)

View File

@ -562,23 +562,13 @@ class TabBar(QTabBar):
tab = QStyleOptionTab() tab = QStyleOptionTab()
self.initStyleOption(tab, idx) self.initStyleOption(tab, idx)
bg_parts = ['tabs', 'bg'] setting = config.val.colors.tabs
fg_parts = ['tabs', 'fg']
if idx == selected: if idx == selected:
bg_parts.append('selected') setting = setting.selected
fg_parts.append('selected') setting = setting.odd if idx % 2 else setting.even
if idx % 2: tab.palette.setColor(QPalette.Window, setting.bg)
bg_parts.append('odd') tab.palette.setColor(QPalette.WindowText, setting.fg)
fg_parts.append('odd')
else:
bg_parts.append('even')
fg_parts.append('even')
bg_color = config.get('colors', '.'.join(bg_parts))
fg_color = config.get('colors', '.'.join(fg_parts))
tab.palette.setColor(QPalette.Window, bg_color)
tab.palette.setColor(QPalette.WindowText, fg_color)
indicator_color = self.tab_indicator_color(idx) indicator_color = self.tab_indicator_color(idx)
tab.palette.setColor(QPalette.Base, indicator_color) tab.palette.setColor(QPalette.Base, indicator_color)
@ -841,7 +831,7 @@ class TabBarStyle(QCommonStyle):
position = config.val.tabs.position position = config.val.tabs.position
if (opt.icon.isNull() and if (opt.icon.isNull() and
position in [QTabWidget.East, QTabWidget.West] and position in [QTabWidget.East, QTabWidget.West] and
config.val.tabs.show_favicons): config.val.tabs.favicons.show):
tab_icon_size = icon_size tab_icon_size = icon_size
else: else:
actual_size = opt.icon.actualSize(icon_size, icon_mode, icon_state) actual_size = opt.icon.actualSize(icon_size, icon_mode, icon_state)