mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make line wrapping configurable
This commit is contained in:
parent
363d10096b
commit
1328d8bf94
@ -12,6 +12,7 @@ tprefs = JSONConfig('tweak_book_gui')
|
||||
tprefs.defaults['editor_theme'] = None
|
||||
tprefs.defaults['editor_font_family'] = None
|
||||
tprefs.defaults['editor_font_size'] = 12
|
||||
tprefs.defaults['editor_line_wrap'] = True
|
||||
|
||||
_current_container = None
|
||||
|
||||
|
@ -49,7 +49,7 @@ class TextEdit(QPlainTextEdit):
|
||||
def __init__(self, parent=None):
|
||||
QPlainTextEdit.__init__(self, parent)
|
||||
self.highlighter = SyntaxHighlighter(self)
|
||||
self.apply_theme()
|
||||
self.apply_settings()
|
||||
self.setMouseTracking(True)
|
||||
self.cursorPositionChanged.connect(self.highlight_cursor_line)
|
||||
self.blockCountChanged[int].connect(self.update_line_number_area_width)
|
||||
@ -59,10 +59,15 @@ class TextEdit(QPlainTextEdit):
|
||||
def sizeHint(self):
|
||||
return self.size_hint
|
||||
|
||||
def apply_theme(self): # {{{
|
||||
theme = THEMES.get(tprefs['editor_theme'], None)
|
||||
def apply_settings(self, prefs=None): # {{{
|
||||
prefs = prefs or tprefs
|
||||
self.setLineWrapMode(QPlainTextEdit.WidgetWidth if prefs['editor_line_wrap'] else QPlainTextEdit.NoWrap)
|
||||
theme = THEMES.get(prefs['editor_theme'], None)
|
||||
if theme is None:
|
||||
theme = THEMES[DEFAULT_THEME]
|
||||
self.apply_theme(theme)
|
||||
|
||||
def apply_theme(self, theme):
|
||||
self.theme = theme
|
||||
pal = self.palette()
|
||||
pal.setColor(pal.Base, theme_color(theme, 'Normal', 'bg'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user