From 9662f691c6e99bf32bbebfc03aaf08cd80d3ad49 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 31 May 2012 21:27:39 +0530 Subject: [PATCH] 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. --- src/calibre/gui2/__init__.py | 34 ++++--- src/calibre/gui2/preferences/look_feel.py | 3 + src/calibre/gui2/preferences/look_feel.ui | 103 ++++++++++++---------- 3 files changed, 83 insertions(+), 57 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 30588a8866..b07dacf572 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -8,7 +8,7 @@ from PyQt4.Qt import (QVariant, QFileInfo, QObject, SIGNAL, QBuffer, Qt, QByteArray, QTranslator, QCoreApplication, QThread, QEvent, QTimer, pyqtSignal, QDateTime, QDesktopServices, QFileDialog, QFileIconProvider, QSettings, - QIcon, QApplication, QDialog, QUrl, QFont) + QIcon, QApplication, QDialog, QUrl, QFont, QPalette) ORG_NAME = 'KovidsBrain' APP_UID = 'libprs500' @@ -106,6 +106,7 @@ gprefs.defaults['auto_add_path'] = None gprefs.defaults['auto_add_check_for_duplicates'] = False gprefs.defaults['blocked_auto_formats'] = [] 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 @@ -737,17 +738,26 @@ class Application(QApplication): if s is not None: font.setStretch(s) QApplication.setFont(font) - st = self.style() - 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') + self.setup_styles() + + def setup_styles(self): + if gprefs['widget_style'] != 'system': + # On OS X QtCurve resets the palette, so we preserve it explicitly + orig_pal = QPalette(self.palette()) + QApplication.setStyle('QtCurve') + self.setPalette(orig_pal) + else: + st = self.style() + 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): with self._file_open_lock: diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index 2117de009c..2c675d1ee2 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -101,6 +101,9 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): r('gui_layout', config, restart_required=True, choices= [(_('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) diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 73e0a85a68..792dd25ec1 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -28,7 +28,34 @@ Main Interface - + + + + Choose &language (requires restart): + + + opt_language + + + + + + + QComboBox::AdjustToMinimumContentsLengthWithIcon + + + 20 + + + + + + + Enable system &tray icon (needs restart) + + + + User Interface &layout (needs restart): @@ -38,7 +65,7 @@ - + @@ -54,34 +81,7 @@ - - - - Choose &language (requires restart): - - - opt_language - - - - - - - QComboBox::AdjustToMinimumContentsLengthWithIcon - - - 20 - - - - - - - Enable system &tray icon (needs restart) - - - - + Disable all animations. Useful if you have a slow/old computer. @@ -91,21 +91,21 @@ - + Disable &notifications in system tray - + Show &splash screen at startup - + &Toolbar @@ -140,7 +140,20 @@ - + + + + Qt::Vertical + + + + 20 + 40 + + + + + @@ -161,25 +174,25 @@ - + Change &font (needs restart) - - - - Qt::Vertical + + + + User interface &style (needs restart): - - - 20 - 40 - + + opt_widget_style - + + + +