diff --git a/src/calibre/gui2/dialogs/config/__init__.py b/src/calibre/gui2/dialogs/config/__init__.py index 1deb025c73..5dcc4feb1a 100644 --- a/src/calibre/gui2/dialogs/config/__init__.py +++ b/src/calibre/gui2/dialogs/config/__init__.py @@ -498,6 +498,20 @@ class ConfigDialog(ResizableDialog, Ui_Dialog): self.opt_gui_layout.setCurrentIndex(li) self.opt_disable_animations.setChecked(config['disable_animations']) self.opt_show_donate_button.setChecked(config['show_donate_button']) + idx = 0 + for i, x in enumerate([(_('Small'), 'small'), (_('Medium'), 'medium'), + (_('Large'), 'large')]): + if x[1] == gprefs.get('toolbar_icon_size', 'medium'): + idx = i + self.opt_toolbar_icon_size.addItem(x[0], x[1]) + self.opt_toolbar_icon_size.setCurrentIndex(idx) + idx = 0 + for i, x in enumerate([(_('Automatic'), 'auto'), (_('Always'), 'always'), + (_('Never'), 'never')]): + if x[1] == gprefs.get('toolbar_text', 'auto'): + idx = i + self.opt_toolbar_text.addItem(x[0], x[1]) + self.opt_toolbar_text.setCurrentIndex(idx) self.category_view.setCurrentIndex(self.category_view.model().index_for_name(initial_category)) @@ -869,6 +883,10 @@ class ConfigDialog(ResizableDialog, Ui_Dialog): config['disable_animations'] = bool(self.opt_disable_animations.isChecked()) config['show_donate_button'] = bool(self.opt_show_donate_button.isChecked()) gprefs['show_splash_screen'] = bool(self.show_splash_screen.isChecked()) + for x in ('toolbar_icon_size', 'toolbar_text'): + w = getattr(self, 'opt_'+x) + data = w.itemData(w.currentIndex()).toString() + gprefs[x] = unicode(data) fmts = [] for i in range(self.viewer.count()): if self.viewer.item(i).checkState() == Qt.Checked: diff --git a/src/calibre/gui2/dialogs/config/config.ui b/src/calibre/gui2/dialogs/config/config.ui index 5d6bff2467..df19aa2a26 100644 --- a/src/calibre/gui2/dialogs/config/config.ui +++ b/src/calibre/gui2/dialogs/config/config.ui @@ -346,21 +346,21 @@ - + Automatically send downloaded &news to ebook reader - + &Delete news from library when it is automatically sent to reader - + @@ -377,7 +377,7 @@ - + @@ -580,6 +580,41 @@ + + + + &Toolbar + + + + + + + + + &Icon size: + + + opt_toolbar_icon_size + + + + + + + + + + Show &text under icons: + + + opt_toolbar_text + + + + + + diff --git a/src/calibre/gui2/layout.py b/src/calibre/gui2/layout.py index 7249d47122..012a9b5ce3 100644 --- a/src/calibre/gui2/layout.py +++ b/src/calibre/gui2/layout.py @@ -16,7 +16,7 @@ from PyQt4.Qt import QIcon, Qt, QWidget, QAction, QToolBar, QSize, \ from calibre.constants import __appname__, isosx from calibre.gui2.search_box import SearchBox2, SavedSearchBox from calibre.gui2.throbber import ThrobbingButton -from calibre.gui2 import config, open_url +from calibre.gui2 import config, open_url, gprefs from calibre.gui2.widgets import ComboBoxWithHelp from calibre import human_readable from calibre.utils.config import prefs @@ -24,7 +24,6 @@ from calibre.ebooks import BOOK_EXTENSIONS from calibre.gui2.dialogs.scheduler import Scheduler from calibre.utils.smtp import config as email_config -ICON_SIZE = 48 class SaveMenu(QMenu): # {{{ @@ -229,12 +228,11 @@ class ToolBar(QToolBar): # {{{ self.setFloatable(False) self.setOrientation(Qt.Horizontal) self.setAllowedAreas(Qt.TopToolBarArea|Qt.BottomToolBarArea) - self.setIconSize(QSize(ICON_SIZE, ICON_SIZE)) - self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) self.setStyleSheet('QToolButton:checked { font-weight: bold }') + self.donate = donate + self.apply_settings() self.all_actions = actions - self.donate = donate self.location_manager = location_manager self.location_manager.locations_changed.connect(self.build_bar) self.d_widget = QWidget() @@ -245,6 +243,16 @@ class ToolBar(QToolBar): # {{{ self.build_bar() self.preferred_width = self.sizeHint().width() + def apply_settings(self): + sz = gprefs.get('toolbar_icon_size', 'medium') + sz = {'small':24, 'medium':48, 'large':64}[sz] + self.setIconSize(QSize(sz, sz)) + style = Qt.ToolButtonTextUnderIcon + if gprefs.get('toolbar_text', 'auto') == 'never': + style = Qt.ToolButtonIconOnly + self.setToolButtonStyle(style) + self.donate.set_normal_icon_size(sz, sz) + def contextMenuEvent(self, *args): pass @@ -298,8 +306,11 @@ class ToolBar(QToolBar): # {{{ def resizeEvent(self, ev): QToolBar.resizeEvent(self, ev) style = Qt.ToolButtonTextUnderIcon + p = gprefs.get('toolbar_text', 'auto') + if p == 'never': + style = Qt.ToolButtonIconOnly - if self.preferred_width > self.width()+35: + if p == 'auto' and self.preferred_width > self.width()+35: style = Qt.ToolButtonIconOnly self.setToolButtonStyle(style) @@ -383,7 +394,6 @@ class MainWindowMixin(object): self.centralwidget.setLayout(self._central_widget_layout) self.resize(1012, 740) self.donate_button = ThrobbingButton(self.centralwidget) - self.donate_button.set_normal_icon_size(ICON_SIZE, ICON_SIZE) self.location_manager = LocationManager(self) self.init_scheduler(db) diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 9913e320e9..ec8d07bdbe 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -380,6 +380,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{ self.tags_view.recount() self.create_device_menu() self.set_device_menu_items_state(bool(self.device_connected)) + self.tool_bar.apply_settings() def library_moved(self, newloc): if newloc is None: return