From c01627b64eddf76848c75cb5af9a74d5a1efd725 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 19 May 2011 17:33:37 -0600 Subject: [PATCH 1/3] More OS X hoops --- src/calibre/gui2/bars.py | 7 +++++++ src/calibre/gui2/layout.py | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/bars.py b/src/calibre/gui2/bars.py index 7dc0567d95..58711f9096 100644 --- a/src/calibre/gui2/bars.py +++ b/src/calibre/gui2/bars.py @@ -249,6 +249,10 @@ class BarsManager(QObject): self.menu_bar = MenuBar(self.location_manager, self.parent()) self.parent().setMenuBar(self.menu_bar) + parent.addToolBar(Qt.TopToolBarArea, self.main_bars[0]) + parent.addToolBar(Qt.BottomToolBarArea, self.main_bars[1]) + parent.addToolBar(Qt.BottomToolBarArea, self.child_bars[0]) + self.apply_settings() self.init_bars() @@ -288,12 +292,15 @@ class BarsManager(QObject): ''' showing_device = self.location_manager.has_device main_bar = self.main_bars[1 if showing_device else 0] + hidden_bar = self.main_bars[0 if showing_device else 1] + self.parent().addToolBar(Qt.BottomToolBarArea, hidden_bar) child_bar = self.child_bars[0] for bar in self.bars: bar.setVisible(False) bar.update_lm_actions() if main_bar.added_actions: main_bar.setVisible(True) + self.parent().addToolBar(Qt.TopToolBarArea, main_bar) if child_bar.added_actions: child_bar.setVisible(True) diff --git a/src/calibre/gui2/layout.py b/src/calibre/gui2/layout.py index 46b6356a6e..85e79d66d3 100644 --- a/src/calibre/gui2/layout.py +++ b/src/calibre/gui2/layout.py @@ -259,10 +259,6 @@ class MainWindowMixin(object): # {{{ self.search_bar = SearchBar(self) self.bars_manager = BarsManager(self.donate_button, self.location_manager, self) - for bar in self.bars_manager.main_bars: - self.addToolBar(Qt.TopToolBarArea, bar) - for bar in self.bars_manager.child_bars: - self.addToolBar(Qt.BottomToolBarArea, bar) self.bars_manager.update_bars() self.setUnifiedTitleAndToolBarOnMac(True) From 079306efdd68bb2881d4a2413545a15d2bb15e4d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 19 May 2011 17:43:44 -0600 Subject: [PATCH 2/3] Axe the unified toolbar on OS X --- src/calibre/gui2/bars.py | 7 ------- src/calibre/gui2/layout.py | 8 +++++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/calibre/gui2/bars.py b/src/calibre/gui2/bars.py index 58711f9096..7dc0567d95 100644 --- a/src/calibre/gui2/bars.py +++ b/src/calibre/gui2/bars.py @@ -249,10 +249,6 @@ class BarsManager(QObject): self.menu_bar = MenuBar(self.location_manager, self.parent()) self.parent().setMenuBar(self.menu_bar) - parent.addToolBar(Qt.TopToolBarArea, self.main_bars[0]) - parent.addToolBar(Qt.BottomToolBarArea, self.main_bars[1]) - parent.addToolBar(Qt.BottomToolBarArea, self.child_bars[0]) - self.apply_settings() self.init_bars() @@ -292,15 +288,12 @@ class BarsManager(QObject): ''' showing_device = self.location_manager.has_device main_bar = self.main_bars[1 if showing_device else 0] - hidden_bar = self.main_bars[0 if showing_device else 1] - self.parent().addToolBar(Qt.BottomToolBarArea, hidden_bar) child_bar = self.child_bars[0] for bar in self.bars: bar.setVisible(False) bar.update_lm_actions() if main_bar.added_actions: main_bar.setVisible(True) - self.parent().addToolBar(Qt.TopToolBarArea, main_bar) if child_bar.added_actions: child_bar.setVisible(True) diff --git a/src/calibre/gui2/layout.py b/src/calibre/gui2/layout.py index 85e79d66d3..281450ed30 100644 --- a/src/calibre/gui2/layout.py +++ b/src/calibre/gui2/layout.py @@ -259,8 +259,14 @@ class MainWindowMixin(object): # {{{ self.search_bar = SearchBar(self) self.bars_manager = BarsManager(self.donate_button, self.location_manager, self) + for bar in self.bars_manager.main_bars: + self.addToolBar(Qt.TopToolBarArea, bar) + for bar in self.bars_manager.child_bars: + self.addToolBar(Qt.BottomToolBarArea, bar) self.bars_manager.update_bars() - self.setUnifiedTitleAndToolBarOnMac(True) + # This is disabled because it introduces various toolbar related bugs + # The width of the toolbar becomes the sum of both toolbars + # self.setUnifiedTitleAndToolBarOnMac(True) l = self.centralwidget.layout() l.addWidget(self.search_bar) From 9c169f638ff393d9421ba8e4694a555e3a965bb2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 19 May 2011 17:51:08 -0600 Subject: [PATCH 3/3] Add a tweak to allow users to turn on the unified title/toolbar if they so desire --- resources/default_tweaks.py | 8 ++++++++ src/calibre/gui2/layout.py | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index 691a82fc36..c215e9634d 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -350,3 +350,11 @@ send_news_to_device_location = "main" # work on all operating systems) server_listen_on = '0.0.0.0' +#: Unified toolbar on OS X +# If you enable this option and restart calibre, the toolbar will be 'unified' +# with the titlebar as is normal for OS X applications. However, doing this has +# various bugs, for instance the minimum width of the toolbar becomes twice +# what it should be and it causes other random bugs on some systems, so turn it +# on at your own risk! +unified_title_toolbar_on_osx = False + diff --git a/src/calibre/gui2/layout.py b/src/calibre/gui2/layout.py index 281450ed30..7d07463b87 100644 --- a/src/calibre/gui2/layout.py +++ b/src/calibre/gui2/layout.py @@ -17,6 +17,7 @@ from calibre.gui2.search_box import SearchBox2, SavedSearchBox from calibre.gui2.throbber import ThrobbingButton from calibre.gui2.bars import BarsManager from calibre.gui2.widgets import ComboBoxWithHelp +from calibre.utils.config_base import tweaks from calibre import human_readable class LocationManager(QObject): # {{{ @@ -266,7 +267,8 @@ class MainWindowMixin(object): # {{{ self.bars_manager.update_bars() # This is disabled because it introduces various toolbar related bugs # The width of the toolbar becomes the sum of both toolbars - # self.setUnifiedTitleAndToolBarOnMac(True) + if tweaks['unified_title_toolbar_on_osx']: + self.setUnifiedTitleAndToolBarOnMac(True) l = self.centralwidget.layout() l.addWidget(self.search_bar)