mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Merge from trunk
This commit is contained in:
commit
43b2b04f52
@ -9,7 +9,7 @@ from PyQt4.Qt import QVariant, QFileInfo, QObject, SIGNAL, QBuffer, Qt, \
|
||||
QByteArray, QTranslator, QCoreApplication, QThread, \
|
||||
QEvent, QTimer, pyqtSignal, QDate, QDesktopServices, \
|
||||
QFileDialog, QMessageBox, QPixmap, QFileIconProvider, \
|
||||
QIcon, QApplication, QDialog, QPushButton, QUrl
|
||||
QIcon, QApplication, QDialog, QPushButton, QUrl, QFont
|
||||
|
||||
ORG_NAME = 'KovidsBrain'
|
||||
APP_UID = 'libprs500'
|
||||
@ -52,6 +52,7 @@ gprefs.defaults['show_splash_screen'] = True
|
||||
gprefs.defaults['toolbar_icon_size'] = 'medium'
|
||||
gprefs.defaults['toolbar_text'] = 'auto'
|
||||
gprefs.defaults['show_child_bar'] = False
|
||||
gprefs.defaults['font'] = None
|
||||
|
||||
# }}}
|
||||
|
||||
@ -613,6 +614,10 @@ class Application(QApplication):
|
||||
qt_app = self
|
||||
self._file_open_paths = []
|
||||
self._file_open_lock = RLock()
|
||||
self.original_font = QFont(QApplication.font())
|
||||
fi = gprefs['font']
|
||||
if fi is not None:
|
||||
QApplication.setFont(QFont(*fi))
|
||||
|
||||
def _send_file_open_events(self):
|
||||
with self._file_open_lock:
|
||||
|
@ -5,10 +5,11 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from PyQt4.Qt import QApplication, QFont, QFontInfo, QFontDialog
|
||||
|
||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
||||
from calibre.gui2.preferences.look_feel_ui import Ui_Form
|
||||
from calibre.gui2 import config, gprefs
|
||||
from calibre.gui2 import config, gprefs, qt_app
|
||||
from calibre.utils.localization import available_translations, \
|
||||
get_language, get_lang
|
||||
from calibre.utils.config import prefs
|
||||
@ -56,12 +57,64 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
(_('Never'), 'never')]
|
||||
r('toolbar_text', gprefs, choices=choices)
|
||||
|
||||
self.current_font = None
|
||||
self.change_font_button.clicked.connect(self.change_font)
|
||||
|
||||
|
||||
def initialize(self):
|
||||
ConfigWidgetBase.initialize(self)
|
||||
self.current_font = gprefs['font']
|
||||
self.update_font_display()
|
||||
|
||||
def restore_defaults(self):
|
||||
ConfigWidgetBase.restore_defaults(self)
|
||||
ofont = self.current_font
|
||||
self.current_font = None
|
||||
if ofont is not None:
|
||||
self.changed_signal.emit()
|
||||
self.update_font_display()
|
||||
|
||||
def build_font_obj(self):
|
||||
font_info = self.current_font
|
||||
if font_info is not None:
|
||||
font = QFont(*font_info)
|
||||
else:
|
||||
font = qt_app.original_font
|
||||
return font
|
||||
|
||||
def update_font_display(self):
|
||||
font = self.build_font_obj()
|
||||
fi = QFontInfo(font)
|
||||
name = unicode(fi.family())
|
||||
|
||||
self.font_display.setFont(font)
|
||||
self.font_display.setText(_('Current font:') + ' ' + name +
|
||||
' [%dpt]'%fi.pointSize())
|
||||
|
||||
def change_font(self, *args):
|
||||
fd = QFontDialog(self.build_font_obj(), self)
|
||||
if fd.exec_() == fd.Accepted:
|
||||
font = fd.selectedFont()
|
||||
fi = QFontInfo(font)
|
||||
self.current_font = (unicode(fi.family()), fi.pointSize(),
|
||||
fi.weight(), fi.italic())
|
||||
self.update_font_display()
|
||||
self.changed_signal.emit()
|
||||
|
||||
def commit(self, *args):
|
||||
rr = ConfigWidgetBase.commit(self, *args)
|
||||
if self.current_font != gprefs['font']:
|
||||
gprefs['font'] = self.current_font
|
||||
QApplication.setFont(self.font_display.font())
|
||||
rr = True
|
||||
return rr
|
||||
|
||||
|
||||
def refresh_gui(self, gui):
|
||||
gui.search.search_as_you_type(config['search_as_you_type'])
|
||||
|
||||
self.update_font_display()
|
||||
|
||||
if __name__ == '__main__':
|
||||
from PyQt4.Qt import QApplication
|
||||
app = QApplication([])
|
||||
test_widget('Interface', 'Look & Feel')
|
||||
|
||||
|
@ -183,7 +183,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -196,6 +196,20 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLineEdit" name="font_display">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QPushButton" name="change_font_button">
|
||||
<property name="text">
|
||||
<string>Change &font (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -19,12 +19,15 @@ def generate_test_db(library_path,
|
||||
max_tags=10
|
||||
):
|
||||
import random, string, os, sys, time
|
||||
from calibre.constants import preferred_encoding
|
||||
|
||||
if not os.path.exists(library_path):
|
||||
os.makedirs(library_path)
|
||||
|
||||
letters = string.letters.decode(preferred_encoding)
|
||||
|
||||
def randstr(length):
|
||||
return ''.join(random.choice(string.letters) for i in
|
||||
return ''.join(random.choice(letters) for i in
|
||||
xrange(length))
|
||||
|
||||
all_tags = [randstr(tag_length) for j in xrange(num_of_tags)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user