From 56ef487a5d91a70577ed92ffbeb8d8e652992ee8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Apr 2014 15:21:14 +0530 Subject: [PATCH] Integrate the dictionary widget into the editor preferences --- src/calibre/gui2/tweak_book/boss.py | 3 +++ src/calibre/gui2/tweak_book/preferences.py | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index fc3f1cb08c..ba168326b6 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -117,6 +117,9 @@ class Boss(QObject): ed.apply_settings() setup_cssutils_serialization() self.gui.apply_settings() + if p.dictionaries_changed: + pass # TODO: Clear dictionary caches and rerun syntax highlighting in + # all open editors so that spellings are updated 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 c605765463..059103258d 100644 --- a/src/calibre/gui2/tweak_book/preferences.py +++ b/src/calibre/gui2/tweak_book/preferences.py @@ -14,11 +14,13 @@ from itertools import product from PyQt4.Qt import ( QDialog, QGridLayout, QStackedWidget, QDialogButtonBox, QListWidget, QListWidgetItem, QIcon, QWidget, QSize, QFormLayout, Qt, QSpinBox, - QCheckBox, pyqtSignal, QDoubleSpinBox, QComboBox, QLabel, QFont, QFontComboBox) + QCheckBox, pyqtSignal, QDoubleSpinBox, QComboBox, QLabel, QFont, + QFontComboBox, QPushButton, QSizePolicy) from calibre.gui2.keyboard import ShortcutConfig from calibre.gui2.tweak_book import tprefs from calibre.gui2.tweak_book.editor.themes import default_theme, THEMES +from calibre.gui2.tweak_book.spell import ManageDictionaries from calibre.gui2.font_family_chooser import FontFamilyChooser class BasicSettings(QWidget): # {{{ @@ -146,6 +148,7 @@ class EditorSettings(BasicSettings): def __init__(self, parent=None): BasicSettings.__init__(self, parent) + self.dictionaries_changed = False self.l = l = QFormLayout(self) self.setLayout(l) @@ -191,6 +194,16 @@ class EditorSettings(BasicSettings): ' time you open a HTML/CSS/etc. file for editing.')) l.addRow(lw) + self.dictionaries = d = QPushButton(_('Manage &spelling dictionaries'), self) + d.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + d.clicked.connect(self.manage_dictionaries) + l.addRow(d) + + def manage_dictionaries(self): + d = ManageDictionaries(self) + d.exec_() + self.dictionaries_changed = True + class IntegrationSettings(BasicSettings): def __init__(self, parent=None): @@ -338,6 +351,10 @@ class Preferences(QDialog): cl.setMaximumWidth(cl.sizeHintForColumn(0) + 35) cl.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + @property + def dictionaries_changed(self): + return self.editor_panel.dictionaries_changed + def restore_all_defaults(self): for i in xrange(self.stacks.count()): w = self.stacks.widget(i)