Add a new 'Calibre style' interface in case you are tired of the system default look. You can select it via Preferences->Look & Feel->User interface style.

This commit is contained in:
Kovid Goyal 2012-05-31 21:27:39 +05:30
parent fc97864a2d
commit 9662f691c6
3 changed files with 83 additions and 57 deletions

View File

@ -8,7 +8,7 @@ from PyQt4.Qt import (QVariant, QFileInfo, QObject, SIGNAL, QBuffer, Qt,
QByteArray, QTranslator, QCoreApplication, QThread, QByteArray, QTranslator, QCoreApplication, QThread,
QEvent, QTimer, pyqtSignal, QDateTime, QDesktopServices, QEvent, QTimer, pyqtSignal, QDateTime, QDesktopServices,
QFileDialog, QFileIconProvider, QSettings, QFileDialog, QFileIconProvider, QSettings,
QIcon, QApplication, QDialog, QUrl, QFont) QIcon, QApplication, QDialog, QUrl, QFont, QPalette)
ORG_NAME = 'KovidsBrain' ORG_NAME = 'KovidsBrain'
APP_UID = 'libprs500' APP_UID = 'libprs500'
@ -106,6 +106,7 @@ gprefs.defaults['auto_add_path'] = None
gprefs.defaults['auto_add_check_for_duplicates'] = False gprefs.defaults['auto_add_check_for_duplicates'] = False
gprefs.defaults['blocked_auto_formats'] = [] gprefs.defaults['blocked_auto_formats'] = []
gprefs.defaults['auto_add_auto_convert'] = True gprefs.defaults['auto_add_auto_convert'] = True
gprefs.defaults['widget_style'] = 'system'
# }}} # }}}
NONE = QVariant() #: Null value to return from the data function of item models NONE = QVariant() #: Null value to return from the data function of item models
@ -737,17 +738,26 @@ class Application(QApplication):
if s is not None: if s is not None:
font.setStretch(s) font.setStretch(s)
QApplication.setFont(font) QApplication.setFont(font)
st = self.style() self.setup_styles()
if st is not None:
st = unicode(st.objectName()).lower() def setup_styles(self):
if (islinux or isbsd) and st in ('windows', 'motif', 'cde'): if gprefs['widget_style'] != 'system':
from PyQt4.Qt import QStyleFactory # On OS X QtCurve resets the palette, so we preserve it explicitly
styles = set(map(unicode, QStyleFactory.keys())) orig_pal = QPalette(self.palette())
if 'Plastique' in styles and os.environ.get('KDE_FULL_SESSION', QApplication.setStyle('QtCurve')
False): self.setPalette(orig_pal)
self.setStyle('Plastique') else:
elif 'Cleanlooks' in styles: st = self.style()
self.setStyle('Cleanlooks') if st is not None:
st = unicode(st.objectName()).lower()
if (islinux or isbsd) and st in ('windows', 'motif', 'cde'):
from PyQt4.Qt import QStyleFactory
styles = set(map(unicode, QStyleFactory.keys()))
if 'Plastique' in styles and os.environ.get('KDE_FULL_SESSION',
False):
self.setStyle('Plastique')
elif 'Cleanlooks' in styles:
self.setStyle('Cleanlooks')
def _send_file_open_events(self): def _send_file_open_events(self):
with self._file_open_lock: with self._file_open_lock:

View File

@ -101,6 +101,9 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('gui_layout', config, restart_required=True, choices= r('gui_layout', config, restart_required=True, choices=
[(_('Wide'), 'wide'), (_('Narrow'), 'narrow')]) [(_('Wide'), 'wide'), (_('Narrow'), 'narrow')])
r('widget_style', gprefs, restart_required=True, choices=
[(_('System default'), 'system'), (_('Calibre style'),
'calibre')])
r('cover_flow_queue_length', config, restart_required=True) r('cover_flow_queue_length', config, restart_required=True)

View File

@ -28,7 +28,34 @@
<string>Main Interface</string> <string>Main Interface</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_9"> <layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Choose &amp;language (requires restart):</string>
</property>
<property name="buddy">
<cstring>opt_language</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="opt_language">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
</property>
<property name="minimumContentsLength">
<number>20</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="opt_systray_icon">
<property name="text">
<string>Enable system &amp;tray icon (needs restart)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_17"> <widget class="QLabel" name="label_17">
<property name="text"> <property name="text">
<string>User Interface &amp;layout (needs restart):</string> <string>User Interface &amp;layout (needs restart):</string>
@ -38,7 +65,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="opt_gui_layout"> <widget class="QComboBox" name="opt_gui_layout">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
@ -54,34 +81,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="3" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Choose &amp;language (requires restart):</string>
</property>
<property name="buddy">
<cstring>opt_language</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="opt_language">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
</property>
<property name="minimumContentsLength">
<number>20</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="opt_systray_icon">
<property name="text">
<string>Enable system &amp;tray icon (needs restart)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="opt_disable_animations"> <widget class="QCheckBox" name="opt_disable_animations">
<property name="toolTip"> <property name="toolTip">
<string>Disable all animations. Useful if you have a slow/old computer.</string> <string>Disable all animations. Useful if you have a slow/old computer.</string>
@ -91,21 +91,21 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="4" column="0">
<widget class="QCheckBox" name="opt_disable_tray_notification"> <widget class="QCheckBox" name="opt_disable_tray_notification">
<property name="text"> <property name="text">
<string>Disable &amp;notifications in system tray</string> <string>Disable &amp;notifications in system tray</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="4" column="1">
<widget class="QCheckBox" name="opt_show_splash_screen"> <widget class="QCheckBox" name="opt_show_splash_screen">
<property name="text"> <property name="text">
<string>Show &amp;splash screen at startup</string> <string>Show &amp;splash screen at startup</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="2"> <item row="6" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="title"> <property name="title">
<string>&amp;Toolbar</string> <string>&amp;Toolbar</string>
@ -140,7 +140,20 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="7" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
@ -161,25 +174,25 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="4" column="1"> <item row="5" column="1">
<widget class="QPushButton" name="change_font_button"> <widget class="QPushButton" name="change_font_button">
<property name="text"> <property name="text">
<string>Change &amp;font (needs restart)</string> <string>Change &amp;font (needs restart)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="0" column="0">
<spacer name="verticalSpacer_3"> <widget class="QLabel" name="label_4">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>User interface &amp;style (needs restart):</string>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="buddy">
<size> <cstring>opt_widget_style</cstring>
<width>20</width>
<height>40</height>
</size>
</property> </property>
</spacer> </widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="opt_widget_style"/>
</item> </item>
</layout> </layout>
</widget> </widget>