diff --git a/src/calibre/gui2/tweak_book/__init__.py b/src/calibre/gui2/tweak_book/__init__.py index 45e80f6fe2..7bcb058ab3 100644 --- a/src/calibre/gui2/tweak_book/__init__.py +++ b/src/calibre/gui2/tweak_book/__init__.py @@ -20,6 +20,11 @@ tprefs.defaults['preview_refresh_time'] = 2 tprefs.defaults['choose_tweak_fmt'] = True tprefs.defaults['tweak_fmt_order'] = ['EPUB', 'AZW3'] tprefs.defaults['update_metadata_from_calibre'] = True +tprefs.defaults['nestable_dock_widgets'] = False +tprefs.defaults['dock_top_left'] = 'horizontal' +tprefs.defaults['dock_top_right'] = 'horizontal' +tprefs.defaults['dock_bottom_left'] = 'horizontal' +tprefs.defaults['dock_bottom_right'] = 'horizontal' ucase_map = {l:string.ascii_uppercase[i] for i, l in enumerate(string.ascii_lowercase)} def capitalize(x): diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 16480369f2..951cbb3ded 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -111,8 +111,8 @@ class Boss(QObject): if p.exec_() == p.Accepted: for ed in editors.itervalues(): ed.apply_settings() - self.gui.keyboard.finalize() setup_cssutils_serialization() + self.gui.apply_settings() def mark_requested(self, name, action): self.commit_dirty_opf() diff --git a/src/calibre/gui2/tweak_book/preferences.py b/src/calibre/gui2/tweak_book/preferences.py index 432b7eacd0..323c60b154 100644 --- a/src/calibre/gui2/tweak_book/preferences.py +++ b/src/calibre/gui2/tweak_book/preferences.py @@ -9,11 +9,12 @@ __copyright__ = '2013, Kovid Goyal ' from operator import attrgetter, methodcaller from collections import namedtuple from future_builtins import map +from itertools import product from PyQt4.Qt import ( QDialog, QGridLayout, QStackedWidget, QDialogButtonBox, QListWidget, QListWidgetItem, QIcon, QWidget, QSize, QFormLayout, Qt, QSpinBox, - QCheckBox, pyqtSignal, QDoubleSpinBox, QComboBox) + QCheckBox, pyqtSignal, QDoubleSpinBox, QComboBox, QLabel) from calibre.gui2.keyboard import ShortcutConfig from calibre.gui2.tweak_book import tprefs @@ -194,6 +195,30 @@ class IntegrationSettings(BasicSettings): ' multiple formats, this is the preference order.')) l.addRow(_('Preferred format order (drag and drop to change)'), order) +class MainWindowSettings(BasicSettings): + + def __init__(self, parent=None): + BasicSettings.__init__(self, parent) + self.l = l = QFormLayout(self) + self.setLayout(l) + + nd = self('nestable_dock_widgets') + nd.setText(_('Allow dockable windows to be nested inside the dock areas')) + nd.setToolTip('

' + _( + 'By default, you can have only a single row or column of windows in the dock' + ' areas (the areas around the central editors). This option allows' + ' for more flexible window layout, but is a little more complex to use.')) + l.addRow(nd) + + l.addRow(QLabel(_('Choose which windows will occupy the corners of the dockable areas'))) + for v, h in product(('top', 'bottom'), ('left', 'right')): + choices = {'vertical':{'left':_('Left'), 'right':_('Right')}[h], + 'horizontal':{'top':_('Top'), 'bottom':_('Bottom')}[v]} + name = 'dock_%s_%s' % (v, h) + w = self.choices_widget(name, choices, 'vertical', 'vertical') + cn = {('top', 'left'): _('The top-left corner'), ('top', 'right'):_('The top-right corner'), + ('bottom', 'left'):_('The bottom-left corner'), ('bottom', 'right'):_('The bottom-right corner')}[(v, h)] + l.addRow(cn + ':', w) class Preferences(QDialog): @@ -238,8 +263,10 @@ class Preferences(QDialog): self.keyboard_panel.initialize(gui.keyboard) self.editor_panel = EditorSettings(self) self.integration_panel = IntegrationSettings(self) + self.main_window_panel = MainWindowSettings(self) for name, icon, panel in [ + (_('Main window'), 'page.png', 'main_window'), (_('Editor settings'), 'modified.png', 'editor'), (_('Keyboard shortcuts'), 'keyboard-prefs.png', 'keyboard'), (_('Integration with calibre'), 'lt.png', 'integration'), diff --git a/src/calibre/gui2/tweak_book/ui.py b/src/calibre/gui2/tweak_book/ui.py index 005ecac80e..c157bd05cd 100644 --- a/src/calibre/gui2/tweak_book/ui.py +++ b/src/calibre/gui2/tweak_book/ui.py @@ -7,6 +7,8 @@ __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal ' from functools import partial +from itertools import product +from future_builtins import map from PyQt4.Qt import ( QDockWidget, Qt, QLabel, QIcon, QAction, QApplication, QWidget, QEvent, @@ -18,7 +20,7 @@ from calibre.gui2 import elided_text, open_url from calibre.gui2.keyboard import Manager as KeyboardManager from calibre.gui2.main_window import MainWindow from calibre.gui2.throbber import ThrobbingButton, create_donate_widget -from calibre.gui2.tweak_book import current_container, tprefs, actions +from calibre.gui2.tweak_book import current_container, tprefs, actions, capitalize from calibre.gui2.tweak_book.file_list import FileListWidget from calibre.gui2.tweak_book.job import BlockingJob from calibre.gui2.tweak_book.boss import Boss @@ -220,9 +222,17 @@ class Main(MainWindow): self.boss(self) g = QApplication.instance().desktop().availableGeometry(self) self.resize(g.width()-50, g.height()-50) - self.restore_state() + self.restore_state() + self.apply_settings() + + def apply_settings(self): self.keyboard.finalize() + self.setDockNestingEnabled(tprefs['nestable_dock_widgets']) + for v, h in product(('top', 'bottom'), ('left', 'right')): + p = 'dock_%s_%s' % (v, h) + area = getattr(Qt, '%sDockWidgetArea' % capitalize({'vertical':h, 'horizontal':v}[tprefs[p] or tprefs.defaults[p]])) + self.setCorner(getattr(Qt, '%s%sCorner' % tuple(map(capitalize, (v, h)))), area) def show_status_message(self, msg, timeout=5): self.status_bar.showMessage(msg, int(timeout*1000))